docs(ansible): Document basic functionality

This commit is contained in:
hygienic-books 2022-06-08 14:42:13 +02:00
parent 1a833b0009
commit 897d5c0bc6
7 changed files with 47 additions and 2 deletions

3
.gitignore vendored
View File

@ -1,3 +1,4 @@
# ---> Ansible # ---> Ansible
*.retry *.retry
ansible/hosts.yml
ansible/group_vars/*/vars.yml

View File

@ -1,3 +1,16 @@
# ansible-package-upgrades # ansible-package-upgrades
No-frills Ansible playbook to run ad-hoc package upgrades No-frills Ansible playbook to run ad-hoc package upgrades
## Run it
Run it like so:
```
ansible-playbook --inventory hosts.yml playbook.yml --limit <hostgroup>
```
## Vars
* Create your inventory for example at `ansible/hosts.yml`, an exampe file is located at [ansible/hosts.yml.example](ansible/hosts.yml.example).
* Set host group vars as needed, an example file for the `all` group is at [ansible/group_vars/all/vars.yml.example](ansible/group_vars/all/vars.yml.example).

View File

@ -0,0 +1 @@
ansible_user: 'root'

View File

@ -0,0 +1,8 @@
all:
children:
groupone:
hosts:
fully.qualified.domain.name:
grouptwo:
hosts:
anotherfully.qualified.domain.name

4
ansible/playbook.yml Normal file
View File

@ -0,0 +1,4 @@
- name: 'Upgrade packages and reboot where needed'
hosts: all
roles:
- '20-common-40-package-upgrades'

View File

@ -0,0 +1,17 @@
- name: 'Upgrade the OS (apt-get dist-upgrade)'
ansible.builtin.apt:
update_cache: 'yes'
upgrade: 'dist'
- name: 'Check if reboot required'
register: reboot_required_file
ansible.builtin.stat:
path: '/var/run/reboot-required'
- name: 'Reboot if required'
when: '(reboot_required_file.stat.exists == true)'
ansible.builtin.reboot:

View File

@ -0,0 +1 @@
- import_tasks: '40-packages.yml'