diff options
author | Bartek Grzybowski <b.grzybowski@partner.samsung.com> | 2021-12-14 14:24:30 +0100 |
---|---|---|
committer | Bartek Grzybowski <b.grzybowski@partner.samsung.com> | 2021-12-15 09:26:47 +0000 |
commit | 4401de0520d291a851d9d78ee867b26cbfcfed84 (patch) | |
tree | 579a746bc07ea675fb3a7050461e041ce2c8eedf /ansible/roles/application | |
parent | fe3e1035137f0666716655b55add40ed461479b2 (diff) |
[ANSIBLE] Fix 'application' role idempotency checks
Change-Id: I9ae95664d30afabc7fd3ba1ea11e466c004f5089
Issue-ID: OOM-2238
Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
Diffstat (limited to 'ansible/roles/application')
8 files changed, 11 insertions, 60 deletions
diff --git a/ansible/roles/application/molecule/custom_role/molecule.yml b/ansible/roles/application/molecule/custom_role/molecule.yml index fed1b121..689e9f69 100644 --- a/ansible/roles/application/molecule/custom_role/molecule.yml +++ b/ansible/roles/application/molecule/custom_role/molecule.yml @@ -37,18 +37,5 @@ provisioner: prepare: ../default/prepare.yml converge: ../default/converge.yml cleanup: ../default/cleanup.yml -scenario: - test_sequence: - - lint - - cleanup - - destroy - - dependency - - syntax - - create - - prepare - - converge - - verify - - cleanup - - destroy verifier: name: testinfra diff --git a/ansible/roles/application/molecule/default/molecule.yml b/ansible/roles/application/molecule/default/molecule.yml index 8b2817b4..fab92fcc 100644 --- a/ansible/roles/application/molecule/default/molecule.yml +++ b/ansible/roles/application/molecule/default/molecule.yml @@ -31,27 +31,5 @@ provisioner: - onap app_helm_chart_name: "{{ app_name }}" helm_version: v3 -scenario: - test_sequence: - - lint - - cleanup - - destroy - - dependency - - syntax - - create - - prepare - - converge - # - idempotence - # --> Action: 'idempotence' - # ERROR: Idempotence test failed because of the following tasks: - # * [instance] => application : Get helm dir - # * [instance] => application : Helm init and upgrade - # * [instance] => application : Helm Serve - # * [instance] => application : Helm Add Repo - # * [instance] => application : Helm Install application moleculetestapp - - side_effect - - verify - - cleanup - - destroy verifier: name: testinfra diff --git a/ansible/roles/application/molecule/default/tests/test_default.py b/ansible/roles/application/molecule/default/tests/test_default.py index 18dc0318..ccef6e09 100644 --- a/ansible/roles/application/molecule/default/tests/test_default.py +++ b/ansible/roles/application/molecule/default/tests/test_default.py @@ -14,6 +14,13 @@ repo add local http://127.0.0.1:8879 deploy moleculetestapp local/moleculetestapp --namespace \ moleculetestapp -f /opt/moleculetestapp/helm_charts/onap/resources/\ overrides/onap-all.yaml -f /opt/moleculetestapp/override.yaml \ +--timeout 1800s +env +repo list +repo add local http://127.0.0.1:8879 +deploy moleculetestapp local/moleculetestapp --namespace \ +moleculetestapp -f /opt/moleculetestapp/helm_charts/onap/resources/\ +overrides/onap-all.yaml -f /opt/moleculetestapp/override.yaml \ --timeout 1800s""" expected_plugin_path = '/root/.local/share/helm/plugins/deploy/' +\ 'deploy.sh' diff --git a/ansible/roles/application/molecule/ubuntu/molecule.yml b/ansible/roles/application/molecule/ubuntu/molecule.yml index e785f846..0ee73e15 100644 --- a/ansible/roles/application/molecule/ubuntu/molecule.yml +++ b/ansible/roles/application/molecule/ubuntu/molecule.yml @@ -35,28 +35,6 @@ provisioner: prepare: ../default/prepare.yml converge: ../default/converge.yml cleanup: ../default/cleanup.yml -scenario: - test_sequence: - - lint - - cleanup - - destroy - - dependency - - syntax - - create - - prepare - - converge - # - idempotence - # --> Action: 'idempotence' - # ERROR: Idempotence test failed because of the following tasks: - # * [instance] => application : Get helm dir - # * [instance] => application : Helm init and upgrade - # * [instance] => application : Helm Serve - # * [instance] => application : Helm Add Repo - # * [instance] => application : Helm Install application moleculetestapp - - side_effect - - verify - - cleanup - - destroy verifier: name: testinfra directory: ../default/tests/ diff --git a/ansible/roles/application/tasks/install-helm-plugins.yml b/ansible/roles/application/tasks/install-helm-plugins.yml index 5d933ed2..9410d4dc 100644 --- a/ansible/roles/application/tasks/install-helm-plugins.yml +++ b/ansible/roles/application/tasks/install-helm-plugins.yml @@ -4,6 +4,7 @@ - name: Get helm environment information command: "{{ helm_bin_dir }}/helm env" register: helm_env + changed_when: false - name: Set helm data dir set_fact: helm_data_dir: diff --git a/ansible/roles/application/tasks/install.yml b/ansible/roles/application/tasks/install.yml index 6cd22d05..02728966 100644 --- a/ansible/roles/application/tasks/install.yml +++ b/ansible/roles/application/tasks/install.yml @@ -48,6 +48,6 @@ --namespace {{ app_kubernetes_namespace }} {{ helm_override_files | map('regex_replace', '^', '-f ') | join(' ') }} {{ helm_extra_install_options | map(attribute='opt') | join(' ') }} - changed_when: true # when executed its a changed type of action + changed_when: false # for idempotency register: helm_install failed_when: "'FAILED' in (helm_install.stdout | upper()) or helm_install.rc != 0" diff --git a/ansible/roles/application/tasks/setup-helm.yml b/ansible/roles/application/tasks/setup-helm.yml index 4b50ec1c..5e36547d 100644 --- a/ansible/roles/application/tasks/setup-helm.yml +++ b/ansible/roles/application/tasks/setup-helm.yml @@ -10,7 +10,7 @@ - name: Helm Add Repo command: "{{ helm_bin_dir }}/helm repo add {{ helm_repository_name | mandatory }} {{ helm_repository_url | mandatory }}" when: "'local' not in helm_repo_list.stdout" - changed_when: true # when executed its a changed type of action + changed_when: false # for idempotency - name: Check for deploy plugin presence stat: diff --git a/ansible/roles/application/tasks/transfer-helm-charts.yml b/ansible/roles/application/tasks/transfer-helm-charts.yml index 9b36cffe..15072dce 100644 --- a/ansible/roles/application/tasks/transfer-helm-charts.yml +++ b/ansible/roles/application/tasks/transfer-helm-charts.yml @@ -8,7 +8,6 @@ warn: false tags: - skip_ansible_lint # Prevent '[303] tar used in place of unarchive module' - changed_when: false # for idempotency delegate_to: localhost - name: Create helm charts dir on infra file: @@ -19,5 +18,6 @@ unarchive: src: "{{ app_helm_charts_install_directory }}.tgz" dest: "{{ app_helm_charts_infra_directory }}" + tags: molecule-idempotence-notest - include_tasks: install-helm-plugins.yml |