Convert with_items to loop

Recommended way to work with loops is now using loop.

Change-Id: I4ce186e16e6ae5b3a6f29542887431f5499286b0
This commit is contained in:
Riccardo Pittau 2020-06-05 15:50:53 +02:00
parent 4e83214d37
commit 7283e3dc54
15 changed files with 29 additions and 29 deletions

View File

@ -29,13 +29,13 @@
file: file:
state: directory state: directory
name: "{{ variable_configdrive_location.stdout }}/{{ uuid }}/openstack/{{ item }}/" name: "{{ variable_configdrive_location.stdout }}/{{ uuid }}/openstack/{{ item }}/"
with_items: "{{ metadata_versions }}" loop: "{{ metadata_versions }}"
- name: "Place template in each openstack/<version> folder" - name: "Place template in each openstack/<version> folder"
template: template:
src: openstack_meta_data.json.j2 src: openstack_meta_data.json.j2
dest: "{{ variable_configdrive_location.stdout }}/{{ uuid }}/openstack/{{ item }}/meta_data.json" dest: "{{ variable_configdrive_location.stdout }}/{{ uuid }}/openstack/{{ item }}/meta_data.json"
with_items: "{{ metadata_versions }}" loop: "{{ metadata_versions }}"
- name: "Generate network_data" - name: "Generate network_data"
network_metadata: network_metadata:
@ -54,7 +54,7 @@
template: template:
src: network_data.json.j2 src: network_data.json.j2
dest: "{{ variable_configdrive_location.stdout }}/{{ uuid }}/openstack/{{ item }}/network_data.json" dest: "{{ variable_configdrive_location.stdout }}/{{ uuid }}/openstack/{{ item }}/network_data.json"
with_items: "{{ metadata_versions }}" loop: "{{ metadata_versions }}"
when: when:
- item in metadata_versions_supporting_network_data - item in metadata_versions_supporting_network_data
- addressing_mode is undefined or "dhcp" not in addressing_mode - addressing_mode is undefined or "dhcp" not in addressing_mode
@ -67,7 +67,7 @@
template: template:
src: network_data.json.j2 src: network_data.json.j2
dest: "{{ variable_configdrive_location.stdout }}/{{ uuid }}/openstack/{{ item }}/network_info.json" dest: "{{ variable_configdrive_location.stdout }}/{{ uuid }}/openstack/{{ item }}/network_info.json"
with_items: "{{ metadata_versions }}" loop: "{{ metadata_versions }}"
when: when:
- item in metadata_versions_supporting_network_data - item in metadata_versions_supporting_network_data
- addressing_mode is undefined or "dhcp" not in addressing_mode - addressing_mode is undefined or "dhcp" not in addressing_mode

View File

@ -140,7 +140,7 @@
testvm_nodes_json: [] testvm_nodes_json: []
- include: create_vm.yml - include: create_vm.yml
with_items: "{{ test_vm_node_names }}" loop: "{{ test_vm_node_names }}"
- name: write to baremetal json file - name: write to baremetal json file
copy: copy:

View File

@ -24,7 +24,7 @@
pip: pip:
name: "{{ item }}" name: "{{ item }}"
extra_args: "-c {{ upper_constraints_file }}" extra_args: "-c {{ upper_constraints_file }}"
with_items: loop:
- libvirt-python - libvirt-python
- lxml - lxml
when: enable_venv | bool == false when: enable_venv | bool == false
@ -35,7 +35,7 @@
state: present state: present
virtualenv: "{{ bifrost_venv_dir }}" virtualenv: "{{ bifrost_venv_dir }}"
virtualenv_command: "{{ venv_command | default(omit) }}" virtualenv_command: "{{ venv_command | default(omit) }}"
with_items: loop:
- libvirt-python - libvirt-python
- lxml - lxml
when: enable_venv | default(false) | bool when: enable_venv | default(false) | bool

View File

