I use this:
In playbook:

---
- hosts: all
  gather_facts: yes
  sudo: yes
  roles:

    - aws_common
    - { role: aws_web, when: "'web' in roles" }
    - { role: aws_data, when: "'data' in roles" }


in role «aws_common»:

# File: roles/aws_common/tasks/set_facts.yml
---
- set_fact:
    roles: "{{ (ec2_tag_Roles|default('')).split(',') }}"



On Tuesday, November 3, 2015 at 10:46:26 PM UTC+5, H. Wade Minter wrote:
>
> Hi all,
>
> I'm managing some Ubuntu EC2 servers with Ansible - they primarily run 
> applications that get deployed with Capistrano, via the cap-ec2 plugin (
> https://github.com/forward3d/cap-ec2). cap-ec2 looks for a "Roles" tag, 
> featuring a comma-separated list of server roles (app, db, web, worker, 
> etc). In the setup we're using, one EC2 server can fill multiple roles, so 
> it's common to see the Roles tag with commas in it. It also uses a "Stages" 
> tag, with values like "production" and "staging", to indicate environment.
>
> I'd also like to use the ec2.py dynamic inventory script to pull the hosts 
> out of EC2, and run playbooks against our staging app servers, for example. 
> However, it seems like ec2.py doesn't play well with comma-separated tag 
> values (turning them into underscores). So a server that has Roles: 
> app,web, that will get turned into tag_Roles_app_web, but another server 
> that has Roles: app,worker would be tag_Roles_app_worker.
>
> So my questions for those wiser in dynamic inventory than I: is there a 
> way that I can aggregate any Role that features "app" into an inventory 
> group, using these existing Roles tags? Do I need to set additional tags 
> like "App: true" so that it would turn into tag_App_true and use those 
> instead? Use a bunch of the :children style tags like below?
>
> [app:children] 
> tag_Roles_app_web
> tag_Roles_app_worker 
>
> [tag_Roles_app_web]
> [tag_Roles_app_worker]
>
> Any suggestions would be appreciated!
>
> Thanks,
> Wade
>

-- 
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/6dd50aba-c815-42b7-ab64-952c39a83c2d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to