Hi,
sorry if I continue with newbie questions.
I have my playbook for create vm from template
- 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
|
tomcat_value: “{{ (filepath == ‘/var/opt/tomcat_1’) | ternary(tomcat_1_value, tomcat_2_value) }}” |
style 2 |
|
but I see also this example
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 |