Hi Abhijeet,
Great help again. Thanks. This is what I have now:
- name: Add the ucloud_vm created into in-memory of ansible hosts.
vars:
user_data: “{{ lookup(‘file’, ‘/root/mltr_source_code/mini.ip’) }}”
tasks:
- add_host:
name: ‘{{ user_data }}’
groups: ucloud_vm_group
…
- name: Configure newly added hosts
hosts: ucloud_vm_group
tasks:
shell: touch /root/hello.txt
I get this when I run the playbook:
ansible-playbook 2.8.0
config file = /root/mltr_source_code/ansible.cfg
configured module search path = [u’/root/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]
ansible python module location = /usr/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible-playbook
python version = 2.7.5 (default, Apr 11 2018, 07:36:10) [GCC 4.8.5 20150623 (Red Hat 4.8.5-28)]
Using /root/mltr_source_code/ansible.cfg as config file
host_list declined parsing /root/mltr_source_code/hosts as it did not pass it’s verify_file() method
script declined parsing /root/mltr_source_code/hosts as it did not pass it’s verify_file() method
auto declined parsing /root/mltr_source_code/hosts as it did not pass it’s verify_file() method
toml declined parsing /root/mltr_source_code/hosts as it did not pass it’s verify_file() method
[WARNING]: * Failed to parse /root/mltr_source_code/hosts with yaml plugin: Syntax Error while loading YAML. did not find
expected The error appears to be in ‘/root/mltr_source_code/hosts’: line 2, column 1, but may be elsewhere in
the file depending on the exact syntax problem. The offending line appears to be: [server] 10.204.74.245 ^ here
File “/usr/lib/python2.7/site-packages/ansible/inventory/manager.py”, line 267, in parse_source
plugin.parse(self._inventory, self._loader, source, cache=cache)
File “/usr/lib/python2.7/site-packages/ansible/plugins/inventory/yaml.py”, line 105, in parse
raise AnsibleParserError(e)
[WARNING]: * Failed to parse /root/mltr_source_code/hosts with ini plugin: /root/mltr_source_code/hosts:7: Section [vms:vars]
not valid for undefined group: vms
File “/usr/lib/python2.7/site-packages/ansible/inventory/manager.py”, line 267, in parse_source
plugin.parse(self._inventory, self._loader, source, cache=cache)
File “/usr/lib/python2.7/site-packages/ansible/plugins/inventory/ini.py”, line 138, in parse
raise AnsibleParserError(e)
[WARNING]: Unable to parse /root/mltr_source_code/hosts as an inventory source
[WARNING]: No inventory was parsed, only implicit localhost is available
[WARNING]: provided hosts list is empty, only localhost is available. Note that the implicit localhost does not match ‘all’
ERROR! Syntax Error while loading YAML.
could not find expected ‘:’
The error appears to be in ‘/root/mltr_source_code/provision_undercloud.yml’: line 255, column 4, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
- name: Configure newly added hosts
^ here
Greetings,
Sandeep.