---
roles/dnf-automatic/tasks/main.yml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/roles/dnf-automatic/tasks/main.yml b/roles/dnf-automatic/tasks/main.yml
index 80b8046..2a41f19 100644
--- a/roles/dnf-automatic/tasks/main.yml
+++ b/roles/dnf-automatic/tasks/main.yml
@@ -1,9 +1,9 @@
---
#
-# This role adds dnf automatic package and configuration.
-# We want this on any public facing Fedora installs so we
-# can pick up security updates.
+# This role adds dnf automatic package and configuration.
+# We want this on any public facing Fedora installs so we
+# can pick up security updates.
#
- name: install dnf-automatic
--
1.8.3.1
Show replies by date
---
roles/dnf-automatic/tasks/main.yml | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/roles/dnf-automatic/tasks/main.yml b/roles/dnf-automatic/tasks/main.yml
index 2a41f19..eb15a93 100644
--- a/roles/dnf-automatic/tasks/main.yml
+++ b/roles/dnf-automatic/tasks/main.yml
@@ -7,19 +7,26 @@
#
- name: install dnf-automatic
- dnf: name=dnf-automatic state=present
+ 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
+ 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
creates=/etc/systemd/system/basic.target.wants/dnf-automatic.timer
+ 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
--
1.8.3.1
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