Having an issue with one of my new playbooks. I am assuming this should 
work:

In my hosts file:


[develop.us-east-1.vpn]
vpn01.us ansible_ssh_host=10.1.1.1
vpn02.us ansible_ssh_host=10.1.1.2

[develop.us-east-1.vpn:vars]
ansible_ssh_user=openvpnas

[develop.us-east-1.haproxy]
haproxy01.us ansible_ssh_host=10.1.1.10

[develop.us-east-1.haproxy:vars]
ansible_ssh_user=ubuntu


In my playbook:

vars:
    machine_environment: 'development'
    vpc_region: 'us-east-1'
    proxy_servers: 'haproxy'
    haproxy_group: "groups['{{machine_environment}}.{{vpc_region}}.{{ 
proxy_servers }}']"

    tasks:

    - debug:
        msg: "{{ item }}"
        with_items: haproxy_group

Which I assume will loop through my proxy servers as they are listed in my 
hosts file, but instead I get this:

TASK: [debug ] 
****************************************************************
fatal: [haproxy01.us] => One or more undefined variables: 'item' is 
undefined

If I change it to this:

    - debug:
        msg: "{{ haproxy_group }}"

I get this:

TASK: [debug ] 
****************************************************************
ok: [haproxy01.us] => {
    "msg": "groups['development.us-east-1.haproxy']"
}

How do I get my groups programmatically so I can use them inside my 
template to configure haproxy, etc?

I'm sure I've just boneheaded something or am assuming it works a specific 
way, any help greatly appreciated!

D

-- 
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/c041fefc-2356-4f69-b45d-45ac7ab3dc53%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to