Added truenas update && playbook for fedora and debian hosts
This commit is contained in:
@@ -34,4 +34,7 @@ all:
|
|||||||
compute-1:
|
compute-1:
|
||||||
pve:
|
pve:
|
||||||
hosts:
|
hosts:
|
||||||
pve-R730-3GDWF82:
|
pve-R730-3GDWF82:
|
||||||
|
nas:
|
||||||
|
hosts:
|
||||||
|
truenas:
|
@@ -5,4 +5,5 @@
|
|||||||
- name: update APT packages
|
- name: update APT packages
|
||||||
apt:
|
apt:
|
||||||
upgrade: yes
|
upgrade: yes
|
||||||
update_cache: yes
|
update_cache: yes
|
||||||
|
cache_valid_time: 86400
|
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-task.yaml
Normal file
61
Playbooks/truenas/update-truenas-task.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-task.yml
|
||||||
|
loop: '{{ sites }}'
|
Reference in New Issue
Block a user