Wolfgang Kulhanek
2020-03-13 5a5e5026c18b0e4d199a9f8450dcb37bffc70617
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
---
- 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
    include_role:
      name: "{{ _ocp_workload }}"
    vars:
      ACTION: create
    loop: "{{ ocp_workloads }}"
    loop_control:
      loop_var: _ocp_workload
 
- name: Cleanup
  import_playbook: cleanup.yml