jayunit100
jayunit100

Reputation: 17648

Ansible: Overriding values in all.yml

From what I can gather, ansible allows you to parameterize things

However, it seems that when we try to override a value (using --extra-vars), all.yml parameters are not replaced. That is, I have a ansible recipe like this:

├── README.md
├── cluster.yml
├── group_vars
│   ├── all.yml

I then invoke

/usr/local/bin/ansible-playbook --private-key=/Users/jayunit100/.ssh/id_rsa --user=fedora --connection=ssh --limit=all --inventory-file=/Users/jayunit100/Development/kubernetes/contrib/ansible/vagrant/... --extra-vars={\"ansible_ssh_user\":\"fedora\",\"dns_setup\":\"false\"}" ../cluster.yml"

In my case, it seems like the roles using ansible_ssh_user are using values from all.yml, rather than those in --extra-vars. Are all.yml values meant to be overriden?

POSSIBLY RELATED

There seem to be a few questions/bugs around precedence in ansible (like https://github.com/ansible/ansible/issues/9877) thus maybe there is no "right" answer to this question without stating ansible version. In my case, its 1.9.2.

Upvotes: 4

Views: 1229

Answers (1)

Régis B.
Régis B.

Reputation: 10588

I managed to reproduce your issue and fix it by re-writing the --extra-vars option with proper JSON formatting:

ansible-playbook ... --extra-vars='{"ansible_ssh_user":"root", "dns_setup":"false"}' ...

Upvotes: 1

Related Questions