@ -134,7 +134,7 @@
mode: 0755 mode: 0755
owner: "ironic" owner: "ironic"
group: "ironic" group: "ironic"
with_items: loop:
- "{{ ironic_log_dir }}" - "{{ ironic_log_dir }}"
- "{{ ironic_agent_deploy_logs_local_path }}" - "{{ ironic_agent_deploy_logs_local_path }}"
@ -174,7 +174,7 @@
mode: 0750 mode: 0750
owner: "ironic" owner: "ironic"
group: "ironic" group: "ironic"
with_items: loop:
- "/var/lib/ironic" - "/var/lib/ironic"
- "/var/lib/ironic/master_images" - "/var/lib/ironic/master_images"
- "/var/lib/ironic/images" - "/var/lib/ironic/images"
@ -185,7 +185,7 @@
dest: "{{ init_dest_dir }}{{ item.service_name }}.service" dest: "{{ init_dest_dir }}{{ item.service_name }}.service"
owner: "root" owner: "root"
group: "root" group: "root"
with_items: loop:
- { service_path: "{{ ironic_install_prefix.stdout | default('') }}", service_name: 'ironic-api', username: 'ironic', args: '--config-file /etc/ironic/ironic.conf'} - { service_path: "{{ ironic_install_prefix.stdout | default('') }}", service_name: 'ironic-api', username: 'ironic', args: '--config-file /etc/ironic/ironic.conf'}
- { service_path: "{{ ironic_install_prefix.stdout | default('') }}", service_name: 'ironic-conductor', username: 'ironic', args: '--config-file /etc/ironic/ironic.conf'} - { service_path: "{{ ironic_install_prefix.stdout | default('') }}", service_name: 'ironic-conductor', username: 'ironic', args: '--config-file /etc/ironic/ironic.conf'}
when: when:
@ -197,7 +197,7 @@
dest: "{{ init_dest_dir }}{{ item.service_name }}.service" dest: "{{ init_dest_dir }}{{ item.service_name }}.service"
owner: "root" owner: "root"
group: "root" group: "root"
with_items: loop:
- { service_path: "{{ ironic_install_prefix.stdout | default('') }}", service_name: 'ironic-api', username: 'ironic', args: '--config-file /etc/ironic/ironic.conf --log-file {{ ironic_log_dir }}/ironic-api.log'} - { service_path: "{{ ironic_install_prefix.stdout | default('') }}", service_name: 'ironic-api', username: 'ironic', args: '--config-file /etc/ironic/ironic.conf --log-file {{ ironic_log_dir }}/ironic-api.log'}
- { service_path: "{{ ironic_install_prefix.stdout | default('') }}", service_name: 'ironic-conductor', username: 'ironic', args: '--config-file /etc/ironic/ironic.conf --log-file {{ ironic_log_dir }}/ironic-conductor.log'} - { service_path: "{{ ironic_install_prefix.stdout | default('') }}", service_name: 'ironic-conductor', username: 'ironic', args: '--config-file /etc/ironic/ironic.conf --log-file {{ ironic_log_dir }}/ironic-conductor.log'}
when: when:
@ -310,7 +310,7 @@
destination_port: "{{ item }}" destination_port: "{{ item }}"
in_interface: "{{ network_interface }}" in_interface: "{{ network_interface }}"
jump: ACCEPT jump: ACCEPT
with_items: loop:
- "{{ file_url_port }}" - "{{ file_url_port }}"
- 6385 - 6385
- block: - block:

View File

@ -17,7 +17,7 @@
# For now, we need to use it, but we can patch that. # For now, we need to use it, but we can patch that.
- name: "Set up PXE and iPXE folders" - name: "Set up PXE and iPXE folders"
file: name={{item}} owner=ironic group=ironic state=directory mode=0755 file: name={{item}} owner=ironic group=ironic state=directory mode=0755
with_items: loop:
- /tftpboot - /tftpboot
- /tftpboot/pxelinux.cfg - /tftpboot/pxelinux.cfg
- "{{ http_boot_folder }}" - "{{ http_boot_folder }}"

View File

@ -33,7 +33,7 @@
until: ipxe_files_download_done is succeeded until: ipxe_files_download_done is succeeded
retries: 5 retries: 5
delay: 10 delay: 10
with_items: loop:
- undionly.kpxe - undionly.kpxe
- ipxe.pxe - ipxe.pxe
environment: "{{ venv }}" environment: "{{ venv }}"
@ -47,7 +47,7 @@
until: ipxe_efi_binary_download_done is succeeded until: ipxe_efi_binary_download_done is succeeded
retries: 5 retries: 5
delay: 10 delay: 10
with_items: loop:
- "{{ ipxe_efi_binary }}" - "{{ ipxe_efi_binary }}"
environment: "{{ venv }}" environment: "{{ venv }}"
when: enable_uefi_ipxe | bool == true when: enable_uefi_ipxe | bool == true

