# default(omit) fails to omit param and place\_holder is used as variable data

**URL:** <https://forum.ansible.com/t/default-omit-fails-to-omit-param-and-place-holder-is-used-as-variable-data/18555>\
**Category:** Ansible Project\
**Created:** [June 19, 2015, 8:36pm UTC](https://forum.ansible.com/t/default-omit-fails-to-omit-param-and-place-holder-is-used-as-variable-data/18555 "2015-06-19T20:36:14Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tom\_Paine](https://avatars.discourse-cdn.com/v4/letter/t/858c86/32.png) [@Tom\_Paine](https://forum.ansible.com/u/Tom_Paine)\
**Post date:** [June 19, 2015, 8:36pm UTC](https://forum.ansible.com/t/default-omit-fails-to-omit-param-and-place-holder-is-used-as-variable-data/18555/1 "2015-06-19T20:36:14Z")

</div>

When running this ec2 module task without the ‘build\_number’ variable, the EC2 machine is created with a build tag of ‘\_\_omit\_place\_holder\_\_6248a11ef81332080f31b81d2894e811f905b723’ instead of being empty as expected.

Is the formatting wrong or is there a bug here?:

- name: provision an instance  
ec2:  
ec2\_access\_key: “{{ ec2\_access\_key }}”  
aws\_secret\_key: “{{ ec2\_secret\_key }}”  
region: “{{ region }}”  
key\_name: “{{ key }}”  
group: “{{ security\_group\_name }}”  
instance\_type: “{{instance\_type }}”  
monitoring: yes  
image: “{{ instance\_store\_ami\_data.ami }}”  
vpc\_subnet\_id: “{{ subnet\_euw1c }}”  
assign\_public\_ip: yes  
wait: true  
exact\_count: 1  
count\_tag:  
role: sid  
env: “{{ environment\_name }}”  
build: “{{ build\_number | default(omit) }}”  
instance\_tags:  
role: sid  
env: “{{ environment\_name }}”  
build: “{{ build\_number | default(omit) }}”  
status: new

---

<div class="post-metadata">

**Author:** ![Tom\_Paine](https://avatars.discourse-cdn.com/v4/letter/t/858c86/32.png) [@Tom\_Paine](https://forum.ansible.com/u/Tom_Paine)\
**Post date:** [June 19, 2015, 8:39pm UTC](https://forum.ansible.com/t/default-omit-fails-to-omit-param-and-place-holder-is-used-as-variable-data/18555/2 "2015-06-19T20:39:18Z")

</div>

> [![](https://lh3.googleusercontent.com/-MjJwu22DXyk/VYR9r9_j4VI/AAAAAAAADKA/kW8VCFxf9D4/s1600/Screen%2BShot%2B2015-06-19%2Bat%2B21.38.10.png)](https://lh3.googleusercontent.com/-MjJwu22DXyk/VYR9r9_j4VI/AAAAAAAADKA/kW8VCFxf9D4/s1600/Screen%2BShot%2B2015-06-19%2Bat%2B21.38.10.png)

The output in the AWS console.

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [June 19, 2015, 9:24pm UTC](https://forum.ansible.com/t/default-omit-fails-to-omit-param-and-place-holder-is-used-as-variable-data/18555/3 "2015-06-19T21:24:27Z")

</div>

That is due to “omit” only working for top level keys (arguments of the module) and not sub keys.

Maybe using “|default(‘’)” would work instead.

---

<div class="post-metadata">

**Author:** ![Tom\_Paine](https://avatars.discourse-cdn.com/v4/letter/t/858c86/32.png) [@Tom\_Paine](https://forum.ansible.com/u/Tom_Paine)\
**Post date:** [June 19, 2015, 9:32pm UTC](https://forum.ansible.com/t/default-omit-fails-to-omit-param-and-place-holder-is-used-as-variable-data/18555/4 "2015-06-19T21:32:14Z")

</div>

Alas, default(‘’) applies an empty tag which then shows up in the inventory.

I don’t see a ticket about this, may I raise an enhancement?

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [June 19, 2015, 9:55pm UTC](https://forum.ansible.com/t/default-omit-fails-to-omit-param-and-place-holder-is-used-as-variable-data/18555/5 "2015-06-19T21:55:24Z")

</div>

I don’t see why not, logging an issue could result in adding such functionality.

Another thing to try in the meantime is to replace with a ‘~’. Quotes are probably necessary.

~ in YAML means None in Python.

---

<div class="post-metadata">

**Author:** ![Tom\_Paine](https://avatars.discourse-cdn.com/v4/letter/t/858c86/32.png) [@Tom\_Paine](https://forum.ansible.com/u/Tom_Paine)\
**Post date:** [June 22, 2015, 12:24pm UTC](https://forum.ansible.com/t/default-omit-fails-to-omit-param-and-place-holder-is-used-as-variable-data/18555/6 "2015-06-22T12:24:14Z")

</div>

Thanks Matt,  
Without quotes:

Failed to template {{ build\_number | default(~) }}: template error while templating string: unexpected ‘~’

With singles quotes it is not converted to null and simple taken as a string. Will raise an issue.
