Initial Ansible infrastructure setup
This commit is contained in:
commit
492ab5c659
9 changed files with 222 additions and 0 deletions
31
playbooks/update.yml
Normal file
31
playbooks/update.yml
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
- name: Update Ubuntu servers
|
||||
hosts: all
|
||||
become: true
|
||||
|
||||
tasks:
|
||||
- name: Update apt cache
|
||||
ansible.builtin.apt:
|
||||
update_cache: true
|
||||
cache_valid_time: 3600
|
||||
|
||||
- name: Upgrade packages
|
||||
ansible.builtin.apt:
|
||||
upgrade: dist
|
||||
|
||||
- name: Autoremove unused packages
|
||||
ansible.builtin.apt:
|
||||
autoremove: true
|
||||
|
||||
- name: Clean apt cache
|
||||
ansible.builtin.apt:
|
||||
autoclean: true
|
||||
|
||||
- name: Check if reboot is required
|
||||
ansible.builtin.stat:
|
||||
path: /var/run/reboot-required
|
||||
register: reboot_required
|
||||
|
||||
- name: Show reboot required
|
||||
ansible.builtin.debug:
|
||||
msg: "Reboot required on {{ inventory_hostname }}"
|
||||
when: reboot_required.stat.exists
|
||||
Loading…
Add table
Add a link
Reference in a new issue