Bugfix: Bind Mounts, keine mehrfachen Reboots mehr (#218)
Co-authored-by: Michael Grote <michael.grote@posteo.de> Reviewed-on: mg/ansible#218 Co-authored-by: mg <mg@noreply.git.mgrote.net> Co-committed-by: mg <mg@noreply.git.mgrote.net>
This commit is contained in:
parent
74a3afafaf
commit
b4ea3967a2
4 changed files with 34 additions and 19 deletions
|
@ -49,8 +49,8 @@
|
|||
users_rw: 'michaelgrote win10'
|
||||
- name: 'hm'
|
||||
path: '/shares_hm'
|
||||
users_ro: 'win10'
|
||||
users_rw: 'michaelgrote'
|
||||
users_ro: ''
|
||||
users_rw: 'michaelgrote win10'
|
||||
- name: 'musik'
|
||||
path: '/shares_music'
|
||||
users_ro: 'navidrome kodi annemariedroessler2 '
|
||||
|
@ -77,12 +77,12 @@
|
|||
users_rw: 'michaelgrote'
|
||||
- name: 'buecher'
|
||||
path: '/shares_buecher'
|
||||
users_ro: 'annemariedroessler2 win10'
|
||||
users_rw: 'michaelgrote'
|
||||
users_ro: 'annemariedroessler2'
|
||||
users_rw: 'michaelgrote win10'
|
||||
- name: 'programme'
|
||||
path: '/shares_programme'
|
||||
users_ro: 'annemariedroessler2 win10'
|
||||
users_rw: 'michaelgrote'
|
||||
users_ro: 'annemariedroessler2'
|
||||
users_rw: 'michaelgrote win10'
|
||||
|
||||
|
||||
smb_workgroup: WORKGROUP
|
||||
|
|
3
roles/mgrote.proxmox_bind_mounts/defaults/main.yml
Normal file
3
roles/mgrote.proxmox_bind_mounts/defaults/main.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
lists_merged: # Liste muss leer existieren damit sie "germerged" werden kann, für Liste welche VMs zu rebooten sind
|
||||
- ''
|
|
@ -1,13 +1,11 @@
|
|||
---
|
||||
- name: restart lxc
|
||||
become: true
|
||||
command: "pct reboot {{ item.vmid }}"
|
||||
when:
|
||||
- "reboot_{{item.vmid}} is defined"
|
||||
- "reboot_{{item.vmid}} is true"
|
||||
command: "pct reboot {{ item }}"
|
||||
failed_when: false
|
||||
loop: "{{ pve_bind_mounts }}"
|
||||
# rebote den lxc wenn:
|
||||
# - sein variable auf true gesetzt ist
|
||||
# wird bei mehreren moiunts mehrfach pro host aufgerufen
|
||||
# aber nur einmal ausgeführt
|
||||
loop: "{{ lists_merged | unique }}"
|
||||
# reboote den lxc wenn:
|
||||
# - er in der Liste "Lists merged" vorhanden ist
|
||||
# unique Filter sorgt dafür das es keine doppelten Elemente gibt
|
||||
# https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#set-theory-filters
|
||||
# https://www.reddit.com/r/ansible/comments/8cp86c/how_do_i_remove_duplicate_items_from_a_variable/
|
||||
|
|
|
@ -21,9 +21,23 @@
|
|||
# füge bind-mount hinzu falls er fehlt, also rc ungleich 0
|
||||
# pro bind-mount
|
||||
|
||||
- name: set reboot var
|
||||
# schreibe vm id in die Liste "reboot"
|
||||
- name: set reboot list
|
||||
set_fact:
|
||||
"reboot_{{ item.vmid }}": true
|
||||
reboot:
|
||||
- "{{ item.vmid }}"
|
||||
when: restart.changed
|
||||
# setze reboot variable fur handler
|
||||
# z.B. reboot_105: true
|
||||
|
||||
# Füge die leere Liste "lists_merged" aus den defaults, mit der Liste "reboot" zusammen. Nur wenn auch etwas geändert wurde, daher "when:..."
|
||||
- name: merge reboot lists
|
||||
set_fact:
|
||||
lists_merged: "{{ lists_merged + reboot }}"
|
||||
when: restart.changed
|
||||
# https://blog.crisp.se/2016/10/20/maxwenzin/how-to-append-to-lists-in-ansible
|
||||
|
||||
# - name: debug config
|
||||
# ansible.builtin.debug:
|
||||
# msg: "{{ lists_merged | unique }}"
|
||||
# unique Filter sorgt dafür das es keine doppelten Elemente gibt
|
||||
# https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#set-theory-filters
|
||||
# https://www.reddit.com/r/ansible/comments/8cp86c/how_do_i_remove_duplicate_items_from_a_variable/
|
||||
|
|
Loading…
Reference in a new issue