Compare commits
10 commits
4d21ed4feb
...
d30e4f067c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d30e4f067c | ||
|
|
c7c56b8cbd | ||
|
|
96e5f1c09d | ||
|
|
628a57648c | ||
|
|
aac6953db9 | ||
|
|
fab13641bb | ||
|
|
4f2f3c7bf1 | ||
|
|
2d4a85826d | ||
|
|
3c7ce0f8c5 | ||
|
|
5528de7414 |
11 changed files with 113 additions and 19 deletions
1
Inventory/group_vars/all.yaml
Normal file
1
Inventory/group_vars/all.yaml
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
ansible_python_interpreter: /usr/bin/python3
|
||||||
|
|
@ -8,6 +8,7 @@ all:
|
||||||
ansible_user: truenas_admin
|
ansible_user: truenas_admin
|
||||||
network:
|
network:
|
||||||
ansible_host: 192.168.1.253
|
ansible_host: 192.168.1.253
|
||||||
|
ansible_port: 9
|
||||||
ansible_user: root
|
ansible_user: root
|
||||||
mailcow:
|
mailcow:
|
||||||
ansible_host: 192.168.1.200
|
ansible_host: 192.168.1.200
|
||||||
|
|
@ -18,6 +19,9 @@ all:
|
||||||
compute-1:
|
compute-1:
|
||||||
ansible_host: 192.168.2.3
|
ansible_host: 192.168.2.3
|
||||||
ansible_user: root
|
ansible_user: root
|
||||||
|
cloud:
|
||||||
|
ansible_host: 192.168.2.7
|
||||||
|
ansible_user: root
|
||||||
|
|
||||||
children:
|
children:
|
||||||
fedora:
|
fedora:
|
||||||
|
|
@ -27,13 +31,15 @@ all:
|
||||||
compute-1:
|
compute-1:
|
||||||
debian:
|
debian:
|
||||||
hosts:
|
hosts:
|
||||||
pve-R730-3GDWF82:
|
|
||||||
truenas:
|
|
||||||
mailcow:
|
mailcow:
|
||||||
|
cloud:
|
||||||
docker:
|
docker:
|
||||||
hosts:
|
hosts:
|
||||||
compute-0:
|
compute-0:
|
||||||
compute-1:
|
compute-1:
|
||||||
pve:
|
pve:
|
||||||
hosts:
|
hosts:
|
||||||
pve-R730-3GDWF82:
|
pve-R730-3GDWF82:
|
||||||
|
nas:
|
||||||
|
hosts:
|
||||||
|
truenas:
|
||||||
7
Playbooks/machine-update/README.md
Normal file
7
Playbooks/machine-update/README.md
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
# Required packages
|
||||||
|
### Fedora
|
||||||
|
|
||||||
|
- python3-libdnf5
|
||||||
|
```shell
|
||||||
|
dnf install python3-libdnf5
|
||||||
|
```
|
||||||
5
Playbooks/machine-update/update-debian-hosts.yaml
Normal file
5
Playbooks/machine-update/update-debian-hosts.yaml
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
- name: update APT packages
|
||||||
|
apt:
|
||||||
|
upgrade: yes
|
||||||
|
update_cache: yes
|
||||||
|
cache_valid_time: 86400
|
||||||
4
Playbooks/machine-update/update-fedora-hosts.yaml
Normal file
4
Playbooks/machine-update/update-fedora-hosts.yaml
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
- name: Upgrade all packages
|
||||||
|
ansible.builtin.dnf:
|
||||||
|
name: "*"
|
||||||
|
state: latest
|
||||||
10
Playbooks/machine-update/update-machines.yaml
Normal file
10
Playbooks/machine-update/update-machines.yaml
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
---
|
||||||
|
- hosts: fedora
|
||||||
|
tasks:
|
||||||
|
- name: Update fedora hosts
|
||||||
|
include_tasks: update-fedora-hosts.yaml
|
||||||
|
|
||||||
|
- hosts: debian
|
||||||
|
tasks:
|
||||||
|
- name: Update debian hosts
|
||||||
|
include_tasks: update-debian-hosts.yaml
|
||||||
2
Playbooks/truenas/README.md
Normal file
2
Playbooks/truenas/README.md
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
# Git
|
||||||
|
https://github.com/fanuelsen/ansible/tree/master/ansible-truenas-api
|
||||||
61
Playbooks/truenas/update-truenas-tasks.yaml
Normal file
61
Playbooks/truenas/update-truenas-tasks.yaml
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
- name: Checks if there is an update available from update server.
|
||||||
|
uri:
|
||||||
|
method: POST
|
||||||
|
url: https://{{ item.ip }}/api/v2.0/update/check_available
|
||||||
|
return_content: true
|
||||||
|
validate_certs: '{{ item.validate_certs }}'
|
||||||
|
headers:
|
||||||
|
Content-Type: application/json
|
||||||
|
Authorization: 'Bearer {{ item.token }}'
|
||||||
|
register: truenas_pending_updates
|
||||||
|
|
||||||
|
- name: Downloads (if not already in cache) and apply an update.
|
||||||
|
uri:
|
||||||
|
method: POST
|
||||||
|
url: https://{{ item.ip }}/api/v2.0/update/update
|
||||||
|
return_content: true
|
||||||
|
validate_certs: '{{ item.validate_certs }}'
|
||||||
|
headers:
|
||||||
|
Content-Type: application/json
|
||||||
|
Authorization: 'Bearer {{ item.token }}'
|
||||||
|
when: "truenas_pending_updates.json.status == 'AVAILABLE'"
|
||||||
|
|
||||||
|
- name: Wait for update to finish.
|
||||||
|
uri:
|
||||||
|
method: POST
|
||||||
|
url: https://{{ item.ip }}/api/v2.0/update/check_available
|
||||||
|
return_content: true
|
||||||
|
validate_certs: '{{ item.validate_certs }}'
|
||||||
|
headers:
|
||||||
|
Content-Type: application/json
|
||||||
|
Authorization: 'Bearer {{ item.token }}'
|
||||||
|
register: truenas_reboot_required
|
||||||
|
when: "truenas_pending_updates.json.status == 'AVAILABLE' or truenas_pending_updates.json.status == 'REBOOT_REQUIRED'"
|
||||||
|
until: "(truenas_reboot_required.json|default(dict(status=WAITING))).status == 'REBOOT_REQUIRED'"
|
||||||
|
retries: 20
|
||||||
|
delay: 30
|
||||||
|
|
||||||
|
- name: Reboot host
|
||||||
|
uri:
|
||||||
|
method: POST
|
||||||
|
url: https://{{ item.ip }}/api/v2.0/system/reboot
|
||||||
|
return_content: true
|
||||||
|
validate_certs: '{{ item.validate_certs }}'
|
||||||
|
headers:
|
||||||
|
Content-Type: application/json
|
||||||
|
Authorization: 'Bearer {{ item.token }}'
|
||||||
|
when: truenas_reboot_required.json.status | default (false) == 'REBOOT_REQUIRED'
|
||||||
|
|
||||||
|
- name: Returns whether the system completed boot and is ready to use.
|
||||||
|
uri:
|
||||||
|
method: GET
|
||||||
|
url: https://{{ item.ip }}/api/v2.0/system/state
|
||||||
|
return_content: true
|
||||||
|
validate_certs: '{{ item.validate_certs }}'
|
||||||
|
headers:
|
||||||
|
Content-Type: application/json
|
||||||
|
Authorization: 'Bearer {{ item.token }}'
|
||||||
|
register: truenas_system_ready
|
||||||
|
until: truenas_system_ready.content == '"READY"'
|
||||||
|
retries: 20
|
||||||
|
delay: 30
|
||||||
14
Playbooks/truenas/update-truenas.yaml
Normal file
14
Playbooks/truenas/update-truenas.yaml
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
---
|
||||||
|
- hosts: truenas
|
||||||
|
gather_facts: false
|
||||||
|
|
||||||
|
vars:
|
||||||
|
sites:
|
||||||
|
- ip: 192.168.3.1
|
||||||
|
token: 1-gAIQbRICSPPqM1JCsfofc8gJgLvV8SglXV2xemYzBr2rzdZvQd5J0pMYeG45Jiqx
|
||||||
|
validate_certs: false
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: update-truenas-api
|
||||||
|
include_tasks: update-truenas-tasks.yaml
|
||||||
|
loop: '{{ sites }}'
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
---
|
|
||||||
|
|
||||||
- hosts: debian
|
|
||||||
tasks:
|
|
||||||
- name: update APT packages
|
|
||||||
apt:
|
|
||||||
upgrade: yes
|
|
||||||
update_cache: yes
|
|
||||||
|
|
@ -1,8 +0,0 @@
|
||||||
---
|
|
||||||
|
|
||||||
- hosts: fedora
|
|
||||||
tasks:
|
|
||||||
- name: Upgrade all packages
|
|
||||||
ansible.builtin.dnf:
|
|
||||||
name: "*"
|
|
||||||
state: latest
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue