On 20. okt. 2016 08:06, Makson Lee wrote:
here is the content of inventory file, admin_pass is defined in secrets.yml
file,

[group1]
host1
[group1:vars]
ansible_become_pass={{admin_pass}}


the question is, how to reference variables defined in a file when running
ansible command? we tried the following but didn't work, can someone help?

$ ansible group1 -a "echo hello" -e "vars_files=secrets.yml"
host1 | FAILED | rc=0 >>
the field 'become_pass' has an invalid value, which appears to include a
variable that is undefined. The error was: 'admin_pass' is undefined

Copy paste from "man ansible"

-e EXTRA_VARS, --extra-vars='EXTRA_VARS
Extra variables to inject into a playbook, in key=value key=value format or as quoted YAML/JSON (hashes and arrays). To load variables from a file, specify the file preceded by @ (e.g. @vars.yml).


--
Kai Stian Olstad

--
You received this message because you are subscribed to the Google Groups "Ansible 
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/54743e11-1f30-ab35-febf-9dc4a5b14b76%40olstad.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to