mirror of
https://github.com/Crocmagnon/ansible.git
synced 2025-01-22 05:03:34 +01:00
apply ansible lint rules
This commit is contained in:
parent
08e196eaa9
commit
4c5733d39c
12 changed files with 115 additions and 81 deletions
3
.ansible-lint
Normal file
3
.ansible-lint
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
profile: production
|
||||||
|
strict: true
|
|
@ -1,3 +1,7 @@
|
||||||
|
---
|
||||||
|
ci:
|
||||||
|
autoupdate_schedule: monthly
|
||||||
|
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v2.3.0
|
rev: v2.3.0
|
||||||
|
@ -6,3 +10,10 @@ repos:
|
||||||
args: [--unsafe]
|
args: [--unsafe]
|
||||||
- id: end-of-file-fixer
|
- id: end-of-file-fixer
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
|
- repo: https://github.com/ansible/ansible-lint
|
||||||
|
rev: v24.9.2
|
||||||
|
hooks:
|
||||||
|
- id: ansible-lint
|
||||||
|
entry: python3 -m ansiblelint -v --force-color --fix
|
||||||
|
additional_dependencies:
|
||||||
|
- ansible
|
||||||
|
|
|
@ -1,15 +1,19 @@
|
||||||
- name: update caddy config
|
---
|
||||||
|
- name: Update caddy config
|
||||||
hosts: servers
|
hosts: servers
|
||||||
become: true
|
become: true
|
||||||
tasks:
|
tasks:
|
||||||
- name: write Caddyfile
|
- name: Write Caddyfile
|
||||||
copy:
|
ansible.builtin.copy:
|
||||||
src: ../../files/Caddyfile
|
src: files/Caddyfile
|
||||||
dest: /etc/caddy/Caddyfile
|
dest: /etc/caddy/Caddyfile
|
||||||
|
mode: "0644"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
notify:
|
notify:
|
||||||
- reload caddy
|
- Reload caddy
|
||||||
handlers:
|
handlers:
|
||||||
- name: reload caddy
|
- name: Reload caddy
|
||||||
service:
|
ansible.builtin.service:
|
||||||
name: caddy
|
name: caddy
|
||||||
state: reloaded
|
state: reloaded
|
||||||
|
|
|
@ -1,57 +1,64 @@
|
||||||
- name: goatcounter
|
---
|
||||||
|
- name: Goatcounter
|
||||||
hosts: servers
|
hosts: servers
|
||||||
tasks:
|
tasks:
|
||||||
- name: get latest release
|
- name: Get latest release
|
||||||
github_release:
|
community.general.github_release:
|
||||||
action: latest_release
|
action: latest_release
|
||||||
user: arp242
|
user: arp242
|
||||||
repo: goatcounter
|
repo: goatcounter
|
||||||
register: release
|
register: release
|
||||||
- name: print release
|
- name: Print release
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
var: release.tag
|
var: release.tag
|
||||||
- name: download binary
|
- name: Download binary
|
||||||
get_url:
|
ansible.builtin.get_url:
|
||||||
url: https://github.com/arp242/goatcounter/releases/download/{{ release.tag }}/goatcounter-{{ release.tag }}-linux-amd64.gz
|
url: https://github.com/arp242/goatcounter/releases/download/{{ release.tag }}/goatcounter-{{ release.tag }}-linux-amd64.gz
|
||||||
dest: "{{ base_dir }}/goatcounter-{{ release.tag }}.gz"
|
dest: "{{ base_dir }}/goatcounter-{{ release.tag }}.gz"
|
||||||
- name: uncompress
|
mode: "0644"
|
||||||
command: gunzip {{base_dir}}/goatcounter-{{release.tag}}.gz
|
owner: gaugendre
|
||||||
|
group: gaugendre
|
||||||
|
- name: Uncompress
|
||||||
|
ansible.builtin.command: gunzip {{ base_dir }}/goatcounter-{{ release.tag }}.gz
|
||||||
args:
|
args:
|
||||||
creates: "{{ base_dir }}/goatcounter-{{ release.tag }}"
|
creates: "{{ base_dir }}/goatcounter-{{ release.tag }}"
|
||||||
- name: make executable
|
- name: Make executable
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: "{{ base_dir }}/goatcounter-{{ release.tag }}"
|
path: "{{ base_dir }}/goatcounter-{{ release.tag }}"
|
||||||
mode: '0775'
|
mode: "0775"
|
||||||
- name: symlink
|
- name: Symlink
|
||||||
file:
|
ansible.builtin.file:
|
||||||
src: "{{ base_dir }}/goatcounter-{{ release.tag }}"
|
src: "{{ base_dir }}/goatcounter-{{ release.tag }}"
|
||||||
dest: "{{ base_dir }}/goatcounter"
|
dest: "{{ base_dir }}/goatcounter"
|
||||||
state: link
|
state: link
|
||||||
- name: write service unit file
|
- name: Write service unit file
|
||||||
become: true
|
become: true
|
||||||
template:
|
ansible.builtin.template:
|
||||||
src: ../../templates/goatcounter.service.j2
|
src: templates/goatcounter.service.j2
|
||||||
dest: /etc/systemd/system/goatcounter.service
|
dest: /etc/systemd/system/goatcounter.service
|
||||||
|
mode: "0644"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
notify:
|
notify:
|
||||||
- daemon-reload
|
- Daemon-reload
|
||||||
- restart service
|
- Restart service
|
||||||
- name: flush handlers
|
- name: Flush handlers
|
||||||
meta: flush_handlers
|
ansible.builtin.meta: flush_handlers
|
||||||
- name: ensure service is running
|
- name: Ensure service is running
|
||||||
become: true
|
become: true
|
||||||
service:
|
ansible.builtin.service:
|
||||||
name: goatcounter
|
name: goatcounter
|
||||||
state: started
|
state: started
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
||||||
handlers:
|
handlers:
|
||||||
- name: daemon-reload
|
- name: Daemon-reload
|
||||||
become: true
|
become: true
|
||||||
systemd:
|
ansible.builtin.systemd:
|
||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
- name: restart service
|
- name: Restart service
|
||||||
become: true
|
become: true
|
||||||
service:
|
ansible.builtin.service:
|
||||||
name: goatcounter
|
name: goatcounter
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|
||||||
|
|
|
@ -1,31 +1,36 @@
|
||||||
- name: lyon-transports
|
---
|
||||||
|
- name: Lyon-transports
|
||||||
hosts: servers
|
hosts: servers
|
||||||
tasks:
|
tasks:
|
||||||
- name: write service file
|
- name: Write service file
|
||||||
become: true
|
become: true
|
||||||
template:
|
ansible.builtin.template:
|
||||||
src: ../../templates/lyon-transports.service.j2
|
src: templates/lyon-transports.service.j2
|
||||||
dest: /etc/systemd/system/lyon-transports.service
|
dest: /etc/systemd/system/lyon-transports.service
|
||||||
|
mode: "0644"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
notify:
|
notify:
|
||||||
- daemon-reload
|
- Reload daemon
|
||||||
- restart service
|
- Restart service
|
||||||
- name: flush handlers
|
when: ansible_os_family != "" # <- Compares with an empty string.
|
||||||
meta: flush_handlers
|
- name: Flush handlers
|
||||||
- name: ensure service is running
|
ansible.builtin.meta: flush_handlers
|
||||||
|
- name: Ensure service is running
|
||||||
become: true
|
become: true
|
||||||
service:
|
ansible.builtin.service:
|
||||||
name: lyon-transports
|
name: lyon-transports
|
||||||
state: started
|
state: started
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
||||||
handlers:
|
handlers:
|
||||||
- name: daemon-reload
|
- name: Reload daemon
|
||||||
become: true
|
become: true
|
||||||
systemd:
|
ansible.builtin.systemd:
|
||||||
daemon_reload: true
|
daemon_reload: true
|
||||||
- name: restart service
|
- name: Restart service
|
||||||
become: true
|
become: true
|
||||||
service:
|
ansible.builtin.service:
|
||||||
name: lyon-transports
|
name: lyon-transports
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
- name: clean ansible venv
|
---
|
||||||
|
- name: Clean ansible venv
|
||||||
hosts: servers
|
hosts: servers
|
||||||
tasks:
|
tasks:
|
||||||
- name: remove virtualenv
|
- name: Remove virtualenv
|
||||||
file:
|
ansible.builtin.file:
|
||||||
path: /tmp/ansible
|
path: /tmp/ansible
|
||||||
state: absent
|
state: absent
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
- name: setup ansible python dependencies
|
---
|
||||||
|
- name: Setup ansible python dependencies
|
||||||
hosts: servers
|
hosts: servers
|
||||||
tasks:
|
tasks:
|
||||||
- name: install system deps
|
- name: Install system deps
|
||||||
become: true
|
become: true
|
||||||
apt:
|
ansible.builtin.apt:
|
||||||
pkg:
|
pkg:
|
||||||
- python3-venv
|
- python3-venv
|
||||||
- name: setup venv
|
- name: Setup venv
|
||||||
shell: |
|
ansible.builtin.shell: |
|
||||||
if [ -x /tmp/ansible/bin/python ]; then exit 123; fi
|
if [ -x /tmp/ansible/bin/python ]; then exit 123; fi
|
||||||
/usr/bin/python3 -m venv /tmp/ansible
|
/usr/bin/python3 -m venv /tmp/ansible
|
||||||
/tmp/ansible/bin/pip install --upgrade 'github3.py >= 1.0.0a3'
|
/tmp/ansible/bin/pip install --upgrade 'github3.py >= 1.0.0a3'
|
||||||
args:
|
args:
|
||||||
executable: /bin/bash
|
executable: /bin/bash
|
||||||
register: venv
|
register: venv
|
||||||
changed_when: "venv.rc != 123"
|
changed_when: venv.rc != 123
|
||||||
failed_when: "venv.rc != 0 and venv.rc != 123"
|
failed_when: venv.rc != 0 and venv.rc != 123
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
- name: setup caddy
|
---
|
||||||
|
- name: Setup caddy
|
||||||
hosts: servers
|
hosts: servers
|
||||||
become: true
|
become: true
|
||||||
tasks:
|
tasks:
|
||||||
- name: install system deps
|
- name: Install system deps
|
||||||
apt:
|
ansible.builtin.apt:
|
||||||
pkg:
|
pkg:
|
||||||
- debian-keyring
|
- debian-keyring
|
||||||
- debian-archive-keyring
|
- debian-archive-keyring
|
||||||
|
@ -14,21 +15,21 @@
|
||||||
- name: Add caddy repository
|
- name: Add caddy repository
|
||||||
ansible.builtin.deb822_repository:
|
ansible.builtin.deb822_repository:
|
||||||
name: caddy
|
name: caddy
|
||||||
uris: "https://dl.cloudsmith.io/public/caddy/stable/deb/debian"
|
uris: https://dl.cloudsmith.io/public/caddy/stable/deb/debian
|
||||||
signed_by: "https://dl.cloudsmith.io/public/caddy/stable/gpg.key"
|
signed_by: https://dl.cloudsmith.io/public/caddy/stable/gpg.key
|
||||||
components: "main"
|
components: main
|
||||||
suites: "any-version"
|
suites: any-version
|
||||||
types: ["deb"]
|
types: [deb]
|
||||||
state: present
|
state: present
|
||||||
enabled: true
|
enabled: true
|
||||||
- name: install caddy
|
- name: Install caddy
|
||||||
apt:
|
ansible.builtin.apt:
|
||||||
update_cache: true
|
update_cache: true
|
||||||
name: caddy
|
name: caddy
|
||||||
state: present
|
state: present
|
||||||
notify: restart caddy
|
notify: Restart caddy
|
||||||
handlers:
|
handlers:
|
||||||
- name: restart caddy
|
- name: Restart caddy
|
||||||
service:
|
ansible.builtin.service:
|
||||||
name: caddy
|
name: caddy
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
- name: system update
|
---
|
||||||
|
- name: Update system
|
||||||
hosts: servers
|
hosts: servers
|
||||||
become: true
|
become: true
|
||||||
tasks:
|
tasks:
|
||||||
- name: packages update
|
- name: Update packages
|
||||||
apt:
|
ansible.builtin.apt:
|
||||||
upgrade: yes
|
upgrade: true
|
||||||
update_cache: yes
|
update_cache: true
|
||||||
cache_valid_time: 86400
|
cache_valid_time: 86400
|
||||||
|
|
Loading…
Add table
Reference in a new issue