summaryrefslogtreecommitdiffstats
path: root/roles/openshift_node/tasks/config.yml
blob: 8210fd88181514a5371669f80d58b17e8640684f (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
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
108
109
110
111
---
- name: Install the systemd units
  include: systemd_units.yml

- name: Check for tuned package
  command: rpm -q tuned
  args:
    warn: no
  register: tuned_installed
  changed_when: false
  failed_when: false

- name: Set atomic-guest tuned profile
  command: "tuned-adm profile atomic-guest"
  when: tuned_installed.rc == 0 and openshift.common.is_atomic | bool

- name: Start and enable openvswitch service
  systemd:
    name: openvswitch.service
    enabled: yes
    state: started
    daemon_reload: yes
  when:
    - openshift.common.is_containerized | bool
    - openshift.common.use_openshift_sdn | default(true) | bool
  register: ovs_start_result
  until: not ovs_start_result | failed
  retries: 3
  delay: 30

- set_fact:
    ovs_service_status_changed: "{{ ovs_start_result | changed }}"

- file:
    dest: "{{ (openshift_node_kubelet_args|default({'config':None})).config}}"
    state: directory
  when: openshift_node_kubelet_args is defined and 'config' in openshift_node_kubelet_args

# TODO: add the validate parameter when there is a validation command to run
- name: Create the Node config
  template:
    dest: "{{ openshift.common.config_base }}/node/node-config.yaml"
    src: node.yaml.v1.j2
    backup: true
    owner: root
    group: root
    mode: 0600
  notify:
    - restart node

- name: Configure Node Environment Variables
  lineinfile:
    dest: /etc/sysconfig/{{ openshift.common.service_type }}-node
    regexp: "^{{ item.key }}="
    line: "{{ item.key }}={{ item.value }}"
    create: true
  with_dict: "{{ openshift.node.env_vars | default({}) }}"
  notify:
    - restart node

# 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
- when: openshift.common.is_containerized | bool
  block:
    - 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 }}/node/ca.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

    - name: Start and enable node dep
      systemd:
        daemon_reload: yes
        name: "{{ openshift.common.service_type }}-node-dep"
        enabled: yes
        state: started

- name: Start and enable node
  systemd:
    name: "{{ openshift.common.service_type }}-node"
    enabled: yes
    state: started
    daemon_reload: yes
  register: node_start_result
  until: not node_start_result | failed
  retries: 1
  delay: 30
  ignore_errors: true

- name: Dump logs from node service if it failed
  command: journalctl --no-pager -n 100 -u {{ openshift.common.service_type }}-node
  when: node_start_result | failed

- name: Abort if node failed to start
  fail:
    msg: Node failed to start please inspect the logs and try again
  when: node_start_result | failed

- set_fact:
    node_service_status_changed: "{{ node_start_result | changed }}"