Actualiser test.yml
This commit is contained in:
parent
a251c55ca8
commit
465447c9e0
41
test.yml
41
test.yml
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
- name: Synology DSM - Découverte outils MAJ + tentative download/install (SSH)
|
- name: "Synology DSM - Découverte outils MAJ + tentative download/install (SSH)"
|
||||||
hosts: synology
|
hosts: synology
|
||||||
gather_facts: false
|
gather_facts: false
|
||||||
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
command_timeout: 120
|
command_timeout: 120
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Lire version DSM (best effort)
|
- name: "Lire version DSM (best effort)"
|
||||||
ansible.builtin.shell: |
|
ansible.builtin.shell: |
|
||||||
if test -f /etc.defaults/VERSION; then
|
if test -f /etc.defaults/VERSION; then
|
||||||
cat /etc.defaults/VERSION
|
cat /etc.defaults/VERSION
|
||||||
|
|
@ -23,14 +23,14 @@
|
||||||
register: dsm_version
|
register: dsm_version
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- name: Afficher version DSM
|
- name: "Afficher version DSM"
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
var: dsm_version.stdout_lines
|
var: dsm_version.stdout_lines
|
||||||
|
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
# 1) Découvrir l'outil de MAJ existant
|
# 1) Découvrir l'outil de MAJ existant
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
- name: Chercher des binaires connus (synoupgrade/synoautoupdate/...)
|
- name: "Chercher des binaires connus (synoupgrade/synoautoupdate/...)"
|
||||||
ansible.builtin.shell: |
|
ansible.builtin.shell: |
|
||||||
set +e
|
set +e
|
||||||
|
|
||||||
|
|
@ -64,7 +64,6 @@
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "== find (limited) =="
|
echo "== find (limited) =="
|
||||||
# petit find limité pour éviter de tourner 3h
|
|
||||||
for root in /usr/syno /usr/sbin /usr/bin /bin /sbin; do
|
for root in /usr/syno /usr/sbin /usr/bin /bin /sbin; do
|
||||||
if [ -d "$root" ]; then
|
if [ -d "$root" ]; then
|
||||||
find "$root" -maxdepth 3 -type f \( -name "syno*update*" -o -name "syno*upgrade*" \) 2>/dev/null | head -n 50
|
find "$root" -maxdepth 3 -type f \( -name "syno*update*" -o -name "syno*upgrade*" \) 2>/dev/null | head -n 50
|
||||||
|
|
@ -77,11 +76,11 @@
|
||||||
register: discover
|
register: discover
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- name: Afficher découverte
|
- name: "Afficher découverte"
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
var: discover.stdout_lines
|
var: discover.stdout_lines
|
||||||
|
|
||||||
- name: Choisir un binaire (priorité: synoupgrade puis synoautoupdate)
|
- name: "Choisir un binaire (priorité: synoupgrade puis synoautoupdate)"
|
||||||
ansible.builtin.shell: |
|
ansible.builtin.shell: |
|
||||||
set +e
|
set +e
|
||||||
|
|
||||||
|
|
@ -107,11 +106,11 @@
|
||||||
register: picked
|
register: picked
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- name: Enregistrer outil de MAJ
|
- name: "Enregistrer outil de MAJ"
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
upgrade_tool: "{{ picked.stdout | trim }}"
|
upgrade_tool: "{{ picked.stdout | trim }}"
|
||||||
|
|
||||||
- name: Stop si aucun outil trouvé (message clair)
|
- name: "Stop si aucun outil trouvé (message clair)"
|
||||||
ansible.builtin.fail:
|
ansible.builtin.fail:
|
||||||
msg: >-
|
msg: >-
|
||||||
Aucun outil de mise à jour trouvé via SSH (synoupgrade/synoautoupdate).
|
Aucun outil de mise à jour trouvé via SSH (synoupgrade/synoautoupdate).
|
||||||
|
|
@ -119,14 +118,14 @@
|
||||||
Si rien n'apparait, on devra rester sur l'API DSM ou faire via interface DSM.
|
Si rien n'apparait, on devra rester sur l'API DSM ou faire via interface DSM.
|
||||||
when: upgrade_tool in ["", "MISSING"]
|
when: upgrade_tool in ["", "MISSING"]
|
||||||
|
|
||||||
- name: Debug outil choisi
|
- name: "Debug outil choisi"
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
msg: "Outil retenu: {{ upgrade_tool }}"
|
msg: "Outil retenu: {{ upgrade_tool }}"
|
||||||
|
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
# 2) Afficher l'aide (pour savoir quelles options existent)
|
# 2) Afficher l'aide (pour savoir quelles options existent)
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
- name: Afficher --help de l'outil
|
- name: "Afficher --help de l'outil"
|
||||||
ansible.builtin.shell: |
|
ansible.builtin.shell: |
|
||||||
set +e
|
set +e
|
||||||
"{{ upgrade_tool }}" --help 2>&1 | head -n 120
|
"{{ upgrade_tool }}" --help 2>&1 | head -n 120
|
||||||
|
|
@ -136,14 +135,14 @@
|
||||||
register: tool_help
|
register: tool_help
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- name: Debug help
|
- name: "Debug help"
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
var: tool_help.stdout_lines
|
var: tool_help.stdout_lines
|
||||||
|
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
# 3) Tenter un check/download/start en best effort
|
# 3) Tenter un check/download/start en best effort
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
- name: Check MAJ (best effort)
|
- name: "Check MAJ (best effort)"
|
||||||
ansible.builtin.shell: |
|
ansible.builtin.shell: |
|
||||||
set +e
|
set +e
|
||||||
T="{{ upgrade_tool }}"
|
T="{{ upgrade_tool }}"
|
||||||
|
|
@ -171,11 +170,11 @@
|
||||||
register: check_out
|
register: check_out
|
||||||
changed_when: false
|
changed_when: false
|
||||||
|
|
||||||
- name: Afficher check
|
- name: "Afficher check"
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
var: check_out.stdout_lines
|
var: check_out.stdout_lines
|
||||||
|
|
||||||
- name: Heuristique update dispo
|
- name: "Heuristique update dispo"
|
||||||
ansible.builtin.set_fact:
|
ansible.builtin.set_fact:
|
||||||
update_available: >-
|
update_available: >-
|
||||||
{{
|
{{
|
||||||
|
|
@ -189,11 +188,11 @@
|
||||||
)
|
)
|
||||||
}}
|
}}
|
||||||
|
|
||||||
- name: Info update dispo
|
- name: "Info update dispo"
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
msg: "MAJ dispo (heuristique) = {{ update_available }}"
|
msg: "MAJ dispo (heuristique) = {{ update_available }}"
|
||||||
|
|
||||||
- name: Télécharger la MAJ (best effort)
|
- name: "Télécharger la MAJ (best effort)"
|
||||||
ansible.builtin.shell: |
|
ansible.builtin.shell: |
|
||||||
set +e
|
set +e
|
||||||
T="{{ upgrade_tool }}"
|
T="{{ upgrade_tool }}"
|
||||||
|
|
@ -218,12 +217,12 @@
|
||||||
changed_when: true
|
changed_when: true
|
||||||
when: update_available | bool
|
when: update_available | bool
|
||||||
|
|
||||||
- name: Afficher download
|
- name: "Afficher download"
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
var: dl_out.stdout_lines
|
var: dl_out.stdout_lines
|
||||||
when: update_available | bool
|
when: update_available | bool
|
||||||
|
|
||||||
- name: Installer (optionnel, best effort)
|
- name: "Installer (optionnel, best effort)"
|
||||||
ansible.builtin.shell: |
|
ansible.builtin.shell: |
|
||||||
set +e
|
set +e
|
||||||
T="{{ upgrade_tool }}"
|
T="{{ upgrade_tool }}"
|
||||||
|
|
@ -250,14 +249,14 @@
|
||||||
- update_available | bool
|
- update_available | bool
|
||||||
- do_install | bool
|
- do_install | bool
|
||||||
|
|
||||||
- name: Afficher install
|
- name: "Afficher install"
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
var: install_out.stdout_lines
|
var: install_out.stdout_lines
|
||||||
when:
|
when:
|
||||||
- update_available | bool
|
- update_available | bool
|
||||||
- do_install | bool
|
- do_install | bool
|
||||||
|
|
||||||
- name: Reboot NAS (optionnel)
|
- name: "Reboot NAS (optionnel)"
|
||||||
ansible.builtin.shell: |
|
ansible.builtin.shell: |
|
||||||
sudo reboot || reboot
|
sudo reboot || reboot
|
||||||
args:
|
args:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue