Hi all,
I have a rpm whcich i have added in a list. I want to make it dynamic i.e when the version of rpm changes playbook should handle it.
I have build a logic but the playbook skips the task where i have mentioned the regex. Kindly help me .
-
hosts: localhost
tasks: -
name: Create a list
set_fact:
some_value: -
dp-steps-common-3.0.12.rpm
-
debug:
msg: “{{ some_value }}” -
name: Print DP steps records
set_fact:
dp_record: “{{ item }}”
when: item is defined and item == ‘regexp (dp-steps-common-[0-9./]+[0-9./]+[0-9][0-9./]rpm$)’
with_items: “{{ some_value }}” -
name: Create an empty list variable
set_fact:
nodes1: -
name: Append string to ECE node list
set_fact:
nodes1: “{{ ece_nodes + [ item ] }}”
with_items: -
“{{ dp_record | default(None) }}”
when: item is defined and item != None and item != “” -
name: Display Lists
debug:
msg: -
“{{ nodes1 }}”
OUTput:
PLAY [localhost] ****************************************************************************************************************************************************************************
TASK [Gathering Facts] **********************************************************************************************************************************************************************
ok: [localhost]
TASK [Create a list] ************************************************************************************************************************************************************************
ok: [localhost]
TASK [debug] ********************************************************************************************************************************************************************************
ok: [localhost] => {
“msg”: [
“dp-steps-common-3.0.12.rpm”
]
}
TASK [Print DP steps records] ***************************************************************************************************************************************************************
skipping: [localhost] => (item=dp-steps-common-3.0.12.rpm)
TASK [Create an empty list variable] ********************************************************************************************************************************************************
ok: [localhost]
TASK [Append string to ECE node list] *******************************************************************************************************************************************************
skipping: [localhost] => (item=)
TASK [Display Lists] ************************************************************************************************************************************************************************
ok: [localhost] => {
“msg”: [
]