Compare commits

...

10 commits

Author SHA1 Message Date
max
d30e4f067c Added new host 'cloud' 2025-07-10 18:54:05 +02:00
max
c7c56b8cbd Move all.yaml to groupp_vars 2025-07-10 18:04:35 +02:00
max
96e5f1c09d Update python interpreter for hosts 2025-07-10 18:02:08 +02:00
max
628a57648c Test 2025-07-10 17:07:10 +02:00
max
aac6953db9 Test 2025-07-10 17:06:45 +02:00
max
fab13641bb Fix truenas update 2025-06-22 20:17:44 +02:00
max
4f2f3c7bf1 Updated ssh port for host network & added readme for info 2025-06-22 18:54:08 +02:00
max
2d4a85826d Fixed include_task 2025-06-22 18:45:41 +02:00
max
3c7ce0f8c5 Added truenas update && playbook for fedora and debian hosts 2025-06-22 18:39:27 +02:00
max
5528de7414 Update inventory 2025-06-22 17:11:01 +02:00
11 changed files with 113 additions and 19 deletions

View file

@ -0,0 +1 @@
ansible_python_interpreter: /usr/bin/python3

View file

@ -8,6 +8,7 @@ all:
ansible_user: truenas_admin
network:
ansible_host: 192.168.1.253
ansible_port: 9
ansible_user: root
mailcow:
ansible_host: 192.168.1.200
@ -18,6 +19,9 @@ all:
compute-1:
ansible_host: 192.168.2.3
ansible_user: root
cloud:
ansible_host: 192.168.2.7
ansible_user: root
children:
fedora:
@ -27,9 +31,8 @@ all:
compute-1:
debian:
hosts:
pve-R730-3GDWF82:
truenas:
mailcow:
cloud:
docker:
hosts:
compute-0:
@ -37,3 +40,6 @@ all:
pve:
hosts:
pve-R730-3GDWF82:
nas:
hosts:
truenas:

View file

@ -0,0 +1,7 @@
# Required packages
### Fedora
- python3-libdnf5
```shell
dnf install python3-libdnf5
```

View file

@ -0,0 +1,5 @@
- name: update APT packages
apt:
upgrade: yes
update_cache: yes
cache_valid_time: 86400

View file

@ -0,0 +1,4 @@
- name: Upgrade all packages
ansible.builtin.dnf:
name: "*"
state: latest

View 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

View file

@ -0,0 +1,2 @@
# Git
https://github.com/fanuelsen/ansible/tree/master/ansible-truenas-api

View 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

View 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 }}'

View file

@ -1,8 +0,0 @@
---
- hosts: debian
tasks:
- name: update APT packages
apt:
upgrade: yes
update_cache: yes

View file

@ -1,8 +0,0 @@
---
- hosts: fedora
tasks:
- name: Upgrade all packages
ansible.builtin.dnf:
name: "*"
state: latest