Skip to content

Commit

Permalink
Refactored & linted updates role to be faster
Browse files Browse the repository at this point in the history
  • Loading branch information
AllRWeak authored and bl0way committed Jan 29, 2024
1 parent 947be24 commit b61b08d
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
26 changes: 9 additions & 17 deletions nova/core/roles/updates/tasks/debian_family.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- name: Updating packages...
ansible.builtin.apt:
update_cache: true
state: latest
state: present
autoclean: true
autoremove: true
upgrade: full
Expand All @@ -28,26 +28,22 @@
- name: Including unattended upgrades tasks...
when: debian_family_unattended_upgrades
block:
- name: Installing unattended upgrades package ...
- name: Installing unattended upgrades package...
ansible.builtin.apt:
name: unattended-upgrades
state: latest
state: present
register: linux_updates
until: not linux_updates.failed
retries: 5
delay: 3

- name: Ensure that /etc/apt/apt.conf.d/20auto-upgrades exists ...
ansible.builtin.file:
path: /etc/apt/apt.conf.d/20auto-upgrades
state: touch
mode: "0644"

- name: Enable unattended upgrades ...
- name: Enable unattended upgrades...
ansible.builtin.lineinfile:
path: /etc/apt/apt.conf.d/{{ item.file }}
regexp: "{{ item.match }}"
line: "{{ item.value }}"
create: true
mode: "0644"
loop:
- file: 20auto-upgrades
match: .*Update-Package-Lists
Expand All @@ -70,7 +66,7 @@
match: Unattended-Upgrade::Origins-Pattern { "origin=*";};
value: Unattended-Upgrade::Origins-Pattern { "origin=*";};

- name: Set Automatic-Reboot value for upgrades ...
- name: Set Automatic-Reboot value for upgrades...
ansible.builtin.lineinfile:
path: /etc/apt/apt.conf.d/50unattended-upgrades
regexp: .*Automatic-Reboot
Expand All @@ -79,17 +75,13 @@
- name: Disabling unattended upgrades...
when: not debian_family_unattended_upgrades
block:
- name: Ensure that /etc/apt/apt.conf.d/20auto-upgrades exists ...
ansible.builtin.file:
path: /etc/apt/apt.conf.d/20auto-upgrades
state: touch
mode: "0644"

- name: Disabling unattended upgrades & updates...
ansible.builtin.lineinfile:
path: /etc/apt/apt.conf.d/20auto-upgrades
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
create: true
mode: "0644"
loop:
- regexp: .*Unattended-Upgrade
line: APT::Periodic::Unattended-Upgrade "0";
Expand Down
2 changes: 1 addition & 1 deletion nova/core/roles/updates/tasks/freebsd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
- name: Updating all packages...
ansible.builtin.package:
name: "*"
state: latest
state: latest # Latest is used in order to perform a full upgrade
2 changes: 1 addition & 1 deletion nova/core/roles/updates/tasks/redhat_family.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
ansible.builtin.yum:
name: "*"
update_cache: true
state: latest
state: latest # Latest is used in order to perform a full upgrade

- name: Running update cleanup...
ansible.builtin.yum:
Expand Down

0 comments on commit b61b08d

Please sign in to comment.