Skip to content

Commit

Permalink
Merge pull request #416 from bshephar/with_items_loop
Browse files Browse the repository at this point in the history
s/with_items/loop/g
  • Loading branch information
openshift-ci[bot] authored Oct 9, 2023
2 parents 0f2c39c + a884e9d commit 7756f5a
Show file tree
Hide file tree
Showing 22 changed files with 47 additions and 47 deletions.
2 changes: 1 addition & 1 deletion molecule/common/test_deps/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
name: "{{ item }}"
state: absent
keepcache: false
with_items:
loop:
- ubi-9-appstream
- ubi-9-baseos
- ubi-9-codeready-builder
Expand Down
2 changes: 1 addition & 1 deletion roles/edpm_container_rm/molecule/default/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,6 @@
detach: true
image: centos:stream9
command: bash
with_items:
loop:
- podman-container1
- podman-container2
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@
detach: true
image: centos:stream9
command: bash
with_items:
loop:
- podman-container1
- podman-container2

- name: Stop test containers
containers.podman.podman_container:
name: "{{ item }}"
state: stopped
with_items:
loop:
- podman-container1
- podman-container2
2 changes: 1 addition & 1 deletion roles/edpm_frr/tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
state: directory
setype: "{{ item.setype }}"
mode: "{{ item.mode }}"
with_items:
loop:
- { 'path': /var/log/containers/frr, 'setype': container_file_t, 'mode': '0750' }
- { 'path': "{{ edpm_frr_config_basedir }}", 'setype': container_file_t, 'mode': '0750' }
- { 'path': /run/frr, 'setype': container_file_t, 'mode': '0755' }
Expand Down
2 changes: 1 addition & 1 deletion roles/edpm_kernel/tasks/reboot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
# This condition will list all the interfaces except the one with valid IP (which is Provisioning network at this stage)
# Simpler Version - hostvars[inventory_hostname]['ansible_' + iface_name ]['ipv4'] is undefined
- hostvars[inventory_hostname]['ansible_facts'][item.path | regex_replace('(^.*ifcfg-)(.*)', '\\2') | replace('-', '_')]['ipv4'] is undefined
with_items:
loop:
- "{{ ifcfg_files.files }}"

- name: Reboot debug message
Expand Down
8 changes: 4 additions & 4 deletions roles/edpm_libvirt/molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
tasks:
- name: ensure expected directories exist
ansible.builtin.include_tasks: "{{test_helper_dir}}/verify_dir.yaml"
with_items:
loop:
# common directories
- "/etc/tmpfiles.d/"
- "/var/lib/openstack"
Expand All @@ -28,23 +28,23 @@
ansible.builtin.include_tasks: "test-helpers/verify_ceph_secret.yaml"
- name: ensure systemd services are defined and functional
ansible.builtin.include_tasks: "{{test_helper_dir}}/verify_systemd_unit.yaml"
with_items:
loop:
- { "name": "edpm_libvirt_virtlogd.service" }
- { "name": "edpm_libvirt_virtnodedevd.service" }
- { "name": "edpm_libvirt_virtproxyd.service" }
- { "name": "edpm_libvirt_virtqemud.service" }
- { "name": "edpm_libvirt_virtsecretd.service" }
- name: ensure podman container exists and are running
ansible.builtin.include_tasks: "{{test_helper_dir}}/verify_podman.yaml"
with_items:
loop:
- "libvirt_virtlogd"
- "libvirt_virtnodedevd"
- "libvirt_virtproxyd"
- "libvirt_virtqemud"
- "libvirt_virtsecretd"
- name: ensure libvirt.target exist and are running
ansible.builtin.include_tasks: "{{test_helper_dir}}/verify_systemd_unit.yaml"
with_items:
loop:
- { "name": "edpm_libvirt.target", "enabled": "static"}
- { "name": "edpm_libvirt_guests.service", "running":false }
- { "name": "virt-guest-shutdown.target", "enabled": "static", "running":false }
4 changes: 2 additions & 2 deletions roles/edpm_libvirt/tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
owner: "{{ item.owner | default(ansible_user) }}"
group: "{{ item.group | default(ansible_user) }}"
mode: "{{ item.mode | default(omit) }}"
with_items:
loop:
- { "path": "/var/lib/openstack/config/libvirt"}
- { "path": "/var/lib/openstack/config/containers"}
- { 'path': "/var/lib/nova"}
Expand Down Expand Up @@ -52,7 +52,7 @@
dest: "/var/lib/openstack/config/libvirt/{{ item.dest }}"
setype: "container_file_t"
mode: 0644
with_items:
loop:
- {"src": "libvirt_virtlogd/virtlogd.conf", "dest": "libvirt_virtlogd/virtlogd.conf"}
- {"src": "libvirt_virtnodedevd/virtnodedevd.conf", "dest": "libvirt_virtnodedevd/virtnodedevd.conf"}
- {"src": "libvirt_virtproxyd/virtproxyd.conf", "dest": "libvirt_virtproxyd/virtproxyd.conf"}
Expand Down
2 changes: 1 addition & 1 deletion roles/edpm_libvirt/tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
owner: "{{ item.owner | default(omit) }}"
group: "{{ item.group | default(omit) }}"
mode: "{{ item.mode | default(omit) }}"
with_items:
loop:
# qemu is not in the libvirt group in the container images so use
# mode 755 to make /var/lib/libvirt traversable.
- { "path": "/var/lib/libvirt", "mode": "0755" }
Expand Down
6 changes: 3 additions & 3 deletions roles/edpm_neutron_dhcp/molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
tasks:
- name: ensure expected directories exist
ansible.builtin.include_tasks: "{{test_helper_dir}}/verify_dir.yaml"
with_items:
loop:
- "/var/lib/neutron"
- "/var/lib/openstack/config/containers"
- "/var/lib/kolla/config_files/neutron_dhcp_agent.json"
Expand All @@ -17,12 +17,12 @@

