Skip to content

Commit 070f58d

Browse files
authored
Merge branch 'master' into dns-zone
2 parents 5e4f101 + 7984903 commit 070f58d

File tree

205 files changed

+14298
-1686
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

205 files changed

+14298
-1686
lines changed

.ansible-lint

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
parseable: true
3+
exclude_paths:
4+
- ci/playbooks
5+
skip_list:
6+
- '106' # Role name does not match ``^[a-z][a-z0-9_]+$`` pattern
7+
- '204' # Lines should be no longer than 160 chars
8+
- '301' # Commands should not change things if nothing needs doing
9+
- '701' # No 'galaxy_info' found\
10+
- 'var-spacing' # Jinja2 variables and filters should have spaces before and after.

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,10 @@ importer_result.json
1010
**.swp
1111

1212
*.tar.gz
13+
doc/build
14+
tmp
15+
16+
#idea
17+
.idea/**
18+
*/.idea/**
19+

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ all dependencies:
116116
debug:
117117
var: gw.nat_gateways
118118
```
119+
[Here](https://github.com/opentelekomcloud/ansible-collection-cloud/tree/master/examples) you can
120+
find some [examples](https://github.com/opentelekomcloud/ansible-collection-cloud/tree/master/examples) of using OTC collection. All
121+
the examples are based on real usecases, and contains some tips and tricks.
119122
120123
Run the playbook to verify the functionality:
121124

changelogs/config.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
changelog_filename_template: ../CHANGELOG.rst
2+
changelog_filename_version_depth: 0
3+
changes_file: changelog.yaml
4+
changes_format: combined
5+
keep_fragments: false
6+
mention_ancestor: true
7+
new_plugins_after_name: removed_features
8+
notesdir: fragments
9+
prelude_section_name: release_summary
10+
prelude_section_title: Release Summary
11+
sections:
12+
- - major_changes
13+
- Major Changes
14+
- - minor_changes
15+
- Minor Changes
16+
- - breaking_changes
17+
- Breaking Changes
18+
- - deprecated_features
19+
- Deprecated Features
20+
- - removed_features
21+
- Removed Features (previously deprecated)
22+
- - security_fixes
23+
- Security Fixes
24+
- - bugfixes
25+
- Bugfixes
26+
- - known_issues
27+
- Known Issues
28+
title: opentelekomcloud.cloud
29+
trivial_section_name: trivial
File renamed without changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
major_changes:
2+
- initializing changelog handling
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
---
2+
3+
# First of all, let's choose type and version of DB of an RDS instance. For example, we want it
4+
# to be a MySQL (besides that you can choose postgresql or sqlserver on Microsoft) in HA (or single or replica) mode
5+
- name: Get info about choosen type of DB
6+
opentelekomcloud.cloud.rds_flavor_info:
7+
datastore: "mysql"
8+
instance_mode: "ha"
9+
register: rds_flavors
10+
11+
# In this debug you can see all the flavors of the chosen DB type, and now you can decide what
12+
# flavor exactly fits your needs
13+
- name: debug
14+
ansible.builtin.debug:
15+
msg: "{{ rds_flavors.rds_flavors[0].name }}"
16+
17+
# Now let's create RDS instance. You can locate it in two or more availability zones.
18+
# Password you pass to the module handles in secure mode: this means that it won't be shown in
19+
# module's output. Please pay attention that automatic backup strategy is setting here, too.
20+
# Attribute 'cmk_id' needed for system encryption, has been created beforehand.
21+
- name: Create RDS instance
22+
opentelekomcloud.cloud.rds_instance:
23+
name: "{{ rds_instance_name }}"
24+
state: present
25+
region: "eu-de"
26+
availability_zone: "eu-de-01,eu-de-02"
27+
datastore_type: "mysql"
28+
datastore_version: "8.0"
29+
flavor: "{{ rds_flavors.rds_flavors[0].name }}"
30+
ha_mode: "semisync"
31+
router: "{{ router }}"
32+
network: "{{ network_id }}"
33+
port: 8080
34+
security_group: "{{ secgroup_id }}"
35+
password: "{{ password }}"
36+
volume_type: "ultrahigh"
37+
volume_size: 40
38+
disk_encryption: "{{ cmk_id }}"
39+
backup_keepdays: 1
40+
backup_timeframe: "02:00-03:00"
41+
wait: true
42+
timeout: 777
43+
register: rds
44+
45+
# With this info module you can get info about your instance
46+
- name: Let's get info about whole RDS instance
47+
opentelekomcloud.cloud.rds_instance_info:
48+
name: "{{ rds.instance.name }}"
49+
50+
- name: Let's get info about datastore
51+
opentelekomcloud.cloud.rds_datastore_info:
52+
name: "{{ rds.instance.id }}"
53+
54+
- name: Now create backup of the created instance
55+
opentelekomcloud.cloud.rds_backup:
56+
instance: "{{ rds.instance.id }}"
57+
name: "{{ rds_backup_name }}"
58+
state: present
59+
description: "Backup of the RDS instance"
60+
wait: true
61+
register: rds_bckp
62+
63+
# Queirying RDS backup info. You can use any of specified attributes, together or separetely.
64+
- name: Get RDS backup info
65+
opentelekomcloud.cloud.rds_backup_info:
66+
instance: "{{ rds.instance.id }}"
67+
backup: "{{ rds_bckp.backup.id }}"
68+
backup_type: "{{ rds_bckp.backup.type }}"

doc/examples/1_initial_infra.yaml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
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
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
3+
# You're able to backup both types of disks: system and additionally attached. Cloud Server
4+
# Backups will be cover in a next examples
5+
- name: Create a backup of the system volume
6+
opentelekomcloud.cloud.volume_backup:
7+
display_name: "{{ backup_name }}"
8+
display_description: "Full backup of the test instance"
9+
state: absent
10+
volume: "{{ ecs_1_vol }}"
11+
force: true
12+
wait: true
13+
timeout: 123
14+
register: bckp
15+
tags:
16+
- volume_backup
17+
18+
- name: Let's check whether we have a backup of the ECS volume
19+
opentelekomcloud.cloud.volume_backup_info:
20+
volume: "{{ ecs_1_vol }}"
21+
tags: backup_info
22+
23+
# Snapshot is mandatory for any kind of backup, both full or incremental. If there are no any
24+
# backups created before, and current backup is the first one for this volume, snapshot will be
25+
# create automatically.
26+
- name: Check if we have a snapshot
27+
opentelekomcloud.cloud.volume_snapshot_info:
28+
name: "yet_another**"
29+
tags:
30+
- snapshot_info

doc/examples/3_autoscaling.yaml

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
3+
# Keypair is mandatory condition for creating and modifying AS configurations and groups. Be avoid
4+
# of accidental deleting of this entity, because in this case you'll lost control on your AS
5+
# entities.
6+
- name: Create new keypair for accessing AS config
7+
openstack.cloud.keypair:
8+
name: "{{ keypair_name }}"
9+
register: kp
10+
tags:
11+
- create_keypair
12+
13+
# You're able to create a new AS config based on existing ECS, using it as a template. For this,
14+
# point ECS's id as a parameter. Here is example of a new AS config, taken from scratch.
15+
- name: Create new AS config
16+
opentelekomcloud.cloud.as_config:
17+
scaling_configuration: "{{ as_new_config_name }}"
18+
key_name: "{{ keypair_name }}"
19+
image: "Standard_CentOS_7_latest"
20+
flavor: "s3.medium.1"
21+
disk:
22+
- size: 10
23+
volume_type: 'SAS'
24+
disk_type: 'SYS'
25+
register: as_config_new
26+
tags:
27+
- create_as_config
28+
29+
# Please pay attention to numbers of desiring instances. It should fall within range given in CIDR
30+
# block of attaching subnet. Router parameter points to VPC ID.
31+
- name: Create AS Group
32+
opentelekomcloud.cloud.as_group:
33+
scaling_group:
34+
name: "{{ as_group_name }}"
35+
scaling_configuration: "{{ as_config_new.as_config.name }}"
36+
min_instance_number: 0
37+
desire_instance_number: 2
38+
max_instance_number: 4
39+
availability_zones: ["eu-de-01"]
40+
networks: [{"id": "{{ network_id }}"}]
41+
security_groups: [{"id": "{{ secgroup_id }}"}]
42+
router: "{{ router }}"
43+
delete_publicip: true
44+
delete_volume: true
45+
action: "resume"
46+
state: "present"
47+
wait: true
48+
timeout: 400
49+
register: as_group
50+
tags:
51+
- create_as_group
52+
53+
- name: Rename AS group
54+
opentelekomcloud.cloud.as_group:
55+
scaling_group:
56+
id: "{{ as_group.as_group.id }}"
57+
name: "{{ new_as_group_name }}"
58+
max_instance_number: 4
59+
register: as_group_new
60+
61+
- name: Get list of AS instances using AS group id
62+
opentelekomcloud.cloud.as_instance_info:
63+
scaling_group: "{{ as_group_new.as_group.id }}"
64+
register: as_inst_list
65+
tags:
66+
- get_list
67+
68+
# Besides creating instances directly from AS group module, you can add already existing ECSs to the
69+
# AS group. Please pay attention that instances to be added must be in the same AZ as AS group.
70+
- name: Add AS instances to the AS group
71+
opentelekomcloud.cloud.as_instance:
72+
scaling_group: "{{ as_group_new.as_group.id }}"
73+
scaling_instances:
74+
- "{{ ecs1.server.id }}"
75+
- "{{ ecs2.server.id }}"
76+
action: "add"
77+
state: present
78+
register: as_instances
79+
tags:
80+
- add_instances
81+
82+
- name: Get list of AS Instances after adding new instances
83+
opentelekomcloud.cloud.as_instance_info:
84+
scaling_group: "{{ as_group.as_group.id }}"
85+
register: as_inst_list_af

0 commit comments

Comments
 (0)