I think someone once may have posted something like this but Im trying to 
merge a list of base firewall rules (AWS) into a master_rules for that role

Example: all the roles listed in default/main.yml would merge in the base 
ip rules. I cant use python eval and not sure what is the best way to 
tackle merging. Here's what Ive been attempting. Im sure there is an easier 
way Im missing. Thanks for any help. 

defaults/main.yml
    roles:
        - nat
        - apps
        - db
        - web
        - log

vars/
      base.yml
      apps.yml
          rules:
             - proto: tcp
               from_port: 22
               to_port: 22
              cidr_ip: 0.0.0.0/0


- name: Include ip Base rules 
  include_vars:
    file: "base.yml"
    name: base

- name: Include Rules per  Role 
  include_vars:
    file: "{{ item }}.yml"
    name: "{{ item }}_rules"
  with_items:
    - "{{ roles }}"


- name: Set facts
  set_fact:
    master_rules_for_{{ item }}: "{{ (item + '_rules')['rules'] | 
 union(base['rules']) }}"
  with_items:
    - "{{ roles }}"

-- 
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/1cc1c952-fc58-4877-acf6-3378a94344be%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to