Wolfgang Kulhanek
2020-03-16 99fb030c4b735e2df2b4804db38954a4aa2f002b
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
---
- name: Set up ocp4_workload_machinesets combined dictionary
  set_fact:
    ocp4_workload_machinesets: >-
      {{ ocp4_workload_machinesets_defaults
       | combine(ocp4_workload_machinesets_vars    | default( {} ),
                 ocp4_workload_machinesets_secrets | default( {} ), recursive=true )
      }}
- name: Print combined role variables
  debug:
    var: ocp4_workload_machinesets
    verbosity: 2
 
- name: Configure OpenShift 4 machinesets
  include_role:
    name: ocp4_machineset_config
  vars:
    ocp4_machineset_config_groups: "{{ ocp4_workload_machinesets.machineset_groups }}"
    ocp4_machineset_config_disable_base_worker_machinesets: "{{ ocp4_workload_machinesets.disable_default_machinesets }}"
 
- name: Wait for Nodes to be available
  k8s_facts:
    api_version: v1
    kind: Node
    label_selectors:
    - "node-role.kubernetes.io/{{ item.role }}="
  register: r_nodes
  until:
  - r_nodes.resources | length | int == item.total_replicas | int
  delay: 30
  retries: 20
  loop: "{{ ocp4_workload_machinesets.machineset_groups }}"
 
# The Machine Config Daemon and Node CA DaemonSets do not include
# Universal Tolerations. So by adding taints to Infra and other 
# nodes the Machine Config Daemon and Node CA DaemonSets
# pods would be removed from those nodes.
# This adds the necessary tolerations.
# The Product fix is curently targeted for OpenShift 4.5.
# See https://bugzilla.redhat.com/show_bug.cgi?id=1780318
- name: Fix Machine Config and Node CA Daemon Sets (add Tolerations for new nodes)
  k8s:
    state: present
    merge_type:
    - merge
    definition: "{{ lookup('template', '{{ item }}') }}"
  loop:
  - ./templates/machine-config-daemonset.j2
  - ./templates/node-ca-daemonset.j2
 
- name: Set up Infra Nodes when one MaschineSet group is called 'infra'
  when:
  - ocp4_workload_machinesets.machineset_groups | selectattr('name', 'contains', 'infra')
  block:
  - name: Configure Ingress Controllers and Image Registry
    k8s:
      state: present
      merge_type:
      - merge
      definition: "{{ lookup('template', '{{ item }}') }}"
    loop:
    - ./templates/ingress-controller.j2
    - ./templates/image-registry.j2
 
  - name: Create Config Map for Cluster Monitoring
    k8s:
      state: present
      definition: "{{ lookup('file', './files/cluster-monitoring-config.yml') }}"
 
# Leave this as the last task in the playbook.
- name: workload tasks complete
  debug:
    msg: "Workload Tasks completed successfully."
  when: not silent|bool