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
|
||||
gather_facts: false
|
||||
|
||||
|
|
@ -9,7 +9,7 @@
|
|||
command_timeout: 120
|
||||
|
||||
tasks:
|
||||
- name: Lire version DSM (best effort)
|
||||
- name: "Lire version DSM (best effort)"
|
||||
ansible.builtin.shell: |
|
||||
if test -f /etc.defaults/VERSION; then
|
||||
cat /etc.defaults/VERSION
|
||||
|
|
@ -23,14 +23,14 @@
|
|||
register: dsm_version
|
||||
changed_when: false
|
||||
|
||||
- name: Afficher version DSM
|
||||
- name: "Afficher version DSM"
|
||||
ansible.builtin.debug:
|
||||
var: dsm_version.stdout_lines
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# 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: |
|
||||
set +e
|
||||
|
||||
|
|
@ -64,7 +64,6 @@
|
|||
done
|
||||
|
||||
echo "== find (limited) =="
|
||||
# petit find limité pour éviter de tourner 3h
|
||||
for root in /usr/syno /usr/sbin /usr/bin /bin /sbin; do
|
||||
if [ -d "$root" ]; then
|
||||
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
|
||||
changed_when: false
|
||||
|
||||
- name: Afficher découverte
|
||||
- name: "Afficher découverte"
|
||||
ansible.builtin.debug:
|
||||
var: discover.stdout_lines
|
||||
|
||||
- name: Choisir un binaire (priorité: synoupgrade puis synoautoupdate)
|
||||
- name: "Choisir un binaire (priorité: synoupgrade puis synoautoupdate)"
|
||||
ansible.builtin.shell: |
|
||||
set +e
|
||||
|
||||
|
|
@ -107,11 +106,11 @@
|
|||
register: picked
|
||||
changed_when: false
|
||||
|
||||
- name: Enregistrer outil de MAJ
|
||||
- name: "Enregistrer outil de MAJ"
|
||||
ansible.builtin.set_fact:
|
||||
upgrade_tool: "{{ picked.stdout | trim }}"
|
||||
|
||||
- name: Stop si aucun outil trouvé (message clair)
|
||||
- name: "Stop si aucun outil trouvé (message clair)"
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
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.
|
||||
when: upgrade_tool in ["", "MISSING"]
|
||||
|
||||
- name: Debug outil choisi
|
||||
- name: "Debug outil choisi"
|
||||
ansible.builtin.debug:
|
||||
msg: "Outil retenu: {{ upgrade_tool }}"
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# 2) Afficher l'aide (pour savoir quelles options existent)
|
||||
# ------------------------------------------------------------
|
||||
- name: Afficher --help de l'outil
|
||||
- name: "Afficher --help de l'outil"
|
||||
ansible.builtin.shell: |
|
||||
set +e
|
||||
"{{ upgrade_tool }}" --help 2>&1 | head -n 120
|
||||
|
|
@ -136,14 +135,14 @@
|
|||
register: tool_help
|
||||
changed_when: false
|
||||
|
||||
- name: Debug help
|
||||
- name: "Debug help"
|
||||
ansible.builtin.debug:
|
||||
var: tool_help.stdout_lines
|
||||
|
||||
# ------------------------------------------------------------
|
||||
# 3) Tenter un check/download/start en best effort
|
||||
# ------------------------------------------------------------
|
||||
- name: Check MAJ (best effort)
|
||||
- name: "Check MAJ (best effort)"
|
||||
ansible.builtin.shell: |
|
||||
set +e
|
||||
T="{{ upgrade_tool }}"
|
||||
|
|
@ -171,11 +170,11 @@
|
|||
register: check_out
|
||||
changed_when: false
|
||||
|
||||
- name: Afficher check
|
||||
- name: "Afficher check"
|
||||
ansible.builtin.debug:
|
||||
var: check_out.stdout_lines
|
||||
|
||||
- name: Heuristique update dispo
|
||||
- name: "Heuristique update dispo"
|
||||
ansible.builtin.set_fact:
|
||||
update_available: >-
|
||||
{{
|
||||
|
|
@ -189,11 +188,11 @@
|
|||
)
|
||||
}}
|
||||
|
||||
- name: Info update dispo
|
||||
- name: "Info update dispo"
|
||||
ansible.builtin.debug:
|
||||
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: |
|
||||
set +e
|
||||
T="{{ upgrade_tool }}"
|
||||
|
|
@ -218,12 +217,12 @@
|
|||
changed_when: true
|
||||
when: update_available | bool
|
||||
|
||||
- name: Afficher download
|
||||
- name: "Afficher download"
|
||||
ansible.builtin.debug:
|
||||
var: dl_out.stdout_lines
|
||||
when: update_available | bool
|
||||
|
||||
- name: Installer (optionnel, best effort)
|
||||
- name: "Installer (optionnel, best effort)"
|
||||
ansible.builtin.shell: |
|
||||
set +e
|
||||
T="{{ upgrade_tool }}"
|
||||
|
|
@ -250,14 +249,14 @@
|
|||
- update_available | bool
|
||||
- do_install | bool
|
||||
|
||||
- name: Afficher install
|
||||
- name: "Afficher install"
|
||||
ansible.builtin.debug:
|
||||
var: install_out.stdout_lines
|
||||
when:
|
||||
- update_available | bool
|
||||
- do_install | bool
|
||||
|
||||
- name: Reboot NAS (optionnel)
|
||||
- name: "Reboot NAS (optionnel)"
|
||||
ansible.builtin.shell: |
|
||||
sudo reboot || reboot
|
||||
args:
|
||||
|
|
|
|||
Loading…
Reference in New Issue