# Can I set a default value for the enabled\_value?

**URL:** <https://forum.ansible.com/t/can-i-set-a-default-value-for-the-enabled-value/43425>\
**Category:** Get Help\
**Tags:** variables, awx, inventory\
**Created:** [June 16, 2025, 8:18pm UTC](https://forum.ansible.com/t/can-i-set-a-default-value-for-the-enabled-value/43425 "2025-06-16T20:18:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ShiverTeapot](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@ShiverTeapot](https://forum.ansible.com/u/ShiverTeapot)\
**Post date:** [June 16, 2025, 8:18pm UTC](https://forum.ansible.com/t/can-i-set-a-default-value-for-the-enabled-value/43425/1 "2025-06-16T20:18:55Z")

</div>

I supply AWX with inventory sources yaml files.  
I need a ‘easy to configure’ way to exclude hosts in an inventory from jobs with a reason attached.  
I came up with an idea to (ab)use the **enabled\_var**.

I found that the **enabled\_var** and **enabled\_value** variables are ways to determine whether to enable a host or not using a host variable from an inventory source. [InventorySource new fields · Issue #7819 · ansible/awx · GitHub](https://github.com/ansible/awx/issues/7819)

I would like to set a default value for this enabled\_value for all my hosts.  
I figured that this could be done on the inventory.yml  
In the inventory source, _enabled\_var_ is set to **is\_it\_actually\_enabled** with the _enabled\_value_ set to **yup**

But I have had no success with this inventory yaml:

```auto
all:
  hosts:
  vars:
    is_it_actually_enabled: yup # default for all
  children:
    updates1:
      hosts:
        trusty1.example.net:
          is_it_actually_enabled: nope
          disabled_reason: idk
        trusty2.example.net:
    updates2:
      hosts:
        xenial1.example.net:
        xenial2.example.net:

```

Am I doomed to having to set it up per host? Or is there some way to get it set up on a higher level, inventory or otherwise.

 ![image](https://us1.discourse-cdn.com/ansible/original/2X/2/2b69a983bb3a055440812e4e242eeafac7d69032.png)

---

<div class="post-metadata">

**Author:** ![bcoca](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bcoca/32/9269_2.png) [@bcoca](https://forum.ansible.com/u/bcoca)\
**Post date:** [June 16, 2025, 9:26pm UTC](https://forum.ansible.com/t/can-i-set-a-default-value-for-the-enabled-value/43425/2 "2025-06-16T21:26:24Z")

</div>

The ‘ultimate’’ way to setup a default is to use a role and then add them to `defaults/main.yml` in the role, that has the lowest precedence.

Setting it in the ‘all’ group, in inventory or via vars plugin should be fine also. It has low precedence and affects ‘all hosts’.

As for you having `no success` … well, can you show a play using that inventory and display the variable per host?

---

<div class="post-metadata">

**Author:** ![ShiverTeapot](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@ShiverTeapot](https://forum.ansible.com/u/ShiverTeapot)\
**Post date:** [June 16, 2025, 10:28pm UTC](https://forum.ansible.com/t/can-i-set-a-default-value-for-the-enabled-value/43425/3 "2025-06-16T22:28:19Z")

</div>

Yeah, i should’ve been more specific 😅  
I use a gitops approach to configure AWX, changing my inventory triggers an inventory sync pipeline.

You are correct that a play would display the variables correctly (using inventory from my original post)

```auto
TASK [Show is_it_actually_enabled value for each host] *****************************************************************
ok: [trusty1.example.net] => {
    "msg": "Host trusty1.example.net has is_it_actually_enabled set to: nope"
}
ok: [trusty2.example.net] => {
    "msg": "Host trusty2.example.net has is_it_actually_enabled set to: yup"
}

```

But in AWX, **I can’t get the hosts to become enabled again once they are disabled**. Unless I explicitly set the enabled\_var on the host itself with the correct enabled\_value, that will work.

So currently, I explicitly disabled trusty1 by setting to enabled\_var on host level.

 ![image](https://us1.discourse-cdn.com/ansible/original/2X/4/4e5323a5b24f0bddae1651abb596589ab3687200.png)

then I change my config to such:

```auto
all:
  hosts:
  vars:
    is_it_actually_enabled: yup # default for this group
  children:
    updates1:
      hosts:
        trusty1.example.net:
        trusty2.example.net:
          is_it_actually_enabled: yup

```

But after the inventory sync, trusty1 was not re-enabled.

So I am wondering if this enabled\_var does not look at variables in the way a play does (or maybe my gitops messes up during sync, but that does not seem likely to me).

I also noticed that, when looking at the variables on AWX, only trusty2 has the value defined. but I imagine this is normal for variables inherited from the parent vs a variable directly defined on host level.

 ![image](https://us1.discourse-cdn.com/ansible/original/2X/5/52d509a138527ef3651c48dff2cd235058f9f573.png)  
 ![image](https://us1.discourse-cdn.com/ansible/original/2X/c/caaf6baa4eef6909c54e8ae75dac7602547d3c73.png)

---

<div class="post-metadata">

**Author:** ![bcoca](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/bcoca/32/9269_2.png) [@bcoca](https://forum.ansible.com/u/bcoca)\
**Post date:** [June 17, 2025, 1:11am UTC](https://forum.ansible.com/t/can-i-set-a-default-value-for-the-enabled-value/43425/4 "2025-06-17T01:11:17Z")

</div>

Ah, so the issue is trying to set the default in awx itself, not for play run. That won’t work, awx does not ‘resolve’ the inventory as ansible-playbook does.

---

<div class="post-metadata">

**Author:** ![ShiverTeapot](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@ShiverTeapot](https://forum.ansible.com/u/ShiverTeapot)\
**Post date:** [June 17, 2025, 7:22pm UTC](https://forum.ansible.com/t/can-i-set-a-default-value-for-the-enabled-value/43425/5 "2025-06-17T19:22:24Z")

</div>

Feared as much, tried it nevertheless. It is as you say, the enabled\_var is only checked on host level.  
I’ll just settle for adjusting the playbook to skip hosts that have the given variable.  
Thanks for the responses!

---

<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 17, 2025, 7:22pm UTC](https://forum.ansible.com/t/can-i-set-a-default-value-for-the-enabled-value/43425/6 "2025-07-17T19:22:39Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
