Reputation: 23
$cat inventory.yaml
---
server1:
hosts:
macbsd1
vars:
ansible_user: unixgirl
ansible_password: *whatever
ansible_connection: ssh
ansible_sudo_pass: *whatever
$ ansible-playbook test.yaml -i inventory.yaml -v
Using ansible.cfg as config file
[WARNING]: * Failed to parse inventory.yaml with auto plugin: Syntax Error while loading YAML.
found undefined alias
The error appears to be in 'inventory.yaml': line 6, column 19,
but may be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be: vars: ansible_password: *whatever
The inventory doesn't get parsed and results in error, but if I remove the asterisk, it works. Asterisk on the username field also results in error.
Upvotes: 0
Views: 636
Reputation: 20688
In YAML, *identifier
is used to reference to a previously defined alias (or anchor in YAML's terminology).
For example:
foo: &HELLO hello world # defines an alias which has "hello world"
bar: *HELLO # dereference the alias
To input a literal string which starts with *
you can use double/single quotes:
bar: "*HELLO" # Double quotes supports escapes like \n so use it carefully
# OR
bar: '*HELLO' # I prefer single quotes
Upvotes: 2