I would first try to make the instance_tags a dictionary instead of a "dictionary-like" string:

instance_tags:
    foo: bar
    baz: bang
    who: doo

And use the same pattern for the count tag.

On 03/26/2014 09:53 AM, Mark Casey wrote:
Okay, so in the interest of moving to exact_count I switched from:

    - name: Set up a new host instance on EC2
      ec2: >
       region="{{ ec2vars.region }}"
       zone="{{ ec2vars.zone }}"
       id="{{ serverPod + '_' + type }}"
       ec2_access_key="{{ ec2vars.ec2_access_key }}"
       ec2_secret_key="{{ ec2vars.ec2_secret_key }}"
       key_name="{{ ec2vars.key_name }}"
       instance_type="{{ ec2vars.instance_type }}"
       image="{{ ec2vars.image }}"
       group="{{ ec2vars.group }}"
       wait="{{ wait }}"
       wait_timeout=600
       user_data="{{ type }}"
       instance_tags='{"ec2serverPod":"{{ serverPod }}", "ec2type":"{{
    type }}", "ec2serverPod_and_ec2type":"{{ serverPod }}_{{ type }}",
    "provisioned":"False", "Name":"{{ virtualhostFullName }}_{{ type }}"}'
       count="{{ count }}"
       vpc_subnet_id="{{ ec2vars.vpc_subnet_id }}"
      register: ec2


to:

    - name: Set up a new host instance on EC2
      ec2: >
       region="{{ ec2vars.region }}"
       zone="{{ ec2vars.zone }}"
       ec2_access_key="{{ ec2vars.ec2_access_key }}"
       ec2_secret_key="{{ ec2vars.ec2_secret_key }}"
       key_name="{{ ec2vars.key_name }}"
       instance_type="{{ ec2vars.instance_type }}"
       image="{{ ec2vars.image }}"
       group="{{ ec2vars.group }}"
       wait="{{ wait }}"
       wait_timeout=600
       user_data="{{ type }}"
       instance_tags='{"ec2serverPod":"{{ serverPod }}", "ec2type":"{{
    type }}", "ec2serverPod_and_ec2type":"{{ serverPod }}_{{ type }}",
    "provisioned":"False", "Name":"{{ virtualhostFullName }}_{{ type }}"}'
       exact_count="{{ count }}"
       count_tag="ec2serverPod_and_ec2type":"{{ serverPod }}_{{ type }}"
       vpc_subnet_id="{{ ec2vars.vpc_subnet_id }}"
      register: ec2


but I seem to have lost idempotence because I get new instances every time it runs. I've since reformatted it to drop the quoted block and make it look more like the docs but there was no improvement:

    - name: Set up a new host instance on EC2
      local_action:
        module: ec2
        region: "{{ ec2vars.region }}"
        zone: "{{ ec2vars.zone }}"
        ec2_access_key: "{{ ec2vars.ec2_access_key }}"
        ec2_secret_key: "{{ ec2vars.ec2_secret_key }}"
        key_name: "{{ ec2vars.key_name }}"
        instance_type: "{{ ec2vars.instance_type }}"
        image: "{{ ec2vars.image }}"
        group: "{{ ec2vars.group }}"
        wait: "{{ wait }}"
        wait_timeout: 600
        user_data: "{{ type }}"
        instance_tags: '{"ec2serverPod":"{{ serverPod }}",
    "ec2type":"{{ type }}", "ec2serverPod_and_ec2type":"{{ serverPod
    }}_{{ type }}", "provisioned":"False", "Name":"{{
    virtualhostFullName }}_{{ type }}"}'
        exact_count: "{{ count }}"
        count_tag: ec2serverPod_and_ec2type:"{{ serverPod }}_{{ type }}"
        vpc_subnet_id: "{{ ec2vars.vpc_subnet_id }}"
      register: ec2


Anyone see anything obvious with that last example? Do I have to list all of the instance's tags in count_tag?

Thank you,
Mark


On Friday, March 7, 2014 8:26:58 PM UTC-6, Michael DeHaan wrote:

    You can see links to the documentation for the ID here:

    http://docs.ansible.com/ec2_module.html
    <http://docs.ansible.com/ec2_module.html>

    However, a better way to do it is to use the "exact_count"
    parameter and specify a tag.

    We should likely mark the id field in the documentation as legacy
    and non-preferred.




    On Fri, Mar 7, 2014 at 6:39 PM, Mark Casey <[email protected]
    <javascript:>> wrote:

        Hello,

        When creating ec2 instances we have the "id" field for
        idempotency. I was wondering how long previously-used ids
        linger for and, if they auto-prune, whether they can be
        removed early/manually.

        Thank you,
        Mark
-- 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 [email protected]
        <javascript:>.
        To post to this group, send email to
        [email protected] <javascript:>.
        To view this discussion on the web visit
        
https://groups.google.com/d/msgid/ansible-project/c4289ff8-74fb-4b7b-8cfb-84d9516b9b35%40googlegroups.com
        
<https://groups.google.com/d/msgid/ansible-project/c4289ff8-74fb-4b7b-8cfb-84d9516b9b35%40googlegroups.com?utm_medium=email&utm_source=footer>.
        For more options, visit https://groups.google.com/d/optout
        <https://groups.google.com/d/optout>.


--
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 [email protected] <mailto:[email protected]>. To post to this group, send email to [email protected] <mailto:[email protected]>. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/13ec338a-eb64-46db-9262-aa0b7da1871a%40googlegroups.com <https://groups.google.com/d/msgid/ansible-project/13ec338a-eb64-46db-9262-aa0b7da1871a%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

--
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/5332E0DB.5010901%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to