From d2cb2d0280d64d852502927c7e00bbf080c91599 Mon Sep 17 00:00:00 2001 From: Artem Goncharov Date: Mon, 12 Sep 2022 17:17:26 +0200 Subject: [PATCH] update --- .gitignore | 2 ++ README.md | 4 ++++ galaxy.yml | 2 +- meta/runtime.yml | 2 ++ plugins/modules/service_catalog.py | 11 +++++------ .../targets/service_catalog/tasks/main.yaml | 17 +++++------------ .../service_catalog/tasks/test_data.yaml | 17 +++++++++++++++++ 7 files changed, 36 insertions(+), 19 deletions(-) create mode 100644 README.md create mode 100644 meta/runtime.yml create mode 100644 tests/integration/targets/service_catalog/tasks/test_data.yaml diff --git a/.gitignore b/.gitignore index 3b333a3..212a279 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,5 @@ tmp .idea/** */.idea/** +tests/output +tests/*/inventory diff --git a/README.md b/README.md new file mode 100644 index 0000000..107d51c --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# Open Telekom Cloud Backend collectio + +This is a collection of useful content helping to operate Open Telekom Cloud +backend diff --git a/galaxy.yml b/galaxy.yml index 69f764e..4271d53 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -2,7 +2,7 @@ namespace: opentelekomcloud name: backend version: 0.1.0 -readme: README.rst +readme: README.md authors: - Artem Goncharov (@gtema) diff --git a/meta/runtime.yml b/meta/runtime.yml new file mode 100644 index 0000000..2ee3c9f --- /dev/null +++ b/meta/runtime.yml @@ -0,0 +1,2 @@ +--- +requires_ansible: '>=2.9.10' diff --git a/plugins/modules/service_catalog.py b/plugins/modules/service_catalog.py index 386dba6..33ec946 100644 --- a/plugins/modules/service_catalog.py +++ b/plugins/modules/service_catalog.py @@ -144,7 +144,7 @@ class ServiceCatalogModule(OTCModule): def process( self, - target_data, + services, target_env='production', dry_run=True, skip_delete=True, @@ -158,8 +158,7 @@ class ServiceCatalogModule(OTCModule): _used_services = set() _used_eps = set() results = dict(services=[], endpoints=[]) - for srv_type, target_srv in target_data.get( - 'services', {}).items(): + for srv_type, target_srv in services.items(): if limit_services is not None and srv_type not in limit_services: # logging.debug(f'Skipping service {srv_type} as requested') continue @@ -319,15 +318,15 @@ class ServiceCatalogModule(OTCModule): def run(self): changed = False (results, changed) = self.process( - target_data=self.params['services'], - target_env=['self.args.environment'], + services=self.params['services'], + target_env=self.params['environment'], dry_run=self.ansible.check_mode, limit_services=self.params['limit_services'] ) if len(self.errors) == 0: self.exit_json( changed=changed, - results=results + changes=results ) else: self.fail_json( diff --git a/tests/integration/targets/service_catalog/tasks/main.yaml b/tests/integration/targets/service_catalog/tasks/main.yaml index 17b67a3..302a154 100644 --- a/tests/integration/targets/service_catalog/tasks/main.yaml +++ b/tests/integration/targets/service_catalog/tasks/main.yaml @@ -1,19 +1,12 @@ --- -- ansible.builtin.set_fact: - services: - compute: - name: "nova" - environments: - production: - endpoints: - eu-de: - - url: "https://ecs.eu-de.otc.t-systems.com/v2.1/$(tenant_id)s" - eu-nl: - - url: "https://ecs.eu-nl.otc.t-systems.com/v2.1/$(tenant_id)s" +- name: include vars + ansible.builtin.include_vars: + file: test_data.yaml + name: "config" - name: Check run opentelekomcloud.backend.service_catalog: cloud: "{{ cloud }}" environment: "production" - services: "{{ services }}" + services: "{{ config.services }}" check_mode: true diff --git a/tests/integration/targets/service_catalog/tasks/test_data.yaml b/tests/integration/targets/service_catalog/tasks/test_data.yaml new file mode 100644 index 0000000..5e1102d --- /dev/null +++ b/tests/integration/targets/service_catalog/tasks/test_data.yaml @@ -0,0 +1,17 @@ +--- +services: + # Key of the dictionary is the service type + # this helps avoiding duplication of the services + compute: + name: "nova" + environments: + production: + endpoints: + eu-de: + - url: "https://ecs.eu-de.otc.t-systems.com/v2.1/$(tenant_id)s" + eu-nl: + - url: "https://ecs.eu-nl.otc.t-systems.com/v2.1/$(tenant_id)s" + preprod: + endpoints: + eu-de: + - url: "https://ecs.eu-de.otctest.t-systems.com/v2.1/$(tenant_id)s"