diff --git a/playbooks/override_ee.yaml b/playbooks/override_ee.yaml new file mode 100644 index 000000000..455024595 --- /dev/null +++ b/playbooks/override_ee.yaml @@ -0,0 +1,24 @@ +--- +# RHPDS virtualenvs -> EE automatic creation +- name: Override EE with default_execution_environment if not defined + vars: + ansible_control_plane: >- + {{ vars.catalog_item_params.__meta__.ansible_control_plane.type | default('tower') }} + + execution_environment: >- + {{ vars.catalog_item_params.__meta__.deployer.execution_environment | default({}) }} + + default_execution_environment: + image: image-registry.apps-dev.open.redhat.com/agnosticd/ee-{{ vars.catalog_item_params.__meta__.deployer.virtualenv | default('ansible2.9-python3.6-2021-11-30') }} + private: true + + to_merge: + __meta__: + deployer: + execution_environment: "{{ default_execution_environment }}" + when: >- + ansible_control_plane == 'controller' + and execution_environment | default('', true) == '' + + set_fact: + catalog_item_params: "{{ vars.catalog_item_params | combine(to_merge, recursive=True) }}" diff --git a/playbooks/service-destroy.yaml b/playbooks/service-destroy.yaml index b8a94d701..378fe6ded 100644 --- a/playbooks/service-destroy.yaml +++ b/playbooks/service-destroy.yaml @@ -10,6 +10,9 @@ catalog_stage: CHANGE ME dev|test|prod catalog_item_params_file: CHANGEME kubeconfig: CHANGEME + babylon_tower_secret: >- + {{ vars.catalog_item_params.__meta__.ansible_control_plane.secret + | default('babylon-tower') }} # After that don't touch catalog_item_name: "{{ account | replace('_', '-') }}.{{ catalog_item | lower | regex_replace('_', '-') }}.{{ catalog_stage }}" @@ -20,6 +23,8 @@ file: "{{ catalog_item_params_file }}" name: catalog_item_params + - include_tasks: override_ee.yaml + - name: Show catalog_item_params debug: var: catalog_item_params @@ -223,11 +228,11 @@ api_version: v1 kind: Secret namespace: "{{ anarchy_namespace }}" - name: babylon-tower + name: "{{ babylon_tower_secret }}" register: r_babylon_tower_secret - fail: - msg: "babylon-tower secret not found" + msg: "{{ babylon_tower_secret }} secret not found" when: r_babylon_tower_secret.resources | length == 0 - set_fact: diff --git a/playbooks/service-lifecycle.yaml b/playbooks/service-lifecycle.yaml index 9b1839e4d..6e9f9763f 100644 --- a/playbooks/service-lifecycle.yaml +++ b/playbooks/service-lifecycle.yaml @@ -15,6 +15,10 @@ # After that don't touch catalog_item_name: "{{ account | replace('_', '-') }}.{{ catalog_item | lower | regex_replace('_', '-') }}.{{ catalog_stage }}" + babylon_tower_secret: >- + {{ vars.catalog_item_params.__meta__.ansible_control_plane.secret + | default('babylon-tower') }} + tasks: - name: Git minimal facts ansible.builtin.setup: @@ -39,6 +43,8 @@ file: "{{ catalog_item_params_file }}" name: catalog_item_params + - include_tasks: override_ee.yaml + - name: Show catalog_item_params debug: var: catalog_item_params @@ -196,7 +202,7 @@ api_version: v1 kind: Secret namespace: "{{ anarchy_namespace }}" - name: babylon-tower + name: "{{ babylon_tower_secret }}" register: r_babylon_tower_secret failed_when: >- r_babylon_tower_secret.resources | length != 1 diff --git a/playbooks/service-provision.yaml b/playbooks/service-provision.yaml index ec5d0cb1f..e891f438e 100644 --- a/playbooks/service-provision.yaml +++ b/playbooks/service-provision.yaml @@ -12,6 +12,9 @@ kubeconfig: CHANGEME platform: CHANGEME cloudforms_username: CHANGEME + babylon_tower_secret: >- + {{ vars.catalog_item_params.__meta__.ansible_control_plane.secret + | default('babylon-tower') }} # After that don't touch user_namespace: user-{{ cloudforms_username | replace('_', '-') | replace('.', '-') }} @@ -28,6 +31,8 @@ file: "{{ catalog_item_params_file }}" name: catalog_item_params + - include_tasks: override_ee.yaml + - name: Show catalog_item_params debug: var: vars.catalog_item_params @@ -408,12 +413,12 @@ api_version: v1 kind: Secret namespace: "{{ anarchy_namespace }}" - name: babylon-tower + name: "{{ babylon_tower_secret }}" register: r_babylon_tower_secret - name: Fail if babylon-tower secret not found fail: - msg: "babylon-tower secret not found" + msg: "{{ babylon_tower_secret }} secret not found" when: r_babylon_tower_secret.resources | length == 0 - name: Create output_dir/secrets diff --git a/playbooks/service-status.yaml b/playbooks/service-status.yaml index 2e2819eed..345944140 100644 --- a/playbooks/service-status.yaml +++ b/playbooks/service-status.yaml @@ -14,6 +14,10 @@ # After that don't touch catalog_item_name: "{{ account | replace('_', '-') }}.{{ catalog_item | lower | regex_replace('_', '-') }}.{{ catalog_stage }}" + babylon_tower_secret: >- + {{ vars.catalog_item_params.__meta__.ansible_control_plane.secret + | default('babylon-tower') }} + tasks: - name: Get minimal ansible_facts ansible.builtin.gather_facts: @@ -24,6 +28,8 @@ file: "{{ catalog_item_params_file }}" name: catalog_item_params + - include_tasks: override_ee.yaml + - name: Show catalog_item_params debug: var: catalog_item_params @@ -188,7 +194,7 @@ api_version: v1 kind: Secret namespace: "{{ anarchy_namespace }}" - name: babylon-tower + name: "{{ babylon_tower_secret }}" register: r_babylon_tower_secret failed_when: >- r_babylon_tower_secret.resources | length != 1