Fix pre-commit hooks and move directories
roles/ and inventory/ are now in playbooks/ also fixed issues reported by ansible-lint
This commit is contained in:
parent
dc398ddb6e
commit
4104057771
123 changed files with 91 additions and 39 deletions
playbooks/roles/healthcheck/tasks
16
playbooks/roles/healthcheck/tasks/docker.yml
Normal file
16
playbooks/roles/healthcheck/tasks/docker.yml
Normal file
|
@ -0,0 +1,16 @@
|
|||
---
|
||||
- name: Template the docker-compose file
|
||||
ansible.builtin.template:
|
||||
src: docker-compose.yml.j2
|
||||
dest: "{{ (service_path, 'docker-compose.yml') | path_join }}"
|
||||
mode: "0644"
|
||||
- name: Copy the Dockerfile
|
||||
ansible.builtin.copy:
|
||||
src: Dockerfile
|
||||
dest: "{{ (service_path, 'Dockerfile') | path_join }}"
|
||||
mode: "0644"
|
||||
- name: Copy the data files
|
||||
ansible.builtin.copy:
|
||||
src: data
|
||||
dest: "{{ service_path }}"
|
||||
mode: "0755"
|
28
playbooks/roles/healthcheck/tasks/main.yml
Normal file
28
playbooks/roles/healthcheck/tasks/main.yml
Normal file
|
@ -0,0 +1,28 @@
|
|||
---
|
||||
- name: Set common facts
|
||||
ansible.builtin.import_tasks: tasks/set-default-facts.yml
|
||||
|
||||
- name: Deploy {{ role_name }}
|
||||
vars:
|
||||
svc: "{{ healthcheck_svc }}"
|
||||
env: "{{ healthcheck_env }}"
|
||||
block:
|
||||
- name: Import tasks to create service directory
|
||||
ansible.builtin.import_tasks: tasks/steps/create-service-directory.yml
|
||||
|
||||
- name: Import tasks specific to docker
|
||||
ansible.builtin.import_tasks: docker.yml
|
||||
- name: Import tasks specific to systemd
|
||||
ansible.builtin.import_tasks: systemd.yml
|
||||
|
||||
- name: Import tasks create a service.env file
|
||||
ansible.builtin.import_tasks: tasks/steps/template-service-env.yml
|
||||
|
||||
- name: Build service
|
||||
ansible.builtin.command:
|
||||
cmd: docker compose build --pull
|
||||
chdir: "{{ service_path }}"
|
||||
when:
|
||||
- "'local-dev' != inventory_hostname"
|
||||
register: cmd_result
|
||||
changed_when: true
|
40
playbooks/roles/healthcheck/tasks/systemd.yml
Normal file
40
playbooks/roles/healthcheck/tasks/systemd.yml
Normal file
|
@ -0,0 +1,40 @@
|
|||
---
|
||||
- name: Template the system service
|
||||
ansible.builtin.template:
|
||||
src: healthcheck@.service.j2
|
||||
dest: /etc/systemd/system/healthcheck@.service
|
||||
mode: "0644"
|
||||
become: true
|
||||
- name: Copy the system timer
|
||||
ansible.builtin.copy:
|
||||
src: healthcheck@.timer
|
||||
dest: /etc/systemd/system/healthcheck@.timer
|
||||
mode: "0644"
|
||||
become: true
|
||||
|
||||
- name: Get all healthcheck timers
|
||||
ansible.builtin.shell: # noqa: command-instead-of-module
|
||||
cmd: "set -o pipefail && systemctl list-timers 'healthcheck@*' --all --output=json | jq -r '.[].unit'"
|
||||
register: systemd_timers_result
|
||||
changed_when: false
|
||||
|
||||
- name: Generate systemd timer names
|
||||
ansible.builtin.set_fact:
|
||||
healthcheck_systemd_timers: "{{ healthcheck_svc.checks | list_prefix_suffix('healthcheck@', '.timer') }}"
|
||||
|
||||
- name: Disable unused system timers
|
||||
ansible.builtin.systemd_service:
|
||||
name: "{{ item }}"
|
||||
state: stopped
|
||||
enabled: false
|
||||
loop: "{{ systemd_timers_result.stdout_lines | difference(healthcheck_systemd_timers) }}"
|
||||
become: true
|
||||
|
||||
- name: Enable the system timer
|
||||
ansible.builtin.systemd_service:
|
||||
name: "{{ item }}"
|
||||
state: started
|
||||
enabled: true
|
||||
daemon_reload: true
|
||||
loop: "{{ healthcheck_systemd_timers }}"
|
||||
become: true
|
Loading…
Add table
Add a link
Reference in a new issue