- name: ensure systemd services are defined and functional
ansible.builtin.include_tasks: "{{test_helper_dir}}/verify_systemd_unit.yaml"
with_items:
loop:
- {"name": "edpm_neutron_dhcp_agent.service"}

- name: ensure podman container exists and are running
ansible.builtin.include_tasks: "{{test_helper_dir}}/verify_podman.yaml"
with_items:
loop:
- "neutron_dhcp_agent"

- name: ensure that log file for neutron-dhcp-agent exist
Expand Down
4 changes: 2 additions & 2 deletions roles/edpm_neutron_dhcp/tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
dest: "{{ edpm_neutron_dhcp_agent_config_dir }}/{{ item.dest }}"
setype: "container_file_t"
mode: "0644"
with_items:
loop:
- {"src": "neutron.conf.j2", "dest": "01-neutron.conf"}
- {"src": "rootwrap.conf.j2", "dest": "01-rootwrap.conf"}
- {"src": "neutron-dhcp-agent.conf.j2", "dest": "01-neutron-dhcp-agent.conf"}
Expand All @@ -49,4 +49,4 @@
dest: "{{ edpm_neutron_dhcp_agent_config_dir }}/{{ item.path | basename }}"
setype: "container_file_t"
mode: "0644"
with_items: "{{ edpm_neutron_dhcp_secrets.files }}"
loop: "{{ edpm_neutron_dhcp_secrets.files }}"
2 changes: 1 addition & 1 deletion roles/edpm_neutron_dhcp/tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
setype: "container_file_t"
state: directory
mode: "{{ item.mode | default(omit) }}"
with_items:
loop:
- {'path': "/var/lib/openstack/config/containers", "mode": "0750" }
- {'path': "/var/lib/neutron", "mode": "0750" }
- {'path': "{{ edpm_neutron_dhcp_agent_config_dir }}", 'mode': '0755'}
Expand Down
6 changes: 3 additions & 3 deletions roles/edpm_neutron_sriov/molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
tasks:
- name: ensure expected directories exist
ansible.builtin.include_tasks: "{{test_helper_dir}}/verify_dir.yaml"
with_items:
loop:
- "/var/lib/neutron"
- "/var/lib/openstack/config/containers"
- "/var/lib/kolla/config_files/neutron_sriov_agent.json"
Expand All @@ -17,12 +17,12 @@

- name: ensure systemd services are defined and functional
ansible.builtin.include_tasks: "{{test_helper_dir}}/verify_systemd_unit.yaml"
with_items:
loop:
- {"name": "edpm_neutron_sriov_agent.service"}

- name: ensure podman container exists and are running
ansible.builtin.include_tasks: "{{test_helper_dir}}/verify_podman.yaml"
with_items:
loop:
- "neutron_sriov_agent"

