systemd_units.yml 7.6 KB

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