systemd_units.yml 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. ---
  2. # systemd_units.yml is included both in the openshift_master role and in the upgrade
  3. # playbooks.
  4. - include: upgrade_facts.yml
  5. when: openshift_master_defaults_in_use is not defined
  6. - name: Set HA Service Info for containerized installs
  7. set_fact:
  8. containerized_svc_dir: "/etc/systemd/system"
  9. ha_svc_template_path: "docker-cluster"
  10. when:
  11. - openshift.common.is_containerized | bool
  12. - include: registry_auth.yml
  13. - name: Disable the legacy master service if it exists
  14. systemd:
  15. name: "{{ openshift.common.service_type }}-master"
  16. state: stopped
  17. enabled: no
  18. masked: yes
  19. ignore_errors: true
  20. - name: Remove the legacy master service if it exists
  21. file:
  22. path: "{{ containerized_svc_dir }}/{{ openshift.common.service_type }}-master.service"
  23. state: absent
  24. ignore_errors: true
  25. when:
  26. - openshift.master.cluster_method == "native"
  27. - not openshift.common.is_master_system_container | bool
  28. # This is the image used for both HA and non-HA clusters:
  29. - name: Pre-pull master image
  30. command: >
  31. docker pull {{ openshift.master.master_image }}:{{ openshift_image_tag }}
  32. register: l_pull_result
  33. changed_when: "'Downloaded newer image' in l_pull_result.stdout"
  34. when:
  35. - openshift.common.is_containerized | bool
  36. - not openshift.common.is_master_system_container | bool
  37. - name: Create the ha systemd unit files
  38. template:
  39. src: "{{ ha_svc_template_path }}/atomic-openshift-master-{{ item }}.service.j2"
  40. dest: "{{ containerized_svc_dir }}/{{ openshift.common.service_type }}-master-{{ item }}.service"
  41. when:
  42. - openshift.master.cluster_method == "native"
  43. - not openshift.common.is_master_system_container | bool
  44. with_items:
  45. - api
  46. - controllers
  47. register: l_create_ha_unit_files
  48. - command: systemctl daemon-reload
  49. when:
  50. - l_create_ha_unit_files | changed
  51. # end workaround for missing systemd unit files
  52. - name: enable master services
  53. systemd:
  54. name: "{{ openshift.common.service_type }}-master-{{ item }}"
  55. enabled: yes
  56. with_items:
  57. - api
  58. - controllers
  59. when:
  60. - openshift.master.cluster_method == "native"
  61. - not openshift.common.is_master_system_container | bool
  62. - name: Preserve Master API Proxy Config options
  63. command: grep PROXY /etc/sysconfig/{{ openshift.common.service_type }}-master-api
  64. register: l_master_api_proxy
  65. when:
  66. - openshift.master.cluster_method == "native"
  67. failed_when: false
  68. changed_when: false
  69. - name: Preserve Master API AWS options
  70. command: grep AWS_ /etc/sysconfig/{{ openshift.common.service_type }}-master-api
  71. register: master_api_aws
  72. when:
  73. - openshift.master.cluster_method == "native"
  74. failed_when: false
  75. changed_when: false
  76. - name: Create the master api service env file
  77. template:
  78. src: "{{ ha_svc_template_path }}/atomic-openshift-master-api.j2"
  79. dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-api
  80. backup: true
  81. when:
  82. - openshift.master.cluster_method == "native"
  83. notify:
  84. - restart master api
  85. - name: Restore Master API Proxy Config Options
  86. when:
  87. - openshift.master.cluster_method == "native"
  88. - l_master_api_proxy.rc == 0
  89. - "'http_proxy' not in openshift.common"
  90. - "'https_proxy' not in openshift.common"
  91. lineinfile:
  92. dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-api
  93. line: "{{ item }}"
  94. with_items: "{{ l_master_api_proxy.stdout_lines | default([]) }}"
  95. - name: Restore Master API AWS Options
  96. when:
  97. - openshift.master.cluster_method == "native"
  98. - master_api_aws.rc == 0
  99. - 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)
  100. lineinfile:
  101. dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-api
  102. line: "{{ item }}"
  103. with_items: "{{ master_api_aws.stdout_lines | default([]) }}"
  104. no_log: True
  105. - name: Preserve Master Controllers Proxy Config options
  106. command: grep PROXY /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
  107. register: master_controllers_proxy
  108. when:
  109. - openshift.master.cluster_method == "native"
  110. failed_when: false
  111. changed_when: false
  112. - name: Preserve Master Controllers AWS options
  113. command: grep AWS_ /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
  114. register: master_controllers_aws
  115. when:
  116. - openshift.master.cluster_method == "native"
  117. failed_when: false
  118. changed_when: false
  119. - name: Create the master controllers service env file
  120. template:
  121. src: "{{ ha_svc_template_path }}/atomic-openshift-master-controllers.j2"
  122. dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
  123. backup: true
  124. when:
  125. - openshift.master.cluster_method == "native"
  126. notify:
  127. - restart master controllers
  128. - name: Restore Master Controllers Proxy Config Options
  129. lineinfile:
  130. dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
  131. line: "{{ item }}"
  132. with_items: "{{ master_controllers_proxy.stdout_lines | default([]) }}"
  133. when:
  134. - openshift.master.cluster_method == "native"
  135. - master_controllers_proxy.rc == 0
  136. - "'http_proxy' not in openshift.common"
  137. - "'https_proxy' not in openshift.common"
  138. - name: Restore Master Controllers AWS Options
  139. lineinfile:
  140. dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
  141. line: "{{ item }}"
  142. with_items: "{{ master_controllers_aws.stdout_lines | default([]) }}"
  143. when:
  144. - openshift.master.cluster_method == "native"
  145. - master_controllers_aws.rc == 0
  146. - 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)