View File

@ -100,7 +100,7 @@
dest: "{{ init_dest_dir }}{{item.service_name}}.service" dest: "{{ init_dest_dir }}{{item.service_name}}.service"
owner: root owner: root
group: root group: root
with_items: loop:
- { service_path: "{{ ironic_install_prefix.stdout | default('') }}", service_name: 'ironic-inspector', username: 'ironic', args: '--config-file /etc/ironic-inspector/inspector.conf'} - { service_path: "{{ ironic_install_prefix.stdout | default('') }}", service_name: 'ironic-inspector', username: 'ironic', args: '--config-file /etc/ironic-inspector/inspector.conf'}
- name: "Inspector - Explicitly permit TCP/5050 for ironic-inspector callback" - name: "Inspector - Explicitly permit TCP/5050 for ironic-inspector callback"
command: iptables -I INPUT -p tcp --dport 5050 -i {{network_interface}} -j ACCEPT command: iptables -I INPUT -p tcp --dport 5050 -i {{network_interface}} -j ACCEPT

View File

@ -110,7 +110,7 @@
- name: "Install extra packages for ironic" - name: "Install extra packages for ironic"
include: pip_install.yml include: pip_install.yml
package={{ item }} package={{ item }}
with_items: "{{ ironic_extra_packages }}" loop: "{{ ironic_extra_packages }}"
- name: "Install Ironic using pip" - name: "Install Ironic using pip"
include: pip_install.yml include: pip_install.yml

View File

@ -43,7 +43,7 @@
owner: root owner: root
group: root group: root
when: enable_venv | bool == true when: enable_venv | bool == true
with_items: loop:
- "{{ bifrost_venv_dir }}/bin/ironic-rootwrap" - "{{ bifrost_venv_dir }}/bin/ironic-rootwrap"
- "{{ bifrost_venv_dir }}/bin/ironic-inspector-rootwrap" - "{{ bifrost_venv_dir }}/bin/ironic-inspector-rootwrap"
- name: "Set sudoers for rootwrap" - name: "Set sudoers for rootwrap"
@ -51,6 +51,6 @@
dest: /etc/sudoers dest: /etc/sudoers
regexp: "{{ item.regexp }}" regexp: "{{ item.regexp }}"
line: "{{ item.line }}" line: "{{ item.line }}"
with_items: loop:
- { regexp: '^ironic(.*)/ironic-rootwrap /etc/ironic/rootwrap.conf(.*)', line: "ironic ALL = (root) NOPASSWD: {{ ironic_rootwrap_dir }}/ironic-rootwrap /etc/ironic/rootwrap.conf *" } - { regexp: '^ironic(.*)/ironic-rootwrap /etc/ironic/rootwrap.conf(.*)', line: "ironic ALL = (root) NOPASSWD: {{ ironic_rootwrap_dir }}/ironic-rootwrap /etc/ironic/rootwrap.conf *" }
- { regexp: '^ironic(.*)/ironic-inspector-rootwrap /etc/ironic-inspector/rootwrap.conf(.*)', line: "ironic ALL = (root) NOPASSWD: {{ ironic_rootwrap_dir }}/ironic-inspector-rootwrap /etc/ironic-inspector/rootwrap.conf *" } - { regexp: '^ironic(.*)/ironic-inspector-rootwrap /etc/ironic-inspector/rootwrap.conf(.*)', line: "ironic ALL = (root) NOPASSWD: {{ ironic_rootwrap_dir }}/ironic-inspector-rootwrap /etc/ironic-inspector/rootwrap.conf *" }

View File

@ -46,7 +46,7 @@
- name: "Ensure services are running with current config" - name: "Ensure services are running with current config"
service: name={{ item }} state=restarted enabled=yes service: name={{ item }} state=restarted enabled=yes
with_items: loop:
- xinetd - xinetd
- nginx - nginx
@ -65,13 +65,13 @@
- name: "Ensure dnsmasq is running with current config" - name: "Ensure dnsmasq is running with current config"
service: name={{ item }} state=restarted enabled=yes service: name={{ item }} state=restarted enabled=yes
with_items: loop:
- dnsmasq - dnsmasq
when: include_dhcp_server | bool == true when: include_dhcp_server | bool == true
- name: "Send services a reload signal" - name: "Send services a reload signal"
service: name={{ item }} state=reloaded service: name={{ item }} state=reloaded
with_items: loop:
- xinetd - xinetd
- nginx - nginx

