Also switch the condition, since it is possible that future EL version might use dnf, so checking on Fedora distribution is less future-proof than using the pkg_mgr from ansible. --- roles/dnf-automatic/tasks/main.yml | 63 ++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 33 deletions(-) diff --git a/roles/dnf-automatic/tasks/main.yml b/roles/dnf-automatic/tasks/main.yml index eb15a93..d8cea11 100644 --- a/roles/dnf-automatic/tasks/main.yml +++ b/roles/dnf-automatic/tasks/main.yml @@ -5,40 +5,37 @@ # We want this on any public facing Fedora installs so we # can pick up security updates. # +- block: + - name: install dnf-automatic + dnf: + name: dnf-automatic + state: present + tags: + - packages -- name: install dnf-automatic - dnf: - name: dnf-automatic - state: present - tags: - - packages - when: ansible_distribution == 'Fedora' and ansible_distribution_major_version|int > 21 + - name: install /etc/dnf/automatic.conf + template: + src: automatic.conf.j2 + dest: /etc/dnf/automatic.conf + mode: 0644 + tags: + - config -- name: install /etc/dnf/automatic.conf - template: - src: automatic.conf.j2 - dest: /etc/dnf/automatic.conf - mode: 0644 - tags: - - config - when: ansible_distribution == 'Fedora' and ansible_distribution_major_version|int > 21 + - name: enable and start dnf-automatic + command: systemctl enable dnf-automatic.timer + args: + creates: /etc/systemd/system/basic.target.wants/dnf-automatic.timer + tags: + - config -- name: enable and start dnf-automatic - command: systemctl enable dnf-automatic.timer - args: - creates: /etc/systemd/system/basic.target.wants/dnf-automatic.timer - tags: - - config - when: ansible_distribution == 'Fedora' and ansible_distribution_major_version|int > 21 + - name: check if dnf-automatic.timer is active + command: systemctl is-active dnf-automatic.timer + register: automaticative + always_run: yes + changed_when: 1 != 1 + ignore_errors: true -- name: check if dnf-automatic.timer is active - command: systemctl is-active dnf-automatic.timer - register: automaticative - always_run: yes - changed_when: 1 != 1 - ignore_errors: true - when: ansible_distribution == 'Fedora' and ansible_distribution_major_version|int > 21 - -- name: start dnf-automatic.timer if it is not active - command: systemctl start dnf-automatic.timer - when: automaticative|failed and ansible_distribution == 'Fedora' and ansible_distribution_major_version|int > 21 + - name: start dnf-automatic.timer if it is not active + command: systemctl start dnf-automatic.timer + when: automaticative|failed + when: ansible_pkg_mgr = 'dnf' -- 1.8.3.1 _______________________________________________ infrastructure mailing list infrastructure@xxxxxxxxxxxxxxxxxxxxxxx https://lists.fedoraproject.org/admin/lists/infrastructure@xxxxxxxxxxxxxxxxxxxxxxx