### Get Load Balancer Information Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Retrieves information about a specified load balancer. This module is useful for verifying the configuration and status of a load balancer after creation or modification. ```yaml - name: Get info about specified load balancer opentelekomcloud.cloud.loadbalancer_info: name: "{{ lb_name }}" register: lb_info ``` -------------------------------- ### Get Auto-Scaling Instance Info using opentelekomcloud.cloud.as_instance_info Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Queries and retrieves information about instances within a specified Auto-Scaling (AS) group. This module is useful for monitoring the instances associated with an AS group after operations like adding new instances. ```yaml - 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 ``` -------------------------------- ### Create Python Virtual Environment and Install Dependencies Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/README.md Sets up a Python virtual environment named 'ansiblevenv', installs necessary system packages (gcc, libssl-dev, python3-dev), and then installs Python dependencies including wheel, ansible, and otcextensions using pip. ```bash sudo apt-get install python3-venv python3 -m venv ansiblevenv sudo apt-get install gcc libssl-dev python3-dev source ansiblevenv/bin/activate pip install wheel ansible otcextensions ``` -------------------------------- ### Get AS Policy Info using opentelekomcloud.cloud.as_policy_info Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md This module retrieves information about Auto Scaling (AS) policies. You can query policies by providing the scaling group name or ID. This is useful for inspecting existing policies and their configurations. ```yaml - name: Get list of AS Policies opentelekomcloud.cloud.as_policy_info: scaling_group: "{{ as_group_name }}" register: as_policies ``` -------------------------------- ### Get Load Balancer Listener Information Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Retrieves information about a specified load balancer listener. This module is useful for checking the configuration and status of a listener, including its protocol and port. ```yaml - name: Get info about specified litener opentelekomcloud.cloud.lb_listener_info: name: "{{ listener_https_name }}" register: listener_https_info ``` -------------------------------- ### Create CSS Cluster Snapshot Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Creates a snapshot of a CSS cluster. Supports backing up all indices or specific indices using a wildcard. Requires cluster ID and snapshot name. ```yaml - name: Create snapshot of the cluster opentelekomcloud.cloud.css_snapshot: cluster: "{{ css_cluster.id }}" name: "{{ css_snapshot_name }}" description: "Example snapshot of the CSS cluster" state: present indices: "yetanother*" register: css_snapshot ``` -------------------------------- ### Create Keypair using openstack.cloud.keypair Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Creates a new keypair, which is essential for accessing and managing AS configurations and groups. It's important to avoid accidental deletion of keypairs to maintain control over AS entities. Requires a name for the keypair. ```yaml - name: Create new keypair for accessing AS config openstack.cloud.keypair: name: "{{ keypair_name }}" register: kp tags: - create_keypair ``` -------------------------------- ### Query DDS Datastore Versions Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Queries the supported datastore versions for DDS. Currently, only 'DDS-Community' is supported. This is essential for configuring DDS instances. ```yaml - name: Query database version opentelekomcloud.cloud.dds_datastore_info: datastore_name: "DDS-Community" register: dds_ds ``` -------------------------------- ### Get RDS Flavor Information Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Fetches information about available RDS flavors for a given datastore type and instance mode. This helps in selecting the appropriate flavor for an RDS instance. ```yaml - name: Get info about choosen type of DB opentelekomcloud.cloud.rds_flavor_info: datastore: "mysql" instance_mode: "ha" register: rds_flavors ``` -------------------------------- ### Get CSS Cluster Snapshot Info Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Retrieves information about CSS snapshots. This module can be used to query details of existing snapshots within a specified cluster. ```yaml - name: Get info about CSS snapshot opentelekomcloud.cloud.css_snapshot_info: cluster: "{{ css_cluster.id }}" ``` -------------------------------- ### Get Load Balancer Certificate Information Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Retrieves information about a specified load balancer certificate. This module helps in verifying certificate details used for secure HTTPS listeners. ```yaml - name: Get info about specified certificate opentelekomcloud.cloud.lb_certificate_info: name: "elb_https_cert" register: elb_cert_info ``` -------------------------------- ### Create RDS Instance Backup Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Manually creates a backup of an RDS instance. Requires the instance ID and a name for the backup. Supports waiting for the backup operation to complete. ```yaml - name: Create backup of the 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 ``` -------------------------------- ### Get Alarm Infos using opentelekomcloud.cloud.ces_alarms_info Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md This module retrieves information about a specific alarm by providing its name. The output is registered for further use. ```yaml - name: Get Alarm Infos opentelekomcloud.cloud.ces_alarms_info: name: "{{ alarm_name }}" register: ces_al_info ``` -------------------------------- ### Get RDS Instance Info Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Fetches detailed information about a specific RDS instance, identified by its name. This module allows querying the configuration and status of an RDS instance. ```yaml - name: Let's get info about whole RDS instance opentelekomcloud.cloud.rds_instance_info: name: "{{ rds.instance.name }}" ``` -------------------------------- ### Create VPC using opentelekomcloud.cloud.vpc Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md This task creates a Virtual Private Cloud (VPC) with a specified name and CIDR block. It ensures the VPC is present in the infrastructure. The output is registered for potential use in subsequent tasks. ```yaml - name: Create VPC opentelekomcloud.cloud.vpc: name: "{{ vpc_name }}" cidr: "10.10.0.0/24" state: present register: newvpc tags: - vpc ``` -------------------------------- ### Get RDS Datastore Info Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Retrieves information about a specific RDS datastore, identified by its name. This module is useful for querying details about supported datastores. ```yaml - name: Let's get info about datastore opentelekomcloud.cloud.rds_datastore_info: name: "{{ rds.instance.id }}" ``` -------------------------------- ### Get RDS Backup Info Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Queries information about RDS backups. Can filter by instance ID, backup ID, and backup type to retrieve specific backup details. ```yaml - 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 }}" ``` -------------------------------- ### Create Load Balancer Certificate Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Integrates public and private keys to create a certificate for an HTTPS listener. The public and private keys must be obtained from third-party resources (e.g., Letsencrypt) and placed in a location accessible by Ansible. ```yaml - name: Create certificate for HTTPS connections opentelekomcloud.cloud.lb_certificate: name: "elb_https_cert" type: "server" content: "/home/user/files/rootCA.pem" private_key: "/home/user/files/rootCA.key" register: elb_cert ``` -------------------------------- ### Get DDS Cluster Info using opentelekomcloud.cloud.dds_instance_info Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md This Ansible task retrieves information about an existing DDS cluster. It requires the instance name as a parameter. This module is useful for verifying the status and details of a DDS cluster after its creation, which typically takes about 15 minutes. ```yaml - name: Get info about DDS cluster opentelekomcloud.cloud.dds_instance_info: instance: "{{ dds_instance_name }}" ``` -------------------------------- ### Get Volume Snapshot Info using opentelekomcloud.cloud.volume_snapshot_info Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Fetches information about volume snapshots. Snapshots are a prerequisite for backups. If no prior backups exist, a snapshot is automatically created for the first backup operation. This module requires a name to filter snapshots. ```yaml - name: Get info about volume shapshot opentelekomcloud.cloud.volume_snapshot_info: name: "yet_another**" tags: - snapshot_info ``` -------------------------------- ### Debug RDS Flavor Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md A simple debug task to display the name of the first available RDS flavor obtained from a previous query. ```yaml - name: debug ansible.builtin.debug: msg: "{{ rds_flavors.rds_flavors[0].name }}" ``` -------------------------------- ### Get Cloud Search Cluster Info using opentelekomcloud.cloud.css_cluster_info Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md This module allows querying information about a Cloud Search cluster using its name or ID. The retrieved information is registered for subsequent use. ```yaml - name: Get info about created cluster opentelekomcloud.cloud.css_cluster_info: name: "{{ css_cluster.id }}" register: css_info ``` -------------------------------- ### Create Router using native OpenStack module Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md This task creates a router using the native OpenStack module. In Open Telekom Cloud terminology, this corresponds to a VPC. The 'network' argument refers to an external network, not necessarily the one created in the previous step, and is a constant for OTC. It also configures interfaces for the router. ```yaml - name: Create router 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 ``` -------------------------------- ### Query DDS Flavors Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Queries available flavors for Document Database Service (DDS) in a specified region. This helps in selecting an appropriate flavor for a DDS cluster. ```yaml - name: Query info about flavors in region opentelekomcloud.cloud.dds_flavor_info: region: "eu-de" register: dds_flavor ``` -------------------------------- ### Install Ansible Collection opentelekomcloud.cloud Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/README.md Installs the opentelekomcloud.cloud Ansible collection using the ansible-galaxy command. This is a prerequisite for using the collection's modules. ```bash ansible-galaxy collection install opentelekomcloud.cloud ``` -------------------------------- ### Clone and Set Up Development Environment for Ansible Collection Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/README.md Guides developers on cloning the Ansible collection repository into a specific directory structure and exporting the ANSIBLE_COLLECTIONS_PATHS environment variable to make the development version available to Ansible. ```bash mkdir -p ~/ansible/ansible_collections/opentelekomcloud/ cd ~/ansible/ansible_collections/opentelekomcloud/ git clone git@github.com:opentelekomcloud/ansible-collection-cloud.git cloud pwd export ANSIBLE_COLLECTIONS_PATHS=/path/to/your/ansible/ansible_collections/ ``` -------------------------------- ### Create AS Policy using opentelekomcloud.cloud.as_policy Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md This module creates an Auto Scaling (AS) policy. It can be configured to trigger based on an alarm, on a schedule, or on a recurrence. Key parameters include the scaling group, policy name, policy type, and specific configurations for alarm-based or scheduled/recurrence policies. The state should be 'present' to create or ensure the policy exists. ```yaml - name: Create AS policy opentelekomcloud.cloud.as_policy: scaling_group: "{{ as_group_name }}" scaling_policy: "{{ as_policy_name }}" scaling_policy_type: "alarm" alarm: "{{ alarm_name }}" state: "present" register: as_policy ``` ```yaml - name: Create AS policy opentelekomcloud.cloud.as_policy: scaling_group: "{{ as_group_name }}" scaling_policy: "{{ as_policy_name }}" scaling_policy_type: "recurrence" scheduled_policy: recurrence_type: "weekly" recurrence_value: "7" launch_time: "01:00" start_time: "2022-08-27T00:00Z" scaling_policy_action: operation: "add" instance_number: "1" state: present register: as_policy ``` -------------------------------- ### Create Volume Backup using opentelekomcloud.cloud.volume_backup Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Creates a backup of a specified volume, either system or attached. The module supports waiting for the backup to complete and has a timeout parameter. It requires the volume name and can optionally take a display name and description. ```yaml - 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 ``` -------------------------------- ### Create Network and Subnet using native OpenStack modules Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md This snippet demonstrates creating a network and a subnet using native OpenStack modules. Note that Open Telekom Cloud's network concept is integrated within the subnet, unlike the separate creation in native OpenStack. The subnet creation mirrors the Open Telekom Cloud subnet functionality. ```yaml - name: Create network 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 ``` -------------------------------- ### Create Auto-Scaling Configuration using opentelekomcloud.cloud.as_config Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Creates a new Auto-Scaling (AS) configuration. This can be based on an existing ECS instance, using its ID as a template, or created from scratch. It requires parameters like scaling configuration name, key name, image, flavor, and disk details. ```yaml - 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 ``` -------------------------------- ### Get Load Balancer Pool Information Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Retrieves information about a specified backend server group (pool) associated with a load balancer. This module helps in verifying the pool's configuration, including its name, protocol, and algorithm. ```yaml - name: Get info about specified backend server group opentelekomcloud.cloud.lb_pool_info: name: "{{ backend_server_name }}" register: backend_group_info ``` -------------------------------- ### Add Instances to Auto-Scaling Group using opentelekomcloud.cloud.as_instance Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Adds existing ECS instances to an Auto-Scaling (AS) group. The instances must reside in the same Availability Zone as the AS group. This module requires the scaling group ID and a list of scaling instance IDs, along with the action 'add' and state 'present'. ```yaml - 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 ``` -------------------------------- ### Get Volume Backup Info using opentelekomcloud.cloud.volume_backup_info Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Retrieves information about a volume backup associated with a specific volume. This module is useful for checking the status or details of existing backups. It requires the volume name as input. ```yaml - name: Get info about volume backup opentelekomcloud.cloud.volume_backup_info: volume: "{{ ecs_1_vol }}" tags: backup_info ``` -------------------------------- ### Get CCE Cluster Certificate Info Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Retrieves information about a CCE cluster's X.509 certificates. This requires obtaining and downloading the cluster's certificate (client.key, client.crt, ca.crt) from the web console beforehand. ```yaml - name: Get info about cluster certificate opentelekomcloud.cloud.cce_cluster_cert_info: cluster: "{{ cluster.cce_cluster.id }}" ``` -------------------------------- ### Check AS Quotas using opentelekomcloud.cloud.as_quota_info Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md This module queries the total and used quotas for various Auto Scaling (AS) resources, including groups, configurations, bandwidth scaling policies, AS policies, and instances. It requires the scaling group ID to fetch the relevant quota information for a specified tenant. ```yaml - name: Check AS group quotas opentelekomcloud.cloud.as_quota_info: scaling_group_id: "{{ scaling_group_id }}" ``` -------------------------------- ### Create Load Balancer Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Creates a load balancer that can be attached to ECS instances. It supports automatic public IP assignment and requires specifying the VIP subnet name. ```yaml - name: Create loadbalancer for cluster opentelekomcloud.cloud.loadbalancer: state: present auto_public_ip: true name: "{{ lb_name }}" vip_subnet: "{{ vpc_subnet_name }}" register: lb ``` -------------------------------- ### Get Load Balancer Health Monitor Information Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Retrieves information about health checks configured for a load balancer. This module allows fetching details about health monitors, such as their type and associated pool. ```yaml - name: Get info about health checks for HTTP protocol opentelekomcloud.cloud.lb_healthmonitor_info: type: http register: https_health_info ``` -------------------------------- ### Create Load Balancer Backend Server Group Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Creates a backend server group (pool) for a load balancer. This module allows specifying the protocol (e.g., http) and load balancing algorithm (e.g., round_robin). It associates the pool with a specific listener and load balancer. ```yaml - name: Create backend server group opentelekomcloud.cloud.lb_pool: state: present name: "{{ backend_server_name }}" protocol: http lb_algorithm: round_robin listener: "{{ listener_https }}" loadbalancer: "{{ lb.loadbalancer.id }}" register: backend ``` -------------------------------- ### Create ELB Watchdog Alarm using opentelekomcloud.cloud.ces_alarms Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md This task sets up a watchdog alarm for ELB to monitor upstream 5xx errors. It requires the alarm name, ELB-specific metric details, and condition parameters. The SMN topic must be created beforehand. ```yaml - name: Create watchdog alarm for Load Balancer opentelekomcloud.cloud.ces_alarms: alarm_name: "lb_watchdog" state: present metric: namespace: "SYS.ELB" dimensions: - name: "lbaas_instance_id" value: "{{ elb_id }}" metric_name: "m16_l7_upstream_5xx" condition: period: 300 filter: average comparison_operator: ">=" value: 5 unit: "Count/s" count: 1 alarm_enabled: true alarm_action_enabled: true alarm_actions: - type: "notification" notificationList: "urn:smn:eu-de:5dd3c0b24cdc4d31952c49589182a89d:yet_another_topic" register: elb_5xx_alarm ``` -------------------------------- ### Install OTC Ansible Collection and Dependencies Source: https://context7.com/opentelekomcloud/ansible-collection-cloud/llms.txt Installs the Open Telekom Cloud Ansible Collection from Ansible Galaxy and its required Python dependencies using pip. ```bash # Install the collection ansible-galaxy collection install opentelekomcloud.cloud # Install required Python dependencies pip install wheel ansible otcextensions ``` -------------------------------- ### Create HTTPS Load Balancer Listener Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Creates a listener for HTTPS traffic on a specified port for a load balancer. It requires the load balancer ID and a TLS container reference for secure connections. Ensure the subnet's address pool is sufficient for all instances and the listener. ```yaml - name: Create listener for HTTPS traffic opentelekomcloud.cloud.lb_listener: name: "{{ listener_https_name }}" protocol: terminated_https protocol_port: 443 loadbalancer: "{{ lb.loadbalancer.id }}" default_tls_container_ref: "{{ elb_cert.elb_certificate.id }}" register: listener_https ``` -------------------------------- ### Create Cloud Search Cluster using opentelekomcloud.cloud.css_cluster Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md This task creates a Cloud Search cluster with specified configurations, including flavor, instance number, datastore version, and volume details. It also handles encryption and backup settings. The CMK ID and password must be pre-configured. ```yaml - name: Create Cloud Search cluster opentelekomcloud.cloud.css_cluster: name: "{{ css_cluster_name }}" state: present flavor: "{{ css_flavour }}" instance_num: 1 datastore_version: "7.6.2" datastore_type: "elasticsearch" volume_type: "common" volume_size: 40 system_encrypted: 1 system_cmkid: "{{ cmk_id }}" https_enable: false authority_enable: false admin_pwd: "{{ password }}" router: "{{ router }}" net: "{{ network_id }}" security_group: "{{ secgroup_id }}" backup_period: "00:00 GMT+03:00" backup_prefix: "yetanother" backup_keepday: 1 register: css_cluster ``` -------------------------------- ### Create Cloud Eye Alarms Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Creates alarms using OpenTelekomCloud's Cloud Eye service to monitor infrastructure resources. This module requires specifying alarm names, dimensions, and metric names, which are often found in the service's user guide. A pre-created SMN topic is necessary for alarm notifications. ```yaml - name: Create several alarms to watch our infrastructure opentelekomcloud.cloud.ces_alarms: alarm_name: "my_alarm_name" dimensions: "metric_name=cpu_util,instance_id=xxx" metric_name: "cpu_util" namespace: "SYS.ECS" smn_topic: "my_smn_topic_urn" comparison_operator: ">" threshold: 80 period: 300 statistic: "average" suppression_window: 60 alarm_description: "High CPU utilization alarm" state: "ALARMING" ok_actions: - "my_smn_topic_urn" alarm_actions: - "my_smn_topic_urn" insufficiency_actions: - "my_smn_topic_urn" ``` -------------------------------- ### Create RDS Instance Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Creates an RDS instance with specified configurations including region, availability zone, datastore type and version, flavor, HA mode, network, security group, and volume details. Supports automatic backup and disk encryption. The 'cmk_id' for system encryption must be created beforehand. ```yaml - 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 ``` -------------------------------- ### Create Subnet using opentelekomcloud.cloud.subnet Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md This task creates a subnet within an existing VPC, specifying the subnet's name, VPC association, CIDR block, gateway IP, and DNS server list. It's crucial to ensure sufficient host availability in the CIDR block to avoid autoscaling issues. The result is registered for later use. ```yaml - 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 ``` -------------------------------- ### Create and Manage DNS Zones with Ansible Source: https://context7.com/opentelekomcloud/ansible-collection-cloud/llms.txt This snippet demonstrates how to create public and private DNS zones using the `opentelekomcloud.cloud.dns_zone` Ansible module. It includes examples for creating a public zone with specific TTL and email, and a private zone associated with a VPC router. It also shows how to retrieve DNS zone information using `opentelekomcloud.cloud.dns_zone_info`. Dependencies include the `opentelekomcloud.cloud` collection. ```yaml --- - hosts: localhost tasks: # Create public DNS zone - name: Create public DNS zone opentelekomcloud.cloud.dns_zone: name: "example.com." state: present zone_type: public description: "Public zone for example.com" ttl: 300 email: "admin@example.com" register: public_zone # Create private DNS zone - name: Create private DNS zone opentelekomcloud.cloud.dns_zone: name: "internal.local." state: present zone_type: private router: "{{ vpc_id }}" description: "Private zone for internal services" ttl: 300 email: "admin@internal.local" register: private_zone # Get zone info - name: Get DNS zone info opentelekomcloud.cloud.dns_zone_info: zone_type: "private" register: zones ``` -------------------------------- ### Create ECS using openstack.cloud.server Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md This task provisions an Elastic Cloud Server (ECS) using the native OpenStack module. It specifies the ECS name, image, network (VPC ID), flavor, availability zone, volume size, security groups, and whether to auto-assign an IP. The created ECS details are registered. ```yaml - 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 ``` ```yaml - 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 ``` -------------------------------- ### Create CCE Node Pool Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Creates a node pool within a CCE cluster to manage worker nodes. It allows configuration of autoscaling, data volumes, flavors, networking, OS, SSH keys, tags, and taints. ```yaml - name: Create node pool opentelekomcloud.cloud.cce_node_pool: name: "{{ node_pool_name }}" availability_zone: "eu-de-01" autoscaling_enabled: false cluster: "{{ cluster.cce_cluster.id }}" data_volumes: - volumetype: "SSD" size: 120 - volumetype: "SATA" size: 100 encrypted: false flavor: "{{ node_flavor }}" initial_node_count: 0 k8s_tags: mytag: "myvalue" mysecondtag: "mysecondvalue" min_node_count: 1 max_node_count: 3 network: "{{ network_id }}" priority: 2 os: "{{ os_cluster_name }}" ssh_key: "{{ keypair_name }}" tags: - key: "my_first_key" value: "my_first_value" - key: "my_second_key" value: "my_secound_value" taints: - key: "first_taint_key" value: "first_taint_value" effect: "NoSchedule" - key: "second_taint_key" value: "second_taint_value" effect: "NoExecute" state: present register: pool ``` -------------------------------- ### Create ECS CPU Utilization Alarm using opentelekomcloud.cloud.ces_alarms Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md This task creates an alarm for ECS CPU utilization. It requires the alarm name, metric details (namespace, dimensions, metric name), and condition parameters. The SMN topic must be created beforehand. ```yaml - name: Create alarm for ECS CPU utilization opentelekomcloud.cloud.ces_alarms: alarm_name: "ecs1_cpu_load" state: present metric: namespace: "SYS.ECS" dimensions: - name: "instance_id" value: "{{ ecs_1_id }}" metric_name: "CPU_usage" condition: period: 300 filter: average comparison_operator: ">=" value: 50 unit: "Percent" count: 1 alarm_enabled: true alarm_action_enabled: false alarm_actions: - type: "notification" notificationList: "urn:smn:eu-de:5dd3c0b24cdc4d31952c49589182a89d:yet_another_topic" register: ecs_cpu_alarm ``` -------------------------------- ### Create CCE Cluster Node Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Adds nodes to a CCE cluster's node pool. The node's availability zone must match the node pool's AZ. It supports configuring annotations, data volumes, flavors, labels, K8s tags, and root volume settings. ```yaml - name: Create CCE Cluster Node opentelekomcloud.cloud.cce_cluster_node: annotations: annotation1: "Test cluster nodes" availability_zone: "eu-de-01" cluster: "{{ cce_cluster_name }}" count: 1 data_volumes: - volumetype: "SATA" size: 100 encrypted: false - volumetype: "SAS" size: 120 flavor: "{{ node_flavor }}" k8s_tags: testtag: "value" ssh_key: "{{ keypair_name }}" labels: mein: "label" max_pods: 16 name: "{{ cce_node_name }}" network: "{{ network_id }}" os: "{{ os_cluster_name }}" root_volume_size: 40 root_volume_type: SATA tags: - key: "key1" value: "value1" - key: "key2" value: "value2" wait: true state: present register: node ``` -------------------------------- ### Create Security Group using opentelekomcloud.cloud.security_group Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md This task creates a security group with specified rules for ingress and egress traffic. The 'exclusive: true' option ensures that only the defined rules are active, removing any pre-existing ones. The created security group is registered for use in subsequent resource creations. ```yaml - 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 ``` -------------------------------- ### Update AS Policy using opentelekomcloud.cloud.as_policy Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md This module allows updating an existing Auto Scaling (AS) policy. It can modify parameters such as the policy name, type, and actions. To update, specify the scaling group, the new policy name, and the desired configuration changes. The state should be 'present' to apply the updates. ```yaml - name: Update AS policy (add scaling_policy_action) opentelekomcloud.cloud.as_policy: scaling_group: "{{ as_group_name }}" scaling_policy: "{{ new_as_policy_name }}" scaling_policy_type: "alarm" alarm: "{{ alarm_name }}" state: "present" scaling_policy_action: operation: "add" instance_number: 1 register: as_policy ``` -------------------------------- ### Add ECS Member to Load Balancer Pool Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Adds an ECS instance (member) to a previously created backend server group (pool). This requires the member's name, IP address, protocol port, subnet, and the pool ID. For round-robin balancing, at least two members are recommended. ```yaml - name: Add first ECS to the backend server group opentelekomcloud.cloud.lb_member: name: "{{ ecs1_name }}" address: "10.10.0.18" protocol_port: 443 subnet: "{{ vpc_subnet_name }}" pool: "{{ backend.server_group.id }}" register: bcknd_1 ``` ```yaml - name: Add second ECS to the backend server group opentelekomcloud.cloud.lb_member: name: "{{ ecs2_name }}" address: "10.10.0.23" protocol_port: 443 subnet: "{{ vpc_subnet_name }}" pool: "{{ backend_group_id }}" register: bcknd_2 ``` -------------------------------- ### Get CCE Node Pool Info Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Fetches information about a specific CCE node pool. It requires the cluster ID to which the node pool belongs. ```yaml - name: Get info about node pool opentelekomcloud.cloud.cce_node_pool_info: cce_cluster: "{{ cluster.cce_cluster.id }}" ``` -------------------------------- ### Create CCE Cluster using opentelekomcloud.cloud.cce_cluster Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md This module creates a Cloud Container Engine (CCE) cluster. It requires specifying the cluster name, description, type, Kubernetes version, flavor, authentication mode, network settings (router, network ID, container network mode/CIDR), and availability zone. The state should be 'present' to create the cluster. ```yaml - name: Create CCE Cluster opentelekomcloud.cloud.cce_cluster: name: "{{ cce_cluster_name }}" description: "Cloud Container Engine test cluster" type: "virtualmachine" version: "v1.21" flavor: "{{ cce_flavor }}" authentication_mode: "rbac" kube_proxy_mode: "iptables" router: "{{ router }}" network: "{{ network_id }}" container_network_mode: "{{ container_network_mode }}" container_network_cidr: "10.0.0.0/16" availability_zone: "multi_az" state: present register: cluster ``` -------------------------------- ### Get CCE Cluster Info Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Retrieves information about a CCE cluster. This module is useful for obtaining details about an existing cluster, identified by its name or ID. ```yaml - name: Get info about cluster opentelekomcloud.cloud.cce_cluster_info: name: "{{ cluster.cce_cluster.id }}" ``` -------------------------------- ### Get CCE Cluster Node Info Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Retrieves information about CCE cluster nodes. This module requires the cluster ID to identify the nodes for which information is needed. ```yaml - name: Get info about cluster nodes opentelekomcloud.cloud.cce_cluster_node_info: cce_cluster: "{{ cluster.cce_cluster.id }}" ``` -------------------------------- ### Get Load Balancer Pool Member Information Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Retrieves information about members within a specified backend server group (pool). This module is useful for checking which ECS instances are part of the pool and their configurations. ```yaml - name: Get info about specified pool members opentelekomcloud.cloud.lb_member_info: pool: "{{ backend_server_name }}" register: bcknd_members_info ``` -------------------------------- ### Get Dedicated Host Info using opentelekomcloud.cloud.deh_host_info Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md This Ansible task retrieves information about a dedicated host, identified by its name. It is used here to verify if a hostname change was successful. The module returns detailed information about the specified dedicated host. ```yaml - name: Get info about host after name changing opentelekomcloud.cloud.deh_host_info: host: "{{ deh_change.deh_host.name }}" register: deh_new_info - name: Assert result ansible.builtin.assert: that: - deh.deh_host.name != deh_change.deh_host.name - deh_new_info.deh_hosts[0].name == deh_change.deh_host.name ``` -------------------------------- ### Get ECSs on Dedicated Host Info - YAML Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md This snippet demonstrates how to use the `deh_server_info` module to retrieve information about ECSs allocated to a specific dedicated host. It requires the dedicated host ID as input and returns details about the associated servers. ```yaml - name: Get info about ECSs allocated on dedicated host opentelekomcloud.cloud.deh_server_info: dedicated_host: "{{ deh_change.deh_host.id }}" ``` -------------------------------- ### Create and Rename Auto-Scaling Group using opentelekomcloud.cloud.as_group Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Manages Auto-Scaling (AS) groups, including creation and renaming. When creating, specify parameters like group name, configuration, instance numbers (min, desired, max), availability zones, networks, security groups, and router ID. The module also supports actions like 'resume' and states like 'present'. Renaming involves providing the group ID and the new name. ```yaml - 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 ``` -------------------------------- ### Ansible Playbook to Get NAT Gateway Info Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/README.md A sample Ansible playbook that uses the opentelekomcloud.cloud.nat_gateway_info module to retrieve information about NAT gateways in the OTC cloud. It registers the output and then debugs the 'nat_gateways' variable. ```yaml # opentelekomcloud.yaml - hosts: localhost tasks: - name: Get NAT gateway info opentelekomcloud.cloud.nat_gateway_info: cloud: otc register: gw - name: debug configs debug: var: gw.nat_gateways ``` -------------------------------- ### Manage VPC Resources with Ansible Source: https://context7.com/opentelekomcloud/ansible-collection-cloud/llms.txt Demonstrates how to manage Virtual Private Cloud (VPC) resources using the opentelekomcloud.cloud.vpc Ansible module. It covers creating, updating, configuring SNAT, and deleting VPCs. ```yaml --- - hosts: localhost tasks: # Create a new VPC with specified CIDR block - name: Create VPC opentelekomcloud.cloud.vpc: name: "my-vpc" cidr: "10.10.0.0/24" state: present register: newvpc # Update VPC with description - name: Update VPC opentelekomcloud.cloud.vpc: name: "my-vpc" description: "Production VPC for web services" # Enable shared SNAT on VPC - name: Configure VPC with SNAT opentelekomcloud.cloud.vpc: name: "my-vpc" enable_shared_snat: true # Delete VPC - name: Delete VPC opentelekomcloud.cloud.vpc: name: "my-vpc" state: absent ``` -------------------------------- ### Assign Floating IP using opentelekomcloud.cloud.floating_ip Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md Obtains a public IP address and assigns it to a resource. The 'network' parameter is a constant value, typically 'admin_external_net'. This module is used to make resources accessible from the internet. ```yaml - name: Assign Floating IP opentelekomcloud.cloud.floating_ip: network: admin_external_net register: fl ``` -------------------------------- ### Change Dedicated Host Name using opentelekomcloud.cloud.deh_host Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md This Ansible task modifies the name of an existing dedicated host. The only required attribute to uniquely identify the host is its ID. This operation allows for renaming a dedicated host after it has been allocated. ```yaml - name: Change host name opentelekomcloud.cloud.deh_host: id: "{{ deh.deh_host.dedicated_host_ids[0] }}" name: "{{ deh_new_name }}" register: deh_change ``` -------------------------------- ### Configure OpenStack Clouds YAML for OTC Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/README.md Creates the necessary directory structure and an empty clouds.yaml file, then populates it with OTC cloud credentials including username, password, project name, domain name, authentication URL, and AK/SK for OBS access. Ensure to replace placeholder values with your actual credentials. ```yaml # clouds.yaml clouds: otc: profile: otc auth: username: '' password: '' project_name: '' # or project_id: '<123456_PROJECT_ID>' user_domain_name: 'OTC00000000001000000xxx' # or user_domain_id: '<123456_DOMAIN_ID>' auth_url: 'https://iam.eu-de.otc.t-systems.com:443/v3' interface: 'public' identity_api_version: 3 # !Important ak: '' # AK/SK pair for access to OBS sk: '' ``` -------------------------------- ### Create DDS Cluster Config Node using opentelekomcloud.cloud.dds_instance Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md This Ansible task creates a configuration node for a DDS (Distributed Database Service) cluster. It requires specifying instance name, region, availability zone, datastore version, network details, security group, password, disk encryption, and flavor details for the config node. The storage size for config nodes is fixed at 20 GB. ```yaml - name: Create config node for DDS cluster opentelekomcloud.cloud.dds_instance: name: "{{ dds_instance_name }}" state: present region: "eu-de" availability_zone: "eu-de-01" datastore_version: "{{ dds_ds.datastores[1].version }}" router: "{{ router }}" network: "{{ network_id }}" security_group: "{{ secgroup_id }}" password: "{{ password }}" disk_encryption: "{{ cmk_id }}" mode: "Sharding" flavors: - type: "config" num: 1 size: 20 spec_code: "dds.mongodb.s2.large.2.config" backup_timeframe: "18:00 GMT+03:00" backup_keepdays: 3 ssl_option: 1 register: dds_conf ``` -------------------------------- ### Create Auto Scaling Group Load Alarm using opentelekomcloud.cloud.ces_alarms Source: https://github.com/opentelekomcloud/ansible-collection-cloud/blob/main/examples/README.md This task configures an alarm for an Auto Scaling Group based on memory utilization. It is designed to trigger scaling actions. The 'alarm_actions' type is set to 'autoscaling' and 'notificationList' should be empty. ```yaml - name: Create load alarm for Auto Scaling Group to adjust number of instances opentelekomcloud.cloud.ces_alarms: alarm_name: "as_load" state: present metric: namespace: "SYS.AS" dimensions: - name: "AutoScalingGroup" value: "{{ as_group_name }}" metric_name: "mem_util" condition: period: 300 filter: average comparison_operator: ">=" value: 50 unit: "Percent" count: 2 alarm_enabled: true alarm_action_enabled: true alarm_actions: - type: "autoscaling" notificationList: [] register: as_mem_alarm ``` -------------------------------- ### Manage Subnet Resources with Ansible Source: https://context7.com/opentelekomcloud/ansible-collection-cloud/llms.txt Illustrates the creation and management of subnets within a VPC using the opentelekomcloud.cloud.subnet Ansible module. It includes specifying CIDR, gateway, and DNS servers. ```yaml --- - hosts: localhost tasks: # Create subnet within VPC - name: Create subnet for VPC opentelekomcloud.cloud.subnet: name: "my-subnet" vpc: "my-vpc" cidr: "10.10.0.0/27" gateway_ip: "10.10.0.1" dns_list: - "100.125.4.25" - "100.125.129.199" register: subnet # Output subnet details - name: Display subnet info debug: var: subnet ```