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'
|
users_rw: 'michaelgrote win10'
|
||||||
- name: 'hm'
|
- name: 'hm'
|
||||||
path: '/shares_hm'
|
path: '/shares_hm'
|
||||||
users_ro: 'win10'
|
users_ro: ''
|
||||||
users_rw: 'michaelgrote'
|
users_rw: 'michaelgrote win10'
|
||||||
- name: 'musik'
|
- name: 'musik'
|
||||||
path: '/shares_music'
|
path: '/shares_music'
|
||||||
users_ro: 'navidrome kodi annemariedroessler2 '
|
users_ro: 'navidrome kodi annemariedroessler2 '
|
||||||
|
@ -77,12 +77,12 @@
|
||||||
users_rw: 'michaelgrote'
|
users_rw: 'michaelgrote'
|
||||||
- name: 'buecher'
|
- name: 'buecher'
|
||||||
path: '/shares_buecher'
|
path: '/shares_buecher'
|
||||||
users_ro: 'annemariedroessler2 win10'
|
users_ro: 'annemariedroessler2'
|
||||||
users_rw: 'michaelgrote'
|
users_rw: 'michaelgrote win10'
|
||||||
- name: 'programme'
|
- name: 'programme'
|
||||||
path: '/shares_programme'
|
path: '/shares_programme'
|
||||||
users_ro: 'annemariedroessler2 win10'
|
users_ro: 'annemariedroessler2'
|
||||||
users_rw: 'michaelgrote'
|
users_rw: 'michaelgrote win10'
|
||||||
|
|
||||||
|
|
||||||
smb_workgroup: WORKGROUP
|
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
|
- name: restart lxc
|
||||||
become: true
|
become: true
|
||||||
command: "pct reboot {{ item.vmid }}"
|
command: "pct reboot {{ item }}"
|
||||||
when:
|
|
||||||
- "reboot_{{item.vmid}} is defined"
|
|
||||||
- "reboot_{{item.vmid}} is true"
|
|
||||||
failed_when: false
|
failed_when: false
|
||||||
loop: "{{ pve_bind_mounts }}"
|
loop: "{{ lists_merged | unique }}"
|
||||||
# rebote den lxc wenn:
|
# reboote den lxc wenn:
|
||||||
# - sein variable auf true gesetzt ist
|
# - er in der Liste "Lists merged" vorhanden ist
|
||||||
# wird bei mehreren moiunts mehrfach pro host aufgerufen
|
# unique Filter sorgt dafür das es keine doppelten Elemente gibt
|
||||||
# aber nur einmal ausgeführt
|
# 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
|
# füge bind-mount hinzu falls er fehlt, also rc ungleich 0
|
||||||
# pro bind-mount
|
# pro bind-mount
|
||||||
|
|
||||||
- name: set reboot var
|
# schreibe vm id in die Liste "reboot"
|
||||||
|
- name: set reboot list
|
||||||
set_fact:
|
set_fact:
|
||||||
"reboot_{{ item.vmid }}": true
|
reboot:
|
||||||
|
- "{{ item.vmid }}"
|
||||||
when: restart.changed
|
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