Hi
I want to invoke a module wich accepts an attribute osCustomAttributes which takes a variable set of properties (sorry if the wording is not the correct one for yaml)
Example below. All the names under osCustomAttributes should be computed dynamically, I cannot predict what they will be in advance
3 examples below
the osCustomAttributes with the list of -name/value pairs should be computed dynamically, this list is variable by essence
I want to reduce the 3 tasks below in a simple, unique task (I provide here 3 examples but I cannot handle the infinite number of variations)
What are my options ?
Thanks
- name : “Example task 1”
create_server_profile:
state: “present”
data:
name: “{{ inventory_hostname }}”
serverHardwareName: “{{ name }}”
osDeploymentSettings:
osDeploymentPlanName: “{{ plan }}”
osCustomAttributes:
-
name: HostName
value: ‘{{ inventory_hostname }}’ -
name: AnsibleNIC1.vlanid
value: ‘0’ -
name: AnsibleNIC1.dhcp
value: false -
name: AnsibleNIC1.networkuri
value: ‘{{ connection.networkUri }}’ -
name: AnsibleNIC1.connectionid
value: ‘{{ connection.id }}’ -
name : “Example task 2”
create_server_profile:
state: “present”
data:
name: “{{ inventory_hostname }}”
serverHardwareName: “{{ name }}”
osDeploymentSettings:
osDeploymentPlanName: “{{ plan }}”
osCustomAttributes:
-
name: HostName
value: ‘{{ inventory_hostname }}’ -
name: MgmtNIC1.vlanid
value: ‘3’ -
name: MgmtNIC1.dhcp
value: false -
name: MgmtNIC1.networkuri
value: ‘{{ connection.networkUri }}’ -
name: MgmtNIC1.connectionid
value: ‘{{ connection.id }}’ -
name : “Example task 3”
create_server_profile:
state: “present”
data:
name: “{{ inventory_hostname }}”
serverHardwareName: “{{ name }}”
osDeploymentSettings:
osDeploymentPlanName: “{{ plan }}”
osCustomAttributes:
- name: HostName
value: ‘{{ inventory_hostname }}’ - name: fooProperty
value: ‘fooValue’