Hi,
I am missing the format of input the extra-vars with multiple choices .
In the playbook , I am passing 2 variables as extra vars and they are working fine .
ansible-playbook myplaybook.yml -e “server_ip=10.100.100.100 host_names=myserver1_10.100.100.100”
and able to execute my playbook successfully. However when I have multiple IP’s to feed in like below
ansible-playbook myplaybook.yml -e "server_ip=‘10.100.100.100’, ‘10.100.100.101’ …‘10.100.100.10N’ host_names=‘myserver1_10.100.100.100’, ‘myserver2_10.100.100.102’, …‘myserver10N_10.100.100.10N’ "
The playbook uses a temporary inventory and looking to input the same with hostnames as myserver_IP one after the other .
ansible.builtin.add_host:
hostname: ‘{{ host_names }}’
groups: my_group
ansible_ssh_private_key_file: “{{ mykeypath }}”
ansible_ssh_user: “root”
ansible_ssh_extra_args: ‘-o StrictHostKeyChecking=no’
Two extra vars as lists to be passed and the items in extra_vars lists are to be processed 1+1 at a time . (ie … the IP 10.100.100.105 must be processed along with host_names=myserver105_10.100.100.105"