Would anyone be able to recommend a way to take the contents of two register variables and pass them into one command? While also lining up the results of the outputs from each variable in a 1:1 fashion. (ie. VS1:rule1, VS2:rule2, and so on from the output shown below)
Here is what's stored in stdout_lines for 'Virtual_Check' and 'Rule_Check':
"Virtual_Check.stdout_lines": [
[
"ltm virtual VS1 ",
"ltm virtual VS2 ",
"ltm virtual VS3 ",
"ltm virtual VS",
"Rule_Check.stdout_lines": [
[
"myrule1",
" ",
"",
" myrule2",
" ",
"",
" myrule3",
" ",
"",
" myrule4",
" ",
"",
Now, I would like to pass the contents of the variables into one command as shown below. When I run this playbook the 'Virtual_Check' portion under 'with_nested' loops as expected, but the issue I'm running into is it won't loop properly for the 'Rule_Check' portion (I've left in the two methods I tried below)
So far I've tried using with_nested to accomplish this and it seems to no be looping over the second variable correctly.
- name: Update VS iRule
bigip_command:
commands:
- "modify ltm virtual {{ item.0 }} rules { {{ item.1 }} myrule10 }"
provider:
server: "{{ inventory_hostname }}"
password: "{{ remote_passwd }}"
user: "{{ remote_username }}"
validate_certs: no
delegate_to: localhost
with_nested:
- [ "{{ Virtual_Check['stdout'][0] | replace('ltm virtual', '') | replace('\n', '') }}"]
- [ "{{ Rule_Check['stdout'][0] | replace('\n', '') }}" ]
- [ "{{ Rule_Check['stdout_lines'][0] }}" ]
I would expect that the 'modify ltm virtual {{ item.0 }} rules { {{ item.1 }} myrule10 }' line would be processed with the content within the Virtual_Check & Rule_Check lists
For example:
modify ltm virtual VS1 rules { myrule1 myrule10 }
modify ltm virtual VS2 rules { myrule2 myrule10 }
modify ltm virtual VS3 rules { myrule3 myrule10 }
modify ltm virtual VS4 rules { myrule4 myrule10 }