Hello Developer Community!
I'm currently working on developing some Ansible playbooks to manage Citrix NetScaler configuration and would like to get some help about the following. I have the following data structure defined in a YAML file:
prefix_header: "foo"
prefix_trailer: "bar"
nsapp_cs_vserver:
- name: "testwebvserver-4_SSL_443"
policybindings:
- policyname: "TO_testwebservice-3"
priority: "100"
- policyname: "To-be-deleted"
priority: "110"
I'm trying to find an easy way to dynamically convert the content of "policybindings" list variable to the following format: (I would like to append header and trailer prefixes to the actual value of "policyname")
policybindings:
- policyname: "foo_TO_testwebservice-3_bar"
priority: "100"
- policyname: "foo_To-be-deleted_bar"
priority: "110"
I would like to use the policy names with header and trailer prefixes to invoke netscaler_cs_vserver Ansible module to configure Content Switching.
- name: "Bind CS policy(ies) to CS vServer(s) on ACTIVE node"
netscaler_cs_vserver:
name: "{{ prefix_header }}{{ item.name }}{{ prefix_trailer}}"
policybindings: "{{ item.policybindings }}"
register: bind_nsapp_cs_policy_result
loop: "{{ nsapp_cs_vserver }}"
Could anybody please advise what is the correct and effective way to achieve this?
Many thanks in advance!