summaryrefslogtreecommitdiffstats
path: root/roles/openshift_manage_node/tasks/main.yml
blob: af22a1a035d34c1f4988e01b5140c58d9ae18384 (plain)
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
---
# Necessary because when you're on a node that's also a master the master will be
# restarted after the node restarts docker and it will take up to 60 seconds for
# systemd to start the master again
- name: Wait for master API to become available before proceeding
  # Using curl here since the uri module requires python-httplib2 and
  # wait_for port doesn't provide health information.
  command: >
    curl --silent --tlsv1.2
    --cacert {{ openshift.common.config_base }}/master/ca-bundle.crt
    {{ openshift_node_master_api_url }}/healthz/ready
  args:
    # Disables the following warning:
    # Consider using get_url or uri module rather than running curl
    warn: no
  register: api_available_output
  until: api_available_output.stdout == 'ok'
  retries: 120
  delay: 1
  changed_when: false
  when: openshift.common.is_containerized | bool
  delegate_to: "{{ openshift_master_host }}"
  run_once: true

- name: Wait for Node Registration
  oc_obj:
    name: "{{ openshift.node.nodename }}"
    kind: node
    state: list
  register: get_node
  until: "'metadata' in get_node.results.results[0]"
  retries: 50
  delay: 5
  when: "'nodename' in openshift.node"
  delegate_to: "{{ openshift_master_host }}"

- name: Set node schedulability
  oc_adm_manage_node:
    node: "{{ openshift.node.nodename | lower }}"
    schedulable: "{{ 'true' if l_openshift_manage_schedulable | bool else 'false' }}"
  retries: 10
  delay: 5
  register: node_schedulable
  until: node_schedulable is succeeded
  when: "'nodename' in openshift.node"
  delegate_to: "{{ openshift_master_host }}"

- name: Label nodes
  oc_label:
    name: "{{ openshift.node.nodename }}"
    kind: node
    state: add
    labels: "{{ openshift_node_labels | oo_dict_to_list_of_dict }}"
    namespace: default
  when:
    - "'nodename' in openshift.node"
    - openshift_node_labels | default({}) != {}
  delegate_to: "{{ openshift_master_host }}"