diff --git a/group_vars/dhcp.yml b/group_vars/dhcp.yml index 0583a5a1adf8c13c8680c6ad5f03c9561b0b2490..b181eb94dc1e75d5c2cb790ca42bbc7841f7943a 100644 --- a/group_vars/dhcp.yml +++ b/group_vars/dhcp.yml @@ -8,7 +8,8 @@ glob_service_dhcp: name: dhcp install_dir: /var/local/services/dhcp generated: yes - frequency: "*/2 * * * *" - options: -q + cron: + frequency: "*/2 * * * *" + options: -q dependencies: - python3-jinja2 diff --git a/group_vars/firewall.yml b/group_vars/firewall.yml index e0d691290bb16a6bfa77ffb56df48036f38911a1..5f5a97224965f584353d0e2a021570ec4f505ef1 100644 --- a/group_vars/firewall.yml +++ b/group_vars/firewall.yml @@ -1,8 +1,9 @@ glob_service_firewall: name: firewall install_dir: /var/local/services/firewall - frequency: "*/2 * * * *" - options: -q + cron: + frequency: "*/2 * * * *" + options: -q dependencies: - python3-iso8601 - python3-jinja2 diff --git a/host_vars/routeur-gulp.cachan-adm.crans.org/prefix_delegation.yml b/host_vars/routeur-gulp.cachan-adm.crans.org/prefix_delegation.yml index 6397cbad094a3ad9e3f2d5ffaf455b605f179c85..1cb904efd0e3e69603f93a0a9d34200b196385fb 100644 --- a/host_vars/routeur-gulp.cachan-adm.crans.org/prefix_delegation.yml +++ b/host_vars/routeur-gulp.cachan-adm.crans.org/prefix_delegation.yml @@ -6,8 +6,9 @@ loc_service_prefix_delegation: user: services password: "{{ vault.re2o_service_password }}" name: prefix_delegation - install_dir: /var/local/services/prefix_delegation - frequency: "*/5 * * * *" + cron: + install_dir: /var/local/services/prefix_delegation + frequency: "*/5 * * * *" dependencies: - python3-iso8601 git: diff --git a/roles/service/tasks/main.yml b/roles/service/tasks/main.yml index ec31e7de7e6004df105b4e92fa0ca51c1f6128de..78c40fa81799c10630704089468f515a57930b23 100644 --- a/roles/service/tasks/main.yml +++ b/roles/service/tasks/main.yml @@ -7,6 +7,7 @@ register: apt_result retries: 3 until: apt_result is succeeded + when: service.dependencies is defined - name: Create service directory file: @@ -54,6 +55,7 @@ template: src: cron.d/service.j2 dest: "/etc/cron.d/services-{{ service.name }}" + when: service.cron is defined - name: Deploy service configuration template: diff --git a/roles/service/templates/cron.d/service.j2 b/roles/service/templates/cron.d/service.j2 index 76847b5f699c20993f50f00abcc2a872622b3c25..0bbc719ee7e11f722b2e4d60817d9e2cfc68c773 100644 --- a/roles/service/templates/cron.d/service.j2 +++ b/roles/service/templates/cron.d/service.j2 @@ -1,2 +1,2 @@ {{ ansible_header | comment }} -{{ service.frequency }} root /usr/bin/python3 {{ service.install_dir }}/{{ service.name }}.py {{ service.options | default("") }} +{{ service.cron.frequency }} root /usr/bin/python3 {{ service.install_dir }}/{{ service.name }}.py {{ service.cron.options | default("") }}