diff --git a/.gitignore b/.gitignore index 83817d9..184a4ca 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ _secrets.yml _user_data*.txt tenant.ini.* +roles/ *.retry .eggs/ .tox/ diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml deleted file mode 100644 index 42a3997..0000000 --- a/.gitlab-ci.yml +++ /dev/null @@ -1,21 +0,0 @@ -stages: -- check -- package - -lint: - stage: check - script: - - sudo apt-get -y install python-pip - - sudo pip install yamllint - - find roles/ -name "*.yml" | xargs ansible-lint - -package: - stage: package - script: - - sudo apt-get -y install ruby ruby-dev rubygems build-essential - - sudo gem install --no-ri --no-rdoc fpm - - fpm -s dir -t deb -d ansible -v "01-${CI_BUILD_REF_NAME}-$(date +%s)" -n ansible-roles-otc --iteration 1 -x .git -x .gitignores --description "Ansible roles for Open Telekom Cloud" --prefix /etc/ansible/roles roles - artifacts: - paths: - - ansible-roles-otc*.deb - expire_in: 1 week diff --git a/.travis.yml b/.travis.yml index 63da42f..7883e0a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,4 @@ --- -sudo: required dist: xenial language: python @@ -7,30 +6,15 @@ python: - "2.7" - "3.5" -# Doc: https://docs.travis-ci.com/user/customizing-the-build#Build-Matrix -# https://docs.travis-ci.com/user/common-build-problems/ -env: - - ANSIBLE_VERSION=latest - - ANSIBLE_VERSION=2.4.3.0 - - ANSIBLE_VERSION=2.5.0 - - ANSIBLE_VERSION=2.5.2 - branches: only: - master - dev + - galaxy -# before_install: -# - sudo apt-get update -qq - -install: - # Install Ansible. - - if [ "$ANSIBLE_VERSION" = "latest" ]; then pip install ansible; else pip install ansible==$ANSIBLE_VERSION; fi - - pip install ansible-lint jmespath +before_install: + - sudo apt-get update + - sudo apt-get install -y tox make latexmk texlive-latex-recommended texlive-fonts-recommended texlive-latex-extra script: - # Check the role/playbook's syntax. - - find roles/ -name "*.yml" | xargs ansible-lint - - # Run the role/playbook with ansible-playbook. - - tests/tests.sh + - tox diff --git a/README.md b/README.md index b6b2865..9639cdb 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,12 @@ For local build use: ``` tox -edocs - pip install -r requirements.txt +``` + +Roles are excluded, to use sample playbooks use: + +``` + ./install_roles.sh ``` @@ -45,8 +50,6 @@ Presentations Contributing ------------ -Very welcome. We are in a very early state of automated platform deployment -on OTC. So each help is still welcome 1. Fork it. 2. Create a branch (`git checkout -b my_markup`) diff --git a/ansible-role-requirements.yml b/ansible-role-requirements.yml new file mode 100644 index 0000000..2758922 --- /dev/null +++ b/ansible-role-requirements.yml @@ -0,0 +1,48 @@ +- name: otc_auth + scm: git + src: https://github.com/eumel8/otc_auth.git +- name: otc_cts + scm: git + src: https://github.com/eumel8/otc_cts.git +- name: otc_dns + scm: git + src: https://github.com/eumel8/otc_dns.git +- name: otc_ecs + scm: git + src: https://github.com/eumel8/otc_ecs.git +- name: otc_eip + scm: git + src: https://github.com/eumel8/otc_eip.git +- name: otc_elb + scm: git + src: https://github.com/eumel8/otc_elb.git +- name: otc_evs + scm: git + src: https://github.com/eumel8/otc_evs.git +- name: otc_ims + scm: git + src: https://github.com/eumel8/otc_ims.git +- name: otc_job + scm: git + src: https://github.com/eumel8/otc_job.git +- name: otc_keypair + scm: git + src: https://github.com/eumel8/otc_keypair.git +- name: otc_obs + scm: git + src: https://github.com/eumel8/otc_obs.git +- name: otc_rds + scm: git + src: https://github.com/eumel8/otc_rds.git +- name: otc_secgroup + scm: git + src: https://github.com/eumel8/otc_secgroup.git +- name: otc_subnet + scm: git + src: https://github.com/eumel8/otc_subnet.git +- name: otc_vpc + scm: git + src: https://github.com/eumel8/otc_vpc.git +- name: os-client-config + scm: git + src: https://github.com/eumel8/os-client-config.git diff --git a/doc/source/galaxy.rst b/doc/source/galaxy.rst new file mode 100644 index 0000000..1614bac --- /dev/null +++ b/doc/source/galaxy.rst @@ -0,0 +1,25 @@ +Ansible Galaxy +============== + +Ansible Galaxy is a repository for sharing roles. +You can search for specific roles on `Galaxy website `__. +All ansible-otc are to find there and you can also use the CLI:: + + ansible-galaxy search otc_ + +To install a specific role you can use:: + + ansible-galaxy install eumel8.otc_auth + +or with the requirements file with Galaxy source:: + + ansible-galaxy install -r galaxy.yml + +or with the requirements file with Git source:: + + ansible-galaxy install -r ansible-role-requirements.yml + +You need to adjust the roles_path in ansible.cfg. The system-white +roles_path is /etc/ansible/roles + +WIP: This feature is a Proof of Concept diff --git a/doc/source/index.rst b/doc/source/index.rst index 63fd1c0..0b6e376 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -19,6 +19,10 @@ Welcome to Ansible-OTC documentation! buildservice dns ara + galaxy +.. toctree:: + :maxdepth: 3 + roles changelog authors diff --git a/doc/source/roles.rst b/doc/source/roles.rst index 974105c..18a5b18 100644 --- a/doc/source/roles.rst +++ b/doc/source/roles.rst @@ -1,8 +1,8 @@ Roles ***** -Variables: -========== +Variables +========= +----------------------------------------------+----------------------------------------------+ | Name | Description | @@ -20,22 +20,231 @@ Variables: | uri_delay | deleay on retries (default: 1) | +----------------------------------------------+----------------------------------------------+ -Functions: -========== - -.. include:: ../../roles/os-client-config/README.rst -.. include:: ../../roles/otc_auth/README.rst -.. include:: ../../roles/otc_cts/README.rst -.. include:: ../../roles/otc_dns/README.rst -.. include:: ../../roles/otc_ecs/README.rst -.. include:: ../../roles/otc_eip/README.rst -.. include:: ../../roles/otc_elb/README.rst -.. include:: ../../roles/otc_evs/README.rst -.. include:: ../../roles/otc_ims/README.rst -.. include:: ../../roles/otc_job/README.rst -.. include:: ../../roles/otc_keypair/README.rst -.. include:: ../../roles/otc_obs/README.rst -.. include:: ../../roles/otc_rds/README.rst -.. include:: ../../roles/otc_secgroup/README.rst -.. include:: ../../roles/otc_subnet/README.rst -.. include:: ../../roles/otc_vpc/README.rst +Functions +========= + +List of all roles + +`otc_auth `__ +---------------------------------------------------------------- + +.. raw:: html + +
+
+.. raw:: html
+   :url: https://raw.githubusercontent.com/eumel8/otc_auth/master/README.rst
+
+.. raw:: html
+
+    
+ +`otc_cts `__ +--------------------------------------------------------------- + +.. raw:: html + +
+
+.. raw:: html
+   :url: https://raw.githubusercontent.com/eumel8/otc_cts/master/README.rst
+
+.. raw:: html
+
+    
+ +`otc_dns `__ +--------------------------------------------------------------- + +.. raw:: html + +
+
+.. raw:: html
+   :url: https://raw.githubusercontent.com/eumel8/otc_dns/master/README.rst
+
+.. raw:: html
+
+    
+ +`otc_ecs `__ +--------------------------------------------------------------- + +.. raw:: html + +
+
+.. raw:: html
+   :url: https://raw.githubusercontent.com/eumel8/otc_ecs/master/README.rst
+
+.. raw:: html
+
+    
+ +`otc_eip `__ +--------------------------------------------------------------- + +.. raw:: html + +
+
+.. raw:: html
+   :url: https://raw.githubusercontent.com/eumel8/otc_eip/master/README.rst
+
+.. raw:: html
+
+    
+ +`otc_elb `__ +--------------------------------------------------------------- + +.. raw:: html + +
+
+.. raw:: html
+   :url: https://raw.githubusercontent.com/eumel8/otc_elb/master/README.rst
+
+.. raw:: html
+
+    
+ +`otc_evs `__ +--------------------------------------------------------------- + +.. raw:: html + +
+
+.. raw:: html
+   :url: https://raw.githubusercontent.com/eumel8/otc_evs/master/README.rst
+
+.. raw:: html
+
+    
+ +`otc_ims `__ +--------------------------------------------------------------- + +.. raw:: html + +
+
+.. raw:: html
+   :url: https://raw.githubusercontent.com/eumel8/otc_ims/master/README.rst
+
+.. raw:: html
+
+    
+ +`otc_job `__ +---------------------------------------------------------------- + +.. raw:: html + +
+
+.. raw:: html
+   :url: https://raw.githubusercontent.com/eumel8/otc_job/master/README.rst
+
+.. raw:: html
+
+    
+ +`otc_keypair `__ +---------------------------------------------------------------------- + +.. raw:: html + +
+
+.. raw:: html
+   :url: https://raw.githubusercontent.com/eumel8/otc_keypair/master/README.rst
+
+.. raw:: html
+
+    
+ +`otc_obs `__ +--------------------------------------------------------------- + +.. raw:: html + +
+
+.. raw:: html
+   :url: https://raw.githubusercontent.com/eumel8/otc_obs/master/README.rst
+
+.. raw:: html
+
+    
+ +`otc_rds `__ +--------------------------------------------------------------- + +.. raw:: html + +
+
+.. raw:: html
+   :url: https://raw.githubusercontent.com/eumel8/otc_rds/master/README.rst
+
+.. raw:: html
+
+    
+ +`otc_secgroup `__ +------------------------------------------------------------------------ + +.. raw:: html + +
+
+.. raw:: html
+   :url: https://raw.githubusercontent.com/eumel8/otc_secgroup/master/README.rst
+
+.. raw:: html
+
+    
+ +`otc_subnet `__ +-------------------------------------------------------------------- + +.. raw:: html + +
+
+.. raw:: html
+   :url: https://raw.githubusercontent.com/eumel8/otc_subnet/master/README.rst
+
+.. raw:: html
+
+    
+ +`otc_vpc `__ +--------------------------------------------------------------- + +.. raw:: html + +
+
+.. raw:: html
+   :url: https://raw.githubusercontent.com/eumel8/otc_vpc/master/README.rst
+
+.. raw:: html
+
+    
+ +`os-client-config `__ +------------------------------------------------------------------------------------ + +.. raw:: html + +
+
+.. raw:: html
+   :url: https://raw.githubusercontent.com/eumel8/os-client-config/master/README.rst
+
+.. raw:: html
+
+    
diff --git a/galaxy.yml b/galaxy.yml new file mode 100644 index 0000000..3c27621 --- /dev/null +++ b/galaxy.yml @@ -0,0 +1,32 @@ +- name: otc_auth + src: eumel8.otc_auth +- name: otc_cts + src: eumel8.otc_cts +- name: otc_dns + src: eumel8.otc_dns +- name: otc_ecs + src: eumel8.otc_ecs +- name: otc_eip + src: eumel8.otc_eip +- name: otc_elb + src: eumel8.otc_elb +- name: otc_evs + src: eumel8.otc_evs +- name: otc_ims + src: eumel8.otc_ims +- name: otc_jobs + src: eumel8.otc_jobs +- name: otc_keypair + src: eumel8.otc_keypair +- name: otc_obs + src: eumel8.otc_obs +- name: otc_rds + src: eumel8.otc_rds +- name: otc_secgroup + src: eumel8.otc_secgroup +- name: otc_subnet + src: eumel8.otc_subnet +- name: otc_vpc + src: eumel8.otc_vpc +- name: os-client-config + src: eumel8.os-client-config diff --git a/install_roles.sh b/install_roles.sh new file mode 100755 index 0000000..1d6b99d --- /dev/null +++ b/install_roles.sh @@ -0,0 +1,2 @@ +#!/bin/sh +ansible-galaxy install -f -r ansible-role-requirements.yml -p roles diff --git a/playbooks/ansible.cfg b/playbooks/ansible.cfg index 51d344d..76dcd0b 100644 --- a/playbooks/ansible.cfg +++ b/playbooks/ansible.cfg @@ -1,2 +1,3 @@ [defaults] roles_path = ../roles +retry_files_enabled = False diff --git a/playbooks/vars/dns.yml b/playbooks/vars/dns.yml index d525ca5..daa5639 100644 --- a/playbooks/vars/dns.yml +++ b/playbooks/vars/dns.yml @@ -1,7 +1,7 @@ --- default: - vpc_name: "ansible-vpc01", - zone_email: "nobody@example.com", + vpc_name: "ansible-vpc01" + zone_email: "nobody@example.com" zone_ttl: 86400 dnszones: ansible.internal.corp: diff --git a/requirements.txt b/requirements.txt index f948626..1e91540 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,10 +3,14 @@ # process, which may cause wedges in the gate later. pbr>=2.0 # Apache-2.0 -sphinx>=1.6.2 # BSD +sphinx>=1.7.6 # BSD ansible==2.5.0.0 jmespath +netaddr # Ara for Web reports ara -# OpenStack CLI for Tests -python-openstackclient==3.14.0 +# for tests +yamllint +ansible-lint +# for docs +otcdocstheme diff --git a/roles/os-client-config/README.rst b/roles/os-client-config/README.rst deleted file mode 100644 index 6560596..0000000 --- a/roles/os-client-config/README.rst +++ /dev/null @@ -1,46 +0,0 @@ -os-client-config -================ - -OTC role for generate os-clientconfig - -Variables: -^^^^^^^^^^ - -+-------------------------+---------------------------------------------+ -| Name | Description | -+=========================+=============================================+ -| occ_profile_name | cloud profile name, e.g. otc | -+-------------------------+---------------------------------------------+ -| occ_auth_url | IAM auth url (version 3 is default) | -+-------------------------+---------------------------------------------+ -| occ_region_name | cloud region name | -+-------------------------+---------------------------------------------+ -| occ_username | cloud username | -+-------------------------+---------------------------------------------+ -| occ_password | cloud password | -+-------------------------+---------------------------------------------+ -| occ_project_name | cloud project name, e.g. eu-de | -+-------------------------+---------------------------------------------+ -| occ_project_domain_name | cloud project domain name, e.g. Default | -+-------------------------+---------------------------------------------+ -| occ_user_domain_name | cloud user domain, e.g. OTC-eu-de-0012345 | -+-------------------------+---------------------------------------------+ - -Functions: -^^^^^^^^^^ - -Create:: - - ansible-playbook os-client-config.yml - -Read:: - - n/a - -Update:: - - n/a - -Delete:: - - n/a diff --git a/roles/os-client-config/tasks/main.yml b/roles/os-client-config/tasks/main.yml deleted file mode 100644 index ef97bda..0000000 --- a/roles/os-client-config/tasks/main.yml +++ /dev/null @@ -1,20 +0,0 @@ -- name: create conf directory - file: - path: ~/.config/openstack - state: directory - mode: 0755 - -- name: Create os-client-config file - template: - src: cloud.yml.j2 - dest: ~/.config/openstack/clouds.yml - mode: 0600 - force: yes - backup: yes - -- name: Create env.yml file - template: - src: env.yml.j2 - dest: ./env.yml - mode: 0600 - force: yes diff --git a/roles/os-client-config/templates/cloud.yml.j2 b/roles/os-client-config/templates/cloud.yml.j2 deleted file mode 100644 index de07efe..0000000 --- a/roles/os-client-config/templates/cloud.yml.j2 +++ /dev/null @@ -1,11 +0,0 @@ -clouds: - {{ occ_profile_name }}: - auth: - auth_url: {{ occ_auth_url }} - username: {{ occ_username }} - password: {{ occ_password }} - project_name: {{ occ_project_name }} - project_domain_name: {{ occ_project_domain_name }} - user_domain_name: {{ occ_user_domain_name }} - identity_api_version: "3" - region_name: {{ occ_region_name }} diff --git a/roles/os-client-config/templates/env.yml.j2 b/roles/os-client-config/templates/env.yml.j2 deleted file mode 100644 index 72faf0c..0000000 --- a/roles/os-client-config/templates/env.yml.j2 +++ /dev/null @@ -1 +0,0 @@ -CLOUD: {{ occ_profile_name }} diff --git a/roles/otc_auth/README.rst b/roles/otc_auth/README.rst deleted file mode 100644 index 8c994c3..0000000 --- a/roles/otc_auth/README.rst +++ /dev/null @@ -1,47 +0,0 @@ -otc_auth -======== - -OTC role for authentification. - -Supports: - -* os-client-config -* env variables - -Variables: -^^^^^^^^^^ - -+--------------+---------------------------------------------+ -| Name | Description | -+==============+=============================================+ -| USERNAME | cloud username | -| | env variable or content of os-client config | -+--------------+---------------------------------------------+ -| PASSWORD | cloud password | -| | env variable or content of os-client config | -+--------------+---------------------------------------------+ -| PROJECTNAME | cloud project name, e.g. eu-de | -| | env variable or content of os-client config | -+--------------+---------------------------------------------+ -| DOMAIN | cloud user domain, e.g. OTC-eu-de-0012345 | -| | env variable or content of os-client config | -+--------------+---------------------------------------------+ - -Functions: -^^^^^^^^^^ - -Create:: - - role otc_auth - -Read:: - - n/a - -Update:: - - n/a - -Delete:: - - n/a diff --git a/roles/otc_auth/defaults/main.yml b/roles/otc_auth/defaults/main.yml deleted file mode 100644 index a91cd5f..0000000 --- a/roles/otc_auth/defaults/main.yml +++ /dev/null @@ -1,4 +0,0 @@ -uri_follow_redirects: "none" -uri_validate_certs: "yes" -uri_retries: 5 -uri_delay: 1 diff --git a/roles/otc_auth/meta/main.yml b/roles/otc_auth/meta/main.yml deleted file mode 100644 index a201a1b..0000000 --- a/roles/otc_auth/meta/main.yml +++ /dev/null @@ -1,16 +0,0 @@ -galaxy_info: - author: Frank Kloeker - description: Ansible Role for Open Telekom Cloud - company: Deutsche Telekom AG - license: Apache2 - min_ansible_version: 2.4 - platforms: - - name: Ubuntu - versions: - - xenial - categories: - - cloud - - python - - openstack -#dependencies: -# - role: otc_auth diff --git a/roles/otc_auth/tasks/main.yml b/roles/otc_auth/tasks/main.yml deleted file mode 100644 index 3de0715..0000000 --- a/roles/otc_auth/tasks/main.yml +++ /dev/null @@ -1,41 +0,0 @@ -- name: Load auth variable file from os-client config or ansible-vault secret - include_vars: "{{ item }}" - with_first_found: - - files: - - "vars/env.yml" - - "vars/_secrets.yml" - skip: true - tags: - - always - -- name: Check if os-client config exists - vars: - user_home: "{{ lookup('env','HOME') }}" - stat: - path: "{{ user_home }}/.config/openstack/clouds.yml" - register: osclientconfigfile - tags: - - always - -- name: Get token with env variables - include: token.yml - vars: - USERNAME: "{{ lookup('env','OS_USERNAME') }}" - PASSWORD: "{{ lookup('env','OS_PASSWORD') }}" - PROJECT_NAME: "{{ lookup('env','OS_PROJECT_NAME') }}" - DOMAIN: "{{ lookup('env','OS_USER_DOMAIN_NAME') }}" - when: not osclientconfigfile.stat.exists - tags: - - always - -- name: Get token with os-client config - include: token.yml - vars: - os_client_config: "{{ lookup('file', osclientconfigfile.stat.path)|from_yaml }}" - USERNAME: "{{ os_client_config['clouds'][CLOUD]['auth']['username'] }}" - PASSWORD: "{{ os_client_config['clouds'][CLOUD]['auth']['password'] }}" - PROJECT_NAME: "{{ os_client_config['clouds'][CLOUD]['auth']['project_name'] }}" - DOMAIN: "{{ os_client_config['clouds'][CLOUD]['auth']['user_domain_name'] }}" - when: osclientconfigfile.stat.exists - tags: - - always diff --git a/roles/otc_auth/tasks/token.yml b/roles/otc_auth/tasks/token.yml deleted file mode 100644 index 2ba292c..0000000 --- a/roles/otc_auth/tasks/token.yml +++ /dev/null @@ -1,57 +0,0 @@ -- name: Fail when cloud variables not set - fail: - msg: "Cloud auth variables not set (USERNAME,PASSWORD,DOMAIN,PROJECT_NAME..)" - when: - - not USERNAME - - not PASSWORD - - not DOMAIN - - not PROJECT_NAME - tags: - - always - -- name: Set facts generic endpoints - set_fact: - PROJECT_NAME: "{{ PROJECT_NAME }}" - IAM_AUTH_URL: "https://iam.{{ PROJECT_NAME }}.otc.t-systems.com/v3" - AUTH_URL_ELB: "https://elb.{{ PROJECT_NAME }}.otc.t-systems.com/v1.0" - AUTH_URL_ECS_CLOUD: "https://ecs.{{ PROJECT_NAME }}.otc.t-systems.com/v1" - AUTH_URL_RDS: "https://rds.{{ PROJECT_NAME }}.otc.t-systems.com/rds/v1" - AUTH_URL_CTS: "https://cts.{{ PROJECT_NAME }}.otc.t-systems.com/v2.0" - -- name: Request token from AUTH API - uri: - url: "{{ IAM_AUTH_URL }}/auth/tokens" - method: POST - body_format: raw - return_content: yes - status_code: 201 - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - body: "{{ lookup('template', 'request.json.j2',convert_data=True)|to_json }}" - register: uritoken - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: uritoken.status == 201 - changed_when: false - -- name: Set fact token - set_fact: - token: "{{ uritoken }}" - -- name: Set facts dynamic endpoints - set_fact: - OS_USER_DOMAIN_ID: "{{ (token.content|from_json)|json_query('token.user.domain.id') }}" - PROJECT_ID: "{{ (token.content|from_json)|json_query('token.project.id') }}" - AUTH_URL_DNS: "{{ (token.content|from_json)|json_query('token.catalog[?type==`dns`].endpoints[].url|[0]') }}" - AUTH_URL_ECS: "{{ (token.content|from_json)|json_query('token.catalog[?type==`compute`].endpoints[].url|[0]') }}" - AUTH_URL_VPC: "{{ (token.content|from_json)|json_query('token.catalog[?type==`network`].endpoints[].url|[0]') }}" - AUTH_URL_EVS: "{{ (token.content|from_json)|json_query('token.catalog[?type==`volume`].endpoints[].url|[0]') }}" - AUTH_URL_EVSv2: "{{ (token.content|from_json)|json_query('token.catalog[?type==`volumev2`].endpoints[].url|[0]') }}" - AUTH_URL_RTS: "{{ (token.content|from_json)|json_query('token.catalog[?type==`orchestration`].endpoints[].url|[0]') }}" - AUTH_URL_IMS: "{{ (token.content|from_json)|json_query('token.catalog[?type==`image`].endpoints[].url|[0]') }}" - IAM_AUTH_URL: "https://iam.{{ PROJECT_NAME }}.otc.t-systems.com/v3" - -#- debug: -# msg: "{{ token }}" diff --git a/roles/otc_auth/templates/request.json.j2 b/roles/otc_auth/templates/request.json.j2 deleted file mode 100644 index f151081..0000000 --- a/roles/otc_auth/templates/request.json.j2 +++ /dev/null @@ -1,24 +0,0 @@ -{ - "auth": { - "identity": { - "methods": [ - "password" - ], - "password": { - "user": { - "name": "{{ USERNAME }}", - "password": "{{ PASSWORD }}", - "domain": { - "name": "{{ DOMAIN }}" - } - } - } - }, - "scope": { - "project": { - "name": "{{ PROJECT_NAME }}" - } - } - } -} - diff --git a/roles/otc_cts/README.rst b/roles/otc_cts/README.rst deleted file mode 100644 index 58d7945..0000000 --- a/roles/otc_cts/README.rst +++ /dev/null @@ -1,30 +0,0 @@ -otc_cts -======= - -OTC role for Cloud Trace Service (CTS) - -Variables: -^^^^^^^^^^ - -+---------------------------+---------------------------------------------------------------+ -| Name | Description | -+===========================+===============================================================+ -| cts_tracker_name | name of the tracker (default: system | -+---------------------------+---------------------------------------------------------------+ -| cts_trace_name | name of trace (i.e.: login) | -+---------------------------+---------------------------------------------------------------+ -| cts_trace_param | param for output filter (i.e.: time,user.name,source_ip | -+---------------------------+---------------------------------------------------------------+ -| cts_limit | limit of output (min=10,max=200) | -+---------------------------+---------------------------------------------------------------+ -| cts_from | trace time from (i.e. 2018-06-15 00:00:00 | -+---------------------------+---------------------------------------------------------------+ -| cts_to | trace time to (i.e. 2018-06-27 00:00:00 | -+---------------------------+---------------------------------------------------------------+ - -Functions: -^^^^^^^^^^ - -Trace:: - - ./grole otc_cts; ansible-playbook roles.yml -e "cts_from=2018-06-25 00:00:00" -e "cts_to=2018-06-27 00:00:00" -e "localaction=trace" diff --git a/roles/otc_cts/defaults/main.yml b/roles/otc_cts/defaults/main.yml deleted file mode 100644 index 8a635e1..0000000 --- a/roles/otc_cts/defaults/main.yml +++ /dev/null @@ -1,10 +0,0 @@ -uri_follow_redirects: "none" -uri_validate_certs: "yes" -uri_retries: 5 -uri_delay: 1 -cts_tracker_name: "system" -cts_trace_name: "login" -cts_trace_param: "time,user.name,source_ip" -cts_limit: 200 -cts_from: "2018-06-15 00:00:00" -cts_to: "2018-06-27 00:00:00" diff --git a/roles/otc_cts/tasks/main.yml b/roles/otc_cts/tasks/main.yml deleted file mode 100644 index d9cbe31..0000000 --- a/roles/otc_cts/tasks/main.yml +++ /dev/null @@ -1,3 +0,0 @@ -- name: action {{ localaction }} - include: "{{ localaction }}.yml" - when: localaction is defined diff --git a/roles/otc_cts/tasks/trace.yml b/roles/otc_cts/tasks/trace.yml deleted file mode 100644 index 9742451..0000000 --- a/roles/otc_cts/tasks/trace.yml +++ /dev/null @@ -1,18 +0,0 @@ -- name: Send request to API (CTS trace) - uri: - url: "{{ AUTH_URL_CTS }}/{{ PROJECT_ID }}/{{ cts_tracker_name }}/trace?limit={{ cts_limit }}&to={{ lookup('pipe','date +%s --date=\"' + cts_to + '\"') }}000&from={{ lookup('pipe','date +%s --date=\"' + cts_from + '\"') }}000&trace_name={{ cts_trace_name }}" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: ctslist - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: ctslist.status == 200 - changed_when: false - -- debug: - msg: "{{ (ctslist.content|from_json)|json_query('traces[].[' + cts_trace_param +']') }}" diff --git a/roles/otc_dns/README.rst b/roles/otc_dns/README.rst deleted file mode 100644 index 20d777d..0000000 --- a/roles/otc_dns/README.rst +++ /dev/null @@ -1,91 +0,0 @@ -otc_dns -======= - -OTC role for DNS. This role creates zones, zone records and reverse -entries (PTR records). -With as transfer option it's possible to fetch zone information from -existing DNS and write an OTC DNS config file in ini, yml, or json -format. This action required xfer rights on the source DNS server. - -Variables: -^^^^^^^^^^ - -+-------------------------+---------------------------------------------+ -| Name | Description | -+=========================+=============================================+ -| zone_name | name of DNS zone | -+-------------------------+---------------------------------------------+ -| zone_id | id of DNS zone | -+-------------------------+---------------------------------------------+ -| zone_description | Description of DNS zone | -+-------------------------+---------------------------------------------+ -| zone_type | DNS zone type (public/private) | -+-------------------------+---------------------------------------------+ -| zone_email | Email address of SOA | -+-------------------------+---------------------------------------------+ -| zone_ttl | DNS zone TTL in sec | -+-------------------------+---------------------------------------------+ -| zone_records | List of zone records | -+-------------------------+---------------------------------------------+ -| ptr_name | FQDN for PTR record | -+-------------------------+---------------------------------------------+ -| config | Format for Zonetransfer (ini,yml,json) | -+-------------------------+---------------------------------------------+ - - -Functions: -^^^^^^^^^^ - -create (public):: - - ansible-playbook dns_yml.yml -e "zone_name=ansible.otc.telekomcloud99.com" -e "localaction=create" - - ansible-playbook dns_ini.yml -e "zone_name=ansible.otc.telekomcloud99.com" -e "localaction=create" - - ansible-playbook dns_json.yml -e "zone_name=ansible.otc.telekomcloud99.com" -e "localaction=create" - -create (internal):: - - ansible-playbook dns_yml.yml -e "zone_name=ansible.internal.corp" -e "vpc_name=ansible-vpc01" -e "localaction=create" - - ansible-playbook dns_ini.yml -e "zone_name=ansible.internal.corp" -e "vpc_name=ansible-vpc01" -e "localaction=create" - - ansible-playbook dns_json.yml -e "zone_name=ansible.internal.corp" -e "vpc_name=ansible-vpc01" -e "localaction=create" - - -ptrcreate:: - - ansible-playbook tenant_yml.yml -e "zone_name=ansible.otc.telekomcloud99.com" -e "ecs_name=ansible-test01" -e "localaction=ptrcreate" - -ptrdelete:: - - ansible-playbook tenant_yml.yml -e "zone_name=ansible.otc.telekomcloud99.com" -e "ecs_name=ansible-test01" -e "localaction=ptrdelete" - - -show:: - - ./grole otc_dns; ansible-playbook roles.yml -e "zone_name=ansible.otc.telekomcloud99.com" -e "localaction=show" - - ./grole otc_vpc otc_dns; ansible-playbook roles.yml -e "zone_name=ansible.otc.telekomcloud99.com" -e "vpc_name=ansible-vpc01" -e "localaction=show" - - -list:: - - ./grole otc_dns; ansible-playbook roles.yml -e "zone_name=ansible.otc.telekomcloud99.com" -e "localaction=list" - - ./grole otc_vpc otc_dns; ansible-playbook roles.yml -e "zone_name=ansible.internal.corp" -e "vpc_name=ansible-vpc01" -e "localaction=list" - - -delete:: - - ./grole otc_dns; ansible-playbook roles.yml ansible-playbook tenant_yml.yml -e "zone_name=ansible.otc.telekomcloud99.com" -e "localaction=delete" - - ./grole otc_vpc otc_dns; ansible-playbook roles.yml -e "zone_name=ansible.internal.corp" -e "vpc_name=ansible-vpc01" -e "localaction=delete" - -transfer:: - - ansible-playbook dns_ini.yml -e "config=ini" -e "localaction=transfer" -e "dns_server=192.168.0.1" -e "zone_name=example.com" -e "zone_type=public" -e "zone_email=nobody@localhost" -e "zone_ttl=86400" - - ansible-playbook dns_yml.yml -e "config=yml" -e "localaction=transfer" -e "dns_server=192.168.0.1" -e "zone_name=example.com" -e "zone_type=public" -e "zone_email=nobody@localhost" -e "zone_ttl=86400" - - ansible-playbook dns_json.yml -e "config=json" -e "localaction=transfer" -e "dns_server=192.168.0.1" -e "zone_name=example.com" -e "zone_type=public" -e "zone_email=nobody@localhost" -e "zone_ttl=86400" diff --git a/roles/otc_dns/defaults/main.yml b/roles/otc_dns/defaults/main.yml deleted file mode 100644 index a91cd5f..0000000 --- a/roles/otc_dns/defaults/main.yml +++ /dev/null @@ -1,4 +0,0 @@ -uri_follow_redirects: "none" -uri_validate_certs: "yes" -uri_retries: 5 -uri_delay: 1 diff --git a/roles/otc_dns/tasks/create.yml b/roles/otc_dns/tasks/create.yml deleted file mode 100644 index 00b64c3..0000000 --- a/roles/otc_dns/tasks/create.yml +++ /dev/null @@ -1,40 +0,0 @@ -- name: Lookup zone_id - include: lookup.yml - -- name: Delete current zone - include: delete.yml - when: zone_id is defined - -- name: Send request to API (create zone) - uri: - url: "{{ AUTH_URL_DNS }}/v2/zones" - method: POST - body_format: raw - follow_redirects: all - return_content: yes - validate_certs: yes - status_code: 200,201,202,203 - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - body: "{{ lookup('template', 'create.json.j2')|to_json }}" - register: zone - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: zone.status == 200 or zone.status == 201 or zone.status == 202 or zone.status == 203 - changed_when: false - when: zone_name is defined - -- name: Pause while creating zone - pause: - minutes: 1 - -- name: Lookup zone_id - include: lookup.yml - -- name: Create zonerecords - include: zonerecord_create.yml -# with_items: -# - "{{ zone_records }}" -# loop_control: -# loop_var: zone_record diff --git a/roles/otc_dns/tasks/delete.yml b/roles/otc_dns/tasks/delete.yml deleted file mode 100644 index 921d590..0000000 --- a/roles/otc_dns/tasks/delete.yml +++ /dev/null @@ -1,22 +0,0 @@ -- name: Lookup zone_id - include: lookup.yml - -- name: Send request to API (delete zone) - uri: - url: "{{ AUTH_URL_DNS }}/v2/zones/{{ zone_id }}" - method: DELETE - return_content: yes - validate_certs: yes - status_code: 200,201,202,203 - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - when: zone_id is defined and zone_id|length != 0 - register: zone - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: zone.status == 200 or zone.status == 201 or zone.status == 202 or zone.status == 203 - changed_when: false - -- debug: var=zone.json - when: zone is defined diff --git a/roles/otc_dns/tasks/list.yml b/roles/otc_dns/tasks/list.yml deleted file mode 100644 index e0dd6bf..0000000 --- a/roles/otc_dns/tasks/list.yml +++ /dev/null @@ -1,38 +0,0 @@ -- name: Send request to API (list public zone) - uri: - url: "{{ AUTH_URL_DNS }}/v2/zones?type=public" - method: GET - return_content: yes - validate_certs: yes - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: zonelist_public - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: zonelist_piblic.status == 200 - changed_when: false - -- name: Send request to API (list private zones) - uri: - url: "{{ AUTH_URL_DNS }}/v2/zones?type=private" - method: GET - return_content: yes - validate_certs: yes - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: zonelist_private - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: zonelist_private.status == 200 - changed_when: false - -- name: Set fact zonelist - set_fact: - zonelist: "{{ zonelist_public.json.zones }} + {{ zonelist_private.json.zones }}" - -- name: List zones - debug: - msg: "{{ zonelist }}" - when: zonelist is defined diff --git a/roles/otc_dns/tasks/lookup.yml b/roles/otc_dns/tasks/lookup.yml deleted file mode 100644 index ca546b6..0000000 --- a/roles/otc_dns/tasks/lookup.yml +++ /dev/null @@ -1,43 +0,0 @@ -- name: Send request to API (list public zones) - uri: - url: "{{ AUTH_URL_DNS }}/v2/zones?type=public" - method: GET - return_content: yes - validate_certs: yes - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: zonelist_public - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: zonelist_public.status == 200 - changed_when: false - when: zone_name is defined - -- name: Send request to API (list private zones) - uri: - url: "{{ AUTH_URL_DNS }}/v2/zones?type=private" - method: GET - return_content: yes - validate_certs: yes - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: zonelist_private - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: zonelist_private.status == 200 - changed_when: false - when: zone_name is defined - -- name: Set fact zonelist_result - set_fact: - zonelist_result: "{{ zonelist_public.json.zones }} + {{ zonelist_private.json.zones }}" - when: zone_name is defined - -- name: Set fact zone_id for dns if zone_name is defined - vars: - zonenamedot: "{{ zone_name }}." - set_fact: - zone_id: "{{ zonelist_result|json_query(\"[?name=='\" + zonenamedot + \"'].id|[0]\") }}" - when: zone_name is defined diff --git a/roles/otc_dns/tasks/main.yml b/roles/otc_dns/tasks/main.yml deleted file mode 100644 index d9cbe31..0000000 --- a/roles/otc_dns/tasks/main.yml +++ /dev/null @@ -1,3 +0,0 @@ -- name: action {{ localaction }} - include: "{{ localaction }}.yml" - when: localaction is defined diff --git a/roles/otc_dns/tasks/ptr_create.yml b/roles/otc_dns/tasks/ptr_create.yml deleted file mode 100644 index e6d57da..0000000 --- a/roles/otc_dns/tasks/ptr_create.yml +++ /dev/null @@ -1,45 +0,0 @@ -- name: Send request to API (list EIP) - uri: - url: "{{ AUTH_URL_VPC }}/v1/{{ PROJECT_ID }}/publicips" - method: GET - return_content: yes - validate_certs: yes - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: floatingiplist_result - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: floatingiplist_result.status == 200 - changed_when: false - -- name: Set fact eip_id if public_ip_address is defined - set_fact: - eip_id: "{{ (floatingiplist_result.content|from_json)|json_query(\"publicips[?public_ip_address=='\" + public_ip_address + \"'].id|[0]\") }}" - when: - - (public_ip_address is defined and public_ip_address | ipaddr) - -- name: Send request to API (create ptr) - uri: - url: "{{ AUTH_URL_DNS }}/v2/reverse/floatingips/{{ PROJECT_NAME }}:{{ eip_id }}" - method: PATCH - body_format: raw - follow_redirects: all - return_content: yes - validate_certs: yes - status_code: 200,201,202,203,400 - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - body: "{{ lookup('template', 'ptr_create.json.j2')|to_json }}" - register: ptrrecord - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: ptrrecord.status == 200 or ptrrecord.status == 201 or ptrrecord.status == 202 or ptrrecord.status == 203 or ptrrecord.status == 400 - changed_when: false - when: - - (ptr_name is defined and ptr_name | length != 0) - - eip_id is defined - -- debug: - msg: "{{ ptrrecord }}" diff --git a/roles/otc_dns/tasks/ptr_delete.yml b/roles/otc_dns/tasks/ptr_delete.yml deleted file mode 100644 index 8650518..0000000 --- a/roles/otc_dns/tasks/ptr_delete.yml +++ /dev/null @@ -1,45 +0,0 @@ -- name: Send request to API (list EIP) - uri: - url: "{{ AUTH_URL_VPC }}/v1/{{ PROJECT_ID }}/publicips" - method: GET - return_content: yes - validate_certs: yes - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: floatingiplist_result - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: floatingiplist_result.status == 200 - changed_when: false - -- name: Set fact eip_id if public_ip_address is defined - set_fact: - eip_id: "{{ (floatingiplist_result.content|from_json)|json_query(\"publicips[?public_ip_address=='\" + public_ip_address + \"'].id|[0]\") }}" - when: - - (public_ip_address is defined and public_ip_address | ipaddr) - - -- name: Send request to API (delete ptr) - uri: - url: "{{ AUTH_URL_DNS }}/v2/reverse/floatingips/{{ PROJECT_NAME }}:{{ eip_id }}" - method: PATCH - body_format: raw - follow_redirects: all - return_content: yes - validate_certs: yes - status_code: 200,201,202,203,400,404 - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - body: '{ "ptrdname": null }' - register: ptrrecord - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: ptrrecord.status == 200 or ptrrecord.status == 201 or ptrrecord.status == 202 or ptrrecord.status == 203 or ptrrecord.status = 400 or ptrrecord.status = 404 - changed_when: false - when: - - eip_id is defined and eip_id|length != 0 - -- debug: - msg: "{{ ptrrecord }}" diff --git a/roles/otc_dns/tasks/ptr_list.yml b/roles/otc_dns/tasks/ptr_list.yml deleted file mode 100644 index 8264eef..0000000 --- a/roles/otc_dns/tasks/ptr_list.yml +++ /dev/null @@ -1,19 +0,0 @@ -- name: Send request to API (list ptr) - uri: - url: "{{ AUTH_URL_DNS }}/v2/reverse/floatingips" - method: GET - follow_redirects: all - return_content: yes - validate_certs: yes - status_code: 200,201,202,203,400 - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: ptrrecord - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: ptrrecord.status == 200 or ptrrecord.status == 201 or ptrrecord.status == 202 or ptrrecord.status == 203 or ptrrecord.status == 400 - changed_when: false - -- debug: - msg: "{{ ptrrecord }}" diff --git a/roles/otc_dns/tasks/show.yml b/roles/otc_dns/tasks/show.yml deleted file mode 100644 index c55e7a9..0000000 --- a/roles/otc_dns/tasks/show.yml +++ /dev/null @@ -1,21 +0,0 @@ -- name: Lookup zone_id - include: lookup.yml - -- name: Send request to API (show zone) - uri: - url: "{{ AUTH_URL_DNS }}/v2/zones/{{ zone_id }}" - method: GET - return_content: yes - validate_certs: yes - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: zone - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: zone.status == 200 - changed_when: false - when: zone_id is defined - -- debug: var=zone.json - when: zone is defined diff --git a/roles/otc_dns/tasks/transfer.yml b/roles/otc_dns/tasks/transfer.yml deleted file mode 100644 index 3669e8e..0000000 --- a/roles/otc_dns/tasks/transfer.yml +++ /dev/null @@ -1,28 +0,0 @@ ---- -- name: Call dig to catch zone information - shell: dig +noall +answer {{ zone_name }} @{{ dns_server }} axfr | grep -E '(\s+)(A|AAAA|CNAME|MX)' - register: zone_data - -- name: Create dns.ini file - template: - src: dns.ini.j2 - dest: ./dns.ini - force: yes - backup: yes - when: config == "ini" - -- name: Create dns.yml file - template: - src: dns.yml.j2 - dest: ./dns.yml - force: yes - backup: yes - when: config == "yml" - -- name: Create dns.json file - template: - src: dns.json.j2 - dest: ./dns.json - force: yes - backup: yes - when: config == "json" diff --git a/roles/otc_dns/tasks/zonerecord_create.yml b/roles/otc_dns/tasks/zonerecord_create.yml deleted file mode 100644 index 2333fa0..0000000 --- a/roles/otc_dns/tasks/zonerecord_create.yml +++ /dev/null @@ -1,22 +0,0 @@ -- name: Send request to API (create zonerecords) - vars: - zonerecord_part: "{{ item.split(';') }}" - uri: - url: "{{ AUTH_URL_DNS }}/v2/zones/{{ zone_id }}/recordsets" - method: POST - body_format: raw - follow_redirects: all - return_content: yes - validate_certs: yes - status_code: 200,201,202,203,400 - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - body: "{{ lookup('template', 'zonerecord_create.json.j2')|to_json }}" - register: zonerecord - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: zonerecord.status == 200 or zonerecord.status == 201 or zonerecord.status == 202 or zonerecord.status == 203 or zonerecord.status == 400 - changed_when: false - with_items: - - "{{ zone_records }}" diff --git a/roles/otc_dns/templates/create.json.j2 b/roles/otc_dns/templates/create.json.j2 deleted file mode 100644 index 697d594..0000000 --- a/roles/otc_dns/templates/create.json.j2 +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "{{ zone_name }}.", -{% if zone_description is defined %} - "description": "{{ zone_description }}", -{% endif %} -{% if zone_type is defined %} - "zone_type": "{{ zone_type }}", -{% endif %} -{% if zone_type == "private" %} - "router": { - "router_id": "{{ router_id }}", - "router_region": "{{ PROJECT_NAME }}" - }, -{% endif %} -{% if zone_email is defined %} - "email": "{{ zone_email }}", -{% endif %} - "ttl": {{ zone_ttl }} -} diff --git a/roles/otc_dns/templates/dns.ini.j2 b/roles/otc_dns/templates/dns.ini.j2 deleted file mode 100644 index f4bcabb..0000000 --- a/roles/otc_dns/templates/dns.ini.j2 +++ /dev/null @@ -1,23 +0,0 @@ -# usage dns (public zones): -# ansible-playbook tenant_yml.yml -e "zone_name=ansible.otc.telekomcloud99.com" -e "localaction=create" -# usage dns (private usage, only in selected vpc): -# ansible-playbook tenant_ini.yml -e "zone_name=ansible.internal.corp" -e "vpc_name=ansible-vpc01" -e "localaction=create" -[{{ zone_name }}] -zone_description=Ansible generated DNS Zone -zone_type={{ zone_type }} -zone_email={{ zone_email }} -zone_ttl={{ zone_ttl }} -[dnszonerecords] -{{ zone_name }}=[ {% for record in zone_data.stdout_lines %} -{% set record_clean = record | regex_replace('(\\s+)', ';') %} -{% set pattern = "^(.*);(.*);(.*);(.*);(.*)$" %} -{% set fqdn = record_clean | regex_replace(pattern, "\\1" ) %} -{% set ttl = record_clean | regex_replace(pattern, "\\2" ) %} -{% set rtyp = record_clean | regex_replace(pattern, "\\4" ) %} -{% set value = record_clean | regex_replace(pattern, "\\5" ) %} -{% if loop.last %} -"{{ fqdn }};;{{ rtyp }};{{ ttl }};{{ value }}" -{% else %} -"{{ fqdn }};;{{ rtyp }};{{ ttl }};{{ value }}", -{% endif %} -{% endfor %}] diff --git a/roles/otc_dns/templates/dns.json.j2 b/roles/otc_dns/templates/dns.json.j2 deleted file mode 100644 index 063b8a7..0000000 --- a/roles/otc_dns/templates/dns.json.j2 +++ /dev/null @@ -1,25 +0,0 @@ -"dnszones": { - "{{ zone_name }}": { - "zone_description": "Ansible generated DNS Zone", - "zone_type": "{{ zone_type }}", - "zone_email": "{{ zone_email }}", - "zone_ttl": "{{ zone_ttl }}" - } -}, -"dnszonerecords": { - "{{ zone_name }}": [{% for record in zone_data.stdout_lines %} -{% set record_clean = record | regex_replace('(\\s+)', ';') %} -{% set pattern = "^(.*);(.*);(.*);(.*);(.*)$" %} -{% set fqdn = record_clean | regex_replace(pattern, "\\1" ) %} -{% set ttl = record_clean | regex_replace(pattern, "\\2" ) %} -{% set rtyp = record_clean | regex_replace(pattern, "\\4" ) %} -{% set value = record_clean | regex_replace(pattern, "\\5" ) %} -{% if loop.last %} -"{{ fqdn }};;{{ rtyp }};{{ ttl }};{{ value }}" -{% else %} -"{{ fqdn }};;{{ rtyp }};{{ ttl }};{{ value }}", -{% endif %} -{% endfor %}] -} - - diff --git a/roles/otc_dns/templates/dns.yml.j2 b/roles/otc_dns/templates/dns.yml.j2 deleted file mode 100644 index c4d783a..0000000 --- a/roles/otc_dns/templates/dns.yml.j2 +++ /dev/null @@ -1,21 +0,0 @@ -# usage dns (public zones): -# ansible-playbook tenant_yml.yml -e "zone_name=ansible.otc.telekomcloud99.com" -e "localaction=create" -# usage dns (private usage, only in selected vpc): -# ansible-playbook tenant_ini.yml -e "zone_name=ansible.internal.corp" -e "vpc_name=ansible-vpc01" -e "localaction=create" -dnszones: - {{ zone_name }}: - zone_description: "Ansible generated DNS Zone" - zone_type: "{{ zone_type }}" - zone_email: "{{ zone_email }}" - zone_ttl: {{ zone_ttl }} -dnszonerecords: - {{ zone_name }}: -{% for record in zone_data.stdout_lines %} -{% set record_clean = record | regex_replace('(\\s+)', ';') %} -{% set pattern = "^(.*);(.*);(.*);(.*);(.*)$" %} -{% set fqdn = record_clean | regex_replace(pattern, "\\1" ) %} -{% set ttl = record_clean | regex_replace(pattern, "\\2" ) %} -{% set rtyp = record_clean | regex_replace(pattern, "\\4" ) %} -{% set value = record_clean | regex_replace(pattern, "\\5" ) %} - - "{{ fqdn }};;{{ rtyp }};{{ ttl }};{{ value }}" -{% endfor %} diff --git a/roles/otc_dns/templates/ptr_create.json.j2 b/roles/otc_dns/templates/ptr_create.json.j2 deleted file mode 100644 index 30d5c7b..0000000 --- a/roles/otc_dns/templates/ptr_create.json.j2 +++ /dev/null @@ -1,9 +0,0 @@ -{ -{% if description is defined and description|length != 0 %} - "description": "{{ description }}", -{% endif %} -{% if ttl is defined and ttl|length != 0 %} - "ttl": {{ ttl }}, -{% endif %} - "ptrdname": "{{ ptr_name }}." -} diff --git a/roles/otc_dns/templates/rule_create.json.j2 b/roles/otc_dns/templates/rule_create.json.j2 deleted file mode 100644 index f0fadc3..0000000 --- a/roles/otc_dns/templates/rule_create.json.j2 +++ /dev/null @@ -1,17 +0,0 @@ -{ - "security_group_rule": { - "direction": "{{ secgrouprule_part[0] }}", - "ethertype": "{{ secgrouprule_part[1] }}", - "protocol": "{{ secgrouprule_part[2] }}", -{% if secgrouprule_part[3] is defined and secgrouprule_part[3]|length != 0 %} - "port_range_min": {{ secgrouprule_part[3] }}, -{% endif %} -{% if secgrouprule_part[4] is defined and secgrouprule_part[4]|length != 0 %} - "port_range_max": {{ secgrouprule_part[4] }}, -{% endif %} -{% if secgrouprule_part[5] is defined and secgrouprule_part[5]|length != 0 %} - "remote_ip_prefix": "{{ secgrouprule_part[5] }}", -{% endif %} - "security_group_id": "{{ secgroup_id }}", - } -} diff --git a/roles/otc_dns/templates/zonerecord_create.json.j2 b/roles/otc_dns/templates/zonerecord_create.json.j2 deleted file mode 100644 index e751071..0000000 --- a/roles/otc_dns/templates/zonerecord_create.json.j2 +++ /dev/null @@ -1,9 +0,0 @@ -{ - "name": "{{ zonerecord_part[0] }}.", -{% if zonerecord_part[1] is defined and zonerecord_part[1]|length != 0 %} - "description": "{{ zonerecord_part[1] }}", -{% endif %} - "type": "{{ zonerecord_part[2] }}", - "ttl": {{ zonerecord_part[3] }}, - "records": [ "{{ zonerecord_part[4] }}" ] -} diff --git a/roles/otc_ecs/README.rst b/roles/otc_ecs/README.rst deleted file mode 100644 index 85fbfc4..0000000 --- a/roles/otc_ecs/README.rst +++ /dev/null @@ -1,64 +0,0 @@ -otc_ecs -======= - -OTC role for ECS. - -Variables: -^^^^^^^^^^ - -+---------------------------+---------------------------------------------------------------+ -| Name | Description | -+===========================+===============================================================+ -| localaction=flavors | show flavors | -+---------------------------+---------------------------------------------------------------+ -| ecs_name | name of ECS | -+---------------------------+---------------------------------------------------------------+ -| ecs_id | id of ECS | -+---------------------------+---------------------------------------------------------------+ -| ecs_volumetype | Volume type of ECS (SATA,SSD,SAS) | -+---------------------------+---------------------------------------------------------------+ -| ecs_volumesize | Size of ECS volume in GB (or image default) | -+---------------------------+---------------------------------------------------------------+ -| ecs_ram | RAM size of ECS | -+---------------------------+---------------------------------------------------------------+ -| ecs_vcpus | CPU core of ECS | -+---------------------------+---------------------------------------------------------------+ -| ecs_ipaddress | IP address of ECS | -+---------------------------+---------------------------------------------------------------+ -| ecs_fileinject_[1-5] | Personal data (file injection) | -| | up to 5 files | -| | example: ansible-playbook -e "ecs_fileinject_1=/etc/hosts \ | -| | ecs_fileinject_data_1=$(base64 -w 0 hosts.txt)" | -+---------------------------+---------------------------------------------------------------+ -| ecs_fileinject_data_[1-5] | Personal data (file injection) | -+---------------------------+---------------------------------------------------------------+ -| ecs_user_data | cloud-init user data file | -| | example [...] -e "ecs_user_data=$(base64 -w 0 user-data.txt)" | -+---------------------------+---------------------------------------------------------------+ -| ecs_adminpass | Admin password ECS | -+---------------------------+---------------------------------------------------------------+ -| ecs_adminkey | SSH key name of ECS | -+---------------------------+---------------------------------------------------------------+ - -Functions: -^^^^^^^^^^ - -Create:: - - ansible-playbook tenant_yml.yml -e "ecs_name=ansible-test01" -e "localaction=create" - - ansible-playbook tenant_ini.yml -e "ecs_name=ansible-test01" -e "localaction=create" - - ansible-playbook tenant_json.yml -e "ecs_name=ansible-test01" -e "localaction=create" - -Show:: - - ./grole otc_ecs; ansible-playbook roles.yml -e "ecs_name=ansible-test01" -e "localaction=show" - -List:: - - ./grole otc_ecs; ansible-playbook roles.yml -e "localaction=list" - -Delete:: - - ./grole otc_ecs; ansible-playbook roles.yml -e "ecs_name=ansible-test01" -e "localaction=delete" diff --git a/roles/otc_ecs/defaults/main.yml b/roles/otc_ecs/defaults/main.yml deleted file mode 100644 index a91cd5f..0000000 --- a/roles/otc_ecs/defaults/main.yml +++ /dev/null @@ -1,4 +0,0 @@ -uri_follow_redirects: "none" -uri_validate_certs: "yes" -uri_retries: 5 -uri_delay: 1 diff --git a/roles/otc_ecs/tasks/create.yml b/roles/otc_ecs/tasks/create.yml deleted file mode 100644 index ab75811..0000000 --- a/roles/otc_ecs/tasks/create.yml +++ /dev/null @@ -1,56 +0,0 @@ -- name: Lookup flavor_id - include: lookup.yml - -- name: Lookup vpc_id - include: ../../otc_vpc/tasks/lookup.yml - -- name: Lookup image_id - include: ../../otc_ims/tasks/lookup.yml - -- name: Lookup subnet_id - include: ../../otc_subnet/tasks/lookup.yml - -- name: Lookup eip_id - include: ../../otc_eip/tasks/lookup.yml - -- name: Lookup secgroup_id - include: ../../otc_secgroup/tasks/lookup.yml - with_items: - - "{{ secgroups }}" - loop_control: - loop_var: secgroup_name - -- name: Send request to API (create ECS) - uri: - url: "{{ AUTH_URL_ECS_CLOUD }}/{{ PROJECT_ID }}/cloudservers" - method: POST - body_format: raw - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - body: "{{ lookup('template', 'create.json.j2')|to_json }}" - register: ecs - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: ecs.status == 200 - changed_when: false - when: - - ecs_name is defined - - image_id is defined - - flavor_id is defined - - not ecs_id or ecs_id is undefined - -- name: Set fact job_id - set_fact: - job_id: "{{ (ecs.content|from_json)|json_query('job_id') }}" - when: - - not ecs_id or ecs_id is undefined - - ecs is defined and ecs.content|length != 0 - -- name: Output of job_id - debug: - msg: "{{ job_id }}" - when: job_id is defined diff --git a/roles/otc_ecs/tasks/delete.yml b/roles/otc_ecs/tasks/delete.yml deleted file mode 100644 index d0964db..0000000 --- a/roles/otc_ecs/tasks/delete.yml +++ /dev/null @@ -1,24 +0,0 @@ -- name: Send request to API (delete ECS) - uri: - url: "{{ AUTH_URL_ECS_CLOUD }}/{{ PROJECT_ID }}/cloudservers/delete" - method: POST - body_format: raw - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - body: "{{ lookup('template', 'delete.json.j2')|to_json }}" - register: ecs - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: ecs.status == 200 - changed_when: false - when: ecs_id is defined and ecs_id|length != 0 - -- pause: - minutes: 1 - -- debug: - msg: "{{ ecs }}" diff --git a/roles/otc_ecs/tasks/flavors.yml b/roles/otc_ecs/tasks/flavors.yml deleted file mode 100644 index 0371ac7..0000000 --- a/roles/otc_ecs/tasks/flavors.yml +++ /dev/null @@ -1,29 +0,0 @@ -- name: Send request to API (list flavors) - uri: - url: "{{ AUTH_URL_ECS_CLOUD }}/{{ PROJECT_ID }}/cloudservers/flavors" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: flavorlist - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: flavorlist.status == 200 - changed_when: false - tags: - - flavors - -- name: Debug output flavor long list - debug: - msg: "{{ flavorlist.content }}" - when: - - output is defined and output == "long" - -- name: Debug output flavors short list - debug: - msg: "[ ] {% for flavor in flavorlist.json.flavors %}[{{ flavor.id }} {{ flavor.name }} {{ flavor.vcpus }} {{ flavor.ram }}]{% endfor %}" - when: - - output is undefined diff --git a/roles/otc_ecs/tasks/list.yml b/roles/otc_ecs/tasks/list.yml deleted file mode 100644 index cf28990..0000000 --- a/roles/otc_ecs/tasks/list.yml +++ /dev/null @@ -1,18 +0,0 @@ -- name: Send request to API (list ECS) - uri: - url: "{{ AUTH_URL_ECS }}/servers" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: ecslist - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: ecslist.status == 200 - changed_when: false - -- debug: - msg: "{{ ecslist.json }}" diff --git a/roles/otc_ecs/tasks/lookup.yml b/roles/otc_ecs/tasks/lookup.yml deleted file mode 100644 index a043343..0000000 --- a/roles/otc_ecs/tasks/lookup.yml +++ /dev/null @@ -1,87 +0,0 @@ -- name: Send request to API (list ECS for lookup) - uri: - url: "{{ AUTH_URL_ECS }}/servers" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: ecs_result - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: ecs_result.status == 200 - changed_when: false - when: ecs_name is defined - -- name: Set fact ecs_id for ecs if ecs_name is defined - set_fact: - ecs_id: "{{ (ecs_result.content|from_json)|json_query(\"servers[?name=='\" + ecs_name + \"'].id|[0]\") }}" - when: ecs_name is defined - -- name: Send request to API (list flavor for lookup) - uri: - url: "{{ AUTH_URL_ECS_CLOUD }}/{{ PROJECT_ID }}/cloudservers/flavors" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: flavor_result - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: flavor_result.status == 200 - changed_when: false - when: - - ecs_name is defined - - (ecs_ram is defined and ecs_ram|length != 0) and (ecs_vcpus is defined and ecs_vcpus|length != 0) - -- name: Set fact flavor_id if ecs_ram or ecs_vcpus is defined - set_fact: - flavor_id: "{{ (flavor_result.content|from_json)|json_query('sort_by(flavors, &ram)|[?ram>=`' + ecs_ram + '` && vcpus>=`' + ecs_vcpus + '`].id|[0]') }}" - when: - - ecs_name is defined - - (ecs_ram is defined and ecs_ram |length != 0) or (ecs_vcpus is defined and ecs_vcpus|length != 0) - -# this code below is duplicated to the ref roles -# - name: Send request to API (list images for lookup) -# uri: -# url: "{{ AUTH_URL_IMS }}/v2/cloudimages?name={{ image_name }}" -# method: GET -# return_content: yes -# validate_certs: yes -# headers: -# Content-Type: "application/json" -# X-Auth-Token: "{{ token['x_subject_token'] }}" -# register: ims_result -# when: -# - image_name is defined -# -# - name: Set fact image_id if image_name is defined -# set_fact: -# image_id: "{{ (ims_result.content|from_json)|json_query('images[].id|[0]') }}" -# when: -# - image_name is defined -# -# - name: Send request to API (list subnet for lookup) -# uri: -# url: "{{ AUTH_URL_VPC }}/v1/{{ PROJECT_ID }}/subnets" -# method: GET -# return_content: yes -# validate_certs: yes -# headers: -# Content-Type: "application/json" -# X-Auth-Token: "{{ token['x_subject_token'] }}" -# when: -# - subnet_name is defined -# register: subnet_result -# -# - name: Set fact for subnet_id if subnet_name is defined -# set_fact: -# subnet_id: "{{ (subnet_result.content|from_json)|json_query(\"subnets[?name=='\" + subnet_name + \"'].id|[0]\") }}" -# when: -# - subnet_name is defined and subnet_name|length != 0 -# diff --git a/roles/otc_ecs/tasks/main.yml b/roles/otc_ecs/tasks/main.yml deleted file mode 100644 index 4f01391..0000000 --- a/roles/otc_ecs/tasks/main.yml +++ /dev/null @@ -1,8 +0,0 @@ -- name: action {{ localaction }} - include: "{{ localaction }}.yml" - when: localaction is defined - -- name: Lookup ecs_id - include: lookup.yml - when: - - ecs_name is defined diff --git a/roles/otc_ecs/tasks/show.yml b/roles/otc_ecs/tasks/show.yml deleted file mode 100644 index ec7a58e..0000000 --- a/roles/otc_ecs/tasks/show.yml +++ /dev/null @@ -1,23 +0,0 @@ -- name: Lookup ecs_id - include: lookup.yml - -- name: Send request to API (show ECS) - uri: - url: "{{ AUTH_URL_ECS }}/servers/{{ ecs_id }}" - method: PUT - body_format: raw - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - body: "{{ lookup('template', 'show.json.j2')|to_json }}" - register: ecs - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: ecs.status == 200 - changed_when: false - -- debug: - msg: "{{ ecs }}" diff --git a/roles/otc_ecs/templates/create.json.j2 b/roles/otc_ecs/templates/create.json.j2 deleted file mode 100644 index 05e8e1a..0000000 --- a/roles/otc_ecs/templates/create.json.j2 +++ /dev/null @@ -1,81 +0,0 @@ -{ - "server": { - "availability_zone": "{{ availability_zone }}", - "name": "{{ ecs_name }}", - "imageRef": "{{ image_id }}", - "root_volume": { -{% if ecs_volumesize is defined and ecs_volumesize|length != 0 %} - "size": "{{ ecs_volumesize }}", -{% endif %} - "volumetype": "{{ ecs_volumetype }}" - }, - "flavorRef": "{{ flavor_id }}", - "vpcid": "{{ vpc_id }}", - "security_groups": [ -{% for secgroup_id in secgroup_ids %} - { - "id": "{{ secgroup_id }}" - }, -{% endfor %} - ], - "nics": [ - { -{% if ecs_ipaddress is defined and ecs_ipaddress|length != 0 %} - "ip_address": "{{ ecs_ipaddress }}", -{% endif %} - "subnet_id": "{{ subnet_id }}" - } - ], -{% if eip_id is defined %} - "publicip": { - "id": "{{ eip_id }}" - }, -{% endif %} -{% if ecs_fileinject_1 is defined %} - "personality": [ - { - "path": "{{ ecs_fileinject_1 }}", - "contents": "{{ ecs_fileinject_data_1 }}" - } -{% if ecs_fileinject_2 is defined %} - ,{ - "path": "{{ ecs_fileinject_2 }}", - "contents": "{{ ecs_fileinject_data_2 }}" - } -{% endif %} -{% if ecs_fileinject_3 is defined %} - ,{ - "path": "{{ ecs_fileinject_3 }}", - "contents": "{{ ecs_fileinject_data_3 }}" - } -{% endif %} -{% if ecs_fileinject_4 is defined %} - ,{ - "path": "{{ ecs_fileinject_4 }}", - "contents": "{{ ecs_fileinject_data_4 }}" - } -{% endif %} -{% if ecs_fileinject_5 is defined %} - ,{ - "path": "{{ ecs_fileinject_5 }}", - "contents": "{{ ecs_fileinject_data_5 }}" - } -{% endif %} - ], -{% endif %} -{% if ecs_user_data is defined %} - "user_data": "{{ ecs_user_data }}", -{% endif %} -{% if ecs_adminpass is defined %} - "adminPass": "{{ ecs_adminpass }}", -{% endif %} -{% if ecs_adminkey is defined %} - "key_name": "{{ ecs_adminkey }}", - "adminPass": "", -{% endif %} - "count": 1, - "},": { - "__vnc_keymap": "de" - } - } -} diff --git a/roles/otc_ecs/templates/delete.json.j2 b/roles/otc_ecs/templates/delete.json.j2 deleted file mode 100644 index 9f0bc0e..0000000 --- a/roles/otc_ecs/templates/delete.json.j2 +++ /dev/null @@ -1,17 +0,0 @@ -{ - "servers": [ - { - "id": "{{ ecs_id }}" - } - ], -{% if delete_publicip is defined %} - "delete_publicip": true, -{% else %} - "delete_publicip": false, -{% endif %} -{% if delete_volume is defined %} - "delete_volume": true -{% else %} - "delete_volume": false -{% endif %} -} diff --git a/roles/otc_ecs/templates/show.json.j2 b/roles/otc_ecs/templates/show.json.j2 deleted file mode 100644 index cebb36f..0000000 --- a/roles/otc_ecs/templates/show.json.j2 +++ /dev/null @@ -1,5 +0,0 @@ -{ - "server": { - "name": "{{ ecs_name }}" - } -} diff --git a/roles/otc_eip/README.rst b/roles/otc_eip/README.rst deleted file mode 100644 index ae435e2..0000000 --- a/roles/otc_eip/README.rst +++ /dev/null @@ -1,39 +0,0 @@ -otc_eip -======= - -OTC role for floating ip (EIP). - -Variables: -^^^^^^^^^^ - -+-------------------------+-----------------------------------------------------------+ -| Name | Description | -+=========================+===========================================================+ -| public_ip_address | Public ip address (alreay allocated or new | -+-------------------------+-----------------------------------------------------------+ -| eip_id | id of EIP | -+-------------------------+-----------------------------------------------------------+ -| eip_bandwidth_name | Bandwith name of EIP | -+-------------------------+-----------------------------------------------------------+ -| eip_bandwidth_size | Bandwith size of EIP (5-500 Mbit/s | -+-------------------------+-----------------------------------------------------------+ - - -Functions: -^^^^^^^^^^ - -Create:: - - ansible-playbook tenant_yml.yml -e "public_ip_address=0.0.0.0" -e "localaction=create" - -Show:: - - ./grole otc_eip; ansible-playbook roles.yml -e "public_ip_address=160.44.1.1" -e "localaction=show" - -List:: - - ./grole otc_eip; ansible-playbook roles.yml -e "localaction=list" - -Delete:: - - ./grole otc_eip; ansible-playbook roles.yml -e "public_ip_address=160.44.1.1" -e "localaction=delete" diff --git a/roles/otc_eip/defaults/main.yml b/roles/otc_eip/defaults/main.yml deleted file mode 100644 index a91cd5f..0000000 --- a/roles/otc_eip/defaults/main.yml +++ /dev/null @@ -1,4 +0,0 @@ -uri_follow_redirects: "none" -uri_validate_certs: "yes" -uri_retries: 5 -uri_delay: 1 diff --git a/roles/otc_eip/tasks/create.yml b/roles/otc_eip/tasks/create.yml deleted file mode 100644 index 0db842a..0000000 --- a/roles/otc_eip/tasks/create.yml +++ /dev/null @@ -1,26 +0,0 @@ -- name: Send request to API (create EIP) - uri: - url: "{{ AUTH_URL_VPC }}/v1/{{ PROJECT_ID }}/publicips" - method: POST - body_format: raw - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - body: "{{ lookup('template', 'create.json.j2')|to_json }}" - register: eip - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: eip.status == 200 - changed_when: false - when: public_ip_address == "0.0.0.0" - -- set_fact: - public_ip_address: "{{ (eip.content|from_json)|json_query('publicip.public_ip_address') }}" - eip_id: "{{ (eip.content|from_json)|json_query('publicip.id') }}" - when: public_ip_address == "0.0.0.0" - -- debug: - msg: "{{ public_ip_address }}" diff --git a/roles/otc_eip/tasks/delete.yml b/roles/otc_eip/tasks/delete.yml deleted file mode 100644 index 6a86e61..0000000 --- a/roles/otc_eip/tasks/delete.yml +++ /dev/null @@ -1,23 +0,0 @@ -- name: Lookup eip_id - include: lookup.yml - -- name: Send request to API (delete EIP) - uri: - url: "{{ AUTH_URL_VPC }}/v1/{{ PROJECT_ID }}/publicips/{{ eip_id }}" - method: DELETE - body_format: raw - return_content: yes - status_code: 200,201,202,203,204 - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: eip - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: eip.status == 200 or eip.status == 201 or eip.status == 202 or eip.status == 203 or eip.status == 204 - changed_when: false - -- debug: - msg: "{{ eip }}" diff --git a/roles/otc_eip/tasks/list.yml b/roles/otc_eip/tasks/list.yml deleted file mode 100644 index cde98e2..0000000 --- a/roles/otc_eip/tasks/list.yml +++ /dev/null @@ -1,18 +0,0 @@ -- name: Send request to API (list EIP) - uri: - url: "{{ AUTH_URL_VPC }}/v1/{{ PROJECT_ID }}/publicips" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: floatingiplist - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: floatingiplist.status == 200 - changed_when: false - -- debug: - msg: "{{ floatingiplist.json }}" diff --git a/roles/otc_eip/tasks/lookup.yml b/roles/otc_eip/tasks/lookup.yml deleted file mode 100644 index 1071463..0000000 --- a/roles/otc_eip/tasks/lookup.yml +++ /dev/null @@ -1,22 +0,0 @@ -- name: Send request to API (list eip for lookup) - uri: - url: "{{ AUTH_URL_VPC }}/v1/{{ PROJECT_ID }}/publicips" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: floatingiplist_result - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: floatingiplist_result.status == 200 - changed_when: false - -- name: Set fact eip_id for eip if public_ip_address is defined - set_fact: - eip_id: "{{ (floatingiplist_result.content|from_json)|json_query(\"publicips[?public_ip_address=='\" + public_ip_address + \"'].id|[0]\") }}" - when: - - public_ip_address | ipaddr -# - (public_ip_address is defined and public_ip_address | ipaddr) diff --git a/roles/otc_eip/tasks/main.yml b/roles/otc_eip/tasks/main.yml deleted file mode 100644 index d9cbe31..0000000 --- a/roles/otc_eip/tasks/main.yml +++ /dev/null @@ -1,3 +0,0 @@ -- name: action {{ localaction }} - include: "{{ localaction }}.yml" - when: localaction is defined diff --git a/roles/otc_eip/tasks/show.yml b/roles/otc_eip/tasks/show.yml deleted file mode 100644 index c74ebb1..0000000 --- a/roles/otc_eip/tasks/show.yml +++ /dev/null @@ -1,21 +0,0 @@ -- name: Lookup eip_id - include: lookup.yml - -- name: Send request to API (show EIP) - uri: - url: "{{ AUTH_URL_VPC }}/v1/{{ PROJECT_ID }}/publicips/{{ eip_id}}" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: floatingipdetails - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: floatingupdetails.status == 200 - changed_when: false - -- debug: - msg: "{{ floatingipdetails.json }}" diff --git a/roles/otc_eip/templates/create.json.j2 b/roles/otc_eip/templates/create.json.j2 deleted file mode 100644 index 38082f6..0000000 --- a/roles/otc_eip/templates/create.json.j2 +++ /dev/null @@ -1,10 +0,0 @@ -{ - "publicip": { - "type": "5_bgp" - }, - "bandwidth": { - "name": "{{ eip_bandwidth_name }}", - "size": {{ eip_bandwidth_size }}, - "share_type": "PER" - } -} diff --git a/roles/otc_elb/README.rst b/roles/otc_elb/README.rst deleted file mode 100644 index 7f87dcd..0000000 --- a/roles/otc_elb/README.rst +++ /dev/null @@ -1,133 +0,0 @@ -otc_elb -======= - -OTC role for Elastic Load Balancer (ELB). - -Variables: -^^^^^^^^^^ - -+------------------------------------+---------------------------------------------------------------+ -| Name | Description | -+====================================+===============================================================+ -| localaction="list" | List ELB | -+------------------------------------+---------------------------------------------------------------+ -| localaction="create" | Create ELB | -+------------------------------------+---------------------------------------------------------------+ -| localaction="show" | Show ELB resources | -+------------------------------------+---------------------------------------------------------------+ -| localaction="listenercreate" | Create ELB Listener | -+------------------------------------+---------------------------------------------------------------+ -| localaction="listenershow" | Show ELB Listener resources | -+------------------------------------+---------------------------------------------------------------+ -| localaction="healthcheckcreate" | Create ELB Healthcheck | -+------------------------------------+---------------------------------------------------------------+ -| localaction="certificatecreate" | Create ELB Certificate | -+------------------------------------+---------------------------------------------------------------+ -| localaction="backendcreate" | Create ELB Backend | -+------------------------------------+---------------------------------------------------------------+ -| localaction="backenddelete" | Delete ELB Backend | -+------------------------------------+---------------------------------------------------------------+ -| localaction="delete" | Delete ELB | -+------------------------------------+---------------------------------------------------------------+ -| localaction="listenerdelete" | Delete ELB Listener | -+------------------------------------+---------------------------------------------------------------+ -| localaction="healthcheckdelete" | Delete ELB Healthcheck | -+------------------------------------+---------------------------------------------------------------+ -| localaction="certificatedelete" | Delete ELB certificate | -+------------------------------------+---------------------------------------------------------------+ -| localaction="backenddelete" | Delete ELB Backend | -+------------------------------------+---------------------------------------------------------------+ -| elb_name | name of ELB | -+------------------------------------+---------------------------------------------------------------+ -| elb_id | id of ELB | -+------------------------------------+---------------------------------------------------------------+ -| admin_state_up | state of the ELB | -+------------------------------------+---------------------------------------------------------------+ -| elb_availability_zone | Availability zone where ELB is located | -+------------------------------------+---------------------------------------------------------------+ -| elb_bandwidth | Bandwidth of the ELB | -+------------------------------------+---------------------------------------------------------------+ -| elb_type | Typ of ELB (internal or external | -+------------------------------------+---------------------------------------------------------------+ -| elb_secgroup_name | Security Group bound on ELB | -+------------------------------------+---------------------------------------------------------------+ -| elb_subnet_name | Subnet of ELB | -+------------------------------------+---------------------------------------------------------------+ -| elb_vpc_name | VPC of ELB | -+------------------------------------+---------------------------------------------------------------+ -| listener_protocol | Listener protocol (HTTP, HTTPS, TCP) | -+------------------------------------+---------------------------------------------------------------+ -| listener_port | Listener Port | -+------------------------------------+---------------------------------------------------------------+ -| listener_backend_protocol | Listener Backend Protocol (HTTP, HTTPS, TCP) | -+------------------------------------+---------------------------------------------------------------+ -| listener_backend_port | Listener Backend Port | -+------------------------------------+---------------------------------------------------------------+ -| listener_lb_algorithm | Listener Algorithm (source, roundrobin, leastconn) | -+------------------------------------+---------------------------------------------------------------+ -| listener_certificate_name | Listener SSL Certificate Name | -+------------------------------------+---------------------------------------------------------------+ -| listener_tcp_timeout | Listener TCP timeout | -+------------------------------------+---------------------------------------------------------------+ -| listener_cookie_timeout | Listener Timeout for Cookies | -+------------------------------------+---------------------------------------------------------------+ -| listener_sticky_session_type | Listener Sticky Session Type (insert if Cookie used) | -+------------------------------------+---------------------------------------------------------------+ -| listener_session_sticky | Listener Session Sticky (true or false) | -+------------------------------------+---------------------------------------------------------------+ -| healthcheck_connect_port | Connect Port for the health check | -+------------------------------------+---------------------------------------------------------------+ -| healthcheck_interval | Interval for the health check | -+------------------------------------+---------------------------------------------------------------+ -| healthcheck_protocol | Protocol for the health check | -+------------------------------------+---------------------------------------------------------------+ -| healthcheck_timeout | Timeout for the health check | -+------------------------------------+---------------------------------------------------------------+ -| healthcheck_uri | URI for the health check (HTTP/HTTPS) | -+------------------------------------+---------------------------------------------------------------+ -| unhealthy_threshold | Treshold for unhealthy state | -+------------------------------------+---------------------------------------------------------------+ -| backend_members | Backend member for the ELB Listener | -+------------------------------------+---------------------------------------------------------------+ - -Functions: -^^^^^^^^^^ - -Create:: - - ansible-playbook tenant_yml.yml -e "elb_name=ansible-elb01" -e "localaction=create" - - ansible-playbook tenant_yml.yml -e "elb_name=ansible-elb01" -e "listener_name=ansible-listener01" -e "localaction=listenercreate" - - ansible-playbook tenant_yml.yml -e "elb_name=ansible-elb01" -e "listener_name=ansible-listener01" -e "localaction=healthcheckcreate" - - ansible-playbook tenant_yml.yml -e "elb_name=ansible-elb01" -e "listener_name=ansible-listener01" -e "localaction=backendcreate" - - ./grole otc_elb; ansible-playbook roles.yml -e "localaction=certificatecreate" -e "elb_certificate_name=ansible-cert01" -e "elb_certificate_certificate_file=cert.pem" -e "elb_certificate_key_file=key.pem" - - -note: similar with ini, and json conf - -Show:: - - ./grole otc_elb; ansible-playbook roles.yml -e "elb_name=ansible-elb01" -e "localaction=show" - - ./grole otc_elb; ansible-playbook roles.yml -e "elb_name=ansible-elb01" -e "localaction=listenershow" - -List:: - - ./grole otc_elb; ansible-playbook roles.yml -e "localaction=list" - -Delete:: - - ./grole otc_elb; ansible-playbook roles.yml -e "elb_name=ansible-elb01" -e "localaction=delete" - - ansible-playbook tenant_yml.yml -e "elb_name=ansible-elb01" -e "localaction=delete" - - ansible-playbook tenant_yml.yml -e "elb_name=ansible-elb01" -e "listener_name=ansible-listener01" -e "localaction=listenerdelete" - - ansible-playbook tenant_yml.yml -e "elb_name=ansible-elb01" -e "listener_name=ansible-listener01" -e "localaction=healthcheckdelete" - - ansible-playbook tenant_yml.yml -e "elb_name=ansible-elb01" -e "listener_name=ansible-listener01" -e "localaction=backenddelete" -e "ecs_name=ansible-test02" - - ./grole otc_elb; ansible-playbook roles.yml -e "localaction=certificatedelete" -e "elb_certificate_name=ansible-cert01" diff --git a/roles/otc_elb/defaults/main.yml b/roles/otc_elb/defaults/main.yml deleted file mode 100644 index a91cd5f..0000000 --- a/roles/otc_elb/defaults/main.yml +++ /dev/null @@ -1,4 +0,0 @@ -uri_follow_redirects: "none" -uri_validate_certs: "yes" -uri_retries: 5 -uri_delay: 1 diff --git a/roles/otc_elb/tasks/backendcreate.yml b/roles/otc_elb/tasks/backendcreate.yml deleted file mode 100644 index 93f53e9..0000000 --- a/roles/otc_elb/tasks/backendcreate.yml +++ /dev/null @@ -1,68 +0,0 @@ -- name: Request full ecs list from API - uri: - url: "{{ AUTH_URL_ECS }}/servers" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: ecs_result - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: ecs_result.status == 200 - changed_when: false - when: listener_name is defined - -- name: Request detail ecs info from API - vars: - backend_member_name: "{{ ecs_result['json']|json_query(\"servers[?name=='\" + item + \"'].id|[0]\") }}" - uri: - url: "{{ AUTH_URL_ECS }}/servers/{{ backend_member_name }}" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: ecs - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: ecs.status == 200 - changed_when: false - when: backend_members is defined - with_items: - - "{{ backend_members.split(',') }}" - -- name: Set fact backend_member_id - set_fact: - backend_member_id: "{{ ecs['results']|json_query('[].json.server.id') }}" - backend_member_ip: "{{ ecs['results']|json_query('[].json.server.addresses.*[*].addr[][]') }}" - when: ecs is defined and listener_id is defined - -- name: Send request to API - uri: - url: "{{ AUTH_URL_ELB }}/{{ PROJECT_ID }}/elbaas/listeners/{{ listener_id }}/members" - method: POST - body_format: raw - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - body: "{{ lookup('template', 'backendcreate.json.j2')|to_json }}" - register: elbbackends - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: elbbackends.status == 200 - changed_when: false - with_together: - - "{{ backend_member_id }}" - - "{{ backend_member_ip }}" - -- debug: - msg: "{{ elbbackends }}" - when: elbbackends is defined diff --git a/roles/otc_elb/tasks/backenddelete.yml b/roles/otc_elb/tasks/backenddelete.yml deleted file mode 100644 index 1713d00..0000000 --- a/roles/otc_elb/tasks/backenddelete.yml +++ /dev/null @@ -1,70 +0,0 @@ -- name: Send request to API (list ECS for lookup) - uri: - url: "{{ AUTH_URL_ECS }}/servers" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: ecs_result - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: ecs_result.status == 200 - changed_when: false - when: ecs_name is defined - -- name: Set fact ecs_id for ecs if ecs_name is defined - set_fact: - ecs_id: "{{ (ecs_result.content|from_json)|json_query(\"servers[?name=='\" + ecs_name + \"'].id|[0]\") }}" - when: ecs_name is defined - -- name: Lookup elb_id - include: lookup.yml - -- name: Send request to API (show ELB backend members) - uri: - url: "{{ AUTH_URL_ELB }}/{{ PROJECT_ID }}/elbaas/listeners/{{ listener_id}}/members" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: backendmembers - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: backendmembers.status == 200 - changed_when: false - when: listener_id is defined - -- name: Set fact backend_member_id - set_fact: - backend_member_id: "{{ (backendmembers.content|from_json)|json_query(\"[?server_id=='\" + ecs_id + \"'].id|[0]\") }}" - when: ecs_id is defined - -- name: Send request to API (delete ELB backend member) - uri: - url: "{{ AUTH_URL_ELB }}/{{ PROJECT_ID }}/elbaas/listeners/{{ listener_id }}/members/action" - method: POST - body_format: raw - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - body: "{{ lookup('template', 'backenddelete.json.j2')|to_json }}" - register: elbbackends - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: elbbackends.status == 200 - changed_when: false - when: - - listener_id is defined - - (backend_member_id is defined and backend_member_id|length != 0) - -- debug: - msg: "{{ elbbackends }}" diff --git a/roles/otc_elb/tasks/backendshow.yml b/roles/otc_elb/tasks/backendshow.yml deleted file mode 100644 index 6ea18b0..0000000 --- a/roles/otc_elb/tasks/backendshow.yml +++ /dev/null @@ -1,22 +0,0 @@ -- name: Lookup elb_id - include: lookup.yml - -- name: Send request to API (show ELB backend members) - uri: - url: "{{ AUTH_URL_ELB }}/{{ PROJECT_ID }}/elbaas/listeners/{{ listener_id}}/members" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: backendmembers - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: backendmembers.status == 200 - changed_when: false - when: listener_id is defined - -- debug: - msg: "{{ backendmembers }}" diff --git a/roles/otc_elb/tasks/certificatecreate.yml b/roles/otc_elb/tasks/certificatecreate.yml deleted file mode 100644 index 3c19f77..0000000 --- a/roles/otc_elb/tasks/certificatecreate.yml +++ /dev/null @@ -1,33 +0,0 @@ -- name: reform certificate - shell: awk '$1=$1' ORS='\\n' {{ elb_certificate_certificate_file }} - register: elb_certificate_certificate - -- name: reform certificate key - shell: awk '$1=$1' ORS='\\n' {{ elb_certificate_key_file }} - register: elb_certificate_key - -- name: Get elb_certificate_id - include: certificatelookup.yml - -- name: Send request to API (Create ELB Certificate) - uri: - url: "{{ AUTH_URL_ELB }}/{{ PROJECT_ID }}/elbaas/certificate" - method: POST - body_format: raw - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - body: "{{ lookup('template', 'certificatecreate.json.j2')|to_json }}" - register: elbcertificate - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: elbcertificate.status == 200 - changed_when: false - when: - - not elb_certificate_id or elb_certificate_id is undefined - -- debug: - msg: "{{ elbcertificate }}" diff --git a/roles/otc_elb/tasks/certificatedelete.yml b/roles/otc_elb/tasks/certificatedelete.yml deleted file mode 100644 index cdd6e2a..0000000 --- a/roles/otc_elb/tasks/certificatedelete.yml +++ /dev/null @@ -1,26 +0,0 @@ -- name: Get elb_certificate_id - include: certificatelookup.yml - -- name: Send request to API (delete certificate) - uri: - url: "{{ AUTH_URL_ELB }}/{{ PROJECT_ID }}/elbaas/certificate/{{ elb_certificate_id }}" - method: DELETE - return_content: yes - status_code: 200,201,202,203,204 - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: elbcertifcate - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: elbcertificate.status == 200 or elbcertificate.status == 201 or elbcertificate.status == 203 or elbcertificate.status == 204 - changed_when: false - when: elb_certificate_id is defined and elb_certificate_id|length != 0 - -- debug: - msg: "{{ elbcertifcate }}" - when: - - elbcertifcate is defined - - elb_certificate_id is defined diff --git a/roles/otc_elb/tasks/certificatelookup.yml b/roles/otc_elb/tasks/certificatelookup.yml deleted file mode 100644 index a5f88ed..0000000 --- a/roles/otc_elb/tasks/certificatelookup.yml +++ /dev/null @@ -1,21 +0,0 @@ -- name: Request elb certificate list from API - uri: - url: "{{ AUTH_URL_ELB }}/{{ PROJECT_ID }}/elbaas/certificate" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: elb_certificate_result - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: elb_certificate_result.status == 200 - changed_when: false - when: elb_certificate_name is defined and elb_certificate_name|length != 0 - -- name: Set fact elb_certificate_id for elb if elb_certificate_name is defined - set_fact: - elb_certificate_id: "{{ (elb_certificate_result.content|from_json)|json_query(\"certificates[?name=='\" + elb_certificate_name + \"'].id|[0]\") }}" - when: elb_certificate_name is defined and elb_certificate_name|length != 0 diff --git a/roles/otc_elb/tasks/create.yml b/roles/otc_elb/tasks/create.yml deleted file mode 100644 index ea2649c..0000000 --- a/roles/otc_elb/tasks/create.yml +++ /dev/null @@ -1,30 +0,0 @@ -- name: Get elb_id - include: lookup.yml - when: - - elb_name is defined - -- name: Send request to API (create ELB) - uri: - url: "{{ AUTH_URL_ELB }}/{{ PROJECT_ID }}/elbaas/loadbalancers" - method: POST - body_format: raw - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - body: "{{ lookup('template', 'create.json.j2')|to_json }}" - register: elb - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: elb.status == 200 - changed_when: false - when: - - listener_name is undefined - - vpc_id is defined - - elb_name is defined - - not elb_id or elb_id is undefined - -- debug: - msg: "{{ elb }}" diff --git a/roles/otc_elb/tasks/delete.yml b/roles/otc_elb/tasks/delete.yml deleted file mode 100644 index ea100ad..0000000 --- a/roles/otc_elb/tasks/delete.yml +++ /dev/null @@ -1,21 +0,0 @@ -#- name: Lookup elb_id -# include: lookup.yml - -- name: Send request to API (delete ELB) - uri: - url: "{{ AUTH_URL_ELB }}/{{ PROJECT_ID }}/elbaas/loadbalancers/{{ elb_id }}" - method: DELETE - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: elb - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: elb.status == 200 - changed_when: false - -- debug: - msg: "{{ elb }}" diff --git a/roles/otc_elb/tasks/healthcheckcreate.yml b/roles/otc_elb/tasks/healthcheckcreate.yml deleted file mode 100644 index 7763d86..0000000 --- a/roles/otc_elb/tasks/healthcheckcreate.yml +++ /dev/null @@ -1,28 +0,0 @@ -- name: Get listener_id - include: lookup.yml - when: - - listener_name is defined - -- name: Send request to API (Create ELB Healthcheck) - uri: - url: "{{ AUTH_URL_ELB }}/{{ PROJECT_ID }}/elbaas/healthcheck" - method: POST - body_format: raw - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - body: "{{ lookup('template', 'healthcheckcreate.json.j2')|to_json }}" - register: elbhealthcheck - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: elbhealthcheck.status == 200 - changed_when: false - when: - - listener_id is defined and listener_id|length != 0 - - not healthcheck_id or healthcheck_id is undefined - -- debug: - msg: "{{ elbhealthcheck }}" diff --git a/roles/otc_elb/tasks/healthcheckdelete.yml b/roles/otc_elb/tasks/healthcheckdelete.yml deleted file mode 100644 index 854fdf4..0000000 --- a/roles/otc_elb/tasks/healthcheckdelete.yml +++ /dev/null @@ -1,19 +0,0 @@ -- name: Send request to API - uri: - url: "{{ AUTH_URL_ELB }}/{{ PROJECT_ID }}/elbaas/healthcheck/{{ healthcheck_id }}" - method: DELETE - return_content: yes - status_code: 200,201,202,203,204 - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: elbhealthcheck - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: elbhealthcheck.status == 200 or elbhealthcheck.status == 201 or elbhealthcheck.status == 203 or elbhealthcheck.status == 204 - changed_when: false - -- debug: - msg: "{{ elbhealthcheck }}" diff --git a/roles/otc_elb/tasks/list.yml b/roles/otc_elb/tasks/list.yml deleted file mode 100644 index 9f9c7af..0000000 --- a/roles/otc_elb/tasks/list.yml +++ /dev/null @@ -1,18 +0,0 @@ -- name: Send request to API (list ELB) - uri: - url: "{{ AUTH_URL_ELB }}/{{ PROJECT_ID }}/elbaas/loadbalancers" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: elblist - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: elblist.status == 200 - changed_when: false - -- debug: - msg: "{{ elblist }}" diff --git a/roles/otc_elb/tasks/listenercreate.yml b/roles/otc_elb/tasks/listenercreate.yml deleted file mode 100644 index 6c05fc1..0000000 --- a/roles/otc_elb/tasks/listenercreate.yml +++ /dev/null @@ -1,28 +0,0 @@ -- name: Get listener_id - include: lookup.yml - when: - - listener_name is defined - -- name: Send request to API (create elb_listener) - uri: - url: "{{ AUTH_URL_ELB }}/{{ PROJECT_ID }}/elbaas/listeners" - method: POST - body_format: raw - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - body: "{{ lookup('template', 'listenercreate.json.j2')|to_json }}" - register: elblistner - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: elblistener.status == 200 - when: - - elb_id is defined - - listener_name is defined - - not listener_id or listener_id is undefined - -- debug: - msg: "{{ elblistner }}" diff --git a/roles/otc_elb/tasks/listenerdelete.yml b/roles/otc_elb/tasks/listenerdelete.yml deleted file mode 100644 index f8d3abb..0000000 --- a/roles/otc_elb/tasks/listenerdelete.yml +++ /dev/null @@ -1,19 +0,0 @@ -- name: Send request to API - uri: - url: "{{ AUTH_URL_ELB }}/{{ PROJECT_ID }}/elbaas/listeners/{{ listener_id}}" - method: DELETE - return_content: yes - status_code: 200,201,202,203,204 - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: elblistener - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: elblistener.status == 200 or elblistener.status == 201 or elblistener.status == 203 or elblistener.status == 204 - changed_when: false - -- debug: - msg: "{{ elblistener }}" diff --git a/roles/otc_elb/tasks/listenershow.yml b/roles/otc_elb/tasks/listenershow.yml deleted file mode 100644 index d3e0f0a..0000000 --- a/roles/otc_elb/tasks/listenershow.yml +++ /dev/null @@ -1,22 +0,0 @@ -- name: Lookup elb_id - include: lookup.yml - -- name: Send request to API - uri: - url: "{{ AUTH_URL_ELB }}/{{ PROJECT_ID }}/elbaas/listeners?loadbalancer_id={{ elb_id}}" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: elblistener - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: elblistener.status == 200 - changed_when: false - when: elb_id is defined - -- debug: - msg: "{{ elblistener }}" diff --git a/roles/otc_elb/tasks/lookup.yml b/roles/otc_elb/tasks/lookup.yml deleted file mode 100644 index 0942464..0000000 --- a/roles/otc_elb/tasks/lookup.yml +++ /dev/null @@ -1,135 +0,0 @@ -- name: Send request to API (list elb) - uri: - url: "{{ AUTH_URL_ELB }}/{{ PROJECT_ID }}/elbaas/loadbalancers" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: elb_result - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: elb_result.status == 200 - changed_when: false - when: elb_name is defined - -- name: Set fact elb_id for elb if elb_name is defined - set_fact: - elb_id: "{{ (elb_result.content|from_json)|json_query(\"loadbalancers[?name=='\" + elb_name + \"'].id|[0]\") }}" - when: elb_name is defined - -- name: Send request to API (list VPC for lookup elb_vpc_name) - uri: - url: "{{ AUTH_URL_VPC }}/v1/{{ PROJECT_ID }}/vpcs" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: elb_vpc_result - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: elb_vpc_result.status == 200 - changed_when: false - -- name: Set fact vpc_id if vpc_name is defined - set_fact: - vpc_id: "{{ (elb_vpc_result.content|from_json)|json_query(\"vpcs[?name=='\" + elb_vpc_name + \"'].id|[0]\") }}" - when: - - elb_vpc_name is defined - -- name: Send request to API (list subnet for lookup elb_subnet_name) - uri: - url: "{{ AUTH_URL_VPC }}/v1/{{ PROJECT_ID }}/subnets" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: elb_subnet_result - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: elb_subnet_result.status == 200 - changed_when: false - when: - - elb_subnet_name is defined - -- name: Set fact for subnet_id if elb_subnet_name is defined - set_fact: - subnet_id: "{{ (elb_subnet_result.content|from_json)|json_query(\"subnets[?name=='\" + elb_subnet_name + \"'].id|[0]\") }}" - when: - - elb_subnet_name is defined and elb_subnet_name|length != 0 - -- name: Send Request to API (list elb certificates) - uri: - url: "{{ AUTH_URL_ELB }}/{{ PROJECT_ID }}/elbaas/certificate" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: listener_certificate_result - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: listener_certificate_result.status == 200 - changed_when: false - -- name: Set fact listener_certificate_id for elb if listener_certificate_name is defined - set_fact: - listener_certificate_id: "{{ (listener_certificate_result.content|from_json)|json_query(\"certificates[?name=='\" + listener_certificate_name + \"'].id|[0]\") }}" - when: - - listener_name is defined - -- name: Send Request to API (list elb listener) - uri: - url: "{{ AUTH_URL_ELB }}/{{ PROJECT_ID }}/elbaas/listeners?loadbalancer_id={{ elb_id}}" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: listener_result - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: listener_result.status == 200 - changed_when: false - when: elb_id is defined - -- name: Set fact listener_id for elb if listener_name is defined - set_fact: - listener_id: "{{ (listener_result.content|from_json)|json_query(\"[?name=='\" + listener_name + \"'].id|[0]\") }}" - when: listener_name is defined - -- name: Send Request to API (show elb listener details) - uri: - url: "{{ AUTH_URL_ELB }}/{{ PROJECT_ID }}/elbaas/listeners/{{ listener_id}}" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: listenerdetail_result - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: listenerdetail_result.status == 200 - changed_when: false - when: listener_id is defined and listener_id|length != 0 - -- name: Set fact healthcheck_id for elb listener - set_fact: - healthcheck_id: "{{ (listenerdetail_result.content|from_json)|json_query('healthcheck_id') }}" - when: - - listenerdetail_result is defined - - listener_id is defined and listener_id|length != 0 diff --git a/roles/otc_elb/tasks/main.yml b/roles/otc_elb/tasks/main.yml deleted file mode 100644 index 8f175ec..0000000 --- a/roles/otc_elb/tasks/main.yml +++ /dev/null @@ -1,8 +0,0 @@ -- name: Lookup elb_id - include: lookup.yml - when: - - elb_name is defined - -- name: action {{ localaction }} - include: "{{ localaction }}.yml" - when: localaction is defined diff --git a/roles/otc_elb/tasks/show.yml b/roles/otc_elb/tasks/show.yml deleted file mode 100644 index f24250d..0000000 --- a/roles/otc_elb/tasks/show.yml +++ /dev/null @@ -1,22 +0,0 @@ -- name: Lookup elb_id - include: lookup.yml - -- name: Send request to API (show ELB) - uri: - url: "{{ AUTH_URL_ELB }}/{{ PROJECT_ID }}/elbaas/loadbalancers/{{ elb_id }}" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: elb - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: elb.status == 200 - changed_when: false - when: elb_id is defined - -- debug: - msg: "{{ elb }}" diff --git a/roles/otc_elb/templates/backendcreate.json.j2 b/roles/otc_elb/templates/backendcreate.json.j2 deleted file mode 100644 index bf9de4c..0000000 --- a/roles/otc_elb/templates/backendcreate.json.j2 +++ /dev/null @@ -1,6 +0,0 @@ -[ -{ - "server_id": "{{ item.0 }}", - "address": "{{ item.1 }}" -} -] diff --git a/roles/otc_elb/templates/backenddelete.json.j2 b/roles/otc_elb/templates/backenddelete.json.j2 deleted file mode 100644 index cd62741..0000000 --- a/roles/otc_elb/templates/backenddelete.json.j2 +++ /dev/null @@ -1,8 +0,0 @@ -{ -"removeMember": -[ -{ -"id": "{{ backend_member_id }}" -} -] -} diff --git a/roles/otc_elb/templates/certificatecreate.json.j2 b/roles/otc_elb/templates/certificatecreate.json.j2 deleted file mode 100644 index 5a49212..0000000 --- a/roles/otc_elb/templates/certificatecreate.json.j2 +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "{{ elb_certificate_name }}", - "certificate": "{{ elb_certificate_certificate.stdout }}", - "private_key": "{{ elb_certificate_key.stdout }}", -} diff --git a/roles/otc_elb/templates/create.json.j2 b/roles/otc_elb/templates/create.json.j2 deleted file mode 100644 index 531bc94..0000000 --- a/roles/otc_elb/templates/create.json.j2 +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "{{ elb_name }}", - "vpc_id": "{{ vpc_id }}", -{% if elb_type == "External" %} - "bandwidth": "{{ elb_bandwidth }}", -{% endif %} - "type": "{{ elb_type }}", -{% if elb_type == "Internal" and secgroup_id is defined %} - "security_group_id": "{{ secgroup_id }}", - "az": "{{ availability_zone_id }}", - "vip_subnet_id": "{{ subnet_id }}", -{% endif %} - "admin_state_up": {{ admin_state_up }} -} diff --git a/roles/otc_elb/templates/delete.json.j2 b/roles/otc_elb/templates/delete.json.j2 deleted file mode 100644 index 9f0bc0e..0000000 --- a/roles/otc_elb/templates/delete.json.j2 +++ /dev/null @@ -1,17 +0,0 @@ -{ - "servers": [ - { - "id": "{{ ecs_id }}" - } - ], -{% if delete_publicip is defined %} - "delete_publicip": true, -{% else %} - "delete_publicip": false, -{% endif %} -{% if delete_volume is defined %} - "delete_volume": true -{% else %} - "delete_volume": false -{% endif %} -} diff --git a/roles/otc_elb/templates/healthcheckcreate.json.j2 b/roles/otc_elb/templates/healthcheckcreate.json.j2 deleted file mode 100644 index 240696e..0000000 --- a/roles/otc_elb/templates/healthcheckcreate.json.j2 +++ /dev/null @@ -1,21 +0,0 @@ -{ - "listener_id": "{{ listener_id }}", -{% if healthcheck_connect_port is defined and healthcheck_connect_port|length != 0 %} - "healthcheck_connect_port": {{ healthcheck_connect_port }}, -{% endif %} -{% if healthcheck_interval is defined and healthcheck_interval|length != 0 %} - "healthcheck_interval": {{ healthcheck_interval }}, -{% endif %} -{% if healthcheck_protocol is defined and healthcheck_protocol|length != 0 %} - "healthcheck_protocol": "{{ healthcheck_protocol }}", -{% endif %} -{% if healthcheck_timeout is defined and healthcheck_timeout|length != 0 %} - "healthcheck_timeout": {{ healthcheck_timeout }}, -{% endif %} -{% if healthcheck_uri is defined and healthcheck_uri|length != 0 %} - "healthcheck_uri": "{{ healthcheck_uri }}", -{% endif %} -{% if healthcheck_treshold is defined and healthcheck_treshold|length != 0 %} - "healthcheck_treshold": {{ healthcheck_treshold }} -{% endif %} -} diff --git a/roles/otc_elb/templates/listenercreate.json.j2 b/roles/otc_elb/templates/listenercreate.json.j2 deleted file mode 100644 index 8012164..0000000 --- a/roles/otc_elb/templates/listenercreate.json.j2 +++ /dev/null @@ -1,24 +0,0 @@ -{ - "name": "{{ listener_name }}", - "loadbalancer_id": "{{ elb_id }}", - "protocol": "{{ listener_protocol }}", - "port": {{ listener_port }}, - "backend_protocol": "{{ listener_backend_protocol }}", - "backend_port": {{ listener_backend_port }}, -{% if listener_certificate_id is defined and listener_certificate_id|length != 0 %} - "certificate_id": "{{ listener_certificate_id }}", -{% endif %} -{% if listener_session_sticky is defined and listener_session_sticky|bool %} - "session_sticky": "{{ listener_session_sticky }}", -{% endif %} -{% if listener_sticky_session_type is defined and listener_sticky_session_type|length != 0 %} - "sticky_session_type": "{{ listener_sticky_session_type }}", -{% endif %} -{% if listener_cookie_timeout is defined and listener_cookie_timeout|length != 0 %} - "cookie_timeout": {{ listener_cookie_timeout }}, -{% endif %} -{% if listener_tcp_timeout is defined and listener_tcp_timeout|length != 0 %} - "tcp_timeout": {{ listener_tcp_timeout }}, -{% endif %} - "lb_algorithm": "{{ listener_lb_algorithm }}" -} diff --git a/roles/otc_elb/templates/show.json.j2 b/roles/otc_elb/templates/show.json.j2 deleted file mode 100644 index cebb36f..0000000 --- a/roles/otc_elb/templates/show.json.j2 +++ /dev/null @@ -1,5 +0,0 @@ -{ - "server": { - "name": "{{ ecs_name }}" - } -} diff --git a/roles/otc_evs/README.rst b/roles/otc_evs/README.rst deleted file mode 100644 index 506a1f1..0000000 --- a/roles/otc_evs/README.rst +++ /dev/null @@ -1,49 +0,0 @@ -otc_evs -======= - -OTC role for Elastic Volume Service (EVS). - -Variables: -^^^^^^^^^^ - -+-------------------------+-----------------------------------------------------------+ -| Name | Description | -+=========================+===========================================================+ -| evs_availability_zone | Availability Zone for EVS | -+-------------------------+-----------------------------------------------------------+ -| evs_id | id of EVS | -+-------------------------+-----------------------------------------------------------+ -| evs_name | name of EVS | -+-------------------------+-----------------------------------------------------------+ -| evs_volume_type | Volume type of EVS (SATA,SSD,SAS) | -+-------------------------+-----------------------------------------------------------+ -| evs_size | Volume size in GB | -+-------------------------+-----------------------------------------------------------+ -| evs_ims_id | ims_id from which the volume should created | -+-------------------------+-----------------------------------------------------------+ -| evs_backup_id | backup_id from which the volume should created | -+-------------------------+-----------------------------------------------------------+ -| evs_scsi | hw passthrough enabled | -+-------------------------+-----------------------------------------------------------+ -| evs_multiattach | multi attache enabled | -+-------------------------+-----------------------------------------------------------+ - - -Functions: -^^^^^^^^^^ - -Create:: - - ansible-playbook tenant_yml.yml -e "evs_name=ansible-evs01" -e "localaction=create" - -Show:: - - ./grole otc_evs; ansible-playbook roles.yml -e "evs_name=ansible-evs01" -e "localaction=show" - -List:: - - ./grole otc_evs; ansible-playbook roles.yml -e "localaction=list" - -Delete:: - - ./grole otc_evs; ansible-playbook roles.yml -e "evs_name=ansible-evs01" -e "localaction=delete" diff --git a/roles/otc_evs/defaults/main.yml b/roles/otc_evs/defaults/main.yml deleted file mode 100644 index a91cd5f..0000000 --- a/roles/otc_evs/defaults/main.yml +++ /dev/null @@ -1,4 +0,0 @@ -uri_follow_redirects: "none" -uri_validate_certs: "yes" -uri_retries: 5 -uri_delay: 1 diff --git a/roles/otc_evs/tasks/create.yml b/roles/otc_evs/tasks/create.yml deleted file mode 100644 index 8e2b53d..0000000 --- a/roles/otc_evs/tasks/create.yml +++ /dev/null @@ -1,28 +0,0 @@ -- name: Get evs_id - include: lookup.yml - when: - - evs_name is defined - -- name: Send request to API (create EVS) - uri: - url: "{{ AUTH_URL_EVS }}/cloudvolumes" - method: POST - body_format: raw - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - body: "{{ lookup('template', 'create.json.j2')|to_json }}" - register: evs - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: evs.status == 200 - changed_when: false - when: - - evs_name is defined - - not evs_id or evs_id is undefined - -- debug: - msg: "{{ evs }}" diff --git a/roles/otc_evs/tasks/delete.yml b/roles/otc_evs/tasks/delete.yml deleted file mode 100644 index 43cc377..0000000 --- a/roles/otc_evs/tasks/delete.yml +++ /dev/null @@ -1,23 +0,0 @@ -- name: Lookup evs_id - include: lookup.yml - -- name: Send request to API (delete EVS) - uri: - url: "{{ AUTH_URL_EVS }}/cloudvolumes/{{ evs_id }}" - method: DELETE - body_format: raw - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - status_code: 200,201,202,203,204 - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: evs - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: evs.status == 200 or evs.status == 201 or evs.status == 202 or evs.status == 203 or evs.status == 204 - changed_when: false - -- debug: - msg: "{{ evs }}" diff --git a/roles/otc_evs/tasks/list.yml b/roles/otc_evs/tasks/list.yml deleted file mode 100644 index 3f20da8..0000000 --- a/roles/otc_evs/tasks/list.yml +++ /dev/null @@ -1,18 +0,0 @@ -- name: Send request to API (list EVS) - uri: - url: "{{ AUTH_URL_EVS }}/cloudvolumes" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: volumeslist - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: volumeslist.status == 200 - changed_when: false - -- debug: - msg: "{{ volumeslist.json }}" diff --git a/roles/otc_evs/tasks/lookup.yml b/roles/otc_evs/tasks/lookup.yml deleted file mode 100644 index a11690d..0000000 --- a/roles/otc_evs/tasks/lookup.yml +++ /dev/null @@ -1,21 +0,0 @@ -- name: Send request to API (list evs for lookup) - uri: - url: "{{ AUTH_URL_EVS }}/cloudvolumes" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: evs_result - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: evs_result.status == 200 - changed_when: false - when: evs_name is defined - -- name: Set fact evs_id if evs_name is defined - set_fact: - evs_id: "{{ (evs_result.content|from_json)|json_query(\"volumes[?name=='\" + evs_name + \"'].id|[0]\") }}" - when: evs_name is defined diff --git a/roles/otc_evs/tasks/main.yml b/roles/otc_evs/tasks/main.yml deleted file mode 100644 index d9cbe31..0000000 --- a/roles/otc_evs/tasks/main.yml +++ /dev/null @@ -1,3 +0,0 @@ -- name: action {{ localaction }} - include: "{{ localaction }}.yml" - when: localaction is defined diff --git a/roles/otc_evs/tasks/show.yml b/roles/otc_evs/tasks/show.yml deleted file mode 100644 index 14df427..0000000 --- a/roles/otc_evs/tasks/show.yml +++ /dev/null @@ -1,21 +0,0 @@ -- name: Lookup evs_id - include: lookup.yml - -- name: Send request to API (show EVS) - uri: - url: "{{ AUTH_URL_EVS }}/volumes/{{ evs_id }}" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: volume - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: volume.status == 200 - changed_when: false - -- debug: - msg: "{{ volume.json }}" diff --git a/roles/otc_evs/templates/create.json.j2 b/roles/otc_evs/templates/create.json.j2 deleted file mode 100644 index 58a3863..0000000 --- a/roles/otc_evs/templates/create.json.j2 +++ /dev/null @@ -1,25 +0,0 @@ -{ - "volume": { - "availability_zone": "{{ evs_availability_zone }}", - "name": "{{ evs_name }}", - "volume_type": "{{ evs_volume_type }}", -{% if evs_size is defined %} - "size": {{ evs_size }}, -{% endif %} -{% if evs_ims_id is defined %} - "imageRef": "{{ evs_ims_id }}", -{% endif %} -{% if evs_backup_id is defined %} - "backup_id": "{{ evs_backup_id }}", -{% endif %} -{% if evs_scsi is defined and evs_scsi == "true" %} - "metadata": { - "hw:passthrough": {{ evs_scsi }} - }, -{% endif %} -{% if evs_multiattach is defined and evs_multiattach == "true" %} - "multiattach": {{ evs_multiattach }}, -{% endif %} - "count": 1 - } -} diff --git a/roles/otc_ims/README.rst b/roles/otc_ims/README.rst deleted file mode 100644 index f35c1a0..0000000 --- a/roles/otc_ims/README.rst +++ /dev/null @@ -1,47 +0,0 @@ -otc_ims -======= - -OTC role for Image. - -Variables: -^^^^^^^^^^ - -+-------------------------+-----------------------------------------------------------+ -| Name | Description | -+=========================+===========================================================+ -| image_name | name of image | -+-------------------------+-----------------------------------------------------------+ -| image_id | id of image | -+-------------------------+-----------------------------------------------------------+ -| image_url | s3 source url for image upload | -| | : | -| | ansible1:/xenial-server-cloudimg-amd64-disk1.vmdk | -+-------------------------+-----------------------------------------------------------+ -| ecs_id | ecs_id as source for image creation (ECS must be stopped) | -+-------------------------+-----------------------------------------------------------+ -| image_min_disk | minimal disk size for image creation (in GB) | -+-------------------------+-----------------------------------------------------------+ -| image_os_version | os_version of the created image | -+-------------------------+-----------------------------------------------------------+ - - -Functions: -^^^^^^^^^^ - -Create:: - - ansible-playbook tenant_yml.yml -e "image_name=ansible-image01" -e "image_url=ansible1:/xenial-server-cloudimg-amd64-disk1.vmdk" -e "image_min_disk=12" "localaction=create" - - ansible-playbook tenant_yml.yml -e "image_name=ansible-image01" -e "ecs_id=12345678901234567890" -e "image_min_disk=12" "localaction=create" - -Show:: - - ./grole otc_evs; ansible-playbook roles.yml -e "image_name=Community_Ubuntu_16.04_TSI_latest" -e "localaction=show" - -List:: - - ./grole otc_evs; ansible-playbook roles.yml -e "localaction=list" - -Delete:: - - ./grole otc_evs; ansible-playbook roles.yml -e "image_name=ansible-image01" -e "localaction=delete" diff --git a/roles/otc_ims/defaults/main.yml b/roles/otc_ims/defaults/main.yml deleted file mode 100644 index a91cd5f..0000000 --- a/roles/otc_ims/defaults/main.yml +++ /dev/null @@ -1,4 +0,0 @@ -uri_follow_redirects: "none" -uri_validate_certs: "yes" -uri_retries: 5 -uri_delay: 1 diff --git a/roles/otc_ims/tasks/create.yml b/roles/otc_ims/tasks/create.yml deleted file mode 100644 index 7ef53c4..0000000 --- a/roles/otc_ims/tasks/create.yml +++ /dev/null @@ -1,22 +0,0 @@ -- name: Send request to API (create image) - uri: - url: "{{ AUTH_URL_IMS }}/v2/cloudimages/action" - method: POST - body_format: raw - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - body: "{{ lookup('template', 'create.json.j2')|to_json }}" - register: image_create - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: image_create.status == 200 - changed_when: false - when: image_name is defined - -- debug: - msg: "{{ image_create }}" - when: image_create is defined diff --git a/roles/otc_ims/tasks/delete.yml b/roles/otc_ims/tasks/delete.yml deleted file mode 100644 index 1f077fe..0000000 --- a/roles/otc_ims/tasks/delete.yml +++ /dev/null @@ -1,21 +0,0 @@ -- name: Lookup image_id - include: lookup.yml - -- name: Send request to API (delete image) - uri: - url: "{{ AUTH_URL_IMS }}/v2/images/{{ image_id }}" - method: DELETE - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: image_delete - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: image_delete.status == 200 - changed_when: false - -- debug: - msg: "{{ image_delete }}" diff --git a/roles/otc_ims/tasks/list.yml b/roles/otc_ims/tasks/list.yml deleted file mode 100644 index f0fbb8f..0000000 --- a/roles/otc_ims/tasks/list.yml +++ /dev/null @@ -1,18 +0,0 @@ -- name: Send request to API (list image) - uri: - url: "{{ AUTH_URL_IMS }}/v2/cloudimages" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: imageslist - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: imagelist.status == 200 - changed_when: false - -- debug: - msg: "{{ imageslist.json }}" diff --git a/roles/otc_ims/tasks/lookup.yml b/roles/otc_ims/tasks/lookup.yml deleted file mode 100644 index 5d70f56..0000000 --- a/roles/otc_ims/tasks/lookup.yml +++ /dev/null @@ -1,23 +0,0 @@ -- name: Send request to API (list images for lookup) - uri: - url: "{{ AUTH_URL_IMS }}/v2/cloudimages?name={{ image_name }}" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: ims_result - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: ims_result.status == 200 - changed_when: false - when: - - image_name is defined - -- name: Set fact image_id if image_name is defined - set_fact: - image_id: "{{ (ims_result.content|from_json)|json_query('images[].id|[0]') }}" - when: - - image_name is defined diff --git a/roles/otc_ims/tasks/main.yml b/roles/otc_ims/tasks/main.yml deleted file mode 100644 index d9cbe31..0000000 --- a/roles/otc_ims/tasks/main.yml +++ /dev/null @@ -1,3 +0,0 @@ -- name: action {{ localaction }} - include: "{{ localaction }}.yml" - when: localaction is defined diff --git a/roles/otc_ims/tasks/show.yml b/roles/otc_ims/tasks/show.yml deleted file mode 100644 index 5604882..0000000 --- a/roles/otc_ims/tasks/show.yml +++ /dev/null @@ -1,23 +0,0 @@ -- name: Lookup image_id - include: lookup.yml - -- name: Send request to API (show image) - uri: - url: "{{ AUTH_URL_IMS }}/v2/images/{{ image_id }}" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: imagedetail - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: imagedetail.status == 200 - changed_when: false - when: - - image_id is defined - -- debug: - msg: "{{ imagedetail.json }}" diff --git a/roles/otc_ims/templates/create.json.j2 b/roles/otc_ims/templates/create.json.j2 deleted file mode 100644 index 08d6c9b..0000000 --- a/roles/otc_ims/templates/create.json.j2 +++ /dev/null @@ -1,15 +0,0 @@ -{ -{% if image_url is defined %} - "image_url": "{{ image_url }}", -{% endif %} -{% if ecs_id is defined %} - "instance_id": "{{ ecs_id }}", -{% endif %} -{% if image_min_disk is defined %} - "min_disk": {{ image_min_disk }}, -{% endif %} -{% if image_os_version is defined %} - "__os_version":"{{ image_os_version }}", -{% endif %} - "name": "{{ image_name }}" -} diff --git a/roles/otc_job/README.rst b/roles/otc_job/README.rst deleted file mode 100644 index 37501fa..0000000 --- a/roles/otc_job/README.rst +++ /dev/null @@ -1,35 +0,0 @@ -otc_job -======= - -OTC role for Job Control. Print out the status and some -messages about OTC jobs, e.g. building ECS. - -Variables: -^^^^^^^^^^ - -+--------------+---------------------------------------------+ -| Name | Description | -+==============+=============================================+ -| job_id | Job ID to lookup | -+--------------+---------------------------------------------+ - -Functions: -^^^^^^^^^^ - -Create:: - - n/a - -Read:: - - ansible-playbook -e "job_id=1234567890" job.yml - - ./ajob "1234567890" - -Update:: - - n/a - -Delete:: - - n/a diff --git a/roles/otc_job/defaults/main.yml b/roles/otc_job/defaults/main.yml deleted file mode 100644 index a91cd5f..0000000 --- a/roles/otc_job/defaults/main.yml +++ /dev/null @@ -1,4 +0,0 @@ -uri_follow_redirects: "none" -uri_validate_certs: "yes" -uri_retries: 5 -uri_delay: 1 diff --git a/roles/otc_job/tasks/main.yml b/roles/otc_job/tasks/main.yml deleted file mode 100644 index 027a979..0000000 --- a/roles/otc_job/tasks/main.yml +++ /dev/null @@ -1,20 +0,0 @@ -- name: Request job status from API - uri: - url: "{{ AUTH_URL_ECS_CLOUD }}/{{ PROJECT_ID }}/jobs/{{ job_id }}" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: jobstatus - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: jobstatus.status == 200 - changed_when: false - when: job_id is defined - -- debug: - msg: "{{ jobstatus.json }}" - when: jobstatus is defined and jobstatus.content|length != 0 diff --git a/roles/otc_keypair/README.rst b/roles/otc_keypair/README.rst deleted file mode 100644 index 5a7e721..0000000 --- a/roles/otc_keypair/README.rst +++ /dev/null @@ -1,41 +0,0 @@ -otc_keypair -=========== - -OTC role for ssh keys. - -Variables: -^^^^^^^^^^ - -+-------------------------+-----------------------------------------------------------+ -| Name | Description | -+=========================+===========================================================+ -| ecs_adminkey | Name of the ssh key (to upload) | -+-------------------------+-----------------------------------------------------------+ -| ecs_adminkey_name | Lookup name of ssh key | -+-------------------------+-----------------------------------------------------------+ -| keypair_file | File to upload as ssh key | -+-------------------------+-----------------------------------------------------------+ - - -Functions: -^^^^^^^^^^ - -Create:: - - ./grole otc_keypair; ansible-playbook roles.yml -e "ecs_adminkey=ansible-key01" -e "keypair_file=.ssh/authorized_keys" -e "localaction=create" - - ansible-playbook tenant_yml.yml -e "ecs_adminkey=ansible-key01" -e "keypair_file=.ssh/authorized_keys" -e "localaction=create" - -note: keypair will be created during ECS creating worklflow - -Show:: - - ./grole otc_keypair; ansible-playbook roles.yml -e "ecs_adminkey=ansible-key01" -e "localaction=show" - -List:: - - ./grole otc_keypair; ansible-playbook roles.yml -e "localaction=list" - -Delete:: - - ./grole otc_keypair; ansible-playbook roles.yml -e "ecs_adminkey=ansible-key01" -e "localaction=delete" diff --git a/roles/otc_keypair/defaults/main.yml b/roles/otc_keypair/defaults/main.yml deleted file mode 100644 index a91cd5f..0000000 --- a/roles/otc_keypair/defaults/main.yml +++ /dev/null @@ -1,4 +0,0 @@ -uri_follow_redirects: "none" -uri_validate_certs: "yes" -uri_retries: 5 -uri_delay: 1 diff --git a/roles/otc_keypair/tasks/create.yml b/roles/otc_keypair/tasks/create.yml deleted file mode 100644 index fa1c186..0000000 --- a/roles/otc_keypair/tasks/create.yml +++ /dev/null @@ -1,34 +0,0 @@ -- name: Keypair lookup - include: lookup.yml - -- stat: path={{ keypair_file }} - register: keypair_file_stat - -- name: grab ssh pub key - shell: awk '$1=$1' ORS='\\n' {{ keypair_file }} - register: keypair_file_content - when: keypair_file_stat.stat.exists - -- name: Send request to API (create keypair) - uri: - url: "{{ AUTH_URL_ECS }}/os-keypairs" - method: POST - body_format: raw - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - body: "{{ lookup('template', 'create.json.j2')|to_json }}" - register: keypair - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: keypair.status == 200 - changed_when: false - when: - - keypair_file_stat.stat.exists - - (not ecs_adminkey_name or ecs_adminkey_name is undefined) - -- debug: - msg: "{{ keypair }}" diff --git a/roles/otc_keypair/tasks/delete.yml b/roles/otc_keypair/tasks/delete.yml deleted file mode 100644 index 074fbec..0000000 --- a/roles/otc_keypair/tasks/delete.yml +++ /dev/null @@ -1,21 +0,0 @@ -- name: Send request to API (delete keypair) - uri: - url: "{{ AUTH_URL_ECS }}/os-keypairs/{{ ecs_adminkey }}" - method: DELETE - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - status_code: 200,201,202,203,204 - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: keypair - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: keypair.status == 200 or keypair.status == 201 or keypair.status == 202 or keypair.status == 203 or keypair.status == 204 - changed_when: false - when: ecs_adminkey_name is defined and ecs_adminkey_name|length != 0 -# ignore_errors: true - -- debug: - msg: "{{ keypair }}" diff --git a/roles/otc_keypair/tasks/list.yml b/roles/otc_keypair/tasks/list.yml deleted file mode 100644 index 99f75e1..0000000 --- a/roles/otc_keypair/tasks/list.yml +++ /dev/null @@ -1,18 +0,0 @@ -- name: Send request to API (keypair list) - uri: - url: "{{ AUTH_URL_ECS }}/os-keypairs" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: keypairlist - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: keypairlist.status == 200 - changed_when: false - -- debug: - msg: "{{ keypairlist.json }}" diff --git a/roles/otc_keypair/tasks/lookup.yml b/roles/otc_keypair/tasks/lookup.yml deleted file mode 100644 index efecf9f..0000000 --- a/roles/otc_keypair/tasks/lookup.yml +++ /dev/null @@ -1,23 +0,0 @@ -- name: Send request to API (list keypair) - uri: - url: "{{ AUTH_URL_ECS }}/os-keypairs" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: keypairlist_result - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: keypairlist_result.status == 200 - changed_when: false - when: - - ecs_adminkey is defined - -- name: Set fact ecs_adminkey_name if ecs_adminkey is defined - set_fact: - ecs_adminkey_name: "{{ (keypairlist_result.content|from_json)|json_query(\"keypairs[?keypair.name=='\" + ecs_adminkey + \"'].keypair.name\") }}" - when: - - ecs_adminkey is defined and ecs_adminkey|length != 0 diff --git a/roles/otc_keypair/tasks/main.yml b/roles/otc_keypair/tasks/main.yml deleted file mode 100644 index b7331af..0000000 --- a/roles/otc_keypair/tasks/main.yml +++ /dev/null @@ -1,10 +0,0 @@ -- name: action {{ localaction }} - include: "{{ localaction }}.yml" - when: localaction is defined - -- name: Keypair lookup - include: lookup.yml -# when: -# - localaction is defined and localaction == "lookup" - tags: - - keypairlookup diff --git a/roles/otc_keypair/tasks/show.yml b/roles/otc_keypair/tasks/show.yml deleted file mode 100644 index 7aeaab9..0000000 --- a/roles/otc_keypair/tasks/show.yml +++ /dev/null @@ -1,19 +0,0 @@ -- name: Send request to API (keypair show) - uri: - url: "{{ AUTH_URL_ECS }}/os-keypairs/{{ ecs_adminkey }}" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: keypairdetail - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: keypairdetail.status == 200 - changed_when: false - - -- debug: - msg: "{{ keypairdetail.json }}" diff --git a/roles/otc_keypair/templates/create.json.j2 b/roles/otc_keypair/templates/create.json.j2 deleted file mode 100644 index fd1d10c..0000000 --- a/roles/otc_keypair/templates/create.json.j2 +++ /dev/null @@ -1,6 +0,0 @@ -{ - "keypair": { - "name": "{{ ecs_adminkey }}", - "public_key": "{{ keypair_file_content.stdout }}", - } -} diff --git a/roles/otc_obs/README.rst b/roles/otc_obs/README.rst deleted file mode 100644 index 54a89cc..0000000 --- a/roles/otc_obs/README.rst +++ /dev/null @@ -1,47 +0,0 @@ -otc_obs -======= - -OTC role for Object Storage Service (OBS). -This role requires curl, libxml2-utils, and openssl installed. - -Authentification will be done with environment variables (e.g. EC2...) -or ansible-vault file in 'vars/_secrets.yml' or 'vars/secrets.yml'. -Dependly on that ansible-playbook must be called with vault param. - - -Variables: -^^^^^^^^^^ - -+-------------------------+-----------------------------------------------------------+ -| Name | Description | -+=========================+===========================================================+ -| EC2_ACCESS_KEY | OBS access key | -+-------------------------+-----------------------------------------------------------+ -| EC2_SECRET_KEY | OBS secret key | -+-------------------------+-----------------------------------------------------------+ -| EC2_URL | OBS URL (default https://obs.otc.t-systems.com) | -+-------------------------+-----------------------------------------------------------+ -| bucket | s3 bucket name | -+-------------------------+-----------------------------------------------------------+ -| object | data to upload | -+-------------------------+-----------------------------------------------------------+ - -Functions: -^^^^^^^^^^ - -list OBS buckets:: - - ansible-playbook s3.yml -e "localaction=list" --vault-password-file vars/vaultpass.txt - -create OBS bucket:: - - ansible-playbook s3.yml -e "bucket=mybucket" -e "localaction=create" --vault-password-file vars/vaultpass.txt - -delete OBS bucket:: - - ansible-playbook s3.yml -e "bucket=mybucket" -e "localaction=delete" --vault-password-file vars/vaultpass.txt - -upload files in OBS (VHD, ZVHD, VMDK, QCOW2 are supported for otc image service):: - - ansible-playbook s3.yml -e "bucket=mybucket" -e "object=xenial-server-cloudimg-amd64-disk1.vmdk" -e "localaction=upload" --vault-password-file vars/vaultpass.txt - diff --git a/roles/otc_obs/tasks/auth.yml b/roles/otc_obs/tasks/auth.yml deleted file mode 100644 index e22fd00..0000000 --- a/roles/otc_obs/tasks/auth.yml +++ /dev/null @@ -1,9 +0,0 @@ -- name: Load auth variable file from ansible-vault secret - include_vars: "{{ item }}" - with_first_found: - - files: - - "vars/_secrets.yml" - - "vars/secrets.yml" - skip: true - tags: - - always diff --git a/roles/otc_obs/tasks/create.yml b/roles/otc_obs/tasks/create.yml deleted file mode 100644 index a73b916..0000000 --- a/roles/otc_obs/tasks/create.yml +++ /dev/null @@ -1,25 +0,0 @@ -- name: Lookup OBS credentials - include: auth.yml - -- name: create timestamp - shell: LC_ALL=en TZ=GMT date +"%a, %d %b %Y %T %z" - register: sigdate - -- name: create signature - vars: - EC2_URL: "https://obs.otc.t-systems.com" - EC2_ACCESS_KEY: "{{ lookup('env','EC2_ACCESS_KEY') }}" - EC2_SECRET_KEY: "{{ lookup('env','EC2_SECRET_KEY') }}" - shell: bash -c 'echo -en "PUT\n\n\n\nx-amz-date:{{ sigdate.stdout }}\n/{{ bucket }}" | openssl sha1 -hmac {{ EC2_SECRET_KEY }} -binary | base64' - register: signature - -- name: curl request create bucket - vars: - EC2_URL: "https://obs.otc.t-systems.com" - EC2_ACCESS_KEY: "{{ lookup('env','EC2_ACCESS_KEY') }}" - EC2_SECRET_KEY: "{{ lookup('env','EC2_SECRET_KEY') }}" - command: 'curl -X PUT -H "Authorization: AWS {{ EC2_ACCESS_KEY }}:{{ signature.stdout }}" -H "x-amz-date: {{ sigdate.stdout }}" {{ EC2_URL }}/{{ bucket }}' - register: curlresponse - -- debug: - msg: "{{ curlresponse.stdout_lines }}" diff --git a/roles/otc_obs/tasks/delete.yml b/roles/otc_obs/tasks/delete.yml deleted file mode 100644 index e23579d..0000000 --- a/roles/otc_obs/tasks/delete.yml +++ /dev/null @@ -1,25 +0,0 @@ -- name: Lookup OBS credentials - include: auth.yml - -- name: create timestamp - shell: LC_ALL=en TZ=GMT date +"%a, %d %b %Y %T %z" - register: sigdate - -- name: create signature - vars: - EC2_URL: "https://obs.otc.t-systems.com" - EC2_ACCESS_KEY: "{{ lookup('env','EC2_ACCESS_KEY') }}" - EC2_SECRET_KEY: "{{ lookup('env','EC2_SECRET_KEY') }}" - shell: bash -c 'echo -en "DELETE\n\n\n\nx-amz-date:{{ sigdate.stdout }}\n/{{ bucket }}" | openssl sha1 -hmac {{ EC2_SECRET_KEY }} -binary | base64' - register: signature - -- name: curl request delete data - vars: - EC2_URL: "https://obs.otc.t-systems.com" - EC2_ACCESS_KEY: "{{ lookup('env','EC2_ACCESS_KEY') }}" - EC2_SECRET_KEY: "{{ lookup('env','EC2_SECRET_KEY') }}" - command: 'curl -X DELETE -H "Authorization: AWS {{ EC2_ACCESS_KEY }}:{{ signature.stdout }}" -H "x-amz-date: {{ sigdate.stdout }}" {{ EC2_URL }}/{{ bucket }}' - register: curlresponse - -- debug: - msg: "{{ curlresponse.stdout_lines }}" diff --git a/roles/otc_obs/tasks/list.yml b/roles/otc_obs/tasks/list.yml deleted file mode 100644 index 578ae6b..0000000 --- a/roles/otc_obs/tasks/list.yml +++ /dev/null @@ -1,29 +0,0 @@ -- name: Lookup OBS credentials - include: auth.yml - -- name: create timestamp - shell: LC_ALL=en TZ=GMT date +"%a, %d %b %Y %T %z" - register: sigdate - -- name: create signature - vars: - EC2_URL: "https://obs.otc.t-systems.com" - EC2_ACCESS_KEY: "{{ lookup('env','EC2_ACCESS_KEY') }}" - EC2_SECRET_KEY: "{{ lookup('env','EC2_SECRET_KEY') }}" - shell: bash -c 'echo -en "GET\n\n\n\nx-amz-date:{{ sigdate.stdout }}\n/" | openssl sha1 -hmac {{ EC2_SECRET_KEY }} -binary | base64' - register: signature - -- name: curl request - vars: - EC2_URL: "https://obs.otc.t-systems.com" - EC2_ACCESS_KEY: "{{ lookup('env','EC2_ACCESS_KEY') }}" - EC2_SECRET_KEY: "{{ lookup('env','EC2_SECRET_KEY') }}" - command: 'curl -H "Authorization: AWS {{ EC2_ACCESS_KEY }}:{{ signature.stdout }}" -H "x-amz-date: {{ sigdate.stdout }}" {{ EC2_URL }}' - register: curlresponse - -- name: xmllint output - shell: echo '{{ curlresponse.stdout }}' | xmllint --format - - register: xmlout - -- debug: - msg: "{{ xmlout.stdout_lines }}" diff --git a/roles/otc_obs/tasks/main.yml b/roles/otc_obs/tasks/main.yml deleted file mode 100644 index d9cbe31..0000000 --- a/roles/otc_obs/tasks/main.yml +++ /dev/null @@ -1,3 +0,0 @@ -- name: action {{ localaction }} - include: "{{ localaction }}.yml" - when: localaction is defined diff --git a/roles/otc_obs/tasks/upload.yml b/roles/otc_obs/tasks/upload.yml deleted file mode 100644 index 87b8cc0..0000000 --- a/roles/otc_obs/tasks/upload.yml +++ /dev/null @@ -1,25 +0,0 @@ -- name: Lookup OBS credentials - include: auth.yml - -- name: create timestamp - shell: LC_ALL=en TZ=GMT date +"%a, %d %b %Y %T %z" - register: sigdate - -- name: create signature - vars: - EC2_URL: "https://obs.otc.t-systems.com" - EC2_ACCESS_KEY: "{{ lookup('env','EC2_ACCESS_KEY') }}" - EC2_SECRET_KEY: "{{ lookup('env','EC2_SECRET_KEY') }}" - shell: bash -c 'echo -en "PUT\n\n\n\nx-amz-date:{{ sigdate.stdout }}\n/{{ bucket }}/{{ object }}" | openssl sha1 -hmac {{ EC2_SECRET_KEY }} -binary | base64' - register: signature - -- name: curl request upload data - vars: - EC2_URL: "https://obs.otc.t-systems.com" - EC2_ACCESS_KEY: "{{ lookup('env','EC2_ACCESS_KEY') }}" - EC2_SECRET_KEY: "{{ lookup('env','EC2_SECRET_KEY') }}" - command: 'curl -X PUT -H "Authorization: AWS {{ EC2_ACCESS_KEY }}:{{ signature.stdout }}" -H "x-amz-date: {{ sigdate.stdout }}" -T {{ object }} {{ EC2_URL }}/{{ bucket }}/{{ object }}' - register: curlresponse - -- debug: - msg: "{{ curlresponse.stdout_lines }}" diff --git a/roles/otc_rds/README.rst b/roles/otc_rds/README.rst deleted file mode 100644 index 7f04383..0000000 --- a/roles/otc_rds/README.rst +++ /dev/null @@ -1,140 +0,0 @@ -otc_rds -======= - -OTC role for RDS. - -Variables: -^^^^^^^^^^ - -+-------------------------+-----------------------------------------------------------+ -| Name | Description | -+=========================+===========================================================+ -| rds_version_id | ID of the RDS version (to use to fetch flavor | -+-------------------------+-----------------------------------------------------------+ -| rds_name | Name of RDS instance | -+-------------------------+-----------------------------------------------------------+ -| rds_type | RDS type (MySQL or PostgreSQL) | -+-------------------------+-----------------------------------------------------------+ -| rds_version | RDS version (i.e. 5.6.7) | -+-------------------------+-----------------------------------------------------------+ -| rds_flavor_id | ID of RDS flavor | -+-------------------------+-----------------------------------------------------------+ -| rds_volume_type | Type of RDS volume (COMMON (SATA) or ULTRAHIGH (SSD)) | -+-------------------------+-----------------------------------------------------------+ -| rds_volume_size | Size of RDS volume (100 GB smallest) | -+-------------------------+-----------------------------------------------------------+ -| rds_port | RDS port | -+-------------------------+-----------------------------------------------------------+ -| rds_ram | Memory for RDS in MB | -+-------------------------+-----------------------------------------------------------+ -| rds_availability_zone | RDS Availability Zone ( i.e. eu_de-01) | -+-------------------------+-----------------------------------------------------------+ -| rds_secgroup_name | RDS Security Group | -+-------------------------+-----------------------------------------------------------+ -| rds_subnet_name | RDS subnet | -+-------------------------+-----------------------------------------------------------+ -| rds_backup_time | Start time of backup (i.e. 01:00:00) | -+-------------------------+-----------------------------------------------------------+ -| rds_backup_id | ID of RDS backup (required for restore | -+-------------------------+-----------------------------------------------------------+ -| rds_backup_name | Name if manual generated backup | -+-------------------------+-----------------------------------------------------------+ -| rds_backup_time | Start time of backup (i.e. 01:00:00) | -+-------------------------+-----------------------------------------------------------+ -| rds_backup_days | Keep days of backups (between 1-35, 0 = disabled) | -+-------------------------+-----------------------------------------------------------+ -| rds_restore_time | Timestamp of RDS restore | -+-------------------------+-----------------------------------------------------------+ -| rds_ha_enabled | RDS HA enabled or not (true or false) | -+-------------------------+-----------------------------------------------------------+ -| rds_ha_replication_mode | RDS replication mode (async or semisync for MySQL, | -| | async or sync for PostgreSQL) | -+-------------------------+-----------------------------------------------------------+ -| rds_root_password | RDS root password | -+-------------------------+-----------------------------------------------------------+ -| errorlog_startdate | Start date of error log (i.e. 2018-04-05+23:59) | -+-------------------------+-----------------------------------------------------------+ -| errorlog_enddate | End date of error log (i.e. 2018-05-05+23:59) | -+-------------------------+-----------------------------------------------------------+ -| errorlog_curpage | Pages per error log (default 1) | -+-------------------------+-----------------------------------------------------------+ -| errorlog_perpage | Error message per page (1-100, default 100) | -+-------------------------+-----------------------------------------------------------+ -| slowlog_type | Type of slowlog (INSERT, UPDATE, SELECT, DELETE, CREATE) | -+-------------------------+-----------------------------------------------------------+ - - -Functions: -^^^^^^^^^^ - -Version:: - - ./grole otc_rds; ansible-playbook roles.yml -e "localaction=version" - -Flavor:: - - ./grole otc_rds; ansible-playbook roles.yml -e "localaction=flavor rds_type=MySQL rds_version=5.7.20" - -List:: - - ./grole otc_rds; ansible-playbook roles.yml -e "localaction=list" - -Show:: - - ./grole otc_rds; ansible-playbook roles.yml -e "localaction=show rds_name=ansible-mysql01_node0" - -Note: configured rds_name will automatically append with number of instances starting from ``_node0`` - -Resize Volume:: - - ./grole otc_rds; ansible-playbook roles.yml -e "localaction=resize_volume rds_name=ansible-mysql01_node0 rds_volume_size=120" - -Resize Flavor:: - - ./grole otc_rds; ansible-playbook roles.yml -e "localaction=resize_flavor rds_name=ansible-mysql01_node0 rds_ram=8196 rds_type=MySQL rds_version=5.7.20 rds_ha_enabled=false" - -Reboot an instance:: - - ./grole otc_rds; ansible-playbook roles.yml -e "localaction=reboot rds_name=ansible-mysql01_node0" - -Delete an instance:: - - ./grole otc_rds; ansible-playbook roles.yml -e "localaction=delete rds_name=ansible-mysql01_node0" - -List backups:: - - ./grole otc_rds; ansible-playbook roles.yml -e "localaction=backups" - -Create a backup:: - - ./grole otc_rds; ansible-playbook roles.yml -e "localaction=create_backup rds_name=ansible-mysql01_node0 rds_backup_name=my_backup_mysql01_1" - -Delete a backup:: - - ./grole otc_rds; ansible-playbook roles.yml -e "localaction=delete_backup rds_backup_id=04eabf2523c8445e80faa0452c991e87br01" - -Note: grab the rds_backup_id from ``List backups`` - -Restore current DB:: - - ./grole otc_rds; ansible-playbook roles.yml -e "localaction=restore_backup_current rds_backup_id=04eabf2523c8445e80faa0452c991e87br01 rds_restore_time='2018-05-13 19:30:01' rds_name=ansible-mysql01_node0" - -Restore to a new instance:: - - ./grole otc_rds; ansible-playbook roles.yml -e "localaction=restore_backup_new rds_backup_id=04eabf2523c8445e80faa0452c991e87br01" rds_backup_instance_id=a5c2ec42d49f41a8b1738f054d88fbc2no01 rds_restore_time='2018-05-13 19:30:01' rds_name=ansible-mysql02 rds_volume_size=120 rds_ram=4096 rds_type=MySQL rds_version=5.7.20 rds_ha_enabled=false" - -Note: grab the different IDs for example from ``List backups`` - -Query error log:: - - ./grole otc_rds; ansible-playbook roles.yml -e "localaction=errorlog rds_name=ansible-mysql01_node0 errorlog_startdate=2018-05-01+00:00 errorlog_enddate=2018-05-13+18:00" - -Note: You can only query error logs generated within a month. - -Query slow query log:: - - ./grole otc_rds; ansible-playbook roles.yml -e "localaction=slowlog rds_name=ansible-mysql01_node0" - - ./grole otc_rds; ansible-playbook roles.yml -e "localaction=slowlog rds_name=ansible-mysql01_node0 slowlog_type=SELECT" - -Note: if ``slowlog_type`` is not set, all types will be queried diff --git a/roles/otc_rds/defaults/main.yml b/roles/otc_rds/defaults/main.yml deleted file mode 100644 index bbfb06a..0000000 --- a/roles/otc_rds/defaults/main.yml +++ /dev/null @@ -1,9 +0,0 @@ -uri_follow_redirects: "none" -uri_validate_certs: "yes" -uri_retries: 5 -uri_delay: 1 -errorlog_startdate: "2018-05-01+00:00" -errorlog_enddate: "2018-05-05+23:59" -errorlog_curpage: 1 -errorlog_perpage: 100 -slowlog_type: diff --git a/roles/otc_rds/tasks/backups.yml b/roles/otc_rds/tasks/backups.yml deleted file mode 100644 index 4180b49..0000000 --- a/roles/otc_rds/tasks/backups.yml +++ /dev/null @@ -1,20 +0,0 @@ -- name: Send request to API (list RDS backups) - uri: - url: "{{ AUTH_URL_RDS }}/{{ OS_USER_DOMAIN_ID }}/backups" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - X-Language: "en-us" - register: rdsbackups - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: rdsbackups.status == 200 - changed_when: false - -- name: Output of rdsbackups - debug: - msg: "{{ rdsbackups.json }}" diff --git a/roles/otc_rds/tasks/create.yml b/roles/otc_rds/tasks/create.yml deleted file mode 100644 index 79a474b..0000000 --- a/roles/otc_rds/tasks/create.yml +++ /dev/null @@ -1,41 +0,0 @@ -- name: Lookup rds_flavor_id - include: flavor.yml - -- name: Lookup vpc_id + subnet_id - vars: - vpc_name: "{{ rds_vpc_name }}" - subnet_name: "{{ rds_subnet_name }}" - include: ../../otc_subnet/tasks/lookup.yml - -- name: Lookup secgroup_id - vars: - secgroup_name: "{{ rds_secgroup_name }}" - include: ../../otc_secgroup/tasks/lookup.yml - -- name: Send request to API (create RDS) - uri: - url: "{{ AUTH_URL_RDS }}/{{ OS_USER_DOMAIN_ID }}/instances" - method: POST - body_format: raw - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - status_code: 200,201,202,203 - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - X-Language: "en-us" - body: "{{ lookup('template', 'create.json.j2')|to_json }}" - register: rds - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: rds.status == 200 or rds.status == 201 or rds.status == 202 or rds.status == 203 - changed_when: false - when: - - rds_name is defined - - rds_flavor_id is defined - - not rds_id or rds_id is undefined - -- name: Output of rds - debug: - msg: "{{ rds }}" diff --git a/roles/otc_rds/tasks/create_backup.yml b/roles/otc_rds/tasks/create_backup.yml deleted file mode 100644 index 500ebf4..0000000 --- a/roles/otc_rds/tasks/create_backup.yml +++ /dev/null @@ -1,28 +0,0 @@ -- name: Lookup rds_id - include: lookup.yml - -- name: Send request to API (create RDS backup) - uri: - url: "{{ AUTH_URL_RDS }}/{{ OS_USER_DOMAIN_ID }}/backups" - method: POST - body_format: raw - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - status_code: 200,201,202,203 - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - X-Language: "en-us" - body: "{{ lookup('template', 'create_backup.json.j2')|to_json }}" - register: rdsbackup - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: rdsbackup.status == 200 or rdsbackup.status == 201 or rdsbackup.status == 202 or rdsbackup.status == 203 - changed_when: false - when: - - rds_backup_name is defined - -- name: Output of rdsbackup - debug: - msg: "{{ rdsbackup }}" diff --git a/roles/otc_rds/tasks/delete.yml b/roles/otc_rds/tasks/delete.yml deleted file mode 100644 index a1741ba..0000000 --- a/roles/otc_rds/tasks/delete.yml +++ /dev/null @@ -1,26 +0,0 @@ -- name: Lookup rds_id - include: lookup.yml - -- name: Send request to API (delete RDS) - uri: - url: "{{ AUTH_URL_RDS }}/{{ OS_USER_DOMAIN_ID }}/instances/{{ rds_id }}" - method: DELETE - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - status_code: 200,201,202,203 - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - X-Language: "en-us" - register: rds - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: rds.status == 200 or rds.status == 201 or rds.status == 202 or rds.status == 203 - changed_when: false - when: - - rds_id is defined - -- name: Output of rds - debug: - msg: "{{ rds }}" diff --git a/roles/otc_rds/tasks/delete_backup.yml b/roles/otc_rds/tasks/delete_backup.yml deleted file mode 100644 index b9a8be5..0000000 --- a/roles/otc_rds/tasks/delete_backup.yml +++ /dev/null @@ -1,22 +0,0 @@ -- name: Send request to API (delete RDS backup) - uri: - url: "{{ AUTH_URL_RDS }}/{{ OS_USER_DOMAIN_ID }}/backups/{{ rds_backup_id }}" - method: DELETE - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - X-Language: "en-us" - register: rdsbackup - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: rdsbackup.status == 200 - changed_when: false - when: - - rds_backup_id is defined - -- name: Output of rds - debug: - msg: "{{ rdsbackup }}" diff --git a/roles/otc_rds/tasks/errorlog.yml b/roles/otc_rds/tasks/errorlog.yml deleted file mode 100644 index 3e75181..0000000 --- a/roles/otc_rds/tasks/errorlog.yml +++ /dev/null @@ -1,25 +0,0 @@ -- name: Lookup rds_id - include: lookup.yml - -- name: Send request to API (show RDS errorlog) - uri: - url: "{{ AUTH_URL_RDS }}/{{ OS_USER_DOMAIN_ID }}/instances/{{ rds_id }}/errorlog?startDate={{ errorlog_startdate | regex_replace(':', '%3A') }}&endDate={{ errorlog_enddate | regex_replace(':', '%3A') }}&curPage={{ errorlog_curpage }}&perPage={{ errorlog_perpage }}" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - X-Language: "en-us" - register: rds - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: rds.status == 200 - changed_when: false - when: - - rds_id is defined - -- name: Output of rds - debug: - msg: "{{ rds.json }}" diff --git a/roles/otc_rds/tasks/flavor.yml b/roles/otc_rds/tasks/flavor.yml deleted file mode 100644 index 38f6b80..0000000 --- a/roles/otc_rds/tasks/flavor.yml +++ /dev/null @@ -1,53 +0,0 @@ -- name: Lookup rds_version_id - include: version.yml - -- name: Request rds flavors from API - uri: - url: "{{ AUTH_URL_RDS }}/{{ OS_USER_DOMAIN_ID }}/flavors?dbId={{ rds_version_id }}®ion={{ PROJECT_NAME }}" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - Accept: "application/json" - X-Language: "en-us" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: rds_flavors - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: rds_flavors.status == 200 - changed_when: false - -- name: Set fact rds_flavor_id (without HA) - set_fact: - rds_flavor_id: "{{ (rds_flavors.content|from_json)|json_query('flavors[?ends_with(specCode,`small`) || ends_with(specCode,`medium`) || ends_with(specCode,`large`)] |sort_by(@, &ram)|[?ram>=`' + rds_ram + '`].id|[0]') }}" - when: - - rds_ram is defined -# - rds_ha_enabled == false - -- name: Set fact rds_flavor_id (HA) - set_fact: - rds_flavor_id: "{{ (rds_flavors.content|from_json)|json_query('flavors[?ends_with(specCode,`.ha`)] |sort_by(@, &ram)|[?ram>=`' + rds_ram + '`].id|[0]') }}" - when: - - rds_ram is defined - - (rds_ha_enabled is defined and rds_ha_enabled == true) - -- name: Set fact rds_flavor_id (without HA) - set_fact: - rds_flavor_id: "{{ (rds_flavors.content|from_json)|json_query('flavors[?ends_with(specCode,`small`) || ends_with(specCode,`medium`) || ends_with(specCode,`large`)] |sort_by(@, &ram)|[?ram>=`' + rds_ram + '`].id|[0]') }}" - when: - - rds_ram is defined - - rds_ha_enabled == false - -- name: debug rds_flavors.json - debug: - msg: "{{ rds_flavors.json }}" - when: - - rds_name is not defined - -- name: debug rds_flavor_id - debug: - msg: "{{ rds_flavor_id }}" - when: - - rds_flavor_id is defined diff --git a/roles/otc_rds/tasks/list.yml b/roles/otc_rds/tasks/list.yml deleted file mode 100644 index bbcefd8..0000000 --- a/roles/otc_rds/tasks/list.yml +++ /dev/null @@ -1,20 +0,0 @@ -- name: Send request to API (list RDS) - uri: - url: "{{ AUTH_URL_RDS }}/{{ OS_USER_DOMAIN_ID }}/instances" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - X-Language: "en-us" - register: rds - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: rds.status == 200 - changed_when: false - -- name: Output of rds - debug: - msg: "{{ rds.json }}" diff --git a/roles/otc_rds/tasks/lookup.yml b/roles/otc_rds/tasks/lookup.yml deleted file mode 100644 index 6f9b28e..0000000 --- a/roles/otc_rds/tasks/lookup.yml +++ /dev/null @@ -1,21 +0,0 @@ -- name: Send request to API (list RDS for lookup) - uri: - url: "{{ AUTH_URL_RDS }}/{{ OS_USER_DOMAIN_ID }}/instances" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - X-Language: "en-us" - register: rds - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: rds.status == 200 - changed_when: false - -- name: Set fact rds_id for rds if rds_name is defined - set_fact: - rds_id: "{{ (rds.content|from_json)|json_query(\"instances[?name=='\" + rds_name + \"'].id|[0]\") }}" - when: rds_name is defined diff --git a/roles/otc_rds/tasks/main.yml b/roles/otc_rds/tasks/main.yml deleted file mode 100644 index d9cbe31..0000000 --- a/roles/otc_rds/tasks/main.yml +++ /dev/null @@ -1,3 +0,0 @@ -- name: action {{ localaction }} - include: "{{ localaction }}.yml" - when: localaction is defined diff --git a/roles/otc_rds/tasks/reboot.yml b/roles/otc_rds/tasks/reboot.yml deleted file mode 100644 index 3435179..0000000 --- a/roles/otc_rds/tasks/reboot.yml +++ /dev/null @@ -1,28 +0,0 @@ -- name: Lookup rds_id - include: lookup.yml - -- name: Send request to API (reboot RDS) - uri: - url: "{{ AUTH_URL_RDS }}/{{ OS_USER_DOMAIN_ID }}/instances/{{ rds_id }}/action" - method: POST - body_format: raw - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - status_code: 200,201,202,203 - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - X-Language: "en-us" - body: "{ \"restart\": {}}" - register: rds - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: rds.status == 200 or rds.status == 201 or rds.status == 202 or rds.status == 203 - changed_when: false - when: - - rds_id is defined - -- name: Output of rds - debug: - msg: "{{ rds }}" diff --git a/roles/otc_rds/tasks/resize_flavor.yml b/roles/otc_rds/tasks/resize_flavor.yml deleted file mode 100644 index aa576f7..0000000 --- a/roles/otc_rds/tasks/resize_flavor.yml +++ /dev/null @@ -1,31 +0,0 @@ -- name: Lookup rds_id - include: lookup.yml - -- name: Lookup rds_flavor_id - include: flavor.yml - -- name: Send request to API (resize RDS flavor) - uri: - url: "{{ AUTH_URL_RDS }}/{{ OS_USER_DOMAIN_ID }}/instances/{{ rds_id }}/action" - method: POST - body_format: raw - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - status_code: 200,201,202,203 - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - X-Language: "en-us" - body: "{{ lookup('template', 'resize_flavor.json.j2')|to_json }}" - register: rds - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: rds.status == 200 or rds.status == 201 or rds.status == 202 or rds.status == 203 - changed_when: false - when: - - rds_id is defined - -- name: Output of rds - debug: - msg: "{{ rds }}" diff --git a/roles/otc_rds/tasks/resize_volume.yml b/roles/otc_rds/tasks/resize_volume.yml deleted file mode 100644 index 04a96d0..0000000 --- a/roles/otc_rds/tasks/resize_volume.yml +++ /dev/null @@ -1,28 +0,0 @@ -- name: Lookup rds_id - include: lookup.yml - -- name: Send request to API (resize RDS volume) - uri: - url: "{{ AUTH_URL_RDS }}/{{ OS_USER_DOMAIN_ID }}/instances/{{ rds_id }}/action" - method: POST - body_format: raw - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - status_code: 200,201,202,203 - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - X-Language: "en-us" - body: "{{ lookup('template', 'resize_volume.json.j2')|to_json }}" - register: rds - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: rds.status == 200 or rds.status == 201 or rds.status == 202 or rds.status == 203 - changed_when: false - when: - - rds_id is defined - -- name: Output of rds - debug: - msg: "{{ rds }}" diff --git a/roles/otc_rds/tasks/restore_backup_current.yml b/roles/otc_rds/tasks/restore_backup_current.yml deleted file mode 100644 index 8b3e27c..0000000 --- a/roles/otc_rds/tasks/restore_backup_current.yml +++ /dev/null @@ -1,28 +0,0 @@ -- name: Lookup rds_id - include: lookup.yml - -- name: Send request to API (restore RDS backup) - uri: - url: "{{ AUTH_URL_RDS }}/{{ OS_USER_DOMAIN_ID }}/instances/{{ rds_id }}/action" - method: POST - body_format: raw - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - status_code: 200,201,202,203 - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - X-Language: "en-us" - body: "{{ lookup('template', 'restore_backup_current.json.j2')|to_json }}" - register: rdsbackup - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: rdsbackup.status == 200 or rdsbackup.status == 201 or rdsbackup.status == 202 or rdsbackup.status == 203 - changed_when: false - when: - - rds_backup_id is defined - -- name: Output of rdsbackup - debug: - msg: "{{ rdsbackup }}" diff --git a/roles/otc_rds/tasks/restore_backup_new.yml b/roles/otc_rds/tasks/restore_backup_new.yml deleted file mode 100644 index 6a149ba..0000000 --- a/roles/otc_rds/tasks/restore_backup_new.yml +++ /dev/null @@ -1,31 +0,0 @@ -#- name: Lookup rds_id -# include: lookup.yml - -- name: Lookup rds_flavor_id - include: flavor.yml - -- name: Send request to API (create RDS backup) - uri: - url: "{{ AUTH_URL_RDS }}/{{ OS_USER_DOMAIN_ID }}/instances" - method: POST - body_format: raw - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - status_code: 200,201,202,203 - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - X-Language: "en-us" - body: "{{ lookup('template', 'restore_backup_new.json.j2')|to_json }}" - register: rdsbackup - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: rdsbackup.status == 200 or rdsbackup.status == 201 or rdsbackup.status == 202 or rdsbackup.status == 203 - changed_when: false - when: - - rds_backup_id is defined - -- name: Output of rdsbackup - debug: - msg: "{{ rdsbackup }}" diff --git a/roles/otc_rds/tasks/show.yml b/roles/otc_rds/tasks/show.yml deleted file mode 100644 index 255efb7..0000000 --- a/roles/otc_rds/tasks/show.yml +++ /dev/null @@ -1,25 +0,0 @@ -- name: Lookup rds_id - include: lookup.yml - -- name: Send request to API (show RDS) - uri: - url: "{{ AUTH_URL_RDS }}/{{ OS_USER_DOMAIN_ID }}/instances/{{ rds_id }}" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - X-Language: "en-us" - register: rds - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: rds.status == 200 - changed_when: false - when: - - rds_id is defined - -- name: Output of rds - debug: - msg: "{{ rds.json }}" diff --git a/roles/otc_rds/tasks/slowlog.yml b/roles/otc_rds/tasks/slowlog.yml deleted file mode 100644 index 3777bdf..0000000 --- a/roles/otc_rds/tasks/slowlog.yml +++ /dev/null @@ -1,25 +0,0 @@ -- name: Lookup rds_id - include: lookup.yml - -- name: Send request to API (show RDS slowlog) - uri: - url: "{{ AUTH_URL_RDS }}/{{ OS_USER_DOMAIN_ID }}/instances/{{ rds_id }}/slowlog?sftype={{ slowlog_type }}" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - X-Language: "en-us" - register: rds - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: rds.status == 200 - changed_when: false - when: - - rds_id is defined - -- name: Output of rds - debug: - msg: "{{ rds.json }}" diff --git a/roles/otc_rds/tasks/version.yml b/roles/otc_rds/tasks/version.yml deleted file mode 100644 index 1a027fc..0000000 --- a/roles/otc_rds/tasks/version.yml +++ /dev/null @@ -1,59 +0,0 @@ -- name: Request rds list from API for mysql - uri: - url: "{{ AUTH_URL_RDS }}/{{ OS_USER_DOMAIN_ID }}/datastores/MySQL/versions" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - Accept: "application/json" - X-Language: "en-us" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: rds_mysql_versions - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: rds_mysql_versions.status == 200 - changed_when: false - -- name: Request rds list from API for postgresql - uri: - url: "{{ AUTH_URL_RDS }}/{{ OS_USER_DOMAIN_ID }}/datastores/PostgreSQL/versions" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - Accept: "application/json" - X-Language: "en-us" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: rds_postgresql_versions - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: rds_postgresql_versions.status == 200 - changed_when: false - -- name: Set fact rds_version_id (MySQL) - set_fact: - rds_version_id: "{{ (rds_mysql_versions.content|from_json)|json_query(\"dataStores[?name=='\" + rds_version + \"'].id|[0]\") }}" - when: - - (rds_name is defined or localaction == "flavor") - - rds_type == "MySQL" - -- name: Set fact rds_version_id (PostgreSQL) - set_fact: - rds_version_id: "{{ (rds_postgresql_versions.content|from_json)|json_query(\"dataStores[?name=='\" + rds_version + \"'].id|[0]\") }}" - when: - - (rds_name is defined or localaction == "flavor") - - rds_type == "PostgreSQL" - -- debug: - msg: "{{ rds_mysql_versions.json }}" - when: - - rds_name is not defined - -- debug: - msg: "{{ rds_postgresql_versions.json }}" - when: - - rds_name is not defined diff --git a/roles/otc_rds/templates/create.json.j2 b/roles/otc_rds/templates/create.json.j2 deleted file mode 100644 index ce8d2d4..0000000 --- a/roles/otc_rds/templates/create.json.j2 +++ /dev/null @@ -1,37 +0,0 @@ -{ - "instance": { - "name": "{{ rds_name }}", - "datastore": { - "type": "{{ rds_type }}", - "version": "{{ rds_version }}" - }, - "flavorRef": "{{ rds_flavor_id }}", - "volume": { - "type": "{{ rds_volume_type }}", - "size": {{ rds_volume_size }} - }, - "region": "eu-de", - "availabilityZone": "eu-de-01", - "vpc": "{{ vpc_id }}", - "nics": { - "subnetId": "{{ subnet_id }}" - }, - "securityGroup": { - "id": "{{ secgroup_id }}" - }, - "dbPort": {{ rds_port }}, -{% if rds_backup_days is defined and rds_backup_days|length != 0 %} - "backupStrategy": { - "startTime": "{{ rds_backup_time }}", - "keepDays": {{ rds_backup_days }} - }, -{% endif %} -{% if rds_ha_enabled == true %} - "ha": { - "enable": true, - "replicationMode": "{{ rds_ha_replication_mode }}" - }, -{% endif %} - "dbRtPd": "{{ rds_root_password }}" - } -} diff --git a/roles/otc_rds/templates/create_backup.json.j2 b/roles/otc_rds/templates/create_backup.json.j2 deleted file mode 100644 index a81cdac..0000000 --- a/roles/otc_rds/templates/create_backup.json.j2 +++ /dev/null @@ -1,7 +0,0 @@ -{ -"backup": { -"description": "Ansible generated backup", -"instance": "{{ rds_id }}", -"name": "{{ rds_backup_name }}" -} -} diff --git a/roles/otc_rds/templates/resize_flavor.json.j2 b/roles/otc_rds/templates/resize_flavor.json.j2 deleted file mode 100644 index aaaa436..0000000 --- a/roles/otc_rds/templates/resize_flavor.json.j2 +++ /dev/null @@ -1,5 +0,0 @@ -{ - "resize": { - "flavorRef": "{{ rds_flavor_id }}" - } -} diff --git a/roles/otc_rds/templates/resize_volume.json.j2 b/roles/otc_rds/templates/resize_volume.json.j2 deleted file mode 100644 index 3dc7376..0000000 --- a/roles/otc_rds/templates/resize_volume.json.j2 +++ /dev/null @@ -1,8 +0,0 @@ -{ - "resize": { - "volume": { - "size": {{ rds_volume_size }} - } - } -} - diff --git a/roles/otc_rds/templates/restore_backup_current.json.j2 b/roles/otc_rds/templates/restore_backup_current.json.j2 deleted file mode 100644 index 83df252..0000000 --- a/roles/otc_rds/templates/restore_backup_current.json.j2 +++ /dev/null @@ -1,8 +0,0 @@ -{ -"restore": { -{% if rds_restore_time is defined and rds_restore_time|length != 0 %} - "restoreTime": {{ lookup('pipe','date +%s --date=\"' + rds_restore_time + '\"') }}, -{% endif %} - "backupRef":"{{ rds_backup_id }}" - } -} diff --git a/roles/otc_rds/templates/restore_backup_new.json.j2 b/roles/otc_rds/templates/restore_backup_new.json.j2 deleted file mode 100644 index ae0f07b..0000000 --- a/roles/otc_rds/templates/restore_backup_new.json.j2 +++ /dev/null @@ -1,14 +0,0 @@ -{ - "instance": { - "name": "{{ rds_name }}", - "flavorRef": "{{ rds_flavor_id }}", - "volume": { - "size": {{ rds_volume_size }} - }, - "restorePoint":{ - "backupRef": "{{ rds_backup_id }}", - "restoreTime": {{ lookup('pipe','date +%s --date=\"' + rds_restore_time + '\"') }}, - "sourceInstanceId": "{{ rds_backup_instance_id }}" - } - } -} diff --git a/roles/otc_secgroup/README.rst b/roles/otc_secgroup/README.rst deleted file mode 100644 index f37b85d..0000000 --- a/roles/otc_secgroup/README.rst +++ /dev/null @@ -1,54 +0,0 @@ -otc_secgroup -============ - -OTC role for security groups. This role creates security groups defined -for an ECS and creates the rules. The rules are defined in an extra section. -Standard rules will be removed before the defined rules are created. - -Variables: -^^^^^^^^^^ - -+-------------------------+---------------------------------------------+ -| Name | Description | -+=========================+=============================================+ -| secgroup_name | name of Secgroup | -+-------------------------+---------------------------------------------+ -| secgroup_id | id of Secgroup | -+-------------------------+---------------------------------------------+ -| secgroup_ids | list of secgroup_ids (to bind on ECS | -+-------------------------+---------------------------------------------+ -| secgroups | list of secgroups in ecs section | -+-------------------------+---------------------------------------------+ -| secgrouprules | list of rules for a security group | -+-------------------------+---------------------------------------------+ -| secgrouprule_id | id of a secgroup rule | -+-------------------------+---------------------------------------------+ - -Functions: -^^^^^^^^^^ - -Create:: - - ansible-playbook tenant_yml.yml -e "ecs_name=ansible-test01" -e "localaction=create" - - ansible-playbook tenant_ini.yml -e "ecs_name=ansible-test01" -e "localaction=create" - - ansible-playbook tenant_json.yml -e "ecs_name=ansible-test01" -e "localaction=create" - -note: subnet will create during ECS creating workflow - -Show:: - - ./grole otc_secgroup; ansible-playbook roles.yml -e "secgroup_name=ansible-secgroup01" -e "localaction=show" - -List:: - - ./grole otc_secgroup; ansible-playbook roles.yml -e "localaction=list" - - ./grole otc_secgroup; ansible-playbook roles.yml -e "vpc_id=1234567891234567890" -e "localaction=list" - - ./grole otc_vpc otc_secgroup; ansible-playbook roles.yml -e "vpc_name=ansible-vpc01" -e "localaction=list" - -Delete:: - - ./grole otc_secgroup; ansible-playbook roles.yml -e "secgroup_name=ansible-secgroup01" -e "localaction=delete" diff --git a/roles/otc_secgroup/defaults/main.yml b/roles/otc_secgroup/defaults/main.yml deleted file mode 100644 index a91cd5f..0000000 --- a/roles/otc_secgroup/defaults/main.yml +++ /dev/null @@ -1,4 +0,0 @@ -uri_follow_redirects: "none" -uri_validate_certs: "yes" -uri_retries: 5 -uri_delay: 1 diff --git a/roles/otc_secgroup/tasks/create.yml b/roles/otc_secgroup/tasks/create.yml deleted file mode 100644 index 6066b7e..0000000 --- a/roles/otc_secgroup/tasks/create.yml +++ /dev/null @@ -1,41 +0,0 @@ -- name: Get secgroup_id - include: lookup.yml - with_items: - - "{{ secgroups }}" - loop_control: - loop_var: secgroup_name - -- name: Send request to API (create security group) - uri: - url: "{{ AUTH_URL_VPC }}/v1/{{ PROJECT_ID }}/security-groups" - method: POST - body_format: raw - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - body: "{{ lookup('template', 'create.json.j2')|to_json }}" - when: - - secgroups is defined - - secgroup_name not in secgroup_names - register: secgroupcreate - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: secgroupcreate.status == 200 - changed_when: false - with_items: - - "{{ secgroups }}" - loop_control: - loop_var: secgroup_name - -- name: Create securiy group rules - include: rule_create.yml - when: - - secgroups is defined - - secgroup_name not in secgroup_names - with_items: - - "{{ secgroups }}" - loop_control: - loop_var: secgroup_name diff --git a/roles/otc_secgroup/tasks/delete.yml b/roles/otc_secgroup/tasks/delete.yml deleted file mode 100644 index 09d25c3..0000000 --- a/roles/otc_secgroup/tasks/delete.yml +++ /dev/null @@ -1,6 +0,0 @@ -- name: Loop over Secgroup List - vars: - secgroup_name: "{{ item }}" - include: deletegrouploop.yml - with_items: - - "{{ secgroups }}" diff --git a/roles/otc_secgroup/tasks/deletegrouploop.yml b/roles/otc_secgroup/tasks/deletegrouploop.yml deleted file mode 100644 index cd36810..0000000 --- a/roles/otc_secgroup/tasks/deletegrouploop.yml +++ /dev/null @@ -1,45 +0,0 @@ -- name: Send request to API (list security groups) - uri: - url: "{{ AUTH_URL_VPC }}/v1/{{ PROJECT_ID }}/security-groups" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - when: - - secgroup_name is defined - register: secgroup_result - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: secgroup_result.status == 200 - changed_when: false - -- name: Set fact for secgroup_id if secgroup_name is defined - set_fact: - secgroup_id: "{{ (secgroup_result.content|from_json)|json_query(\"security_groups[?name=='\" + secgroup_name + \"'].id|[0]\") }}" - when: - - secgroup_name is defined and secgroup_name| length != 0 - -- name: Send request to API (delete security group) - uri: - url: "{{ AUTH_URL_VPC }}/v2.0/security-groups/{{ secgroup_id }}" - method: DELETE - body_format: raw - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - status_code: 200,201,202,203,204 - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: secgroup - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: secgroup.status == 200 or secgroup.status == 201 or secgroup.status == 202 or secgroup.status == 203 or secgroup.status == 204 - changed_when: false - when: (secgroup_id is defined and secgroup_id| length != 0) - -- debug: - msg: "{{ secgroup }}" diff --git a/roles/otc_secgroup/tasks/list.yml b/roles/otc_secgroup/tasks/list.yml deleted file mode 100644 index 4b68416..0000000 --- a/roles/otc_secgroup/tasks/list.yml +++ /dev/null @@ -1,41 +0,0 @@ -- name: Send request to API (list security groups for search vpc_id) - uri: - url: "{{ AUTH_URL_VPC }}/v1/{{ PROJECT_ID }}/security-groups?vpc_id={{ vpc_id }}" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: secgrouplistvpc - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: secgrouplistvpc.status == 200 - changed_when: false - when: vpc_id is defined - -- name: Send request to API (list security groups) - uri: - url: "{{ AUTH_URL_VPC }}/v1/{{ PROJECT_ID }}/security-groups" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: secgrouplist - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: secgrouplist.status == 200 - changed_when: false - when: vpc_id is not defined - -- debug: - msg: "{{ secgrouplistvpc.json }}" - when: vpc_id is defined - -- debug: - msg: "{{ secgrouplist.json }}" - when: vpc_id is not defined diff --git a/roles/otc_secgroup/tasks/lookup.yml b/roles/otc_secgroup/tasks/lookup.yml deleted file mode 100644 index a6daeca..0000000 --- a/roles/otc_secgroup/tasks/lookup.yml +++ /dev/null @@ -1,42 +0,0 @@ -- name: Send request to API (list security groups) - uri: - url: "{{ AUTH_URL_VPC }}/v1/{{ PROJECT_ID }}/security-groups" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: secgroup_result - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: secgroup_result.status == 200 - changed_when: false - when: - - secgroup_name is defined - -- name: Set fact for secgroup_id if secgroup_name is defined - set_fact: - secgroup_id: "{{ (secgroup_result.content|from_json)|json_query(\"security_groups[?name=='\" + secgroup_name + \"'].id|[0]\") }}" - when: - - secgroup_name is defined and secgroup_name| length != 0 - -- name: Set empty fact secgroup_names - set_fact: - secgroup_names: [] - when: - - secgroup_names is not defined - -- name: Set empty fact secgroup_ids - set_fact: - secgroup_ids: [] - when: - - secgroup_ids is not defined - -- name: Set fact for secgroup_ids if secgroup_id is defined - set_fact: - secgroup_ids: "{{ secgroup_ids }} + [ '{{ secgroup_id }}' ]" - secgroup_names: "{{ secgroup_names }} + [ '{{ secgroup_name }}' ]" - when: - - secgroup_id is defined and secgroup_id| length != 0 diff --git a/roles/otc_secgroup/tasks/main.yml b/roles/otc_secgroup/tasks/main.yml deleted file mode 100644 index d9cbe31..0000000 --- a/roles/otc_secgroup/tasks/main.yml +++ /dev/null @@ -1,3 +0,0 @@ -- name: action {{ localaction }} - include: "{{ localaction }}.yml" - when: localaction is defined diff --git a/roles/otc_secgroup/tasks/rule_create.yml b/roles/otc_secgroup/tasks/rule_create.yml deleted file mode 100644 index e669857..0000000 --- a/roles/otc_secgroup/tasks/rule_create.yml +++ /dev/null @@ -1,92 +0,0 @@ -- name: Send request to API (security group list) - uri: - url: "{{ AUTH_URL_VPC }}/v1/{{ PROJECT_ID }}/security-groups" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: secgroup_result - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: secgroup_result.status == 200 - changed_when: false - when: - - secgroup_name is defined - -- name: Set fact for secgroup_id if secgroup_name is defined - set_fact: - secgroup_id: "{{ (secgroup_result.content|from_json)|json_query(\"security_groups[?name=='\" + secgroup_name + \"'].id|[0]\") }}" - when: - - secgroup_name is defined and secgroup_name| length != 0 - -- name: Send request to API (securiy group rule list) - uri: - url: "{{ AUTH_URL_VPC }}/v2.0/security-group-rules?security_group_id={{ secgroup_id }}" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: secgrouprule_result - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: secgrouprule_result.status == 200 - changed_when: false - when: - - secgroup_id is defined - -- name: Send request to API (remove security group default rules) - vars: - secgrouprule_id: "{{ item }}" - uri: - url: "{{ AUTH_URL_VPC }}/v2.0/security-group-rules/{{ secgrouprule_id }}" - method: DELETE - body_format: raw - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - status_code: 200,201,202,203,204 - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: secgroup_rule - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: secgroup_rule.status == 200 or secgroup_rule.status == 201 or secgroup_rule.status == 202 or secgroup_rule.status == 203 or secgroup_rule.status == 204 - changed_when: false - when: - - secgrouprule_result is defined - with_items: - - "{{ secgrouprule_result.json|json_query('security_group_rules[].id') }}" - -- name: Send request to API (create security group rule) - vars: - secgrouprule_part: "{{ item.split(';') }}" - uri: - url: "{{ AUTH_URL_VPC }}/v2.0/security-group-rules" - method: POST - body_format: raw - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - status_code: 200,201,202,203,204,409 - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - body: "{{ lookup('template', 'rule_create.json.j2')|to_json }}" - register: secgrouprule - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: secgrouprule.status == 200 or secgrouprule.status == 201 or secgrouprule.status == 202 or secgrouprule.status == 203 or secgrouprule.status == 204 or secgrouprule.status == 409 - changed_when: false - - when: - - secgroup_id is defined - - secgrouprules is defined - with_items: - - "{{ secgrouprules }}" diff --git a/roles/otc_secgroup/tasks/show.yml b/roles/otc_secgroup/tasks/show.yml deleted file mode 100644 index 2671e6e..0000000 --- a/roles/otc_secgroup/tasks/show.yml +++ /dev/null @@ -1,25 +0,0 @@ -- name: Lookup secgroup_id - include: lookup.yml - -- name: Send request to API (show security group) - uri: - url: "{{ AUTH_URL_VPC }}/v1/{{ PROJECT_ID }}/security-groups/{{ secgroup_id }}" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: secgroupdetail - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: secgroupdetail.status == 200 - changed_when: false - when: - - secgroup_id is defined - -- debug: - msg: "{{ secgroupdetail.json }}" - when: - - secgroup_id is defined diff --git a/roles/otc_secgroup/templates/create.json.j2 b/roles/otc_secgroup/templates/create.json.j2 deleted file mode 100644 index b636a43..0000000 --- a/roles/otc_secgroup/templates/create.json.j2 +++ /dev/null @@ -1,8 +0,0 @@ -{ - "security_group": { -{% if vpc_id is defined %} - "vpc_id": "{{ vpc_id }}", -{% endif %} - "name": "{{ secgroup_name }}" - } -} diff --git a/roles/otc_secgroup/templates/rule_create.json.j2 b/roles/otc_secgroup/templates/rule_create.json.j2 deleted file mode 100644 index f0fadc3..0000000 --- a/roles/otc_secgroup/templates/rule_create.json.j2 +++ /dev/null @@ -1,17 +0,0 @@ -{ - "security_group_rule": { - "direction": "{{ secgrouprule_part[0] }}", - "ethertype": "{{ secgrouprule_part[1] }}", - "protocol": "{{ secgrouprule_part[2] }}", -{% if secgrouprule_part[3] is defined and secgrouprule_part[3]|length != 0 %} - "port_range_min": {{ secgrouprule_part[3] }}, -{% endif %} -{% if secgrouprule_part[4] is defined and secgrouprule_part[4]|length != 0 %} - "port_range_max": {{ secgrouprule_part[4] }}, -{% endif %} -{% if secgrouprule_part[5] is defined and secgrouprule_part[5]|length != 0 %} - "remote_ip_prefix": "{{ secgrouprule_part[5] }}", -{% endif %} - "security_group_id": "{{ secgroup_id }}", - } -} diff --git a/roles/otc_subnet/README.rst b/roles/otc_subnet/README.rst deleted file mode 100644 index 06a23f8..0000000 --- a/roles/otc_subnet/README.rst +++ /dev/null @@ -1,40 +0,0 @@ -otc_subnet -========== - -OTC role for Subnet. - -Variables: -^^^^^^^^^^ - -+-------------------------+---------------------------------------------+ -| Name | Description | -+=========================+=============================================+ -| subnet_name | name of Subnet | -+-------------------------+---------------------------------------------+ -| subnet_id | id of Subnet | -+-------------------------+---------------------------------------------+ - -Functions: -^^^^^^^^^^ - -Create:: - - ansible-playbook tenant_yml.yml -e "ecs_name=ansible-test01" -e "localaction=create" - - ansible-playbook tenant_ini.yml -e "ecs_name=ansible-test01" -e "localaction=create" - - ansible-playbook tenant_json.yml -e "ecs_name=ansible-test01" -e "localaction=create" - -note: subnet will create during ECS creating workflow - -Show:: - - ./grole otc_subnet; ansible-playbook roles.yml -e "subnet_name=ansible-subnet01" -e "localaction=show" - -List:: - - ./grole otc_subnet; ansible-playbook roles.yml -e "localaction=list" - -Delete:: - - ./grole otc_subnet; ansible-playbook roles.yml -e "subnet_name=ansible-subnet01" -e "localaction=delete" diff --git a/roles/otc_subnet/defaults/main.yml b/roles/otc_subnet/defaults/main.yml deleted file mode 100644 index a91cd5f..0000000 --- a/roles/otc_subnet/defaults/main.yml +++ /dev/null @@ -1,4 +0,0 @@ -uri_follow_redirects: "none" -uri_validate_certs: "yes" -uri_retries: 5 -uri_delay: 1 diff --git a/roles/otc_subnet/tasks/create.yml b/roles/otc_subnet/tasks/create.yml deleted file mode 100644 index 4ae800a..0000000 --- a/roles/otc_subnet/tasks/create.yml +++ /dev/null @@ -1,28 +0,0 @@ -- name: Get subnet_id - include: lookup.yml - when: - - subnet_name is defined - -- name: Send request to API (create subnet) - uri: - url: "{{ AUTH_URL_VPC }}/v1/{{ PROJECT_ID }}/subnets" - method: POST - body_format: raw - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - body: "{{ lookup('template', 'create.json.j2')|to_json }}" - register: subnet - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: subnet.status == 200 - changed_when: false - when: - - subnet_name is defined - - not subnet_id or subnet_id is undefined - -- debug: - msg: "{{ subnet }}" diff --git a/roles/otc_subnet/tasks/delete.yml b/roles/otc_subnet/tasks/delete.yml deleted file mode 100644 index 1ce9a90..0000000 --- a/roles/otc_subnet/tasks/delete.yml +++ /dev/null @@ -1,24 +0,0 @@ -- name: Lookup subnet_id - include: lookup.yml - -- name: Send request to API (delete subnet) - uri: - url: "{{ AUTH_URL_VPC }}/v1/{{ PROJECT_ID }}/vpcs/{{ vpc_id }}/subnets/{{ subnet_id }}" - method: DELETE - body_format: raw - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - status_code: 200,201,202,203,204 - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: subnet - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: subnet.status == 200 or subnet.status == 201 or subnet.status == 202 or subnet.status == 203 or subnet.status == 204 - changed_when: false - when: subnet_id is defined and subnet_id|length != 0 - -- debug: - msg: "{{ subnet }}" diff --git a/roles/otc_subnet/tasks/list.yml b/roles/otc_subnet/tasks/list.yml deleted file mode 100644 index cd7380d..0000000 --- a/roles/otc_subnet/tasks/list.yml +++ /dev/null @@ -1,18 +0,0 @@ -- name: Request subnet list from API (list subnet) - uri: - url: "{{ AUTH_URL_VPC }}/v1/{{ PROJECT_ID }}/subnets" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: subnetlist - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: subnetlist.status == 200 - changed_when: false - -- debug: - msg: "{{ subnetlist.json }}" diff --git a/roles/otc_subnet/tasks/lookup.yml b/roles/otc_subnet/tasks/lookup.yml deleted file mode 100644 index 1ccfe1a..0000000 --- a/roles/otc_subnet/tasks/lookup.yml +++ /dev/null @@ -1,48 +0,0 @@ -- name: Send request to API (list subnet for lookup) - uri: - url: "{{ AUTH_URL_VPC }}/v1/{{ PROJECT_ID }}/subnets" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: subnet_result - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: subnet_result.status == 200 - changed_when: false - when: - - subnet_name is defined - -- name: Set fact for subnet_id if subnet_name is defined - set_fact: - subnet_id: "{{ (subnet_result.content|from_json)|json_query(\"subnets[?name=='\" + subnet_name + \"'].id|[0]\") }}" - when: - - subnet_name is defined and subnet_name|length != 0 - -# duplicated code -- name: Send request to API (list VPC for lookup) - uri: - url: "{{ AUTH_URL_VPC }}/v1/{{ PROJECT_ID }}/vpcs" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: vpc_result - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: vpc_result.status == 200 - changed_when: false - when: - - vpc_name is defined - -- name: Set fact vpc_id if vpc_name is defined - set_fact: - vpc_id: "{{ (vpc_result.content|from_json)|json_query(\"vpcs[?name=='\" + vpc_name + \"'].id|[0]\") }}" - when: - - vpc_name is defined diff --git a/roles/otc_subnet/tasks/main.yml b/roles/otc_subnet/tasks/main.yml deleted file mode 100644 index d9cbe31..0000000 --- a/roles/otc_subnet/tasks/main.yml +++ /dev/null @@ -1,3 +0,0 @@ -- name: action {{ localaction }} - include: "{{ localaction }}.yml" - when: localaction is defined diff --git a/roles/otc_subnet/tasks/show.yml b/roles/otc_subnet/tasks/show.yml deleted file mode 100644 index 101d141..0000000 --- a/roles/otc_subnet/tasks/show.yml +++ /dev/null @@ -1,23 +0,0 @@ -- name: Lookup subnet_id - include: lookup.yml - -- name: Send request to API (show subnet) - uri: - url: "{{ AUTH_URL_VPC }}/v1/{{ PROJECT_ID }}/subnets/{{ subnet_id }}" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: subnetdetail - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: subnetdetail.status == 200 - changed_when: false - when: - - subnet_id is defined - -- debug: - msg: "{{ subnetdetail.json }}" diff --git a/roles/otc_subnet/templates/create.json.j2 b/roles/otc_subnet/templates/create.json.j2 deleted file mode 100644 index debf327..0000000 --- a/roles/otc_subnet/templates/create.json.j2 +++ /dev/null @@ -1,18 +0,0 @@ -{ - "subnet": { - "name": "{{ subnet_name }}", - "cidr": "{{ subnet_net }}", - "gateway_ip": "{{ subnet_gateway }}", -{% if subnet_dhcp_enable is defined %} - "dhcp_enable": {{ subnet_dhcp_enable }}, -{% endif %} -{% if subnet_primary_dns is defined and subnet_primary_dns | length != 0 %} - "primary_dns": "{{ subnet_primary_dns }}", -{% endif %} -{% if subnet_secondary_dns is defined and subnet_secondary_dns|length != 0 %} - "secondary_dns": "{{ subnet_secondary_dns }}", -{% endif %} - "availability_zone": "{{ availability_zone }}", - "vpc_id": "{{ vpc_id }}" - } -} diff --git a/roles/otc_vpc/README.rst b/roles/otc_vpc/README.rst deleted file mode 100644 index 3bfcb0a..0000000 --- a/roles/otc_vpc/README.rst +++ /dev/null @@ -1,46 +0,0 @@ -otc_vpc -======= - -OTC role for VPC. - -Variables: -^^^^^^^^^^ - -+-------------------------+---------------------------------------------+ -| Name | Description | -+=========================+=============================================+ -| localaction=router | Information about VPC Router as fact | -+-------------------------+---------------------------------------------+ -| localaction=snat | Configure SNAT on VPC | -+-------------------------+---------------------------------------------+ -| enable_snat=true|false | Enable or disable SNAT | -+-------------------------+---------------------------------------------+ -| vpc_name | name of VPC | -+-------------------------+---------------------------------------------+ -| vpc_id | id of VPC | -+-------------------------+---------------------------------------------+ - -Functions: -^^^^^^^^^^ - -Create:: - - ansible-playbook tenant_yml.yml -e "ecs_name=ansible-test01" -e "localaction=create" - - ansible-playbook tenant_ini.yml -e "ecs_name=ansible-test01" -e "localaction=create" - - ansible-playbook tenant_json.yml -e "ecs_name=ansible-test01" -e "localaction=create" - -note: VPC will create during ECS creating workflow - -Show:: - - ./grole otc_vpc; ansible-playbook roles.yml -e "vpc_name=ansible-vpc01" -e "localaction=show" - -List:: - - ./grole otc_vpc; ansible-playbook roles.yml -e "localaction=list" - -Delete:: - - ./grole otc_vpc; ansible-playbook roles.yml -e "vpc_name=ansible-vpc01" -e "localaction=delete" diff --git a/roles/otc_vpc/defaults/main.yml b/roles/otc_vpc/defaults/main.yml deleted file mode 100644 index a91cd5f..0000000 --- a/roles/otc_vpc/defaults/main.yml +++ /dev/null @@ -1,4 +0,0 @@ -uri_follow_redirects: "none" -uri_validate_certs: "yes" -uri_retries: 5 -uri_delay: 1 diff --git a/roles/otc_vpc/tasks/create.yml b/roles/otc_vpc/tasks/create.yml deleted file mode 100644 index c9aefae..0000000 --- a/roles/otc_vpc/tasks/create.yml +++ /dev/null @@ -1,28 +0,0 @@ -- name: Get vpc_id - include: lookup.yml - when: - - vpc_name is defined - -- name: Send request to API (create VPC) - uri: - url: "{{ AUTH_URL_VPC }}/v1/{{ PROJECT_ID }}/vpcs" - method: POST - body_format: raw - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - body: "{{ lookup('template', 'create.json.j2')|to_json }}" - register: vpc - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: vpc.status == 200 - changed_when: false - when: - - not vpc_id or vpc_id is undefined -# - vpc_name is defined - -- debug: - msg: "{{ vpc }}" diff --git a/roles/otc_vpc/tasks/delete.yml b/roles/otc_vpc/tasks/delete.yml deleted file mode 100644 index f279672..0000000 --- a/roles/otc_vpc/tasks/delete.yml +++ /dev/null @@ -1,25 +0,0 @@ -- name: Lookup vpc_id - include: lookup.yml - -- name: Send request to API (delete VPC) - uri: - url: "{{ AUTH_URL_VPC }}/v1/{{ PROJECT_ID }}/vpcs/{{ vpc_id}}" - method: DELETE - body_format: raw - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - status_code: 200,201,202,203,204 - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: vpc - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: vpc.status == 200 or vpc.status == 200 or vpc.status == 202 or vpc.status == 203 or vpc.status == 204 - changed_when: false - when: vpc_id is defined and vpc_id|length != 0 - -- debug: - msg: "{{ vpc }}" - when: vpc_id is defined diff --git a/roles/otc_vpc/tasks/list.yml b/roles/otc_vpc/tasks/list.yml deleted file mode 100644 index b00bbde..0000000 --- a/roles/otc_vpc/tasks/list.yml +++ /dev/null @@ -1,18 +0,0 @@ -- name: Send request to API (list VPC) - uri: - url: "{{ AUTH_URL_VPC }}/v1/{{ PROJECT_ID }}/vpcs" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: vpclist - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: vpclist.status == 200 - changed_when: false - -- debug: - msg: "{{ vpclist.json }}" diff --git a/roles/otc_vpc/tasks/lookup.yml b/roles/otc_vpc/tasks/lookup.yml deleted file mode 100644 index 179de92..0000000 --- a/roles/otc_vpc/tasks/lookup.yml +++ /dev/null @@ -1,23 +0,0 @@ -- name: Send request to API (list VPC for lookup) - uri: - url: "{{ AUTH_URL_VPC }}/v1/{{ PROJECT_ID }}/vpcs" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: vpc_result - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: vpc_result.status == 200 - changed_when: false - when: - - vpc_name is defined - -- name: Set fact vpc_id if vpc_name is defined - set_fact: - vpc_id: "{{ (vpc_result.content|from_json)|json_query(\"vpcs[?name=='\" + vpc_name + \"'].id|[0]\") }}" - when: - - vpc_name is defined diff --git a/roles/otc_vpc/tasks/main.yml b/roles/otc_vpc/tasks/main.yml deleted file mode 100644 index e1e97e8..0000000 --- a/roles/otc_vpc/tasks/main.yml +++ /dev/null @@ -1,8 +0,0 @@ -- name: action {{ localaction }} - include: "{{ localaction }}.yml" - when: localaction is defined - -- name: Get vpc_id - include: lookup.yml - when: - - vpc_name is defined diff --git a/roles/otc_vpc/tasks/router.yml b/roles/otc_vpc/tasks/router.yml deleted file mode 100644 index f50fbdd..0000000 --- a/roles/otc_vpc/tasks/router.yml +++ /dev/null @@ -1,39 +0,0 @@ -- name: Lookup vpc_id - include: lookup.yml - -- name: Send request to API (list routers) - uri: - url: "{{ AUTH_URL_VPC }}/v2.0/routers/{{ vpc_id }}" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: routerlist - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: routerlist.status == 200 - changed_when: false - when: - - vpc_id is defined - -- set_fact: - router_id: "{{ (routerlist.content|from_json)|json_query('router.id') }}" - router_name: "{{ (routerlist.content|from_json)|json_query('router.name') }}" - router_status: "{{ (routerlist.content|from_json)|json_query('router.status') }}" - router_admin_state_up: "{{ (routerlist.content|from_json)|json_query('router.admin_state_up') }}" - router_routes: "{{ (routerlist.content|from_json)|json_query('router.routes[]') }}" - router_tenant_id: "{{ (routerlist.content|from_json)|json_query('router.tenant_id') }}" - external_network_id: "{{ (routerlist.content|from_json)|json_query('router.external_gateway_info.network_id') }}" - external_network_snat_state: "{{ (routerlist.content|from_json)|json_query('router.external_gateway_info.enable_snat') }}" - when: - - vpc_id is defined - - routerlist is defined - -- debug: - msg: "{{ routerlist.json }}" - when: - - vpc_id is defined - - routerlist is defined diff --git a/roles/otc_vpc/tasks/show.yml b/roles/otc_vpc/tasks/show.yml deleted file mode 100644 index 5aa110b..0000000 --- a/roles/otc_vpc/tasks/show.yml +++ /dev/null @@ -1,23 +0,0 @@ -- name: Lookup vpc_id - include: lookup.yml - -- name: Send request to API (show VPC) - uri: - url: "{{ AUTH_URL_VPC }}/v1/{{ PROJECT_ID }}/vpcs/{{ vpc_id }}" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: vpcdetail - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: vpcdetail.status == 200 - changed_when: false - when: - - vpc_id is defined - -- debug: - msg: "{{ vpcdetail.json }}" diff --git a/roles/otc_vpc/tasks/snat.yml b/roles/otc_vpc/tasks/snat.yml deleted file mode 100644 index 5b3c63b..0000000 --- a/roles/otc_vpc/tasks/snat.yml +++ /dev/null @@ -1,49 +0,0 @@ -- name: Lookup vpc_id - include: lookup.yml - -- name: Send request to API (list router for SNAT) - uri: - url: "{{ AUTH_URL_VPC }}/v2.0/routers/{{ vpc_id }}" - method: GET - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - register: routerlist - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: routerlist.status == 200 - changed_when: false - when: - - vpc_id is defined - -- set_fact: - external_network_id: "{{ (routerlist.content|from_json)|json_query('router.external_gateway_info.network_id') }}" - when: routerlist is defined - -- name: Send request to API (set SNAT) - uri: - url: "{{ AUTH_URL_VPC }}/v2.0/routers/{{ vpc_id }}" - method: PUT - body_format: raw - return_content: yes - follow_redirects: "{{ uri_follow_redirects }}" - validate_certs: "{{ uri_validate_certs }}" - headers: - Content-Type: "application/json" - X-Auth-Token: "{{ token['x_subject_token'] }}" - body: "{{ lookup('template', 'snat.json.j2')|to_json }}" - register: router - retries: "{{ uri_retries }}" - delay: "{{ uri_delay }}" - until: router.status == 200 - changed_when: false - when: - - vpc_id is defined - - enable_snat is defined - - external_network_id|length != 0 - -- debug: - msg: "{{ router }}" diff --git a/roles/otc_vpc/templates/create.json.j2 b/roles/otc_vpc/templates/create.json.j2 deleted file mode 100644 index d1413eb..0000000 --- a/roles/otc_vpc/templates/create.json.j2 +++ /dev/null @@ -1,6 +0,0 @@ -{ - "vpc": { - "name": "{{ vpc_name }}", - "cidr": "{{ vpc_net }}" - } -} diff --git a/roles/otc_vpc/templates/snat.json.j2 b/roles/otc_vpc/templates/snat.json.j2 deleted file mode 100644 index 0fd092b..0000000 --- a/roles/otc_vpc/templates/snat.json.j2 +++ /dev/null @@ -1,8 +0,0 @@ -{ - "router": { - "external_gateway_info": { - "network_id": "{{ external_network_id }}", - "enable_snat": {{ enable_snat }} - } - } -} diff --git a/tests/ansible.cfg b/tests/ansible.cfg index 51d344d..1cfd566 100644 --- a/tests/ansible.cfg +++ b/tests/ansible.cfg @@ -1,2 +1,2 @@ [defaults] -roles_path = ../roles +# roles_path = ../roles diff --git a/tests/test.yml b/tests/test.yml index 5f9f664..dd95fc4 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -2,11 +2,11 @@ - hosts: localhost gather_facts: no roles: - - role: ../roles/otc_auth - - role: ../roles/otc_ims + - role: otc_auth + - role: otc_ims localaction: "show" image_name: "Community_Ubuntu_16.04_TSI_latest" - - role: ../roles/otc_ecs + - role: otc_ecs localaction: "flavors" # tasks: # - include: ../roles/otc_ecs/tasks/flavors.yml diff --git a/tox.ini b/tox.ini index 5df7b22..371eb2c 100644 --- a/tox.ini +++ b/tox.ini @@ -1,7 +1,7 @@ [tox] minversion = 2.0 -envlist = checkbuild skipsdist = True +envlist = docs,lint [testenv] usedevelop = True @@ -13,11 +13,29 @@ deps = -r{toxinidir}/requirements.txt commands = {posargs} [testenv:docs] +deps = -r{toxinidir}/requirements.txt commands= +# role documentation is raw included here +# it's possible to clone the roles and build doc with local includes +# ansible-galaxy install -f -r ansible-role-requirements.yml -p roles python setup.py build_sphinx sphinx-build -M text doc/source doc/build sphinx-build -M singlehtml doc/source doc/build sphinx-build -M epub doc/source doc/build sphinx-build -M latexpdf doc/source doc/build -deps=sphinx +[testenv:lint] +commands= + yamllint playbooks +deps=yamllint + +[doc8] +# File extensions to check +extensions = .rst, .yaml +# Maximal line length should be 80 but we have some overlong lines. +# Let's not get far more in. +max-line-length = 80 +# Disable some doc8 checks: +# D000: Check RST validity +# - cannot handle "none" for code-block directive +#ignore = D000