Ansible Collections for using with OTC (addition to the native OpenStack modules)
cloud- collection containing additional ansible modules for managing T Cloud Public specific resources (or modified OpenStack modules in case of behavioral differences)
- otcextension
- openstacksdk (installed via otcextensions)
Run the following command to install the collection.
ansible-galaxy collection install opentelekomcloud.cloudIf you need further information to get started, please see section:
Installation on a blank system in a Python virtual environment
Installation was tested on Ubuntu 20.04
Install python3-venv for Python virtual environment:
sudo apt-get install python3-venvCreate virtual environment ansiblevenv:
python3 -m venv ansiblevenvInstall dependencies for python package otcextensions which are described in its documentation:
sudo apt-get install gcc libssl-dev python3-devEnable virtual environment ansiblevenv:
source ansiblevenv/bin/activateInstall wheel, ansible and otcextensions:
(ansiblevenv) $ pip install wheel ansible otcextensionsInstall opentelekomcloud.cloud collection from Ansible-Galaxy:
(ansiblevenv) $ ansible-galaxy collection install opentelekomcloud.cloudPrepare credential file clouds.yaml and necessary folders to connect to
your cloud:
(ansiblevenv) $ mkdir -p ~/.config/openstack/
(ansiblevenv) $ touch ~/.config/openstack/clouds.yaml
(ansiblevenv) $ chmod 700 -R ~/.config/Paste in the following content with your credentials:
# clouds.yaml
clouds:
otc:
profile: otc
auth:
username: '<USER_NAME>'
password: '<PASSWORD>'
project_name: '<eu-de_project>'
# 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_VALUE>' # AK/SK pair for access to OBS
sk: '<SK_VALUE>'Verify the installation process by creating a sample playbook which invokes all dependencies:
(ansiblevenv) $ vim opentelekomcloud.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_gatewaysHere you can find some examples of using T Cloud Public collection. All the examples are based on real use cases, and contains some tips and tricks.
Run the playbook to verify the functionality:
(ansiblevenv) $ ansible-playbook opentelekomcloud.yaml
# output without NAT gateways enabled
PLAY [localhost] ***************************************************************
TASK [Gathering Facts] *********************************************************
ok: [localhost]
TASK [Get NAT gateway info] ****************************************************
ok: [localhost]
TASK [debug configs] ***********************************************************
ok: [localhost] => {
"gw.nat_gateways": []
}Create a path where you place your development files e.g.:
mkdir -p ~/ansible/ansible_collections/tcloud/Clone the development files into your path and rename it to cloud.
cd ~/ansible/ansible_collections/tcloud/
git clone git@github.com:opentelekomcloud/ansible-collection-cloud.git cloudExport the path variable and make it available for your system:
pwd
> /path/to/your/ansible/ansible_collections/
export ANSIBLE_COLLECTIONS_PATHS=/path/to/your/ansible/ansible_collections/Validate the entry of your development environment by running the following command.
source ~/youransiblevenv/bin/activate
ansible-galaxy collection list