# host-specific ansible.cfg?

**URL:** <https://forum.ansible.com/t/host-specific-ansible-cfg/28768>\
**Category:** Ansible Project\
**Created:** [October 11, 2018, 4:11pm UTC](https://forum.ansible.com/t/host-specific-ansible-cfg/28768 "2018-10-11T16:11:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![erichymowitz](https://avatars.discourse-cdn.com/v4/letter/e/9d8465/32.png) [@erichymowitz](https://forum.ansible.com/u/erichymowitz)\
**Post date:** [October 11, 2018, 4:11pm UTC](https://forum.ansible.com/t/host-specific-ansible-cfg/28768/1 "2018-10-11T16:11:19Z")

</div>

Greetings.

Short question – Where/how can I set configuration settings (not variables) based on the target host?

Long question –

My standard ansible.cfg includes:

[privilege\_escalation]  
#become=True  
#become\_method=sudo  
#become\_user=root  
#become\_ask\_pass=False

And these settings are good for most of our hosts. But there are a handful of hosts that require a sudo password.

I tried putting this into /etc/ansible/group\_vars/sudohosts  
become\_ask\_pass: true  
but that doesn’t appear to be working.

I found this list of variables:  
[https://docs.ansible.com/ansible/2.6/user\_guide/intro\_inventory.html#list-of-behavioral-inventory-parameters](https://docs.ansible.com/ansible/2.6/user_guide/intro_inventory.html#list-of-behavioral-inventory-parameters)  
but “become\_ask\_pass” isn’t one of them.

Is there a way that i can set a configuration option on a per-host basis?

Thanks.

---

<div class="post-metadata">

**Author:** ![bill\_paxton](https://avatars.discourse-cdn.com/v4/letter/b/46a35a/32.png) [@bill\_paxton](https://forum.ansible.com/u/bill_paxton)\
**Post date:** [October 11, 2018, 4:24pm UTC](https://forum.ansible.com/t/host-specific-ansible-cfg/28768/2 "2018-10-11T16:24:59Z")

</div>

in your inventory, make sure the hosts are in the group “sudohosts” if you want any variables in the group\_vars/sudohosts/ directory to be picked up.

`

all:vars]

ansible\_connection=local  
another\_var\_all\_servers\_get=some\_value

[sudohosts]

server1  
server2

`

Here “sudohosts” is a subdirectory of group\_vars/ and any .yml in that “sudohosts” sub dir should get picked up by any hosts you’ve listed in the “sudohosts” group in the inventory.

`

├── group\_vars

│ ├── all.yml

│ ├── sudohosts  
│ │ ├── README.md

│ │ ├── vars.yml

│ │ ├── more\_vars.yml

│ └── some\_other\_group

│ └── vars.yml

│ └── i\_want\_vars.yml

├── host\_vars

│ └── server1.yml

│ └── server2.yml

`

---

<div class="post-metadata">

**Author:** ![erichymowitz](https://avatars.discourse-cdn.com/v4/letter/e/9d8465/32.png) [@erichymowitz](https://forum.ansible.com/u/erichymowitz)\
**Post date:** [October 11, 2018, 4:39pm UTC](https://forum.ansible.com/t/host-specific-ansible-cfg/28768/3 "2018-10-11T16:39:20Z")

</div>

Yes, I am aware of all that. I left all of that out for the sake of brevity.

However, as far as I can tell, my problem is not with variables, it is with configuration settings. If there is a variable to accomplish my task, I cannot find it.

---

<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:** [October 11, 2018, 5:37pm UTC](https://forum.ansible.com/t/host-specific-ansible-cfg/28768/4 "2018-10-11T17:37:19Z")

</div>

For settings that are 'host specific' you'll find there are existing  
variables that can be used, as for 'ask password' those are 'global'  
so they cannot be host specific. Passwords are prompted for BEFORE any  
host data is looked at and only once per run, not per host contacted.

---

<div class="post-metadata">

**Author:** ![bill\_paxton](https://avatars.discourse-cdn.com/v4/letter/b/46a35a/32.png) [@bill\_paxton](https://forum.ansible.com/u/bill_paxton)\
**Post date:** [October 11, 2018, 6:08pm UTC](https://forum.ansible.com/t/host-specific-ansible-cfg/28768/5 "2018-10-11T18:08:35Z")

</div>

> Apologies, I guess I was confusing this with be able to control this as shown here [https://docs.ansible.com/ansible/2.5/network/user\_guide/network\_best\_practices\_2.5.html](https://docs.ansible.com/ansible/2.5/network/user_guide/network_best_practices_2.5.html). I had just assume since the ‘user’ can be specified per group, then the ability control to ‘ask\_pass’ per group could be too.
