Use 'loop' syntax instead of 'with_nested'

This commit is contained in:
Jérémy Lecour 2021-05-04 14:29:50 +02:00 committed by Jérémy Lecour
parent 07fd6451e1
commit 485ec39674
5 changed files with 24 additions and 20 deletions

View file

@ -19,7 +19,7 @@ The **patch** part changes incrementally at each release.
### Changed
* Use 'loop' syntax instead of 'with_first_found/with_items/with_dict'
* Use 'loop' syntax instead of 'with_first_found/with_items/with_dict/with_nested'
* apt: store keys in /etc/apt/trusted.gpg.d in ascii format
* evolinux-base: copy GPG key instead of using apt-key
* ntpd: Add leapfile configuration setting to ntpd on debian 10+

View file

@ -21,9 +21,10 @@
state: present
key: "{{ item[0] }}"
delegate_to: "{{ item[1] }}"
with_nested:
- "{{ ssh_keys.stdout }}"
- "{{ groups['hypervisors'] }}"
loop: "{{ _keys | product(_servers) | list }}"
vars:
_keys: ssh_keys.stdout
_servers: groups['hypervisors']
when: item[1] != inventory_hostname
- name: Crontab for sync libvirt xml file

View file

@ -71,11 +71,12 @@
option: '{{ item[1].option }}'
value: '{{ item[1].value }}'
create: yes
with_nested:
- [ "client", "mysql_upgrade" ]
- [ { option: 'user', value: 'debian-sys-maint' },
{ option: 'password', value: '{{ mysql_debian_password.stdout }}' }
]
loop: "{{ _sections | product(_credentials) | list }}"
vars:
_sections: [ 'client', 'mysql_upgrade' ]
_credentials:
- { option: 'user', value: 'debian-sys-maint' }
- { option: 'password', value: '{{ mysql_debian_password.stdout }}' }
when: create_debian_user is changed
tags:
- mysql

View file

@ -63,7 +63,7 @@
config_file: "/root/.my.cnf"
register: create_debian_user
tags:
- mysql
- mysql
- name: store debian-sys-maint user credentials
ini_file:
@ -73,14 +73,15 @@
option: '{{ item[1].option }}'
value: '{{ item[1].value }}'
create: yes
with_nested:
- [ "client", "mysql_upgrade" ]
- [ { option: 'user', value: 'debian-sys-maint' },
{ option: 'password', value: '{{ mysql_debian_password.stdout }}' }
]
loop: "{{ _sections | product(_credentials) | list }}"
vars:
_sections: [ 'client', 'mysql_upgrade' ]
_credentials:
- { option: 'user', value: 'debian-sys-maint' }
- { option: 'password', value: '{{ mysql_debian_password.stdout }}' }
when: create_debian_user.changed
tags:
- mysql
- mysql
- name: remove root user
mysql_user:
@ -89,4 +90,4 @@
config_file: "/root/.my.cnf"
state: absent
tags:
- mysql
- mysql

View file

@ -28,8 +28,9 @@
state: link
src: '/usr/share/munin/plugins/{{item[0]}}'
dest: '/etc/munin/plugins/{{item[0]}}{{item[1]}}'
with_nested:
- ['postgres_cache_', 'postgres_connections_', 'postgres_locks_', 'postgres_querylength_', 'postgres_scans_', 'postgres_size_', 'postgres_transactions_', 'postgres_tuples_']
- '{{postgresql_databases}}'
loop: "{{ _plugins | product(_databases) | list }}"
vars:
_plugins: ['postgres_cache_', 'postgres_connections_', 'postgres_locks_', 'postgres_querylength_', 'postgres_scans_', 'postgres_size_', 'postgres_transactions_', 'postgres_tuples_']
_databases: postgresql_databases
notify: restart munin-node
when: etc_munin_plugins.stat.exists and usr_share_munin_plugins.stat.exists