# Conditional parameters to vmware\_guest

**URL:** <https://forum.ansible.com/t/conditional-parameters-to-vmware-guest/28419>\
**Category:** Ansible Project\
**Tags:** awx\
**Created:** [August 24, 2018, 7:43pm UTC](https://forum.ansible.com/t/conditional-parameters-to-vmware-guest/28419 "2018-08-24T19:43:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![enzo.tano](https://avatars.discourse-cdn.com/v4/letter/e/6f9a4e/32.png) [@enzo.tano](https://forum.ansible.com/u/enzo.tano)\
**Post date:** [August 24, 2018, 7:43pm UTC](https://forum.ansible.com/t/conditional-parameters-to-vmware-guest/28419/1 "2018-08-24T19:43:28Z")

</div>

Hi,

sorry if I continue with newbie questions.  
I have my playbook for create vm from template

```auto
- name: Clone a VM from Template and customize
  vmware_guest:
    hostname: 192.168.1.209
    username: user
    password: pass
    validate_certs: no
    datacenter: datacenter1
    cluster: cluster
    name: '{{ guest_vm }}'
    template: '{{ template_name }}'
    networks:
    - name: '{{ vmnetwork }}'
      ip: '{{ ip_address }}'
      netmask: '{{ ip_netmask }}'
      gateway: '{{ ip_gateway }}'
      domain: '{{ dns_domain }}'
      dns_servers:
      - 192.168.1.1
      - 192.168.1.2
  delegate_to: localhost

awx take variables from survey, arg vmnetwork is taken from multichoice.
I want set all others parameters with conditional and not take it from survey. For example in meta language.

if vmnetwork == "blue" then
    ip_address = 192.168.10.XXX
    ip_netmask = 192.168.10.1
    dns_domain = "blue.com"
    dns_server = [ip1, ip2]
else if vmnetwork == "red" then
    ip_address = 192.168.11.XXX
    ip_netmask = 192.168.11.1
    dns_domain = "red.com"
    dns_server = [ip1, ip2]
....
     and so on
....
end if

Which is the best way for do it in ansible 2.6?
I see this example and should be good for me

# style 1 using filter

```

| 
- set\_fact:

 |
|
| |

| 

tomcat\_value: “{{ (filepath == ‘/var/opt/tomcat\_1’) | ternary(tomcat\_1\_value, tomcat\_2\_value) }}”

 |
|
| |

| 
# style 2
 |
|
| |

| 
- set\_fact:

 |
|
| |

tomcat\_value: "{{ tomcat\_1\_value if (filepath == '/var/opt/tomcat\_1') else tomcat\_2\_value }}"

but I see also this example

```auto
tasks:
  - name: "shut down CentOS 6 and Debian 7 systems"
    command: /sbin/shutdown -t now
    when: (ansible_distribution == "CentOS" and ansible_distribution_major_version == "6") or
          (ansible_distribution == "Debian" and ansible_distribution_major_version == "7")

```

Can I set more network: and for each set a when: ‘{{ vmnetwork }}’ == “XXXX” ?

| 

Thank you for your suggestions  
Enzo

 |
|
| |

```auto

```
