Wolfgang Kulhanek
2020-03-13 ef0cb9e58d9bd87bd1ff33f2cbfed8478ed342ec
commit | author | age
100690 1 ---
GC 2 - name: Deploy workload(s) role on bastion of the shared cluster
3   hosts: ocp_bastions
4   become: false
5   gather_facts: false
6   tags:
039e80 7   - step005
100690 8   tasks:
039e80 9   - name: Set up combined ocp_workloads dictionary
WK 10     set_fact:
11       ocp_workloads: >-
12         {{ ocp_workloads_defaults
13         | combine(ocp_workloads_input  | default( {} ),
14                   ocp_workloads_secret | default( {} ), recursive=true)
15         }}
16   - name: Print combined role variables
17     debug:
18       var: ocp_workloads
19       verbosity: 2
100690 20
039e80 21   # This is a potential future enhancement... For now just check if one is there
WK 22   # and use it when it's there
23   # - name: Ensure virtualenv exists if it should be used
24   #   when: ocp_workloads.use_virtualenv | bool
25   #   block:
26   #   - name: Check if desired virtualenv is available on the host
27   #     stat:
28   #       path: "{{ ocp_workloads.virtualenv_path}}/bin/python"
29   #     register: r_virtualenv
100690 30
039e80 31   #   - name: Install Virtualenv if it doesn't exist yet
WK 32   #     when:
33   #     - not r_virtualenv.exists
34   #     - ocp_workloads.install_virtualenv | bool
35   #     block:
36   #     - name: Ensure Virtualenv package is installed
37   #       package:
38   #         state: present
39   #         name: "{{ ocp_workloads.virtualenv_package }}"
40   #     - name: Set up Virtualenv
41   #       pip:
42   #         state: present
43   #         name: "{{ ocp_workloads.python_packages }}"
44   #         virtualenv: "{{ ocp_workloads.virtualenv_path }}"
45   #         virtualenv_python: "{{ ocp_workloads.virtualenv_python }}"
46
47   - name: Check if desired virtualenv is available on the host
48     stat:
49       path: "{{ ocp_workloads.virtualenv_path}}/bin/python"
50     register: r_virtualenv
51   - name: Set Ansible Python interpreter to virtualenv
5a5e50 52     when: r_virtualenv.stat.exists
039e80 53     set_fact:
WK 54       ansible_python_interpreter: "{{ ocp_workloads.virtualenv_path }}/bin/python"
55
56   - name: Run a single workload
57     when: ocp_workload is defined
58     include_role:
59       name: "{{ ocp_workload }}"
60     vars:
61       ACTION: create
62
63   - name: Run a list of workloads
64     when:
65     - ocp_workloads is defined
66     - ocp_workloads | length > 0
ef0cb9 67     loop: "{{ ocp_workloads }}"
WK 68     loop_control:
69       loop_var: _ocp_workload
039e80 70     include_role:
WK 71       name: "{{ _ocp_workload }}"
72     vars:
73       ACTION: create
74
75 - name: Cleanup
76   import_playbook: cleanup.yml