forked from redhat-cop/agnosticd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost_software.yml
107 lines (98 loc) · 3.18 KB
/
post_software.yml
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
---
- 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:
config_ocp_workloads: >-
{{ config_ocp_workloads_defaults
| combine( config_ocp_workloads_vars | default( {} ),
config_ocp_workloads_secrets | default( {} ), recursive=true)
}}
- name: Print combined role variables
debug:
var: config_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: config_ocp_workloads.use_virtualenv | bool
# block:
# - name: Check if desired virtualenv is available on the host
# stat:
# path: "{{ config_ocp_workloads.virtualenv_path}}/bin/python"
# register: r_virtualenv
# - name: Install Virtualenv if it doesn't exist yet
# when:
# - not r_virtualenv.exists
# - config_ocp_workloads.install_virtualenv | bool
# block:
# - name: Ensure Virtualenv package is installed
# package:
# state: present
# name: "{{ config_ocp_workloads.virtualenv_package }}"
# - name: Set up Virtualenv
# pip:
# state: present
# name: "{{ config_ocp_workloads.python_packages }}"
# virtualenv: "{{ config_ocp_workloads.virtualenv_path }}"
# virtualenv_python: "{{ config_ocp_workloads.virtualenv_python }}"
- name: Check if desired virtualenv is available on the host
stat:
path: "{{ config_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: "{{ config_ocp_workloads.virtualenv_path }}/bin/python"
- name: Install infra_workloads
tags:
- infra_workloads
loop: "{{ infra_workloads }}"
loop_control:
loop_var: __workload_role
include_role:
name: "{{ __workload_role }}"
vars:
ocp_username: system:admin
ACTION: provision
- 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: Install student_workloads
tags:
- student_workloads
loop: >-
{{ range(user_count_start | int, user_count_start | int + user_count | int)
| product(student_workloads)
| list
}}
loop_control:
loop_var: __user_n_workload_role
label: "{{ __workload_role }} for {{ ocp_username }}"
vars:
ACTION: provision
ocp_username: "user{{ __user_n_workload_role[0] }}"
__workload_role: "{{ __user_n_workload_role[1] }}"
include_role:
name: "{{ __workload_role }}"
- name: Cleanup
import_playbook: cleanup.yml