ansible-role-cloud-launcher/tasks/create_clouds_resources.yml
Ricardo Carrillo Cruz 691970f923 Use new loop_control/loop_var constructs from Ansible devel
Ansible now allows you to name the loop var, fixing nested
with_items include issue:

https://github.com/ansible/ansible/issues/14146#

Switching to it for making role future proof.
2016-04-25 02:55:50 +00:00

429 lines
16 KiB
YAML

---
- 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 }}"
- domains
- { skip_missing: yes }
when: "{{ 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 }}"
- projects
- { skip_missing: yes}
when: "{{ 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 }}"
- users
- { skip_missing: yes}
when: "{{ 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.1.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 }}"
- networks
- { skip_missing: yes}
when: "{{ 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 }}"
- subnets
- { skip_missing: yes }
when: "{{ 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.subnets|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 }}"
- routers
- { skip_missing: yes }
when: "{{ 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 }}"
- flavors
- { skip_missing: yes }
when: "{{ 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 }}"
- images
- { skip_missing: yes }
when: "{{ 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 }}"
- security_groups
- { skip_missing: yes }
when: "{{ 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 }}"
- security_groups_rules
- { skip_missing: yes }
when: "{{ 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 }}"
- keypairs
- { skip_missing: yes }
when: "{{ 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 }}"
- volumes
- { skip_missing: yes }
when: "{{ item.0.name in item_cloud.profiles }}"
tags:
- volumes
- name: Create per-cloud servers for {{ item_cloud.name }}
os_server:
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
state: "{{ item.state|default(omit) }}"
name: "{{ item.name }}"
image: "{{ item.image }}"
auto_ip: "{{ item.auto_ip|default(omit) }}"
boot_from_volume: "{{ item.boot_from_volume|default(omit) }}"
boot_volume: "{{ item.boot_volume|default(omit) }}"
config_drive: "{{ item.config_drive|default(omit) }}"
flavor: "{{ item.flavor|default(omit) }}"
flavor_include: "{{ item.flavor_include|default(omit) }}"
flavor_ram: "{{ item.flavor_ram|default(omit) }}"
floating_ip_pools: "{{ item.floating_ip_pools|default(omit) }}"
floating_ips: "{{ item.floating_ips|default(omit) }}"
image_exclude: "{{ item.image_exclude|default(omit) }}"
key: "{{ item.key|default(omit) }}"
key_name: "{{ item.key_name|default(omit) }}"
meta: "{{ item.meta|default(omit) }}"
network: "{{ item.network|default(omit) }}"
nics: "{{ item.nics|default(omit) }}"
scheduler_hints: "{{ item.scheduler_hints|default(omit) }}"
security_groups: "{{ item.security_groups|default(omit) }}"
terminate_volume: "{{ item.terminate_volume|default(omit) }}"
userdata: "{{ item.userdata|default(omit) }}"
volume_size: "{{ item.volume_size|default(omit) }}"
volumes: "{{ item.volumes|default(omit) }}"
with_items: "{{ item_cloud.servers|default([]) }}"
tags:
- servers
- name: Create profiles servers for {{ item_cloud.name }}
os_server:
cloud: "{{ item_cloud.oscc_cloud|default(item_cloud.name) }}"
state: "{{ item.1.state|default(omit) }}"
name: "{{ item.1.name }}"
image: "{{ item.1.image }}"
auto_ip: "{{ item.1.auto_ip|default(omit) }}"
boot_from_volume: "{{ item.1.boot_from_volume|default(omit) }}"
boot_volume: "{{ item.1.boot_volume|default(omit) }}"
config_drive: "{{ item.1.config_drive|default(omit) }}"
flavor: "{{ item.1.flavor|default(omit) }}"
flavor_include: "{{ item.1.flavor_include|default(omit) }}"
flavor_ram: "{{ item.1.flavor_ram|default(omit) }}"
floating_ip_pools: "{{ item.1.floating_ip_pools|default(omit) }}"
floating_ips: "{{ item.1.floating_ips|default(omit) }}"
image_exclude: "{{ item.1.image_exclude|default(omit) }}"
key: "{{ item.1.key|default(omit) }}"
key_name: "{{ item.1.key_name|default(omit) }}"
meta: "{{ item.1.meta|default(omit) }}"
network: "{{ item.1.network|default(omit) }}"
nics: "{{ item.1.nics|default(omit) }}"
scheduler_hints: "{{ item.1.scheduler_hints|default(omit) }}"
security_groups: "{{ item.1.security_groups|default(omit) }}"
terminate_volume: "{{ item.1.terminate_volume|default(omit) }}"
userdata: "{{ item.1.userdata|default(omit) }}"
volume_size: "{{ item.1.volume_size|default(omit) }}"
volumes: "{{ item.1.volumes|default(omit) }}"
with_subelements:
- "{{ profiles }}"
- servers
- { skip_missing: yes }
when: "{{ item.0.name in item_cloud.profiles }}"
tags:
- servers