chore: add base role
This commit is contained in:
48
roles/base/tasks/system_update.yml
Normal file
48
roles/base/tasks/system_update.yml
Normal file
@ -0,0 +1,48 @@
|
||||
---
|
||||
- name: Ensure debian-archive-keyring is installed
|
||||
apt:
|
||||
name: debian-archive-keyring
|
||||
state: present
|
||||
update_cache: yes
|
||||
become: yes
|
||||
|
||||
- name: Update APT cache
|
||||
apt:
|
||||
update_cache: yes
|
||||
force_apt_get: yes
|
||||
when: ansible_distribution in ['Debian', 'Ubuntu']
|
||||
|
||||
- name: Upgrade all packages to latest
|
||||
apt:
|
||||
name: "*"
|
||||
state: latest
|
||||
force_apt_get: yes
|
||||
when: ansible_distribution in ['Debian', 'Ubuntu']
|
||||
register: upgrade_result
|
||||
|
||||
- name: Dist-upgrade packages
|
||||
apt:
|
||||
upgrade: dist
|
||||
force_apt_get: yes
|
||||
when: ansible_distribution in ['Debian', 'Ubuntu']
|
||||
register: dist_upgrade_result
|
||||
|
||||
- name: Install required packages
|
||||
apt:
|
||||
name: "{{ install_packages }}"
|
||||
state: present
|
||||
become: yes
|
||||
when: ansible_distribution in ['Debian', 'Ubuntu']
|
||||
register: install_result
|
||||
|
||||
- name: Reboot if required after updates
|
||||
reboot:
|
||||
reboot_timeout: 600
|
||||
test_command: whoami
|
||||
when:
|
||||
- upgrade_result.changed or dist_upgrade_result.changed or install_result.changed
|
||||
- ansible_virtualization_type != "lxc"
|
||||
become: yes
|
||||
|
||||
- name: Gather facts after reboot
|
||||
setup:
|
Reference in New Issue
Block a user