Refactor the per-cloud and per-profile code
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
This commit is contained in:
parent
59c05c8048
commit
301ae3faee
@ -1,364 +1,6 @@
|
||||
---
|
||||
- name: Create per-cloud domains for cloud "{{ item_cloud.name }}"
|
||||
os_keystone_domain:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item.state|default(omit) }}"
|
||||
name: "{{ item.name }}"
|
||||
description: "{{ item.description|default(omit) }}"
|
||||
with_items: "{{ item_cloud.domains|default([]) }}"
|
||||
tags:
|
||||
- domains
|
||||
|
||||
- name: Create profiles domains for cloud {{ item_cloud.name }}
|
||||
os_keystone_domain:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item.1.state|default(omit) }}"
|
||||
name: "{{ item.1.name }}"
|
||||
description: "{{ item.1.description|default(omit) }}"
|
||||
with_subelements:
|
||||
- "{{ profiles|default([]) }}"
|
||||
- domains
|
||||
- { skip_missing: yes }
|
||||
when: "{{ item_cloud.profiles is defined and item.0.name in item_cloud.profiles }}"
|
||||
tags:
|
||||
- domains
|
||||
|
||||
- name: Create per-cloud projects for cloud {{ item_cloud.name }}
|
||||
os_project:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item.state|default(omit) }}"
|
||||
name: "{{ item.name }}"
|
||||
description: "{{ item.description|default(omit) }}"
|
||||
domain: "{{ item.domain|default(omit) }}"
|
||||
with_items: "{{ item_cloud.projects|default([]) }}"
|
||||
tags:
|
||||
- projects
|
||||
|
||||
- name: Create profiles projects for cloud {{ item_cloud.name }}
|
||||
os_project:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item.1.state|default(omit) }}"
|
||||
name: "{{ item.1.name }}"
|
||||
description: "{{ item.1.description|default(omit) }}"
|
||||
domain: "{{ item.1.domain|default(omit) }}"
|
||||
with_subelements:
|
||||
- "{{ profiles|default([]) }}"
|
||||
- projects
|
||||
- { skip_missing: yes}
|
||||
when: "{{ item_cloud.profiles is defined and item.0.name in item_cloud.profiles }}"
|
||||
tags:
|
||||
- projects
|
||||
|
||||
- name: Create per-cloud users for cloud {{ item_cloud.name }}
|
||||
os_user:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item.state|default(omit) }}"
|
||||
name: "{{ item.name }}"
|
||||
password: "{{ item.password }}"
|
||||
email: "{{ item.email|default(omit) }}"
|
||||
domain: "{{ item.domain|default(omit) }}"
|
||||
default_project: "{{ item.default_project|default(omit) }}"
|
||||
with_items: "{{ item_cloud.users|default([]) }}"
|
||||
tags:
|
||||
- users
|
||||
|
||||
- name: Create profiles users for cloud {{ item_cloud.name }}
|
||||
os_user:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item.1.state|default(omit) }}"
|
||||
name: "{{ item.1.name }}"
|
||||
password: "{{ item.1.password }}"
|
||||
email: "{{ item.1.email|default(omit) }}"
|
||||
domain: "{{ item.1.domain|default(omit) }}"
|
||||
default_project: "{{ item.1.default_project|default(omit) }}"
|
||||
with_subelements:
|
||||
- "{{ profiles|default([]) }}"
|
||||
- users
|
||||
- { skip_missing: yes}
|
||||
when: "{{ item_cloud.profiles is defined and item.0.name in item_cloud.profiles }}"
|
||||
tags:
|
||||
- users
|
||||
|
||||
- name: Create per-cloud networks for {{ item_cloud.name }}
|
||||
os_network:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item.state|default(omit) }}"
|
||||
name: "{{ item.name }}"
|
||||
external: "{{ item.external|default(omit) }}"
|
||||
project: "{{ item.project|default(omit) }}"
|
||||
with_items: "{{ item_cloud.networks|default([]) }}"
|
||||
tags:
|
||||
- networks
|
||||
|
||||
- name: Create profiles networks for {{ item_cloud.name }}
|
||||
os_network:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item.1.state|default(omit) }}"
|
||||
name: "{{ item.1.name }}"
|
||||
external: "{{ item.1.external|default(omit) }}"
|
||||
project: "{{ item.1.project|default(omit) }}"
|
||||
with_subelements:
|
||||
- "{{ profiles|default([]) }}"
|
||||
- networks
|
||||
- { skip_missing: yes}
|
||||
when: "{{ item_cloud.profiles is defined and item.0.name in item_cloud.profiles }}"
|
||||
tags:
|
||||
- networks
|
||||
|
||||
- name: Create per-cloud subnets for cloud {{ item_cloud.name }}
|
||||
os_subnet:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item.state|default(omit) }}"
|
||||
name: "{{ item.name }}"
|
||||
network_name: "{{ item.network_name|default(omit) }}"
|
||||
cidr: "{{ item.cidr }}"
|
||||
dns_nameservers: "{{ item.dns_nameservers|default(omit) }}"
|
||||
with_items: "{{ item_cloud.subnets|default([]) }}"
|
||||
tags:
|
||||
- subnets
|
||||
|
||||
- name: Create profiles subnets for {{ item_cloud.name }}
|
||||
os_subnet:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item.1.state|default(omit) }}"
|
||||
name: "{{ item.1.name }}"
|
||||
network_name: "{{ item.1.network_name|default(omit) }}"
|
||||
cidr: "{{ item.1.cidr }}"
|
||||
dns_nameservers: "{{ item.1.dns_nameservers|default(omit) }}"
|
||||
with_subelements:
|
||||
- "{{ profiles|default([]) }}"
|
||||
- subnets
|
||||
- { skip_missing: yes }
|
||||
when: "{{ item_cloud.profiles is defined and item.0.name in item_cloud.profiles }}"
|
||||
tags:
|
||||
- subnets
|
||||
|
||||
- name: Create per-cloud routers for cloud {{ item_cloud.name }}
|
||||
os_router:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item.state|default(omit) }}"
|
||||
name: "{{ item.name }}"
|
||||
network: "{{ item.network }}"
|
||||
admin_state_up: "{{ item.admin_state_up|default(omit) }}"
|
||||
enable_snat: "{{ item.enable_snat|default(omit) }}"
|
||||
external_fixed_ips: "{{ item.external_fixed_ips|default(omit) }}"
|
||||
interfaces: "{{ item.interfaces|default(omit) }}"
|
||||
with_items: "{{ item_cloud.routers|default([]) }}"
|
||||
tags:
|
||||
- routers
|
||||
|
||||
- name: Create profiles routers for {{ item_cloud.name }}
|
||||
os_router:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item.1.state|default(omit) }}"
|
||||
name: "{{ item.1.name }}"
|
||||
network: "{{ item.1.network }}"
|
||||
admin_state_up: "{{ item.1.admin_state_up|default(omit) }}"
|
||||
enable_snat: "{{ item.1.enable_snat|default(omit) }}"
|
||||
external_fixed_ips: "{{ item.1.external_fixed_ips|default(omit) }}"
|
||||
interfaces: "{{ item.1.interfaces|default(omit) }}"
|
||||
with_subelements:
|
||||
- "{{ profiles|default([]) }}"
|
||||
- routers
|
||||
- { skip_missing: yes }
|
||||
when: "{{ item_cloud.profiles is defined and item.0.name in item_cloud.profiles }}"
|
||||
tags:
|
||||
- routers
|
||||
|
||||
- name: Create per-cloud flavors for {{ item_cloud.name }}
|
||||
os_nova_flavor:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item.state|default(omit) }}"
|
||||
name: "{{ item.name }}"
|
||||
vcpus: "{{ item.vcpus }}"
|
||||
ram: "{{ item.ram }}"
|
||||
disk: "{{ item.disk }}"
|
||||
swap: "{{ item.swap|default(omit) }}"
|
||||
ephemeral: "{{ item.ephemeral|default(omit) }}"
|
||||
rxtx_factor: "{{ item.rxtx_factor|default(omit) }}"
|
||||
with_items: "{{ item_cloud.flavors|default([]) }}"
|
||||
tags:
|
||||
- flavors
|
||||
|
||||
- name: Create profiles flavors for {{ item_cloud.name }}
|
||||
os_nova_flavor:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item.1.state|default(omit) }}"
|
||||
name: "{{ item.1.name }}"
|
||||
vcpus: "{{ item.1.vcpus }}"
|
||||
ram: "{{ item.1.ram }}"
|
||||
disk: "{{ item.1.disk }}"
|
||||
swap: "{{ item.1.swap|default(omit) }}"
|
||||
ephemeral: "{{ item.1.ephemeral|default(omit) }}"
|
||||
rxtx_factor: "{{ item.1.rxtx_factor|default(omit) }}"
|
||||
with_subelements:
|
||||
- "{{ profiles|default([]) }}"
|
||||
- flavors
|
||||
- { skip_missing: yes }
|
||||
when: "{{ item_cloud.profiles is defined and item.0.name in item_cloud.profiles }}"
|
||||
tags:
|
||||
- flavors
|
||||
|
||||
- name: Create per-cloud images for {{ item_cloud.name }}
|
||||
os_image:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item.state|default(omit) }}"
|
||||
name: "{{ item.name }}"
|
||||
container_format: "{{ item.container_format|default(omit) }}"
|
||||
disk_format: "{{ item.disk_format|default(omit) }}"
|
||||
kernel: "{{ item.kernel|default(omit) }}"
|
||||
ramdisk: "{{ item.ramdisk|default(omit) }}"
|
||||
filename: "{{ item.filename|default(omit) }}"
|
||||
min_disk: "{{ item.min_disk|default(omit) }}"
|
||||
min_ram: "{{ item.min_ram|default(omit) }}"
|
||||
owner: "{{ item.owner|default(omit) }}"
|
||||
properties: "{{ item.properties|default(omit) }}"
|
||||
is_public: "{{ item.is_public|default(omit) }}"
|
||||
with_items: "{{ item_cloud.images|default([]) }}"
|
||||
tags:
|
||||
- images
|
||||
|
||||
- name: Create profiles images for {{ item_cloud.name }}
|
||||
os_image:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item.1.state|default(omit) }}"
|
||||
name: "{{ item.1.name }}"
|
||||
container_format: "{{ item.1.container_format|default(omit) }}"
|
||||
disk_format: "{{ item.1.disk_format|default(omit) }}"
|
||||
kernel: "{{ item.1.kernel|default(omit) }}"
|
||||
ramdisk: "{{ item.1.ramdisk|default(omit) }}"
|
||||
filename: "{{ item.1.filename|default(omit) }}"
|
||||
min_disk: "{{ item.1.min_disk|default(omit) }}"
|
||||
min_ram: "{{ item.1.min_ram|default(omit) }}"
|
||||
owner: "{{ item.1.owner|default(omit) }}"
|
||||
properties: "{{ item.1.properties|default(omit) }}"
|
||||
is_public: "{{ item.1.is_public|default(omit) }}"
|
||||
with_subelements:
|
||||
- "{{ profiles|default([]) }}"
|
||||
- images
|
||||
- { skip_missing: yes }
|
||||
when: "{{ item_cloud.profiles is defined and item.0.name in item_cloud.profiles }}"
|
||||
tags:
|
||||
- images
|
||||
|
||||
- name: Create per-cloud security groups for {{ item_cloud.name }}
|
||||
os_security_group:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item.state|default(omit) }}"
|
||||
name: "{{ item.name }}"
|
||||
description: "{{ item.description|default(omit) }}"
|
||||
with_items: "{{ item_cloud.security_groups|default([]) }}"
|
||||
tags:
|
||||
- security_groups
|
||||
|
||||
- name: Create profiles security groups for {{ item_cloud.name }}
|
||||
os_security_group:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item.1.state|default(omit) }}"
|
||||
name: "{{ item.1.name }}"
|
||||
description: "{{ item.1.description|default(omit) }}"
|
||||
with_subelements:
|
||||
- "{{ profiles|default([]) }}"
|
||||
- security_groups
|
||||
- { skip_missing: yes }
|
||||
when: "{{ item_cloud.profiles is defined and item.0.name in item_cloud.profiles }}"
|
||||
tags:
|
||||
- security_groups
|
||||
|
||||
- name: Create per-cloud security groups rules for {{ item_cloud.name }}
|
||||
os_security_group_rule:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item.state|default(omit) }}"
|
||||
security_group: "{{ item.security_group }}"
|
||||
direction: "{{ item.direction|default(omit) }}"
|
||||
ethertype: "{{ item.ethertype|default(omit) }}"
|
||||
port_range_max: "{{ item.port_range_max|default(omit) }}"
|
||||
port_range_min: "{{ item.port_range_min|default(omit) }}"
|
||||
protocol: "{{ item.protocol|default(omit) }}"
|
||||
remote_group: "{{ item.remote_group|default(omit) }}"
|
||||
remote_ip_prefix: "{{ item.remote_ip_prefix|default(omit) }}"
|
||||
with_items: "{{ item_cloud.security_groups_rules|default([]) }}"
|
||||
tags:
|
||||
- security_groups_rules
|
||||
|
||||
- name: Create profiles security groups rules for {{ item_cloud.name }}
|
||||
os_security_group_rule:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item.1.state|default(omit) }}"
|
||||
security_group: "{{ item.1.security_group }}"
|
||||
direction: "{{ item.1.direction|default(omit) }}"
|
||||
ethertype: "{{ item.1.ethertype|default(omit) }}"
|
||||
port_range_max: "{{ item.1.port_range_max|default(omit) }}"
|
||||
port_range_min: "{{ item.1.port_range_min|default(omit) }}"
|
||||
protocol: "{{ item.1.protocol|default(omit) }}"
|
||||
remote_group: "{{ item.1.remote_group|default(omit) }}"
|
||||
remote_ip_prefix: "{{ item.1.remote_ip_prefix|default(omit) }}"
|
||||
with_subelements:
|
||||
- "{{ profiles|default([]) }}"
|
||||
- security_groups_rules
|
||||
- { skip_missing: yes }
|
||||
when: "{{ item_cloud.profiles is defined and item.0.name in item_cloud.profiles }}"
|
||||
tags:
|
||||
- security_groups_rules
|
||||
|
||||
- name: Create per-cloud keypairs for {{ item_cloud.name }}
|
||||
os_keypair:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item.state|default(omit) }}"
|
||||
name: "{{ item.name }}"
|
||||
public_key: "{{ item.public_key|default(omit) }}"
|
||||
public_key_file: "{{ item.public_key_file|default(omit) }}"
|
||||
with_items: "{{ item_cloud.keypairs|default([]) }}"
|
||||
tags:
|
||||
- keypairs
|
||||
|
||||
- name: Create profiles keypairs rules for {{ item_cloud.name }}
|
||||
os_keypair:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item.1.state|default(omit) }}"
|
||||
name: "{{ item.1.name }}"
|
||||
public_key: "{{ item.1.public_key|default(omit) }}"
|
||||
public_key_file: "{{ item.1.public_key_file|default(omit) }}"
|
||||
with_subelements:
|
||||
- "{{ profiles|default([]) }}"
|
||||
- keypairs
|
||||
- { skip_missing: yes }
|
||||
when: "{{ item_cloud.profiles is defined and item.0.name in item_cloud.profiles }}"
|
||||
tags:
|
||||
- keypairs
|
||||
|
||||
- name: Create per-cloud volumes for {{ item_cloud.name }}
|
||||
os_volume:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item.state|default(omit) }}"
|
||||
name: "{{ item.name }}"
|
||||
size: "{{ item.size }}"
|
||||
display_description: "{{ item.display_description|default(omit) }}"
|
||||
image: "{{ item.image|default(omit) }}"
|
||||
key: "{{ item.key|default(omit) }}"
|
||||
snapshot_id: "{{ item.snapshot_id|default(omit) }}"
|
||||
volume_type: "{{ item.volume_type|default(omit) }}"
|
||||
with_items: "{{ item_cloud.volumes|default([]) }}"
|
||||
tags:
|
||||
- volumes
|
||||
|
||||
- name: Create profiles volumes for {{ item_cloud.name }}
|
||||
os_volume:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item.1.state|default(omit) }}"
|
||||
name: "{{ item.1.name }}"
|
||||
size: "{{ item.1.size }}"
|
||||
display_description: "{{ item.1.display_description|default(omit) }}"
|
||||
image: "{{ item.1.image|default(omit) }}"
|
||||
key: "{{ item.1.key|default(omit) }}"
|
||||
snapshot_id: "{{ item.1.snapshot_id|default(omit) }}"
|
||||
volume_type: "{{ item.1.volume_type|default(omit) }}"
|
||||
with_subelements:
|
||||
- "{{ profiles|default([]) }}"
|
||||
- volumes
|
||||
- { skip_missing: yes }
|
||||
when: "{{ item_cloud.profiles is defined and item.0.name in item_cloud.profiles }}"
|
||||
tags:
|
||||
- volumes
|
||||
|
||||
- include: create_servers.yml
|
||||
- include: create_per_cloud_profiles_resources.yml
|
||||
with_items: "{{ item_cloud.profiles|default([]) }}"
|
||||
loop_control:
|
||||
loop_var: item_profile
|
||||
- include: create_per_cloud_resources.yml
|
||||
|
6
tasks/create_domain.yml
Normal file
6
tasks/create_domain.yml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
- os_keystone_domain:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item_domain.state|default(omit) }}"
|
||||
name: "{{ item_domain.name }}"
|
||||
description: "{{ item_domain.description|default(omit) }}"
|
11
tasks/create_flavor.yml
Normal file
11
tasks/create_flavor.yml
Normal file
@ -0,0 +1,11 @@
|
||||
---
|
||||
- os_nova_flavor:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item_flavor.state|default(omit) }}"
|
||||
name: "{{ item_flavor.name }}"
|
||||
vcpus: "{{ item_flavor.vcpus }}"
|
||||
ram: "{{ item_flavor.ram }}"
|
||||
disk: "{{ item_flavor.disk }}"
|
||||
swap: "{{ item_flavor.swap|default(omit) }}"
|
||||
ephemeral: "{{ item_flavor.ephemeral|default(omit) }}"
|
||||
rxtx_factor: "{{ item_flavor.rxtx_factor|default(omit) }}"
|
15
tasks/create_image.yml
Normal file
15
tasks/create_image.yml
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
- os_image:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item_image.state|default(omit) }}"
|
||||
name: "{{ item_image.name }}"
|
||||
container_format: "{{ item_image.container_format|default(omit) }}"
|
||||
disk_format: "{{ item_image.disk_format|default(omit) }}"
|
||||
kernel: "{{ item_image.kernel|default(omit) }}"
|
||||
ramdisk: "{{ item_image.ramdisk|default(omit) }}"
|
||||
filename: "{{ item_image.filename|default(omit) }}"
|
||||
min_disk: "{{ item_image.min_disk|default(omit) }}"
|
||||
min_ram: "{{ item_image.min_ram|default(omit) }}"
|
||||
owner: "{{ item_image.owner|default(omit) }}"
|
||||
properties: "{{ item_image.properties|default(omit) }}"
|
||||
is_public: "{{ item_image.is_public|default(omit) }}"
|
7
tasks/create_keypair.yml
Normal file
7
tasks/create_keypair.yml
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
- os_keypair:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item_keypair.state|default(omit) }}"
|
||||
name: "{{ item_keypair.name }}"
|
||||
public_key: "{{ item_keypair.public_key|default(omit) }}"
|
||||
public_key_file: "{{ item_keypair.public_key_file|default(omit) }}"
|
7
tasks/create_network.yml
Normal file
7
tasks/create_network.yml
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
- os_network:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item_network.state|default(omit) }}"
|
||||
name: "{{ item_network.name }}"
|
||||
external: "{{ item_network.external|default(omit) }}"
|
||||
project: "{{ item_network.project|default(omit) }}"
|
104
tasks/create_per_cloud_profiles_resources.yml
Normal file
104
tasks/create_per_cloud_profiles_resources.yml
Normal file
@ -0,0 +1,104 @@
|
||||
---
|
||||
- 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
|
91
tasks/create_per_cloud_resources.yml
Normal file
91
tasks/create_per_cloud_resources.yml
Normal file
@ -0,0 +1,91 @@
|
||||
---
|
||||
- include: create_domain.yml
|
||||
with_items: "{{ item_cloud.domains|default([]) }}"
|
||||
loop_control:
|
||||
loop_var: item_domain
|
||||
tags:
|
||||
- domains
|
||||
|
||||
- include: create_project.yml
|
||||
with_items: "{{ item_cloud.projects|default([]) }}"
|
||||
loop_control:
|
||||
loop_var: item_project
|
||||
tags:
|
||||
- projects
|
||||
|
||||
- include: create_user.yml
|
||||
with_items: "{{ item_cloud.users|default([]) }}"
|
||||
loop_control:
|
||||
loop_var: item_user
|
||||
tags:
|
||||
- users
|
||||
|
||||
- include: create_network.yml
|
||||
with_items: "{{ item_cloud.networks|default([]) }}"
|
||||
loop_control:
|
||||
loop_var: item_network
|
||||
tags:
|
||||
- networks
|
||||
|
||||
- include: create_subnet.yml
|
||||
with_items: "{{ item_cloud.subnets|default([]) }}"
|
||||
loop_control:
|
||||
loop_var: item_subnet
|
||||
tags:
|
||||
- subnets
|
||||
|
||||
- include: create_router.yml
|
||||
with_items: "{{ item_cloud.routers|default([]) }}"
|
||||
loop_control:
|
||||
loop_var: item_router
|
||||
tags:
|
||||
- routers
|
||||
|
||||
- include: create_flavor.yml
|
||||
with_items: "{{ item_cloud.flavors|default([]) }}"
|
||||
loop_control:
|
||||
loop_var: item_flavor
|
||||
tags:
|
||||
- flavors
|
||||
|
||||
- include: create_image.yml
|
||||
with_items: "{{ item_cloud.images|default([]) }}"
|
||||
loop_control:
|
||||
loop_var: item_image
|
||||
tags:
|
||||
- images
|
||||
|
||||
- include: create_security_group.yml
|
||||
with_items: "{{ item_cloud.security_groups|default([]) }}"
|
||||
loop_control:
|
||||
loop_var: item_security_group
|
||||
tags:
|
||||
- security_groups
|
||||
|
||||
- include: create_security_group_rule.yml
|
||||
with_items: "{{ item_cloud.security_groups_rules|default([]) }}"
|
||||
loop_control:
|
||||
loop_var: item_security_group_rule
|
||||
tags:
|
||||
- security_groups_rules
|
||||
|
||||
- include: create_keypair.yml
|
||||
with_items: "{{ item_cloud.keypairs|default([]) }}"
|
||||
loop_control:
|
||||
loop_var: item_keypair
|
||||
tags:
|
||||
- keypairs
|
||||
|
||||
- include: create_volume.yml
|
||||
with_items: "{{ item_cloud.volumes|default([]) }}"
|
||||
loop_control:
|
||||
loop_var: item_volume
|
||||
tags:
|
||||
- volumes
|
||||
|
||||
- include: create_server.yml
|
||||
with_items: "{{ item_cloud.servers|default([]) }}"
|
||||
loop_control:
|
||||
loop_var: item_server
|
||||
tags:
|
||||
- servers
|
7
tasks/create_project.yml
Normal file
7
tasks/create_project.yml
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
- os_project:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item_project.state|default(omit) }}"
|
||||
name: "{{ item_project.name }}"
|
||||
description: "{{ item_project.description|default(omit) }}"
|
||||
domain: "{{ item_project.domain|default(omit) }}"
|
10
tasks/create_router.yml
Normal file
10
tasks/create_router.yml
Normal file
@ -0,0 +1,10 @@
|
||||
---
|
||||
- os_router:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item_router.state|default(omit) }}"
|
||||
name: "{{ item_router.name }}"
|
||||
network: "{{ item_router.network }}"
|
||||
admin_state_up: "{{ item_router.admin_state_up|default(omit) }}"
|
||||
enable_snat: "{{ item_router.enable_snat|default(omit) }}"
|
||||
external_fixed_ips: "{{ item_router.external_fixed_ips|default(omit) }}"
|
||||
interfaces: "{{ item_router.interfaces|default(omit) }}"
|
6
tasks/create_security_group.yml
Normal file
6
tasks/create_security_group.yml
Normal file
@ -0,0 +1,6 @@
|
||||
---
|
||||
- os_security_group:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item_security_group.state|default(omit) }}"
|
||||
name: "{{ item_security_group.name }}"
|
||||
description: "{{ item_security_group.description|default(omit) }}"
|
12
tasks/create_security_group_rule.yml
Normal file
12
tasks/create_security_group_rule.yml
Normal file
@ -0,0 +1,12 @@
|
||||
---
|
||||
- os_security_group_rule:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item_security_group_rule.state|default(omit) }}"
|
||||
security_group: "{{ item_security_group_rule.security_group }}"
|
||||
direction: "{{ item_security_group_rule.direction|default(omit) }}"
|
||||
ethertype: "{{ item_security_group_rule.ethertype|default(omit) }}"
|
||||
port_range_max: "{{ item_security_group_rule.port_range_max|default(omit) }}"
|
||||
port_range_min: "{{ item_security_group_rule.port_range_min|default(omit) }}"
|
||||
protocol: "{{ item_security_group_rule.protocol|default(omit) }}"
|
||||
remote_group: "{{ item_security_group_rule.remote_group|default(omit) }}"
|
||||
remote_ip_prefix: "{{ item_security_group_rule.remote_ip_prefix|default(omit) }}"
|
27
tasks/create_server.yml
Normal file
27
tasks/create_server.yml
Normal file
@ -0,0 +1,27 @@
|
||||
---
|
||||
- os_server:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item_server.state|default(omit) }}"
|
||||
name: "{{ item_server.name }}"
|
||||
image: "{{ item_server.image }}"
|
||||
auto_ip: "{{ item_server.auto_ip|default(omit) }}"
|
||||
boot_from_volume: "{{ item_server.boot_from_volume|default(omit) }}"
|
||||
boot_volume: "{{ item_server.boot_volume|default(omit) }}"
|
||||
config_drive: "{{ item_server.config_drive|default(omit) }}"
|
||||
flavor: "{{ item_server.flavor|default(omit) }}"
|
||||
flavor_include: "{{ item_server.flavor_include|default(omit) }}"
|
||||
flavor_ram: "{{ item_server.flavor_ram|default(omit) }}"
|
||||
floating_ip_pools: "{{ item_server.floating_ip_pools|default(omit) }}"
|
||||
floating_ips: "{{ item_server.floating_ips|default(omit) }}"
|
||||
image_exclude: "{{ item_server.image_exclude|default(omit) }}"
|
||||
key: "{{ item_server.key|default(omit) }}"
|
||||
key_name: "{{ item_server.key_name|default(omit) }}"
|
||||
meta: "{{ item_server.meta|default(omit) }}"
|
||||
network: "{{ item_server.network|default(omit) }}"
|
||||
nics: "{{ item_server.nics|default(omit) }}"
|
||||
scheduler_hints: "{{ item_server.scheduler_hints|default(omit) }}"
|
||||
security_groups: "{{ item_server.security_groups|default(omit) }}"
|
||||
terminate_volume: "{{ item_server.terminate_volume|default(omit) }}"
|
||||
userdata: "{{ item_server.userdata|default(omit) }}"
|
||||
volume_size: "{{ item_server.volume_size|default(omit) }}"
|
||||
volumes: "{{ item_server.volumes|default(omit) }}"
|
8
tasks/create_subnet.yml
Normal file
8
tasks/create_subnet.yml
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
- os_subnet:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item_subnet.state|default(omit) }}"
|
||||
name: "{{ item_subnet.name }}"
|
||||
network_name: "{{ item_subnet.network_name|default(omit) }}"
|
||||
cidr: "{{ item_subnet.cidr }}"
|
||||
dns_nameservers: "{{ item_subnet.dns_nameservers|default(omit) }}"
|
9
tasks/create_user.yml
Normal file
9
tasks/create_user.yml
Normal file
@ -0,0 +1,9 @@
|
||||
---
|
||||
- os_user:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item_user.state|default(omit) }}"
|
||||
name: "{{ item_user.name }}"
|
||||
password: "{{ item_user.password }}"
|
||||
email: "{{ item_user.email|default(omit) }}"
|
||||
domain: "{{ item_user.domain|default(omit) }}"
|
||||
default_project: "{{ item_user.default_project|default(omit) }}"
|
11
tasks/create_volume.yml
Normal file
11
tasks/create_volume.yml
Normal file
@ -0,0 +1,11 @@
|
||||
---
|
||||
- os_volume:
|
||||
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
|
||||
state: "{{ item_volume.state|default(omit) }}"
|
||||
name: "{{ item_volume.name }}"
|
||||
size: "{{ item_volume.size }}"
|
||||
display_description: "{{ item_volume.display_description|default(omit) }}"
|
||||
image: "{{ item_volume.image|default(omit) }}"
|
||||
key: "{{ item_volume.key|default(omit) }}"
|
||||
snapshot_id: "{{ item_volume.snapshot_id|default(omit) }}"
|
||||
volume_type: "{{ item_volume.volume_type|default(omit) }}"
|
0
tests/hooks/post_test_hook.sh
Normal file → Executable file
0
tests/hooks/post_test_hook.sh
Normal file → Executable file
Loading…
x
Reference in New Issue
Block a user