301ae3faee
Rather than copy-pasting around same tasks but changing slightly the way we loop them when it's a per-profile or a per-cloud resource, refactor the code a bit so both mechanisms call the same task. e.g. the per-profile projects and per-cloud projects will call in the end create_project, the only thing it varies is the loop prior to getting the individual project items. Change-Id: Ida2aebadafd4d60d11fa18aa2208dad235badd4c
105 lines
3.8 KiB
YAML
105 lines
3.8 KiB
YAML
---
|
|
- include: create_domain.yml
|
|
with_items: "{{ profiles|selectattr('name', 'equalto', item_profile)|map(attribute='domains')|list }}"
|
|
loop_control:
|
|
loop_var: item_domain
|
|
when: "{{ 'domains' in profiles|selectattr('name', 'equalto', item_profile)|list|first }}"
|
|
tags:
|
|
- domains
|
|
|
|
- include: create_project.yml
|
|
with_items: "{{ profiles|selectattr('name', 'equalto', item_profile)|map(attribute='projects')|list }}"
|
|
loop_control:
|
|
loop_var: item_project
|
|
when: "{{ 'projects' in profiles|selectattr('name', 'equalto', item_profile)|list|first }}"
|
|
tags:
|
|
- projects
|
|
|
|
- include: create_user.yml
|
|
with_items: "{{ profiles|selectattr('name', 'equalto', item_profile)|map(attribute='users')|list }}"
|
|
loop_control:
|
|
loop_var: item_user
|
|
when: "{{ 'users' in profiles|selectattr('name', 'equalto', item_profile)|list|first }}"
|
|
tags:
|
|
- users
|
|
|
|
- include: create_network.yml
|
|
with_items: "{{ profiles|selectattr('name', 'equalto', item_profile)|map(attribute='networks')|list }}"
|
|
loop_control:
|
|
loop_var: item_network
|
|
when: "{{ 'networks' in profiles|selectattr('name', 'equalto', item_profile)|list|first }}"
|
|
tags:
|
|
- networks
|
|
|
|
- include: create_subnet.yml
|
|
with_items: "{{ profiles|selectattr('name', 'equalto', item_profile)|map(attribute='subnets')|list }}"
|
|
loop_control:
|
|
loop_var: item_subnet
|
|
when: "{{ 'subnets' in profiles|selectattr('name', 'equalto', item_profile)|list|first }}"
|
|
tags:
|
|
- subnets
|
|
|
|
- include: create_router.yml
|
|
with_items: "{{ profiles|selectattr('name', 'equalto', item_profile)|map(attribute='routers')|list }}"
|
|
loop_control:
|
|
loop_var: item_router
|
|
when: "{{ 'routers' in profiles|selectattr('name', 'equalto', item_profile)|list|first }}"
|
|
tags:
|
|
- routers
|
|
|
|
- include: create_flavor.yml
|
|
with_items: "{{ profiles|selectattr('name', 'equalto', item_profile)|map(attribute='flavors')|list }}"
|
|
loop_control:
|
|
loop_var: item_flavor
|
|
when: "{{ 'flavors' in profiles|selectattr('name', 'equalto', item_profile)|list|first }}"
|
|
tags:
|
|
- flavors
|
|
|
|
- include: create_image.yml
|
|
with_items: "{{ profiles|selectattr('name', 'equalto', item_profile)|map(attribute='images')|list }}"
|
|
loop_control:
|
|
loop_var: item_image
|
|
when: "{{ 'images' in profiles|selectattr('name', 'equalto', item_profile)|list|first }}"
|
|
tags:
|
|
- images
|
|
|
|
- include: create_security_group.yml
|
|
with_items: "{{ profiles|selectattr('name', 'equalto', item_profile)|map(attribute='security_groups')|list }}"
|
|
loop_control:
|
|
loop_var: item_security_group
|
|
when: "{{ 'security_groups' in profiles|selectattr('name', 'equalto', item_profile)|list|first }}"
|
|
tags:
|
|
- security_groups
|
|
|
|
- include: create_security_group_rule.yml
|
|
with_items: "{{ profiles|selectattr('name', 'equalto', item_profile)|map(attribute='security_groups_rules')|list }}"
|
|
loop_control:
|
|
loop_var: item_security_group_rule
|
|
when: "{{ 'security_groups_rules' in profiles|selectattr('name', 'equalto', item_profile)|list|first }}"
|
|
tags:
|
|
- security_groups_rules
|
|
|
|
- include: create_keypair.yml
|
|
with_items: "{{ profiles|selectattr('name', 'equalto', item_profile)|map(attribute='keypairs')|list }}"
|
|
loop_control:
|
|
loop_var: item_keypair
|
|
when: "{{ 'keypairs' in profiles|selectattr('name', 'equalto', item_profile)|list|first }}"
|
|
tags:
|
|
- keypairs
|
|
|
|
- include: create_volume.yml
|
|
with_items: "{{ profiles|selectattr('name', 'equalto', item_profile)|map(attribute='volumes')|list }}"
|
|
loop_control:
|
|
loop_var: item_volume
|
|
when: "{{ 'volumes' in profiles|selectattr('name', 'equalto', item_profile)|list|first }}"
|
|
tags:
|
|
- volumes
|
|
|
|
- include: create_server.yml
|
|
with_items: "{{ profiles|selectattr('name', 'equalto', item_profile)|map(attribute='servers')|list }}"
|
|
loop_control:
|
|
loop_var: item_server
|
|
when: "{{ 'servers' in profiles|selectattr('name', 'equalto', item_profile)|list|first }}"
|
|
tags:
|
|
- servers
|