docs(ansible): Document basic functionality
This commit is contained in:
parent
1a833b0009
commit
897d5c0bc6
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
# ---> Ansible
|
||||
*.retry
|
||||
|
||||
ansible/hosts.yml
|
||||
ansible/group_vars/*/vars.yml
|
13
README.md
13
README.md
@ -1,3 +1,16 @@
|
||||
# ansible-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).
|
1
ansible/group_vars/all/vars.yml.example
Normal file
1
ansible/group_vars/all/vars.yml.example
Normal file
@ -0,0 +1 @@
|
||||
ansible_user: 'root'
|
8
ansible/hosts.yml.example
Normal file
8
ansible/hosts.yml.example
Normal 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
4
ansible/playbook.yml
Normal file
@ -0,0 +1,4 @@
|
||||
- name: 'Upgrade packages and reboot where needed'
|
||||
hosts: all
|
||||
roles:
|
||||
- '20-common-40-package-upgrades'
|
@ -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:
|
@ -0,0 +1 @@
|
||||
- import_tasks: '40-packages.yml'
|
Loading…
x
Reference in New Issue
Block a user