# Ansible Inventory Security (all)

**URL:** <https://forum.ansible.com/t/ansible-inventory-security-all/35126>\
**Category:** Ansible Project\
**Created:** [May 6, 2021, 6:12pm UTC](https://forum.ansible.com/t/ansible-inventory-security-all/35126 "2021-05-06T18:12:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Martin\_Parrella](https://avatars.discourse-cdn.com/v4/letter/m/e19b73/32.png) [@Martin\_Parrella](https://forum.ansible.com/u/Martin_Parrella)\
**Post date:** [May 6, 2021, 6:12pm UTC](https://forum.ansible.com/t/ansible-inventory-security-all/35126/1 "2021-05-06T18:12:35Z")

</div>

Hi there! Is there any way to overwrite the ‘all/\*’ keyword in Ansible inventory? How can we prevent someone to run something nasty (intentionally or by mistake) over all our inventory?

We did a couple of tests using a dynamic inventory, but no luck. As a workaround, we are thinking to force all the playbooks to have a line similar to this one:

- hosts: “{{ target\_hosts | regex\_replace(‘(all|\*)’, ‘invalid\_target\_host’) }}”

… but this doesn’t sound like the best option, any ideas?

Thanks!

---

<div class="post-metadata">

**Author:** ![Alex\_Wanderley](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/alex_wanderley/32/3232_2.png) [@Alex\_Wanderley](https://forum.ansible.com/u/Alex_Wanderley)\
**Post date:** [May 6, 2021, 7:25pm UTC](https://forum.ansible.com/t/ansible-inventory-security-all/35126/2 "2021-05-06T19:25:54Z")

</div>

Hello,

What we’re doing here is assigning a variable to “hosts”.

Something like:  
hosts: {{ variable }}

So, our playbooks have always to be called as "ansible-playbooks -e “variable=|” otherwise they will fail.

Alex
