I have a role, route53-healthcheck, which execute a series of command:
tasks using the aws cli (Ansible route53 module is for DNS records-only).

I have a dictionary of Application names and metadata in group_vars/all. I
want am trying to loop over the dictionary using with_dict calling the roll
each time with different parameters:

route53-healthchecks.yml
---
# create Route53 Health check and CloudWatch Alarm
- name: Route53 Health Checks for all Apps
   hosts: webservers[0]
   connection: local
   gather_facts: no
   roles:
     - { role: route53-healthcheck,
           app: '{{ item.key }}' ,
           app_domain: '{{ app_host }}',
           fqdn: '{{ item.key }}-{{ app_environment }}.{{ app_host }}',
         with_dict: apps }


I am getting an error that 'item' is undefined:


$ ansible-playbook -vvv -i staging route53-healthcheck.yml

PLAY [Route53 Health Checks for all Apps]
*************************************

TASK: [route53-healthcheck | Route53 Caller Reference for this Health
Check] ***
fatal: [web-1.us-east-1.example.com] => One or more undefined variables:
'item' is undefined

FATAL: all hosts have already failed -- aborting

PLAY RECAP
********************************************************************
            to retry, use: --limit @/home/ubuntu/route53-healthcheck.retry

web-1.us-east-1.example.com : ok=0 changed=0 unreachable=1 failed=0


What is the proper way to loop through calling roles?

Thanks,
Robb

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/ae023bb8-226f-456f-be49-99af5840aedb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Michael DeHaan at Dec 1, 2014 at 10:14 pm
    Roles cannot be presently used with iterators. This is something the 'v2/'
    subtree may allow at a later date.

    Until then, the solution is to apply the loop to each task inside the role
    that needs to be looped.


    On Mon, Dec 1, 2014 at 3:03 PM, wrote:




    I have a role, route53-healthcheck, which execute a series of command:
    tasks using the aws cli (Ansible route53 module is for DNS records-only).

    I have a dictionary of Application names and metadata in group_vars/all.
    I want am trying to loop over the dictionary using with_dict calling the
    roll each time with different parameters:

    route53-healthchecks.yml
    ---
    # create Route53 Health check and CloudWatch Alarm
    - name: Route53 Health Checks for all Apps
    hosts: webservers[0]
    connection: local
    gather_facts: no
    roles:
    - { role: route53-healthcheck,
    app: '{{ item.key }}' ,
    app_domain: '{{ app_host }}',
    fqdn: '{{ item.key }}-{{ app_environment }}.{{ app_host }}',
    with_dict: apps }


    I am getting an error that 'item' is undefined:


    $ ansible-playbook -vvv -i staging route53-healthcheck.yml

    PLAY [Route53 Health Checks for all Apps]
    *************************************

    TASK: [route53-healthcheck | Route53 Caller Reference for this Health
    Check] ***
    fatal: [web-1.us-east-1.example.com] => One or more undefined variables:
    'item' is undefined

    FATAL: all hosts have already failed -- aborting

    PLAY RECAP
    ********************************************************************
    to retry, use: --limit @/home/ubuntu/route53-healthcheck.retry

    web-1.us-east-1.example.com : ok=0 changed=0 unreachable=1
    failed=0


    What is the proper way to loop through calling roles?

    Thanks,
    Robb

    --
    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.
    To view this discussion on the web visit
    https://groups.google.com/d/msgid/ansible-project/ae023bb8-226f-456f-be49-99af5840aedb%40googlegroups.com
    <https://groups.google.com/d/msgid/ansible-project/ae023bb8-226f-456f-be49-99af5840aedb%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 ansible-project+unsubscribe@googlegroups.com.
    To post to this group, send email to ansible-project@googlegroups.com.
    To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgx3uek6VVzCVERSJf69LL2o8TToo9bVs0aS5qBjoYkxMg%40mail.gmail.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupansible-project @
postedDec 1, '14 at 8:35p
activeDec 1, '14 at 10:14p
posts2
users2

2 users in discussion

Michael DeHaan: 1 post Robb: 1 post

People

Translate

site design / logo © 2017 Grokbase