0

I define a custom ansible.cfg, and export it as below in the

export ANSIBLE_CONFIG="../aws_ansible.cfg"

when I run it, this is picked up but when I pass the inventory as an arg, it fails to recognize the arg or take precedence although there is no inventory specified in the aws_ansible.cfg.

 export ANSIBLE_CONFIG=../aws_ansible.cfg
 ansible-playbook demo.yml -i ./inventories/dev1 --verbose
 Using /projects/demo/aws_ansible.cfg as config file 

If I specify the inventory within aws_ansible.cfg it would work, but I would like to pass it as an argument.

Please advice if also extra-vars would take precedence over what are specified in aws_ansible.cfg

aws_ansible.cfg looks as below

[defaults]
; strategy_plugins = ../mitogen/ansible_mitogen/plugins/strategy

private_key_file=~/.ssh/id_rsa
inventory = ./inventories/dev2/hosts
remote_user=ec2-user
host_key_checking = false
filter_plugins = ./filter_plugins
roles_path = ./roles
retry_files_enabled = False

[ssh_connection]

ssh_args = -o ControlMaster=auto -o ControlPersist=600s -o ControlPath="~/.ansible/cp/ansible-ssh-%h-%p-%r"
pipelining = True
hackmabrain
  • 457
  • 1
  • 6
  • 21
  • For *variables*, [this guide](https://docs.ansible.com/ansible/2.5/user_guide/playbooks_variables.html#variable-precedence-where-should-i-put-a-variable) says `--extra-vars` always wins precedence. [When CLI options exist](https://docs.ansible.com/ansible/latest/installation_guide/intro_configuration.html#command-line-options) they always override the config file. What else is in that file? – Paul Hodges Jul 24 '18 at 13:45
  • I edited the question above – hackmabrain Jul 24 '18 at 17:22

1 Answers1

0

You might want to find out what ansible_inventory_sources are listed.

- debug:                                                                                 
    msg: "{{ ansible_inventory_sources }}"                                               
Vladimir Botka
  • 58,131
  • 4
  • 32
  • 63