Skip to content

Commit

Permalink
Merge branch 'master' into dns-zone
Browse files Browse the repository at this point in the history
  • Loading branch information
gtema authored Nov 11, 2022
2 parents 5e4f101 + 7984903 commit 070f58d
Show file tree
Hide file tree
Showing 205 changed files with 14,298 additions and 1,686 deletions.
10 changes: 10 additions & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
parseable: true
exclude_paths:
- ci/playbooks
skip_list:
- '106' # Role name does not match ``^[a-z][a-z0-9_]+$`` pattern
- '204' # Lines should be no longer than 160 chars
- '301' # Commands should not change things if nothing needs doing
- '701' # No 'galaxy_info' found\
- 'var-spacing' # Jinja2 variables and filters should have spaces before and after.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,10 @@ importer_result.json
**.swp

*.tar.gz
doc/build
tmp

#idea
.idea/**
*/.idea/**

3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ all dependencies:
debug:
var: gw.nat_gateways
```
[Here](https://github.com/opentelekomcloud/ansible-collection-cloud/tree/master/examples) you can
find some [examples](https://github.com/opentelekomcloud/ansible-collection-cloud/tree/master/examples) of using OTC collection. All
the examples are based on real usecases, and contains some tips and tricks.
Run the playbook to verify the functionality:
Expand Down
29 changes: 29 additions & 0 deletions changelogs/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
changelog_filename_template: ../CHANGELOG.rst
changelog_filename_version_depth: 0
changes_file: changelog.yaml
changes_format: combined
keep_fragments: false
mention_ancestor: true
new_plugins_after_name: removed_features
notesdir: fragments
prelude_section_name: release_summary
prelude_section_title: Release Summary
sections:
- - major_changes
- Major Changes
- - minor_changes
- Minor Changes
- - breaking_changes
- Breaking Changes
- - deprecated_features
- Deprecated Features
- - removed_features
- Removed Features (previously deprecated)
- - security_fixes
- Security Fixes
- - bugfixes
- Bugfixes
- - known_issues
- Known Issues
title: opentelekomcloud.cloud
trivial_section_name: trivial
File renamed without changes.
2 changes: 2 additions & 0 deletions changelogs/fragments/initialize.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
major_changes:
- initializing changelog handling
68 changes: 68 additions & 0 deletions doc/examples/10_relation_database.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
---

# First of all, let's choose type and version of DB of an RDS instance. For example, we want it
# to be a MySQL (besides that you can choose postgresql or sqlserver on Microsoft) in HA (or single or replica) mode
- name: Get info about choosen type of DB
opentelekomcloud.cloud.rds_flavor_info:
datastore: "mysql"
instance_mode: "ha"
register: rds_flavors

# In this debug you can see all the flavors of the chosen DB type, and now you can decide what
# flavor exactly fits your needs
- name: debug
ansible.builtin.debug:
msg: "{{ rds_flavors.rds_flavors[0].name }}"

# Now let's create RDS instance. You can locate it in two or more availability zones.
# Password you pass to the module handles in secure mode: this means that it won't be shown in
# module's output. Please pay attention that automatic backup strategy is setting here, too.
# Attribute 'cmk_id' needed for system encryption, has been created beforehand.
- name: Create RDS instance
opentelekomcloud.cloud.rds_instance:
name: "{{ rds_instance_name }}"
state: present
region: "eu-de"
availability_zone: "eu-de-01,eu-de-02"
datastore_type: "mysql"
datastore_version: "8.0"
flavor: "{{ rds_flavors.rds_flavors[0].name }}"
ha_mode: "semisync"
router: "{{ router }}"
network: "{{ network_id }}"
port: 8080
security_group: "{{ secgroup_id }}"
password: "{{ password }}"
volume_type: "ultrahigh"
volume_size: 40
disk_encryption: "{{ cmk_id }}"
backup_keepdays: 1
backup_timeframe: "02:00-03:00"
wait: true
timeout: 777
register: rds

# With this info module you can get info about your instance
- name: Let's get info about whole RDS instance
opentelekomcloud.cloud.rds_instance_info:
name: "{{ rds.instance.name }}"

- name: Let's get info about datastore
opentelekomcloud.cloud.rds_datastore_info:
name: "{{ rds.instance.id }}"

- name: Now create backup of the created instance
opentelekomcloud.cloud.rds_backup:
instance: "{{ rds.instance.id }}"
name: "{{ rds_backup_name }}"
state: present
description: "Backup of the RDS instance"
wait: true
register: rds_bckp

# Queirying RDS backup info. You can use any of specified attributes, together or separetely.
- name: Get RDS backup info
opentelekomcloud.cloud.rds_backup_info:
instance: "{{ rds.instance.id }}"
backup: "{{ rds_bckp.backup.id }}"
backup_type: "{{ rds_bckp.backup.type }}"
111 changes: 111 additions & 0 deletions doc/examples/1_initial_infra.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
---

# First, we need to create ecosystem for further infrastructure. Its include network entities, such
# VPC and subnet, security group and couple of ECSs.
- name: Create VPC
opentelekomcloud.cloud.vpc:
name: "{{ vpc_name }}"
cidr: "10.10.0.0/24"
state: present
register: newvpc
tags:
- vpc

# Please pay attention on CIDR block: in case of insufficient numbers of available hosts there
# could be errors in autoscaling groups behavior
- name: Create subnet for VPC
opentelekomcloud.cloud.subnet:
name: "{{ vpc_subnet_name }}"
vpc: "{{ vpc_name }}"
cidr: "10.10.0.0/27"
gateway_ip: "10.10.0.1"
dns_list:
- "100.125.4.25"
- "100.125.129.199"
register: sn
tags:
- subnet

# There are a few mismatches in resources logic and naming between native Openstack and
# Opentelekomcloud. To make it clear we placed examples using native Openstack resources.
#
# - name: Create network. In Open Telekom Cloud infrastructure this entity is hidden inside
# Subnet summary, and isn't create separately, but only querying from the existing Subnet.
# openstack.cloud.os_network:
# name: "{{ network_name }}"
# state: present
# register: network
#
# - name: Create subnet. Openstack's Subnet is equal Open Telekom Cloud Subnet.
# openstack.cloud.os_subnet:
# name: "{{ subnet_name }}"
# state: present
# network_name: "{{ network.network.name }}"
# cidr: "192.168.110.0/24"
# dns_nameservers: "{{ ['100.125.4.25', '8.8.8.8'] }}"
# register: subnet
#
# - name: Create router. In Open Telekom Cloud terms it's a VPC. Please pay attention that
# Network argument here is not an Network created on previous step, but constanta for OTC.
# openstack.cloud.os_router:
# name: "{{ router_name }}"
# state: present
# network: admin_external_net
# enable_snat: true
# interfaces:
# - net: "{{ network.network.name }}"
# subnet: "{{ subnet.subnet.name }}"
# register: router

# Exclusive mode guarantee that only explicitly passed rules are will take effect, and all of the
# existing before will be deleted. To disable this behavior set Exclusive option as False
- name: Create new security group
opentelekomcloud.cloud.security_group:
state: present
name: "{{ security_group_name }}"
description: "Security group for testing purposes"
security_group_rules:
- direction: "egress"
ethertype: "IPv4"
protocol: "tcp"
- direction: "egress"
ethertype: "IPv6"
- direction: "ingress"
ethertype: "IPv4"
protocol: "tcp"
port_range_max: 22
port_range_min: 22
exclusive: true
register: secgroup
tags:
- security_group

- name: Create first ECS and attach it to the resources
openstack.cloud.server:
name: "{{ ecs1_name }}"
image: "{{ ecs_image }}"
network: "{{ newvpc.vpc.id }}"
flavor: "s3.medium.1"
availability_zone: "eu-de-01"
volume_size: 6
security_groups: "{{ security_group_name }}"
auto_ip: false
state: present
register: ecs1
tags:
- server1

- name: Create second ECS and attach it to the resources
openstack.cloud.server:
name: "{{ ecs2_name }}"
image: "{{ ecs_image }}"
network: "{{ newvpc.vpc.id }}"
flavor: "s3.medium.1"
availability_zone: "eu-de-01"
volume_size: 6
security_groups: "{{ security_group_name }}"
auto_ip: false
state: present
register: ecs2
tags:
- server2
30 changes: 30 additions & 0 deletions doc/examples/2_volume_backup_and_maintenance.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---

# You're able to backup both types of disks: system and additionally attached. Cloud Server
# Backups will be cover in a next examples
- name: Create a backup of the system volume
opentelekomcloud.cloud.volume_backup:
display_name: "{{ backup_name }}"
display_description: "Full backup of the test instance"
state: absent
volume: "{{ ecs_1_vol }}"
force: true
wait: true
timeout: 123
register: bckp
tags:
- volume_backup

- name: Let's check whether we have a backup of the ECS volume
opentelekomcloud.cloud.volume_backup_info:
volume: "{{ ecs_1_vol }}"
tags: backup_info

# Snapshot is mandatory for any kind of backup, both full or incremental. If there are no any
# backups created before, and current backup is the first one for this volume, snapshot will be
# create automatically.
- name: Check if we have a snapshot
opentelekomcloud.cloud.volume_snapshot_info:
name: "yet_another**"
tags:
- snapshot_info
85 changes: 85 additions & 0 deletions doc/examples/3_autoscaling.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
---

# Keypair is mandatory condition for creating and modifying AS configurations and groups. Be avoid
# of accidental deleting of this entity, because in this case you'll lost control on your AS
# entities.
- name: Create new keypair for accessing AS config
openstack.cloud.keypair:
name: "{{ keypair_name }}"
register: kp
tags:
- create_keypair

# You're able to create a new AS config based on existing ECS, using it as a template. For this,
# point ECS's id as a parameter. Here is example of a new AS config, taken from scratch.
- name: Create new AS config
opentelekomcloud.cloud.as_config:
scaling_configuration: "{{ as_new_config_name }}"
key_name: "{{ keypair_name }}"
image: "Standard_CentOS_7_latest"
flavor: "s3.medium.1"
disk:
- size: 10
volume_type: 'SAS'
disk_type: 'SYS'
register: as_config_new
tags:
- create_as_config

# Please pay attention to numbers of desiring instances. It should fall within range given in CIDR
# block of attaching subnet. Router parameter points to VPC ID.
- name: Create AS Group
opentelekomcloud.cloud.as_group:
scaling_group:
name: "{{ as_group_name }}"
scaling_configuration: "{{ as_config_new.as_config.name }}"
min_instance_number: 0
desire_instance_number: 2
max_instance_number: 4
availability_zones: ["eu-de-01"]
networks: [{"id": "{{ network_id }}"}]
security_groups: [{"id": "{{ secgroup_id }}"}]
router: "{{ router }}"
delete_publicip: true
delete_volume: true
action: "resume"
state: "present"
wait: true
timeout: 400
register: as_group
tags:
- create_as_group

- name: Rename AS group
opentelekomcloud.cloud.as_group:
scaling_group:
id: "{{ as_group.as_group.id }}"
name: "{{ new_as_group_name }}"
max_instance_number: 4
register: as_group_new

- name: Get list of AS instances using AS group id
opentelekomcloud.cloud.as_instance_info:
scaling_group: "{{ as_group_new.as_group.id }}"
register: as_inst_list
tags:
- get_list

# Besides creating instances directly from AS group module, you can add already existing ECSs to the
# AS group. Please pay attention that instances to be added must be in the same AZ as AS group.
- name: Add AS instances to the AS group
opentelekomcloud.cloud.as_instance:
scaling_group: "{{ as_group_new.as_group.id }}"
scaling_instances:
- "{{ ecs1.server.id }}"
- "{{ ecs2.server.id }}"
action: "add"
state: present
register: as_instances
tags:
- add_instances

- name: Get list of AS Instances after adding new instances
opentelekomcloud.cloud.as_instance_info:
scaling_group: "{{ as_group.as_group.id }}"
register: as_inst_list_af
Loading

0 comments on commit 070f58d

Please sign in to comment.