# Forcing the -l parameter in ansible-playbook

**URL:** <https://forum.ansible.com/t/forcing-the-l-parameter-in-ansible-playbook/13269>\
**Category:** Ansible Project\
**Created:** [August 7, 2013, 10:51am UTC](https://forum.ansible.com/t/forcing-the-l-parameter-in-ansible-playbook/13269 "2013-08-07T10:51:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rike-Benjamin\_Schupp](https://avatars.discourse-cdn.com/v4/letter/r/97f17d/32.png) [@Rike-Benjamin\_Schupp](https://forum.ansible.com/u/Rike-Benjamin_Schupp)\
**Post date:** [August 7, 2013, 10:51am UTC](https://forum.ansible.com/t/forcing-the-l-parameter-in-ansible-playbook/13269/1 "2013-08-07T10:51:29Z")

</div>

Hi,

we are using a few on-demand playbooks for upgrading, formatting and re-installation purposes. Currently, all of these files use a `hosts: all` pattern for flexibility. However, this means that we’ll have to be extremely careful to always include an `-l SUBSET` parameter which specifies the subset we want to act on.  
Is there a way to always ensure that a subset has been specified?  
I understand that Ansible’s focus is a bit more on the idempotent side of server management, so in that sense there may be no need for this. But it certainly would make me sleep better when those destructive tasks had another security layer before them. 🙂

Cheers  
/rike

---

<div class="post-metadata">

**Author:** ![Grzegorz\_Nosek](https://avatars.discourse-cdn.com/v4/letter/g/5daacb/32.png) [@Grzegorz\_Nosek](https://forum.ansible.com/u/Grzegorz_Nosek)\
**Post date:** [August 7, 2013, 11:04am UTC](https://forum.ansible.com/t/forcing-the-l-parameter-in-ansible-playbook/13269/2 "2013-08-07T11:04:51Z")

</div>

Hi,

W dniu środa, 7 sierpnia 2013 12:51:29 UTC+2 użytkownik Rike-Benjamin Schuppner napisał:

> Hi,
> 
> we are using a few on-demand playbooks for upgrading, formatting and re-installation purposes. Currently, all of these files use a `hosts: all` pattern for flexibility. However, this means that we’ll have to be extremely careful to always include an `-l SUBSET` parameter which specifies the subset we want to act on.  
> Is there a way to always ensure that a subset has been specified?  
> I understand that Ansible’s focus is a bit more on the idempotent side of server management, so in that sense there may be no need for this. But it certainly would make me sleep better when those destructive tasks had another security layer before them. 🙂

How about hosts: $host inside playbook and ansible-playbook -e [host=foo.example.com](http://host=foo.example.com) destroy-everything.yml?

That should at least fail safe 🙂

Best regards,  
Grzegorz Nosek

---

<div class="post-metadata">

**Author:** ![Tomasz\_Lesniewski](https://avatars.discourse-cdn.com/v4/letter/t/7ab992/32.png) [@Tomasz\_Lesniewski](https://forum.ansible.com/u/Tomasz_Lesniewski)\
**Post date:** [August 7, 2013, 11:13am UTC](https://forum.ansible.com/t/forcing-the-l-parameter-in-ansible-playbook/13269/3 "2013-08-07T11:13:02Z")

</div>

Or for some default values:

hosts: “{{ host | default(‘foo’) }}”

Then you can run:  
ansible-playbook play.yml -e host=bar #run on host bar  
ansible-playbook play.yml #run on host foo

W dniu środa, 7 sierpnia 2013 12:51:29 UTC+2 użytkownik Rike-Benjamin Schuppner napisał:

---

<div class="post-metadata">

**Author:** ![Rike-Benjamin\_Schupp](https://avatars.discourse-cdn.com/v4/letter/r/97f17d/32.png) [@Rike-Benjamin\_Schupp](https://forum.ansible.com/u/Rike-Benjamin_Schupp)\
**Post date:** [August 7, 2013, 1:54pm UTC](https://forum.ansible.com/t/forcing-the-l-parameter-in-ansible-playbook/13269/4 "2013-08-07T13:54:43Z")

</div>

Thanks. These are great ideas. I thought of using a variable somehow but did’t think of putting it inside the hosts-definition.

---

<div class="post-metadata">

**Author:** ![Jesse\_Keating](https://avatars.discourse-cdn.com/v4/letter/j/3bc359/32.png) [@Jesse\_Keating](https://forum.ansible.com/u/Jesse_Keating)\
**Post date:** [August 7, 2013, 2:13pm UTC](https://forum.ansible.com/t/forcing-the-l-parameter-in-ansible-playbook/13269/5 "2013-08-07T14:13:10Z")

</div>

This is what I do on a few playbooks that would be dangerous to run on "all". Instead of a --limit which could be too greedy, I force my users to specify a : separated host list and only use that.

-jlk
