From 668830fc9449976c68106be88a5cb75d014fcaf9 Mon Sep 17 00:00:00 2001 From: Rafael Guterres Jeffman Date: Thu, 12 Jun 2025 17:10:08 -0300 Subject: [PATCH] ansible-core 2.19: 'upper' and 'lower' make lists into strings As ansible-core 2.19 'upper' and 'lower' filters make lists into strings and these strings are not interpreted as lists when running the plugins, it is needed to use 'map()' to apply the filter to all entries of a list. Signed-off-by: Rafael Guterres Jeffman --- tests/group/test_group_case_insensitive.yml | 18 +++++++++--------- ...st_hbacsvcgroup_member_case_insensitive.yml | 16 ++++++++-------- .../test_hostgroup_case_insensitive.yml | 10 +++++----- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/tests/group/test_group_case_insensitive.yml b/tests/group/test_group_case_insensitive.yml index 098d77e6..22fcc0d4 100644 --- a/tests/group/test_group_case_insensitive.yml +++ b/tests/group/test_group_case_insensitive.yml @@ -49,8 +49,8 @@ - { id: 2, value: "{{ user_names[0] | upper }}", expected: false } - { id: 3, value: "{{ user_names[0] }}", expected: false } - { id: 4, value: "{{ user_names }}", expected: true } - - { id: 5, value: "{{ user_names | upper }}", expected: false } - - { id: 6, value: "{{ user_names | lower }}", expected: false } + - { id: 5, value: "{{ user_names | map('upper') }}", expected: false } + - { id: 6, value: "{{ user_names | map('lower') }}", expected: false } - { id: 7, value: "{{ user_names[1] }}", expected: true } - { id: 8, value: "{{ user_names[1] | upper }}", expected: false } - { id: 9, value: "{{ user_names[1] | lower }}", expected: false } @@ -64,7 +64,7 @@ failed_when: output.changed != item.expected or output.failed loop: "{{ test_cases }}" loop_control: - label: "Test id: {{ item.id }}" + label: "Test id: {{ item.id }} - {{ item.value }}" - name: Test group presence with group parameter vars: @@ -73,8 +73,8 @@ - { id: 2, value: "{{ group_names[0] | upper }}", expected: false } - { id: 3, value: "{{ group_names[0] }}", expected: false } - { id: 4, value: "{{ group_names }}", expected: true } - - { id: 5, value: "{{ group_names | upper }}", expected: false } - - { id: 6, value: "{{ group_names | lower }}", expected: false } + - { id: 5, value: "{{ group_names | map('upper') }}", expected: false } + - { id: 6, value: "{{ group_names | map('lower') }}", expected: false } - { id: 7, value: "{{ group_names[1] }}", expected: true } - { id: 8, value: "{{ group_names[1] | upper }}", expected: false } - { id: 9, value: "{{ group_names[1] | lower }}", expected: false } @@ -159,8 +159,8 @@ - { id: 2, value: "{{ user_names[0] | upper }}", expected: false } - { id: 3, value: "{{ user_names[0] }}", expected: false } - { id: 4, value: "{{ user_names }}", expected: true } - - { id: 5, value: "{{ user_names | upper }}", expected: false } - - { id: 6, value: "{{ user_names | lower }}", expected: false } + - { id: 5, value: "{{ user_names | map('upper') }}", expected: false } + - { id: 6, value: "{{ user_names | map('lower') }}", expected: false } - { id: 7, value: "{{ user_names[1] }}", expected: true } - { id: 8, value: "{{ user_names[1] | upper }}", expected: false } - { id: 9, value: "{{ user_names[1] | lower }}", expected: false } @@ -183,8 +183,8 @@ - { id: 2, value: "{{ group_names[0] | upper }}", expected: false } - { id: 3, value: "{{ group_names[0] }}", expected: false } - { id: 4, value: "{{ group_names }}", expected: true } - - { id: 5, value: "{{ group_names | upper }}", expected: false } - - { id: 6, value: "{{ group_names | lower }}", expected: false } + - { id: 5, value: "{{ group_names | map('upper') }}", expected: false } + - { id: 6, value: "{{ group_names | map('lower') }}", expected: false } - { id: 7, value: "{{ group_names[1] }}", expected: true } - { id: 8, value: "{{ group_names[1] | upper }}", expected: false } - { id: 9, value: "{{ group_names[1] | lower }}", expected: false } diff --git a/tests/hbacsvcgroup/test_hbacsvcgroup_member_case_insensitive.yml b/tests/hbacsvcgroup/test_hbacsvcgroup_member_case_insensitive.yml index 6a62c830..b986e1e0 100644 --- a/tests/hbacsvcgroup/test_hbacsvcgroup_member_case_insensitive.yml +++ b/tests/hbacsvcgroup/test_hbacsvcgroup_member_case_insensitive.yml @@ -97,7 +97,7 @@ ipahbacsvcgroup: ipaadmin_password: SomeADMINpassword name: testgroup - hbacsvc: "{{ hbacsvc_list | lower }}" + hbacsvc: "{{ hbacsvc_list | map('lower') }}" register: result failed_when: result.changed or result.failed @@ -105,7 +105,7 @@ ipahbacsvcgroup: ipaadmin_password: SomeADMINpassword name: testgroup - hbacsvc: "{{ hbacsvc_list | upper }}" + hbacsvc: "{{ hbacsvc_list | map('upper') }}" register: result failed_when: result.changed or result.failed @@ -153,7 +153,7 @@ ipahbacsvcgroup: ipaadmin_password: SomeADMINpassword name: testgroup - hbacsvc: "{{ hbacsvc_list | lower }}" + hbacsvc: "{{ hbacsvc_list | map('lower') }}" action: member register: result failed_when: result.changed or result.failed @@ -162,7 +162,7 @@ ipahbacsvcgroup: ipaadmin_password: SomeADMINpassword name: testgroup - hbacsvc: "{{ hbacsvc_list | upper }}" + hbacsvc: "{{ hbacsvc_list | map('upper') }}" action: member register: result failed_when: result.changed or result.failed @@ -171,7 +171,7 @@ ipahbacsvcgroup: ipaadmin_password: SomeADMINpassword name: testgroup - hbacsvc: "{{ hbacsvc_list | upper }}" + hbacsvc: "{{ hbacsvc_list | map('upper') }}" action: member state: absent check_mode: yes @@ -182,7 +182,7 @@ ipahbacsvcgroup: ipaadmin_password: SomeADMINpassword name: testgroup - hbacsvc: "{{ hbacsvc_list | upper }}" + hbacsvc: "{{ hbacsvc_list | map('upper') }}" action: member state: absent register: result @@ -192,7 +192,7 @@ ipahbacsvcgroup: ipaadmin_password: SomeADMINpassword name: testgroup - hbacsvc: "{{ hbacsvc_list | upper }}" + hbacsvc: "{{ hbacsvc_list | map('upper') }}" action: member state: absent check_mode: yes @@ -213,7 +213,7 @@ ipahbacsvcgroup: ipaadmin_password: SomeADMINpassword name: testgroup - hbacsvc: "{{ hbacsvc_list | lower }}" + hbacsvc: "{{ hbacsvc_list | map('lower') }}" action: member state: absent register: result diff --git a/tests/hostgroup/test_hostgroup_case_insensitive.yml b/tests/hostgroup/test_hostgroup_case_insensitive.yml index ca0b7bad..abe41804 100644 --- a/tests/hostgroup/test_hostgroup_case_insensitive.yml +++ b/tests/hostgroup/test_hostgroup_case_insensitive.yml @@ -81,8 +81,8 @@ - name: Test hostgroup presence with multiple hosts and action hostgroup vars: test_cases: - - { id: 1, value: "{{ test_hosts | lower }}", expected: true } - - { id: 2, value: "{{ test_hosts | upper }}", expected: false } + - { id: 1, value: "{{ test_hosts | map('lower') }}", expected: true } + - { id: 2, value: "{{ test_hosts | map('upper') }}", expected: false } - { id: 3, value: "{{ test_hosts }}", expected: false } - { id: 4, value: "{{ test_hosts[1] }}", expected: true } - { id: 5, value: "{{ test_hosts[1] | lower }}", expected: false } @@ -104,8 +104,8 @@ - name: Test hostgroup with multiple hosts and action member vars: test_cases: - - { id: 1, value: "{{ test_hosts | lower }}", state: "absent", expected: true } - - { id: 2, value: "{{ test_hosts | upper }}", state: "absent", expected: false } + - { id: 1, value: "{{ test_hosts | map('lower') }}", state: "absent", expected: true } + - { id: 2, value: "{{ test_hosts | map('upper') }}", state: "absent", expected: false } - { id: 3, value: "{{ test_hosts }}", state: "present", expected: true } - { id: 4, value: "{{ test_hosts[1] }}", state: "absent", expected: true } - { id: 5, value: "{{ test_hosts[1] | lower }}", state: "absent", expected: false } @@ -113,7 +113,7 @@ - { id: 7, value: "{{ test_hosts[0] | lower }}", state: "present", expected: false } - { id: 8, value: "{{ test_hosts[0] }}", state: "present", expected: false } - { id: 9, value: "{{ test_hosts[0] | upper }}", state: "present", expected: false } - - { id: 10, value: "{{ test_hosts | upper }}", state: "present", expected: true } + - { id: 10, value: "{{ test_hosts | map('upper') }}", state: "present", expected: true } - { id: 11, value: "{{ test_hosts[1] }}", state: "present", expected: false } - { id: 12, value: "{{ test_hosts[0] | lower }}", state: "present", expected: false } - { id: 13, value: "{{ test_hosts[0] }}", state: "absent", expected: true }