- name: ensure that log file for neutron-sriov-agent exist
Expand Down
4 changes: 2 additions & 2 deletions roles/edpm_neutron_sriov/tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
dest: "{{ edpm_neutron_sriov_agent_config_dir }}/{{ item.dest }}"
setype: "container_file_t"
mode: "0644"
with_items:
loop:
- {"src": "neutron.conf.j2", "dest": "01-neutron.conf"}
- {"src": "rootwrap.conf.j2", "dest": "01-rootwrap.conf"}
- {"src": "neutron-sriov-agent.conf.j2", "dest": "01-neutron-sriov-agent.conf"}
Expand All @@ -49,4 +49,4 @@
dest: "{{ edpm_neutron_sriov_agent_config_dir }}/{{ item.path | basename }}"
setype: "container_file_t"
mode: "0644"
with_items: "{{ edpm_neutron_sriov_secrets.files }}"
loop: "{{ edpm_neutron_sriov_secrets.files }}"
2 changes: 1 addition & 1 deletion roles/edpm_neutron_sriov/tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
setype: "container_file_t"
state: directory
mode: "{{ item.mode | default(omit) }}"
with_items:
loop:
- {'path': "/var/lib/openstack/config/containers", "mode": "0750" }
- {'path': "/var/lib/neutron", "mode": "0750" }
- {'path': "{{ edpm_neutron_sriov_agent_config_dir }}", 'mode': '0755'}
Expand Down
8 changes: 4 additions & 4 deletions roles/edpm_nova/molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
tasks:
- name: ensure expected directories exist
ansible.builtin.include_tasks: "{{test_helper_dir}}/verify_dir.yaml"
with_items:
loop:
# common directories
- "/etc/tmpfiles.d/"
- "/var/lib/openstack"
Expand All @@ -26,17 +26,17 @@
- "/var/log/containers/nova"
- name: ensure systemd services are defined and functional
ansible.builtin.include_tasks: "{{test_helper_dir}}/verify_systemd_unit.yaml"
with_items:
loop:
- { "name": "edpm_nova_compute.service" }
- name: ensure podman container exists and are running
ansible.builtin.include_tasks: "{{test_helper_dir}}/verify_podman.yaml"
with_items:
loop:
- "nova_compute"
- name: ensure kolla_set_configs copied the expected files
become: true
ansible.builtin.shell: |
podman logs nova_compute 2>&1 | grep "{{item}}" > /dev/null
with_items:
loop:
- "Copying /var/lib/kolla/config_files/nova-blank.conf to /etc/nova/nova.conf"
- "Copying /var/lib/kolla/config_files/01-nova.conf to /etc/nova/nova.conf.d/01-nova.conf"
- "Copying /var/lib/kolla/config_files/02-nova-log.conf to /etc/nova/nova.conf.d/02-nova-log.conf"
8 changes: 4 additions & 4 deletions roles/edpm_nova/tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
owner: "{{ item.owner | default(ansible_user) }}"
group: "{{ item.group | default(ansible_user) }}"
mode: "{{ item.mode | default(omit) }}"
with_items:
loop:
- { "path": "{{edpm_nova_config_dest}}" }
- { "path": "/var/lib/openstack/config/containers"}
- name: create persistent directories
Expand All @@ -26,7 +26,7 @@
owner: "{{ item.owner | default(omit) }}"
group: "{{ item.group | default(omit) }}"
mode: "{{ item.mode | default(omit) }}"
with_items:
loop:
- { "path": "/var/lib/nova"}
- { "path": "/var/lib/_nova_secontext"}
- { "path": "/var/lib/nova/instances"}
Expand All @@ -46,7 +46,7 @@
dest: "{{edpm_nova_config_dest}}/{{ item.dest }}"
setype: "container_file_t"
mode: 0644
with_items:
loop:
- {"src": "config.json.j2", "dest": "config.json"}
- {"src": "nova-blank.conf", "dest": "nova-blank.conf"}
notify:
Expand All @@ -71,6 +71,6 @@
dest: "{{edpm_nova_config_dest}}/{{ item.path | basename }}"
setype: "container_file_t"
mode: "0644"
with_items: "{{ edpm_nova_configmaps.files }}"
loop: "{{ edpm_nova_configmaps.files }}"
notify:
- restart nova
16 changes: 8 additions & 8 deletions roles/edpm_ovn/molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
ansible.builtin.shell: grep -q "{{ item }}" /etc/nftables/edpm-rules.nft
register: rule_exists
ignore_errors: true
with_items:
loop:
- "118 neutron vxlan networks"
- "119 neutron geneve networks"
- "120 neutron geneve networks no conntrack"
Expand All @@ -47,14 +47,14 @@
that:
- item.rc == 0
fail_msg: "firewall rule {{ item.item }} does not exist in /etc/nftables/edpm-rules.nft"
with_items: "{{ rule_exists.results }}"
loop: "{{ rule_exists.results }}"

