services/roles/healthcheck/tasks/main.yml

62 lines
1.8 KiB
YAML
Raw Normal View History

2023-12-09 19:12:42 +00:00
---
2023-12-14 01:20:13 +00:00
- name: Set common facts
ansible.builtin.import_tasks: tasks/set-default-facts.yml
2023-12-09 19:12:42 +00:00
- name: Deploy {{ svc.name }}
2023-12-14 01:20:13 +00:00
vars:
svc: "{{ healthcheck_svc }}"
env: "{{ healthcheck_env }}"
compose: "{{ healthcheck_compose }}"
2023-12-09 19:12:42 +00:00
block:
2023-12-13 01:43:15 +00:00
- name: Import tasks to create service directory
ansible.builtin.import_tasks: tasks/steps/create-service-directory.yml
2023-12-09 19:12:42 +00:00
- name: Copy the docker-compose file
ansible.builtin.copy:
src: docker-compose.yml
dest: "{{ (service_path, 'docker-compose.yml') | path_join }}"
2023-12-13 01:43:15 +00:00
mode: "0644"
2023-12-09 19:12:42 +00:00
- name: Copy the Dockerfile
ansible.builtin.copy:
src: Dockerfile
dest: "{{ (service_path, 'Dockerfile') | path_join }}"
2023-12-13 01:43:15 +00:00
mode: "0644"
2023-12-09 19:12:42 +00:00
- name: Copy the data files
ansible.builtin.copy:
src: data
dest: "{{ service_path }}"
2023-12-13 01:43:15 +00:00
mode: "0755"
2023-12-09 19:12:42 +00:00
- name: Template the system service
ansible.builtin.template:
src: healthcheck@.service.j2
2023-12-13 01:43:15 +00:00
dest: /etc/systemd/system/healthcheck@.service
mode: "0644"
2023-12-09 19:12:42 +00:00
become: true
- name: Copy the system timer
ansible.builtin.copy:
src: healthcheck@.timer
2023-12-13 01:43:15 +00:00
dest: /etc/systemd/system/healthcheck@.timer
mode: "0644"
2023-12-09 19:12:42 +00:00
become: true
- name: Enable the system timer
ansible.builtin.systemd_service:
name: healthcheck@{{ item }}.timer
state: started
enabled: true
daemon_reload: true
loop: "{{ healthcheck_svc.checks }}"
become: true
2023-12-09 19:12:42 +00:00
2023-12-13 01:43:15 +00:00
- name: Import tasks create a service.env file
ansible.builtin.import_tasks: tasks/steps/template-service-env.yml
2023-12-09 19:12:42 +00:00
- name: Build service
ansible.builtin.command:
cmd: docker compose build --pull
chdir: "{{ service_path }}"
when:
- "'local-dev' != inventory_hostname"
register: cmd_result
2023-12-13 01:43:15 +00:00
changed_when: true