mirror of
https://github.com/Crocmagnon/ansible.git
synced 2024-11-21 14:58:02 +01:00
Compare commits
10 commits
5971129176
...
06630d79fd
Author | SHA1 | Date | |
---|---|---|---|
06630d79fd | |||
6eacfa69d9 | |||
8c45080d36 | |||
191a09a137 | |||
559c75c762 | |||
f016336bd8 | |||
13fc53a3ea | |||
e76097b206 | |||
4887f6f061 | |||
dc8e0da2bb |
9 changed files with 153 additions and 8 deletions
24
LICENSE
Normal file
24
LICENSE
Normal file
|
@ -0,0 +1,24 @@
|
|||
This is free and unencumbered software released into the public domain.
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||
distribute this software, either in source code form or as a compiled
|
||||
binary, for any purpose, commercial or non-commercial, and by any
|
||||
means.
|
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors
|
||||
of this software dedicate any and all copyright interest in the
|
||||
software to the public domain. We make this dedication for the benefit
|
||||
of the public at large and to the detriment of our heirs and
|
||||
successors. We intend this dedication to be an overt act of
|
||||
relinquishment in perpetuity of all present and future rights to this
|
||||
software under copyright law.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more information, please refer to <https://unlicense.org>
|
6
Makefile
6
Makefile
|
@ -1,5 +1,7 @@
|
|||
.PHONY: dry-run
|
||||
dry-run:
|
||||
ansible-playbook playbook.yaml --check --diff
|
||||
ansible-playbook playbooks/*.yaml --check --diff
|
||||
|
||||
.PHONY: run
|
||||
run:
|
||||
ansible-playbook playbook.yaml
|
||||
ansible-playbook playbooks/*.yaml
|
||||
|
|
10
README.md
10
README.md
|
@ -3,3 +3,13 @@ Server management
|
|||
|
||||
## vault
|
||||
Create a `vault.pass` file with the ansible vault password.
|
||||
|
||||
## initial setup
|
||||
```shell
|
||||
ansible-playbook playbooks/dependencies/*.yaml
|
||||
```
|
||||
|
||||
## run
|
||||
```shell
|
||||
ansible-playbook playbooks/*.yaml
|
||||
```
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
[servers]
|
||||
192.168.0.6:38303 ansible_python_interpreter=auto_silent
|
||||
ubuntu ansible_host=192.168.0.6 ansible_port=38303 ansible_python_interpreter=auto_silent
|
||||
|
|
7
playbooks/dependencies/00-clean-deps.yaml
Normal file
7
playbooks/dependencies/00-clean-deps.yaml
Normal file
|
@ -0,0 +1,7 @@
|
|||
- name: clean ansible venv
|
||||
hosts: servers
|
||||
tasks:
|
||||
- name: remove virtualenv
|
||||
file:
|
||||
path: /tmp/ansible
|
||||
state: absent
|
18
playbooks/dependencies/01-setup-deps.yaml
Normal file
18
playbooks/dependencies/01-setup-deps.yaml
Normal file
|
@ -0,0 +1,18 @@
|
|||
- name: setup ansible python dependencies
|
||||
hosts: servers
|
||||
tasks:
|
||||
- name: install system deps
|
||||
become: true
|
||||
apt:
|
||||
pkg:
|
||||
- python3-venv
|
||||
- name: setup venv
|
||||
shell: |
|
||||
if [ -x /tmp/ansible/bin/python ]; then exit 123; fi
|
||||
/usr/bin/python3 -m venv /tmp/ansible
|
||||
/tmp/ansible/bin/pip install --upgrade 'github3.py >= 1.0.0a3'
|
||||
args:
|
||||
executable: /bin/bash
|
||||
register: venv
|
||||
changed_when: "venv.rc != 123"
|
||||
failed_when: "venv.rc != 0 and venv.rc != 123"
|
69
playbooks/goatcounter.yaml
Normal file
69
playbooks/goatcounter.yaml
Normal file
|
@ -0,0 +1,69 @@
|
|||
- name: goatcounter
|
||||
hosts: servers
|
||||
tasks:
|
||||
- name: get latest release
|
||||
github_release:
|
||||
action: latest_release
|
||||
user: arp242
|
||||
repo: goatcounter
|
||||
register: release
|
||||
- name: print release
|
||||
ansible.builtin.debug:
|
||||
var: release.tag
|
||||
- name: download binary
|
||||
get_url:
|
||||
url: https://github.com/arp242/goatcounter/releases/download/{{release.tag}}/goatcounter-{{release.tag}}-linux-amd64.gz
|
||||
dest: "{{base_dir}}/goatcounter-{{release.tag}}.gz"
|
||||
- name: uncompress
|
||||
command: gunzip {{base_dir}}/goatcounter-{{release.tag}}.gz
|
||||
args:
|
||||
creates: "{{base_dir}}/goatcounter-{{release.tag}}"
|
||||
- name: make executable
|
||||
file:
|
||||
path: "{{base_dir}}/goatcounter-{{release.tag}}"
|
||||
mode: '0775'
|
||||
- name: symlink
|
||||
file:
|
||||
src: "{{base_dir}}/goatcounter-{{release.tag}}"
|
||||
dest: "{{base_dir}}/goatcounter"
|
||||
state: link
|
||||
- name: write service unit file
|
||||
become: true
|
||||
template:
|
||||
src: ../templates/goatcounter.service.j2
|
||||
dest: /etc/systemd/system/goatcounter.service
|
||||
notify:
|
||||
- daemon-reload
|
||||
- restart goatcounter
|
||||
- name: flush handlers
|
||||
meta: flush_handlers
|
||||
- name: ensure service is running
|
||||
become: true
|
||||
service:
|
||||
name: goatcounter
|
||||
state: started
|
||||
enabled: true
|
||||
|
||||
handlers:
|
||||
- name: daemon-reload
|
||||
become: true
|
||||
systemd:
|
||||
daemon_reload: true
|
||||
- name: restart service
|
||||
become: true
|
||||
service:
|
||||
name: goatcounter
|
||||
state: restarted
|
||||
|
||||
vars:
|
||||
ansible_python_interpreter: /tmp/ansible/bin/python
|
||||
base_dir: /mnt/data/goatcounter
|
||||
gc_mailgun_api_key: !vault |
|
||||
$ANSIBLE_VAULT;1.1;AES256
|
||||
31386237653033306338393237353961396535363061363931643863653461333631376365663338
|
||||
3266346337353564656539666235656265356435343834380a616232383839663639616537393233
|
||||
64303764306639636136346233366666633765393565353062396632636163643031616235303130
|
||||
3662343162643033380a326161313036643835636562636165356464393236303533303435353365
|
||||
36336163313338346235396565363631366564393562326536353262363637653432643830663532
|
||||
30356133383335653330613965623261323531613131663437363430636565393262353565326132
|
||||
323830313235313462633335333763363161
|
|
@ -1,15 +1,17 @@
|
|||
- name: lyon-transports
|
||||
hosts: servers
|
||||
tasks:
|
||||
- name: write lyon-transports unit file
|
||||
- name: write service file
|
||||
become: true
|
||||
template:
|
||||
src: templates/lyon-transports.service.j2
|
||||
src: ../templates/lyon-transports.service.j2
|
||||
dest: /etc/systemd/system/lyon-transports.service
|
||||
notify:
|
||||
- daemon-reload
|
||||
- restart lyon-transports
|
||||
- name: ensure lyon-transports is running
|
||||
- name: flush handlers
|
||||
meta: flush_handlers
|
||||
- name: ensure service is running
|
||||
become: true
|
||||
service:
|
||||
name: lyon-transports
|
||||
|
@ -21,7 +23,7 @@
|
|||
become: true
|
||||
systemd:
|
||||
daemon_reload: true
|
||||
- name: restart lyon-transports
|
||||
- name: restart service
|
||||
become: true
|
||||
service:
|
||||
name: lyon-transports
|
13
templates/goatcounter.service.j2
Normal file
13
templates/goatcounter.service.j2
Normal file
|
@ -0,0 +1,13 @@
|
|||
[Unit]
|
||||
Description=Goatcounter
|
||||
After=network.target
|
||||
|
||||
[Service]
|
||||
ExecStart={{base_dir}}/goatcounter serve -listen *:8081 -tls http -smtp smtps://goatcounter%%40mg.augendre.info:{{gc_mailgun_api_key}}@smtp.mailgun.org:587 -email-from goatcounter@mg.augendre.info -automigrate -db sqlite+{{base_dir}}/db/goatcounter.sqlite3
|
||||
Type=simple
|
||||
Restart=always
|
||||
User=gaugendre
|
||||
Group=gaugendre
|
||||
|
||||
[Install]
|
||||
WantedBy=default.target
|
Loading…
Reference in a new issue