default(omit) fails to omit param and place_holder is used as variable data

1,112 views
Skip to first unread message

ddffgpmfn

unread,
Jun 19, 2015, 4:36:14 PM6/19/15
to ansible...@googlegroups.com
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


ddffgpmfn

unread,
Jun 19, 2015, 4:39:18 PM6/19/15
to ansible...@googlegroups.com

 The output in the AWS console.

Matt Martz

unread,
Jun 19, 2015, 5:24:30 PM6/19/15
to ansible...@googlegroups.com
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.


On Friday, June 19, 2015, ddffgpmfn <t...@aioue.net> wrote:

 The output in the AWS console.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/5b44ad27-7d34-4e64-b1a0-96f3cb0fb77c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Matt Martz
@sivel
sivel.net

ddffgpmfn

unread,
Jun 19, 2015, 5:32:14 PM6/19/15
to ansible...@googlegroups.com
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?

Matt Martz

unread,
Jun 19, 2015, 5:55:27 PM6/19/15
to ansible...@googlegroups.com
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.


On Friday, June 19, 2015, ddffgpmfn <t...@aioue.net> wrote:
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?

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

ddffgpmfn

unread,
Jun 22, 2015, 8:24:14 AM6/22/15
to ansible...@googlegroups.com
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.


On Friday, June 19, 2015 at 10:55:27 PM UTC+1, Matt Martz wrote:
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.

On Friday, June 19, 2015, ddffgpmfn <t...@aioue.net> wrote:
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?

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages