Skip to content

Commit f1e09b5

Browse files
Merge pull request #993 from rabi/conditional
Make edpm-ansible ansible 2.19 compatible
2 parents 7a9930c + e8685a6 commit f1e09b5

File tree

11 files changed

+50
-39
lines changed

11 files changed

+50
-39
lines changed

docs/docs-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# this is required for the docs build jobs
2-
ansible-core>=2.15.0,<2.19.0
2+
ansible-core>=2.15.0
33
sphinx>=2.0.0,!=2.1.0 # BSD
44
reno>=3.1.0 # Apache-2.0
55
doc8>=0.8.1 # Apache-2.0

molecule-requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ansible-core>=2.15.0,<2.19.0
1+
ansible-core>=2.15.0
22
molecule>=5.1.0,<6.0.0
33
molecule-plugins[podman,vagrant]>=23.5.0
44
pytest-testinfra
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
ansible-core>=2.16.1,<2.19.0
1+
ansible-core>=2.16.1
22
ansible-runner>=2.4.0
33
ansible-builder>=3.1.0
44
dumb-init>=1.2.2

plugins/action/container_systemd.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525

2626
from ansible.errors import AnsibleActionFail
2727
from ansible.plugins.action import ActionBase
28+
try:
29+
from ansible.template import trust_as_template
30+
except ImportError:
31+
def trust_as_template(data):
32+
return data
2833
from ansible.utils.display import Display
2934

3035

@@ -200,11 +205,10 @@ def _get_unit_template(self):
200205
'systemd-service.j2'
201206
)
202207
if not os.path.exists(source):
203-
raise AnsibleActionFail('Template {} was '
204-
'not found'.format(source))
208+
raise AnsibleActionFail('Template {} was not found'.format(source))
205209
with open(source) as template_file:
206210
data = template_file.read()
207-
return data
211+
return trust_as_template(data)
208212

