summaryrefslogtreecommitdiffstats
path: root/roles/openshift_master/tasks/systemd_units.yml
blob: ee76413e3576363745355147b025be625369770c (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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
---
# systemd_units.yml is included both in the openshift_master role and in the upgrade
# playbooks.

- name: Set HA Service Info for containerized installs
  set_fact:
    containerized_svc_dir: "/etc/systemd/system"
    ha_svc_template_path: "docker-cluster"
  when:
  - openshift.common.is_containerized | bool

- include_tasks: registry_auth.yml

- name: Disable the legacy master service if it exists
  systemd:
    name: "{{ openshift.common.service_type }}-master"
    state: stopped
    enabled: no
    masked: yes
  ignore_errors: true

- name: Remove the legacy master service if it exists
  file:
    path: "{{ containerized_svc_dir }}/{{ openshift.common.service_type }}-master.service"
    state: absent
  ignore_errors: true
  when:
  - not l_is_master_system_container | bool

# This is the image used for both HA and non-HA clusters:
- name: Pre-pull master image
  command: >
    docker pull {{ openshift.master.master_image }}:{{ openshift_image_tag }}
  register: l_pull_result
  changed_when: "'Downloaded newer image' in l_pull_result.stdout"
  when:
  - openshift.common.is_containerized | bool
  - not l_is_master_system_container | bool

- name: Create the ha systemd unit files
  template:
    src: "{{ ha_svc_template_path }}/atomic-openshift-master-{{ item }}.service.j2"
    dest: "{{ containerized_svc_dir }}/{{ openshift.common.service_type }}-master-{{ item }}.service"
  when:
  - not l_is_master_system_container | bool
  with_items:
  - api
  - controllers
  register: l_create_ha_unit_files

- command: systemctl daemon-reload
  when:
  - l_create_ha_unit_files | changed
# end workaround for missing systemd unit files

- name: enable master services
  systemd:
    name: "{{ openshift.common.service_type }}-master-{{ item }}"
    enabled: yes
  with_items:
  - api
  - controllers
  when:
  - not l_is_master_system_container | bool

- name: Preserve Master API Proxy Config options
  command: grep PROXY /etc/sysconfig/{{ openshift.common.service_type }}-master-api
  register: l_master_api_proxy
  failed_when: false
  changed_when: false

- name: Preserve Master API AWS options
  command: grep AWS_ /etc/sysconfig/{{ openshift.common.service_type }}-master-api
  register: master_api_aws
  failed_when: false
  changed_when: false

- name: Create the master api service env file
  template:
    src: "{{ ha_svc_template_path }}/atomic-openshift-master-api.j2"
    dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-api
    backup: true
  notify:
  - restart master api

- name: Restore Master API Proxy Config Options
  when:
  - l_master_api_proxy.rc == 0
  - "'http_proxy' not in openshift.common"
  - "'https_proxy' not in openshift.common"
  lineinfile:
    dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-api
    line: "{{ item }}"
  with_items: "{{ l_master_api_proxy.stdout_lines | default([]) }}"

- name: Restore Master API AWS Options
  when:
  - master_api_aws.rc == 0
  - not (openshift_cloudprovider_kind is defined and openshift_cloudprovider_kind == 'aws' and openshift_cloudprovider_aws_access_key is defined and openshift_cloudprovider_aws_secret_key is defined)
  lineinfile:
    dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-api
    line: "{{ item }}"
  with_items: "{{ master_api_aws.stdout_lines | default([]) }}"
  no_log: True

- name: Preserve Master Controllers Proxy Config options
  command: grep PROXY /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
  register: master_controllers_proxy
  failed_when: false
  changed_when: false

- name: Preserve Master Controllers AWS options
  command: grep AWS_ /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
  register: master_controllers_aws
  failed_when: false
  changed_when: false

- name: Create the master controllers service env file
  template:
    src: "{{ ha_svc_template_path }}/atomic-openshift-master-controllers.j2"
    dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
    backup: true
  notify:
  - restart master controllers

- name: Restore Master Controllers Proxy Config Options
  lineinfile:
    dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
    line: "{{ item }}"
  with_items: "{{ master_controllers_proxy.stdout_lines | default([]) }}"
  when:
  - master_controllers_proxy.rc == 0
  - "'http_proxy' not in openshift.common"
  - "'https_proxy' not in openshift.common"

- name: Restore Master Controllers AWS Options
  lineinfile:
    dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
    line: "{{ item }}"
  with_items: "{{ master_controllers_aws.stdout_lines | default([]) }}"
  when:
  - master_controllers_aws.rc == 0
  - not (openshift_cloudprovider_kind is defined and openshift_cloudprovider_kind == 'aws' and openshift_cloudprovider_aws_access_key is defined and openshift_cloudprovider_aws_secret_key is defined)