- name: Check rule content
become: true
ansible.builtin.shell: grep -q "{{ item }}" /etc/nftables/edpm-rules.nft
register: rule_content_exists
ignore_errors: true
with_items:
loop:
- "EDPM_INPUT udp dport { 4789 } ct state new counter accept"
- "EDPM_INPUT udp dport { 6081 } ct state untracked counter accept"
- "EDPM_OUTPUT udp dport { 6081 } counter notrack"
Expand All @@ -65,14 +65,14 @@
that:
- item.rc == 0
fail_msg: "rule content {{ item.item }} does not exist in /etc/nftables/edpm-rules.nft"
with_items: "{{ rule_content_exists.results }}"
loop: "{{ rule_content_exists.results }}"

- name: Check input chain rules are loaded
become: true
ansible.builtin.shell: nft list table inet filter | awk '/chain EDPM_INPUT {/,/}/' | grep -q "{{ item }}.*accept"
register: input_rules_loaded
ignore_errors: true
with_items:
loop:
- "udp dport 4789 ct state new counter"
- "udp dport 6081 ct state untracked counter"

Expand All @@ -81,14 +81,14 @@
that:
- item.rc == 0
fail_msg: "rule {{ item.item }} not loaded"
with_items: "{{ input_rules_loaded.results }}"
loop: "{{ input_rules_loaded.results }}"

- name: Check notrack rules are loaded
become: true
ansible.builtin.shell: nft list table inet raw | awk '/chain {{ item }} {/,/}/' | grep -q "udp dport 6081 counter packets.*notrack"
register: notrack_rules_loaded
ignore_errors: true
with_items:
loop:
- EDPM_OUTPUT
- EDPM_PREROUTING

Expand All @@ -97,7 +97,7 @@
that:
- item.rc == 0
fail_msg: "rule {{ item.item }} not loaded"
with_items: "{{ notrack_rules_loaded.results }}"
loop: "{{ notrack_rules_loaded.results }}"

- name: Ensure that 10-neutron-metadata.conf was copied into the container
block:
Expand Down
4 changes: 2 additions & 2 deletions roles/edpm_ovn/tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@
dest: "{{ edpm_ovn_neutron_metadata_agent_config_dir }}/{{ item.dest }}"
setype: "container_file_t"
mode: "0644"
with_items:
loop:
- {"src": "rootwrap.conf.j2", "dest": "01-rootwrap.conf"}
- {"src": "neutron-ovn-metadata-agent.conf.j2", "dest": "01-neutron-ovn-metadata-agent.conf"}

Expand All @@ -109,4 +109,4 @@
dest: "{{ edpm_ovn_neutron_metadata_agent_config_dir }}/{{ item.path | basename }}"
setype: "container_file_t"
mode: "0644"
with_items: "{{ edpm_neutron_metadata_secrets.files }}"
loop: "{{ edpm_neutron_metadata_secrets.files }}"
2 changes: 1 addition & 1 deletion roles/edpm_ovn_bgp_agent/tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
state: directory
setype: "{{ item.setype }}"
mode: "{{ item.mode }}"
with_items:
loop:
- { 'path': /var/log/containers/ovn-bgp-agent, 'setype': container_file_t, 'mode': '0750' }
- { 'path': "{{ edpm_ovn_bgp_agent_config_basedir }}", 'setype': container_file_t, 'mode': '0750' }

Expand Down
2 changes: 1 addition & 1 deletion roles/edpm_podman/molecule/default/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@
image: "ubi8:latest"
detach: true
command: sleep 1d
with_items:
loop:
- test-container1
- test-container2
2 changes: 1 addition & 1 deletion roles/edpm_users/molecule/default/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@
- "hugetlbfs"
- name: ensure expected directories exist
ansible.builtin.include_tasks: "{{test_helper_dir}}/verify_dir.yaml"
with_items:
loop:
- /var/lib/vhost_sockets
2 changes: 1 addition & 1 deletion roles/edpm_users/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

- name: create host users and groups
ansible.builtin.include_tasks: create_users_and_groups.yml
with_items: "{{ edpm_users_users }}"
loop: "{{ edpm_users_users }}"

- name: create host directories
become: true
Expand Down

0 comments on commit 7756f5a

Please sign in to comment.