209213
def _create_units(self, container_config, task_vars):
210214
"""Create system units and get list of changed services

roles/edpm_kernel/tasks/hugepages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
_converted_hugepages: {}
2020
_nonconfig_hugepages: {}
2121
_hugepages_modification: false
22-
when: edpm_kernel_hugepages | length
22+
when: edpm_kernel_hugepages | default({}) | length > 0
2323
block:
2424
- name: Rewrite edpm_kernel_hugepages to use integers as keys
2525
ansible.builtin.set_fact:

roles/edpm_libvirt/tasks/virsh-secret.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,4 @@
3838
KEY: "{{ cephx_key.stdout | regex_replace('\"', '') }}"
3939
when:
4040
- cephx_key.stdout is defined
41-
- cephx_key.stdout | regex_replace('\"', '') | regex_search('^[a-zA-Z0-9+/]{38}==$')
41+
- cephx_key.stdout | regex_replace('\"', '') | regex_search('^[a-zA-Z0-9+/]{38}==$') | length > 0
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
{%- set ns = namespace(_dport='') %}
1+
{%- set ns = namespace(dport='') %}
22
{%- if 'dport' in rule %}
33
{% if rule['dport'] is iterable and (rule['dport'] is not string and rule['dport'] is not mapping) -%}
4-
{% set ns._dport = rule['dport'] |join(', ') -%}
4+
{% set ns.dport = rule['dport'] |join(', ') -%}
55
{% else -%}
6-
{% set ns._dport = rule['dport'] -%}
6+
{% set ns.dport = rule['dport'] -%}
77
{% endif -%}
88
{%- endif %}
99
{#- This is for legacy things - Really, use dport... #}
1010
{%- if 'port' in rule %}
1111
{% if rule['port'] is iterable and (rule['port'] is not string and rule['port'] is not mapping) -%}
12-
{% set ns._dport = rule['port'] |join(', ') -%}
12+
{% set ns.dport = rule['port'] |join(', ') -%}
1313
{% else -%}
14-
{% set ns._dport = rule['port'] -%}
14+
{% set ns.dport = rule['port'] -%}
1515
{% endif -%}
1616
{%- endif %}
17-
{%- if ns._dport != '' %}
18-
{{ rule.get('proto', false)|ternary('', 'tcp ') }}dport { {{ ns._dport |replace(':', '-') }} }
17+
{%- if ns.dport != '' %}
18+
{{ rule.get('proto', false)|ternary('', 'tcp ') }}dport { {{ ns.dport |replace(':', '-') }} }
1919
{%- endif %}

roles/edpm_ovn/tasks/cleanup.yml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,44 +31,51 @@
3131
changed_when: false
3232
ignore_errors: true
3333

34+
- name: Initialize cleanup_ovn_cms_options_stdout variable
35+
ansible.builtin.set_fact:
36+
cleanup_ovn_cms_options_stdout: "{{ cleanup_ovn_cms_options.stdout | default('') }}"
37+
when: cleanup_ovn_cms_options.rc == 0
38+
3439
- name: Cleanup enable-chassis-as-gw when chassis GW not enabled
3540
ansible.builtin.set_fact:
36-
cleanup_ovn_cms_options: "{{ cleanup_ovn_cms_options | regex_replace('enable-chassis-as-gw' ~ ',?', '') }}"
41+
cleanup_ovn_cms_options_stdout: "{{ cleanup_ovn_cms_options_stdout | regex_replace('enable-chassis-as-gw' ~ ',?', '') }}"
3742
when:
3843
- not edpm_enable_chassis_gw | bool
3944
- cleanup_ovn_cms_options.rc == 0
45+
- cleanup_ovn_cms_options_stdout | length > 0
4046

4147
- name: Cleanup enable-chassis-as-extport-host when chassis extport not enabled
4248
ansible.builtin.set_fact:
43-
cleanup_ovn_cms_options: "{{ cleanup_ovn_cms_options | regex_replace('enable-chassis-as-extport-host' ~ ',?', '') }}"
49+
cleanup_ovn_cms_options_stdout: "{{ cleanup_ovn_cms_options_stdout | regex_replace('enable-chassis-as-extport-host' ~ ',?', '') }}"
4450
when:
4551
- not edpm_enable_chassis_extport | bool
4652
- cleanup_ovn_cms_options.rc == 0
53+
- cleanup_ovn_cms_options_stdout | length > 0
4754

4855
- name: Cleanup availability-zones
4956
when:
5057
- edpm_ovn_availability_zones | length == 0
5158
- cleanup_ovn_cms_options.rc == 0
59+
- cleanup_ovn_cms_options_stdout | length > 0
5260
block:
5361
- name: Filter out availability-zones from stdout when undefined
5462
ansible.builtin.set_fact:
55-
filtered_azs:
56-
stdout: "{{ cleanup_ovn_cms_options.stdout | regex_replace('availability-zones=[^,]*' ~ ',?', '') }}"
63+
filtered_azs: "{{ cleanup_ovn_cms_options_stdout | regex_replace('availability-zones=[^,]*' ~ ',?', '') }}"
5764

5865
- name: Update cleanup_ovn_cms_options with filtered azs
5966
ansible.builtin.set_fact:
60-
cleanup_ovn_cms_options: "{{ cleanup_ovn_cms_options | combine(filtered_azs | default({})) }}"
67+
cleanup_ovn_cms_options_stdout: "{{ filtered_azs }}"
6168

6269
- name: Set updated OVN CMS Options to the local OVSDB
6370
become: true
6471
ansible.builtin.shell: >
65-
ovs-vsctl set Open_vSwitch . external_ids:ovn-cms-options={{ cleanup_ovn_cms_options.stdout }}
72+
ovs-vsctl set Open_vSwitch . external_ids:ovn-cms-options={{ cleanup_ovn_cms_options_stdout }}
6673
register: cleanup_ovn_cms_options_set
6774
changed_when: cleanup_ovn_cms_options_set.rc == 0
6875
failed_when: cleanup_ovn_cms_options_set.rc != 0
6976
when:
7077
- cleanup_ovn_cms_options.rc == 0
71-
- cleanup_ovn_cms_options.stdout != ""
78+
- cleanup_ovn_cms_options_stdout | length > 0
7279

7380
- name: Clear OVN CMS Options if updated string is empty
7481
become: true
@@ -79,4 +86,4 @@
7986
failed_when: cleanup_ovn_cms_options_remove.rc != 0
8087
when:
8188
- cleanup_ovn_cms_options.rc == 0
82-
- cleanup_ovn_cms_options.stdout == ""
89+
- cleanup_ovn_cms_options_stdout | length == 0

roles/edpm_ovs_dpdk/tasks/configure.yml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
- name: Check valid input for edpm_ovs_dpdk_pmd_core_list
1818
ansible.builtin.fail:
1919
msg: "List of PMD cores cannot be empty - edpm_ovs_dpdk_pmd_core_list"
20-
when: not edpm_ovs_dpdk_pmd_core_list|string or edpm_ovs_dpdk_pmd_core_list == 'null'
20+
when: edpm_ovs_dpdk_pmd_core_list|string|length == 0 or edpm_ovs_dpdk_pmd_core_list == 'null'
2121

2222
- name: PMD cores config
23-
when: edpm_ovs_dpdk_pmd_core_list|string
23+
when: edpm_ovs_dpdk_pmd_core_list|string|length > 0
2424
block:
2525
- name: Apply PMD cores config
2626
ansible.builtin.set_fact:
@@ -47,7 +47,7 @@
4747
edpm_ovs_other_config: "{{ edpm_ovs_other_config | combine(dpdk_extra) }}"
4848

4949
- name: Set socket-mem and socket-limit config
50-
when: edpm_ovs_dpdk_socket_memory|string
50+
when: edpm_ovs_dpdk_socket_memory|string|length > 0
5151
block:
5252
- name: Apply socket-mem config
5353
ansible.builtin.set_fact:
@@ -64,7 +64,7 @@
6464
edpm_ovs_other_config: "{{ edpm_ovs_other_config | combine(dpdk_socket_mem) | combine(dpdk_socket_limit) }}"
6565

6666
- name: Set Revalidator threads config
67-
when: edpm_ovs_dpdk_revalidator_cores|string
67+
when: edpm_ovs_dpdk_revalidator_cores|string|length > 0
6868
block:
6969
- name: Apply Revalidator threads config
7070
ansible.builtin.set_fact:
@@ -76,7 +76,7 @@
7676
edpm_ovs_other_config: "{{ edpm_ovs_other_config | combine(n_revalidator_threads) }}"
7777

7878
- name: Set Handler threads config
79-
when: edpm_ovs_dpdk_handler_cores|string
79+
when: edpm_ovs_dpdk_handler_cores|string|length > 0
8080
block:
8181
- name: Apply Handler threads config
8282
ansible.builtin.set_fact:
@@ -88,7 +88,7 @@
8888
edpm_ovs_other_config: "{{ edpm_ovs_other_config | combine(n_handler_threads) }}"
8989

9090
- name: Set EMC Insertion Probability config
91-
when: edpm_ovs_dpdk_emc_insertion_probablity|string
91+
when: edpm_ovs_dpdk_emc_insertion_probablity|string|length > 0
9292
block:
9393
- name: Apply EMC Insertion Probability config
9494
ansible.builtin.set_fact:
@@ -149,7 +149,7 @@
149149
edpm_ovs_other_config: "{{ edpm_ovs_other_config | combine(pmd_auto_lb) }}"
150150

151151
- name: Set minimum PMD thread load threshold
152-
when: edpm_ovs_dpdk_pmd_load_threshold|string
152+
when: edpm_ovs_dpdk_pmd_load_threshold|string|length > 0
153153
block:
154154
- name: Apply minimum PMD thread load threshold
155155
ansible.builtin.set_fact:
@@ -161,7 +161,7 @@
161161
edpm_ovs_other_config: "{{ edpm_ovs_other_config | combine(pmd_auto_lb_load_threshold) }}"
162162

163163
- name: Set PMD load variance improvement threshold
164-
when: edpm_ovs_dpdk_pmd_improvement_threshold|string
164+
when: edpm_ovs_dpdk_pmd_improvement_threshold|string|length > 0
165165
block:
166166
- name: Apply PMD load variance improvement threshold
167167
ansible.builtin.set_fact:
@@ -173,7 +173,7 @@
173173
edpm_ovs_other_config: "{{ edpm_ovs_other_config | combine(pmd_auto_lb_improvement_threshold) }}"
174174

175175
- name: Set PMD auto load balancing interval
176-
when: edpm_ovs_dpdk_pmd_rebal_interval|string
176+
when: edpm_ovs_dpdk_pmd_rebal_interval|string|length > 0
177177
block:
178178
- name: Apply PMD auto load balancing interval
179179
ansible.builtin.set_fact:
@@ -185,7 +185,7 @@
185185
edpm_ovs_other_config: "{{ edpm_ovs_other_config | combine(pmd_auto_lb_rebal_interval) }}"
186186

187187
- name: OVN bridge datapath type config
188-
when: edpm_ovn_datapath_type|string
188+
when: edpm_ovn_datapath_type|string|length > 0
189189
block:
190190
- name: Apply PMD cores config
191191
ansible.builtin.set_fact:
@@ -197,7 +197,7 @@
197197
edpm_ovs_external_ids: "{{ {} | combine(ovn_bridge_datapath_type) }}"
198198

199199
- name: Set shared memory pool config
200-
when: edpm_ovs_dpdk_shared_mem_pool|string
200+
when: edpm_ovs_dpdk_shared_mem_pool|string|length > 0
201201
block:
202202
- name: Apply shared memory pool config
203203
ansible.builtin.set_fact:
@@ -209,7 +209,7 @@
209209
edpm_ovs_other_config: "{{ edpm_ovs_other_config | combine(dpdk_shared_mem_pool) }}"
210210

211211
- name: Set PMD maximum sleep time
212-
when: edpm_ovs_dpdk_pmd_sleep_max|string
212+
when: edpm_ovs_dpdk_pmd_sleep_max|string|length > 0
213213
block:
214214
- name: Apply PMD maximum sleep time
215215
ansible.builtin.set_fact:

roles/edpm_pre_adoption_validation/tasks/kernel_args.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,4 @@
4141
# In the other hand neither the edpm_kernel role during deployment and
4242
# adoption nor this adoption check enforces to list the existing kernel args
4343
# in edpm_kernel_args ansible variable.
44-
failed_when: not (cmdline | regex_search( '^.*' + edpm_kernel_args | default('') + '.*$' | string ))
44+
failed_when: not (cmdline | regex_search( '^.*' + edpm_kernel_args | default('') + '.*$' | string))

0 commit comments

Comments
 (0)