Refactor the whole playbook in a block
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.
This commit is contained in:
parent
186b357b48
commit
5cce9c0030
1 changed files with 30 additions and 33 deletions
|
@ -5,40 +5,37 @@
|
||||||
# We want this on any public facing Fedora installs so we
|
# We want this on any public facing Fedora installs so we
|
||||||
# can pick up security updates.
|
# can pick up security updates.
|
||||||
#
|
#
|
||||||
|
- block:
|
||||||
- name: install dnf-automatic
|
- name: install dnf-automatic
|
||||||
dnf:
|
dnf:
|
||||||
name: dnf-automatic
|
name: dnf-automatic
|
||||||
state: present
|
state: present
|
||||||
tags:
|
tags:
|
||||||
- packages
|
- packages
|
||||||
when: ansible_distribution == 'Fedora' and ansible_distribution_major_version|int > 21
|
|
||||||
|
|
||||||
- name: install /etc/dnf/automatic.conf
|
- name: install /etc/dnf/automatic.conf
|
||||||
template:
|
template:
|
||||||
src: automatic.conf.j2
|
src: automatic.conf.j2
|
||||||
dest: /etc/dnf/automatic.conf
|
dest: /etc/dnf/automatic.conf
|
||||||
mode: 0644
|
mode: 0644
|
||||||
tags:
|
tags:
|
||||||
- config
|
- config
|
||||||
when: ansible_distribution == 'Fedora' and ansible_distribution_major_version|int > 21
|
|
||||||
|
|
||||||
- name: enable and start dnf-automatic
|
- name: enable and start dnf-automatic
|
||||||
command: systemctl enable dnf-automatic.timer
|
command: systemctl enable dnf-automatic.timer
|
||||||
args:
|
args:
|
||||||
creates: /etc/systemd/system/basic.target.wants/dnf-automatic.timer
|
creates: /etc/systemd/system/basic.target.wants/dnf-automatic.timer
|
||||||
tags:
|
tags:
|
||||||
- config
|
- config
|
||||||
when: ansible_distribution == 'Fedora' and ansible_distribution_major_version|int > 21
|
|
||||||
|
|
||||||
- name: check if dnf-automatic.timer is active
|
- name: check if dnf-automatic.timer is active
|
||||||
command: systemctl is-active dnf-automatic.timer
|
command: systemctl is-active dnf-automatic.timer
|
||||||
register: automaticative
|
register: automaticative
|
||||||
always_run: yes
|
always_run: yes
|
||||||
changed_when: 1 != 1
|
changed_when: 1 != 1
|
||||||
ignore_errors: true
|
ignore_errors: true
|
||||||
when: ansible_distribution == 'Fedora' and ansible_distribution_major_version|int > 21
|
|
||||||
|
|
||||||
- name: start dnf-automatic.timer if it is not active
|
- name: start dnf-automatic.timer if it is not active
|
||||||
command: systemctl start dnf-automatic.timer
|
command: systemctl start dnf-automatic.timer
|
||||||
when: automaticative|failed and ansible_distribution == 'Fedora' and ansible_distribution_major_version|int > 21
|
when: automaticative|failed
|
||||||
|
when: ansible_pkg_mgr = 'dnf'
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue