--- - name: Deploy workload(s) role on bastion of the shared cluster hosts: ocp_bastions become: false gather_facts: false tags: - step005 tasks: - name: Set up combined ocp_workloads dictionary set_fact: ocp_workloads: >- {{ ocp_workloads_defaults | combine(ocp_workloads_input | default( {} ), ocp_workloads_secret | default( {} ), recursive=true) }} - name: Print combined role variables debug: var: ocp_workloads verbosity: 2 # This is a potential future enhancement... For now just check if one is there # and use it when it's there # - name: Ensure virtualenv exists if it should be used # when: ocp_workloads.use_virtualenv | bool # block: # - name: Check if desired virtualenv is available on the host # stat: # path: "{{ ocp_workloads.virtualenv_path}}/bin/python" # register: r_virtualenv # - name: Install Virtualenv if it doesn't exist yet # when: # - not r_virtualenv.exists # - ocp_workloads.install_virtualenv | bool # block: # - name: Ensure Virtualenv package is installed # package: # state: present # name: "{{ ocp_workloads.virtualenv_package }}" # - name: Set up Virtualenv # pip: # state: present # name: "{{ ocp_workloads.python_packages }}" # virtualenv: "{{ ocp_workloads.virtualenv_path }}" # virtualenv_python: "{{ ocp_workloads.virtualenv_python }}" - name: Check if desired virtualenv is available on the host stat: path: "{{ ocp_workloads.virtualenv_path}}/bin/python" register: r_virtualenv - name: Set Ansible Python interpreter to virtualenv when: r_virtualenv.stat.exists set_fact: ansible_python_interpreter: "{{ ocp_workloads.virtualenv_path }}/bin/python" - name: Run a single workload when: ocp_workload is defined include_role: name: "{{ ocp_workload }}" vars: ACTION: create - name: Run a list of workloads when: - ocp_workloads is defined - ocp_workloads | length > 0 loop: "{{ ocp_workloads }}" loop_control: loop_var: _ocp_workload include_role: name: "{{ _ocp_workload }}" vars: ACTION: create - name: Cleanup import_playbook: cleanup.yml