[ANSIBLE] Fix 'application' role idempotency checks 27/126227/1
authorBartek Grzybowski <b.grzybowski@partner.samsung.com>
Tue, 14 Dec 2021 13:24:30 +0000 (14:24 +0100)
committerBartek Grzybowski <b.grzybowski@partner.samsung.com>
Tue, 14 Dec 2021 13:42:47 +0000 (14:42 +0100)
Change-Id: I9ae95664d30afabc7fd3ba1ea11e466c004f5089
Issue-ID: OOM-2238
Signed-off-by: Bartek Grzybowski <b.grzybowski@partner.samsung.com>
ansible/roles/application/molecule/custom_role/molecule.yml
ansible/roles/application/molecule/default/molecule.yml
ansible/roles/application/molecule/default/tests/test_default.py
ansible/roles/application/molecule/ubuntu/molecule.yml
ansible/roles/application/tasks/install-helm-plugins.yml
ansible/roles/application/tasks/install.yml
ansible/roles/application/tasks/setup-helm.yml
ansible/roles/application/tasks/transfer-helm-charts.yml

index fed1b12..689e9f6 100644 (file)
@@ -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
index 8b2817b..fab92fc 100644 (file)
@@ -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
index 18dc031..ccef6e0 100644 (file)
@@ -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'
index e785f84..0ee73e1 100644 (file)
@@ -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/
index 5d933ed..9410d4d 100644 (file)
@@ -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:
index 6cd22d0..0272896 100644 (file)
@@ -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"
index 4b50ec1..5e36547 100644 (file)
@@ -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:
index 9b36cff..15072dc 100644 (file)
@@ -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