Ignore a module option

Hello,

I’m trying to create a helper role to raise ec2 instances, and I stumbled in a problem where I wanted to deleted or ignore some module options, based on the role vars.
First, let’s say I have a playbook like this.

try:

exact_count: "{{my_count|default(omit)}}"

Thanks!

Sorry for the stupid question, I should’ve looked up a little better :frowning:
I’ve managed to obtain the behaviour I wanted like this:

my_aws_role/tasks/main.yml

  • name: Raise ec2 instance
    ec2:
    key_name: my_key
    instance_type: m1.medium
    image: i999999
    region: us-east-1
    zone: us-east-1e
    wait: 1000
    count_tags: “{{my_tags}}”
    exact_count: “{{my_count}}”

my_aws_role/defaults/main.yml

exact_count: “{{ omit }}”

my_tags: “{{mandatory}}”

create-instance.yml

  • name: Create a pong server
    hosts: localhost:
    vars:
    exact_count: 1
    tags:
    server_app: pong
    roles:
  • my_aws_role

Thank you again!