# how to invoke an ansible module which accepts a variable set of parameters

**URL:** <https://forum.ansible.com/t/how-to-invoke-an-ansible-module-which-accepts-a-variable-set-of-parameters/29624>\
**Category:** Ansible Project\
**Created:** [February 5, 2019, 9:56pm UTC](https://forum.ansible.com/t/how-to-invoke-an-ansible-module-which-accepts-a-variable-set-of-parameters/29624 "2019-02-05T21:56:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Chris7444](https://avatars.discourse-cdn.com/v4/letter/c/8edcca/32.png) [@Chris7444](https://forum.ansible.com/u/Chris7444)\
**Post date:** [February 5, 2019, 9:56pm UTC](https://forum.ansible.com/t/how-to-invoke-an-ansible-module-which-accepts-a-variable-set-of-parameters/29624/1 "2019-02-05T21:56:35Z")

</div>

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’
