# Overriding ansible.cfg with extra vars

**URL:** <https://forum.ansible.com/t/overriding-ansible-cfg-with-extra-vars/28130>\
**Category:** Ansible Developer\
**Created:** [July 24, 2018, 5:23am UTC](https://forum.ansible.com/t/overriding-ansible-cfg-with-extra-vars/28130 "2018-07-24T05:23:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hackmabrain](https://avatars.discourse-cdn.com/v4/letter/h/4491bb/32.png) [@hackmabrain](https://forum.ansible.com/u/hackmabrain)\
**Post date:** [July 24, 2018, 5:23am UTC](https://forum.ansible.com/t/overriding-ansible-cfg-with-extra-vars/28130/1 "2018-07-24T05:23:43Z")

</div>

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

```auto
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`.

```auto
 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`

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [July 24, 2018, 1:14am UTC](https://forum.ansible.com/t/overriding-ansible-cfg-with-extra-vars/28130/2 "2018-07-24T01:14:01Z")

</div>

I'm not sure i can answer your question because it seems based on a  
misconception extra vars are variables, the config file does not use  
variables, these are not equivalent things.

That said, there are some configuration items (mostly connection  
related) that are overridable via a variable, it doesn't matter where  
the variable came from, just that it exists.