View File

@ -272,7 +272,7 @@
dest: "{{ init_dest_dir }}{{ item.service_name }}.service" dest: "{{ init_dest_dir }}{{ item.service_name }}.service"
owner: "root" owner: "root"
group: "root" group: "root"
with_items: loop:
- { service_path: "{{ uwsgi_install_prefix.stdout | default('') }}", - { service_path: "{{ uwsgi_install_prefix.stdout | default('') }}",
service_name: 'uwsgi', service_name: 'uwsgi',
username: "{{ nginx_user }}", username: "{{ nginx_user }}",

View File

@ -16,6 +16,6 @@
- name: "Ensure services are running with current config" - name: "Ensure services are running with current config"
service: name={{ item }} state=restarted enabled=yes service: name={{ item }} state=restarted enabled=yes
with_items: loop:
- nginx - nginx
- uwsgi - uwsgi

View File

@ -29,10 +29,10 @@
version: "{{ item.git_branch }}" version: "{{ item.git_branch }}"
update: yes update: yes
clone: yes clone: yes
with_items: "{{ bifrost_install_sources }}" loop: "{{ bifrost_install_sources }}"
when: ci_testing_zuul | bool == false and copy_from_local_path | bool == false when: ci_testing_zuul | bool == false and copy_from_local_path | bool == false
- name: "Copy from local path" - name: "Copy from local path"
command: cp -a {{ item.git_url }} {{ item.git_folder }} creates={{ item.git_folder }} command: cp -a {{ item.git_url }} {{ item.git_folder }} creates={{ item.git_folder }}
with_items: "{{ bifrost_install_sources }}" loop: "{{ bifrost_install_sources }}"
when: ci_testing_zuul | bool == true or copy_from_local_path | bool == true when: ci_testing_zuul | bool == true or copy_from_local_path | bool == true

View File

@ -23,7 +23,7 @@
# NOTE(TheJulia): add_host only triggers once per play. Since we need to # NOTE(TheJulia): add_host only triggers once per play. Since we need to
# add all hosts, we need to use a loop. # add all hosts, we need to use a loop.
add_host: name="{{ hostvars[item]['ipv4_address'] }}:22" groups=test add_host: name="{{ hostvars[item]['ipv4_address'] }}:22" groups=test
with_items: "{{ groups['baremetal'] }}" loop: "{{ groups['baremetal'] }}"
when: ipv4_address is defined when: ipv4_address is defined
- name: "Ensure ~/.ssh/known_hosts is present" - name: "Ensure ~/.ssh/known_hosts is present"
file: file:

View File

@ -22,7 +22,7 @@
dest: "/etc/hosts" dest: "/etc/hosts"
regexp: "{{ item.regexp }}.*({{ ansible_hostname }}|localhost).*" regexp: "{{ item.regexp }}.*({{ ansible_hostname }}|localhost).*"
line: "{{ item.contents }}" line: "{{ item.contents }}"
with_items: loop:
- { regexp: '^127\.0\.0\.1', contents: '127.0.0.1 {{ ansible_hostname }} {{ ansible_fqdn }} localhost' } - { regexp: '^127\.0\.0\.1', contents: '127.0.0.1 {{ ansible_hostname }} {{ ansible_fqdn }} localhost' }
- { regexp: '^::1', contents: '::1 {{ ansible_hostname }} {{ ansible_fqdn }} localhost ipv6-localhost ipv6-loopback' } - { regexp: '^::1', contents: '::1 {{ ansible_hostname }} {{ ansible_fqdn }} localhost ipv6-localhost ipv6-loopback' }
when: not skip_bootstrap | bool when: not skip_bootstrap | bool
@ -44,7 +44,7 @@
- systemd: daemon_reload=yes - systemd: daemon_reload=yes
- service: name={{ item }} state=stopped enabled=no - service: name={{ item }} state=stopped enabled=no
with_items: loop:
- epmd.socket - epmd.socket
- epmd - epmd
when: when: