|
| 1 | +--- |
| 2 | + |
| 3 | +# First, we need to create ecosystem for further infrastructure. Its include network entities, such |
| 4 | +# VPC and subnet, security group and couple of ECSs. |
| 5 | +- name: Create VPC |
| 6 | + opentelekomcloud.cloud.vpc: |
| 7 | + name: "{{ vpc_name }}" |
| 8 | + cidr: "10.10.0.0/24" |
| 9 | + state: present |
| 10 | + register: newvpc |
| 11 | + tags: |
| 12 | + - vpc |
| 13 | + |
| 14 | +# Please pay attention on CIDR block: in case of insufficient numbers of available hosts there |
| 15 | +# could be errors in autoscaling groups behavior |
| 16 | +- name: Create subnet for VPC |
| 17 | + opentelekomcloud.cloud.subnet: |
| 18 | + name: "{{ vpc_subnet_name }}" |
| 19 | + vpc: "{{ vpc_name }}" |
| 20 | + cidr: "10.10.0.0/27" |
| 21 | + gateway_ip: "10.10.0.1" |
| 22 | + dns_list: |
| 23 | + - "100.125.4.25" |
| 24 | + - "100.125.129.199" |
| 25 | + register: sn |
| 26 | + tags: |
| 27 | + - subnet |
| 28 | + |
| 29 | +# There are a few mismatches in resources logic and naming between native Openstack and |
| 30 | +# Opentelekomcloud. To make it clear we placed examples using native Openstack resources. |
| 31 | +# |
| 32 | +# - name: Create network. In Open Telekom Cloud infrastructure this entity is hidden inside |
| 33 | +# Subnet summary, and isn't create separately, but only querying from the existing Subnet. |
| 34 | +# openstack.cloud.os_network: |
| 35 | +# name: "{{ network_name }}" |
| 36 | +# state: present |
| 37 | +# register: network |
| 38 | +# |
| 39 | +# - name: Create subnet. Openstack's Subnet is equal Open Telekom Cloud Subnet. |
| 40 | +# openstack.cloud.os_subnet: |
| 41 | +# name: "{{ subnet_name }}" |
| 42 | +# state: present |
| 43 | +# network_name: "{{ network.network.name }}" |
| 44 | +# cidr: "192.168.110.0/24" |
| 45 | +# dns_nameservers: "{{ ['100.125.4.25', '8.8.8.8'] }}" |
| 46 | +# register: subnet |
| 47 | +# |
| 48 | +# - name: Create router. In Open Telekom Cloud terms it's a VPC. Please pay attention that |
| 49 | +# Network argument here is not an Network created on previous step, but constanta for OTC. |
| 50 | +# openstack.cloud.os_router: |
| 51 | +# name: "{{ router_name }}" |
| 52 | +# state: present |
| 53 | +# network: admin_external_net |
| 54 | +# enable_snat: true |
| 55 | +# interfaces: |
| 56 | +# - net: "{{ network.network.name }}" |
| 57 | +# subnet: "{{ subnet.subnet.name }}" |
| 58 | +# register: router |
| 59 | + |
| 60 | +# Exclusive mode guarantee that only explicitly passed rules are will take effect, and all of the |
| 61 | +# existing before will be deleted. To disable this behavior set Exclusive option as False |
| 62 | +- name: Create new security group |
| 63 | + opentelekomcloud.cloud.security_group: |
| 64 | + state: present |
| 65 | + name: "{{ security_group_name }}" |
| 66 | + description: "Security group for testing purposes" |
| 67 | + security_group_rules: |
| 68 | + - direction: "egress" |
| 69 | + ethertype: "IPv4" |
| 70 | + protocol: "tcp" |
| 71 | + - direction: "egress" |
| 72 | + ethertype: "IPv6" |
| 73 | + - direction: "ingress" |
| 74 | + ethertype: "IPv4" |
| 75 | + protocol: "tcp" |
| 76 | + port_range_max: 22 |
| 77 | + port_range_min: 22 |
| 78 | + exclusive: true |
| 79 | + register: secgroup |
| 80 | + tags: |
| 81 | + - security_group |
| 82 | + |
| 83 | +- name: Create first ECS and attach it to the resources |
| 84 | + openstack.cloud.server: |
| 85 | + name: "{{ ecs1_name }}" |
| 86 | + image: "{{ ecs_image }}" |
| 87 | + network: "{{ newvpc.vpc.id }}" |
| 88 | + flavor: "s3.medium.1" |
| 89 | + availability_zone: "eu-de-01" |
| 90 | + volume_size: 6 |
| 91 | + security_groups: "{{ security_group_name }}" |
| 92 | + auto_ip: false |
| 93 | + state: present |
| 94 | + register: ecs1 |
| 95 | + tags: |
| 96 | + - server1 |
| 97 | + |
| 98 | +- name: Create second ECS and attach it to the resources |
| 99 | + openstack.cloud.server: |
| 100 | + name: "{{ ecs2_name }}" |
| 101 | + image: "{{ ecs_image }}" |
| 102 | + network: "{{ newvpc.vpc.id }}" |
| 103 | + flavor: "s3.medium.1" |
| 104 | + availability_zone: "eu-de-01" |
| 105 | + volume_size: 6 |
| 106 | + security_groups: "{{ security_group_name }}" |
| 107 | + auto_ip: false |
| 108 | + state: present |
| 109 | + register: ecs2 |
| 110 | + tags: |
| 111 | + - server2 |
0 commit comments