systemd_units.yml 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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. - command: systemctl daemon-reload
  31. when: create_master_unit_file | changed
  32. - name: Create the ha systemd unit files
  33. template:
  34. src: "{{ ha_svc_template_path }}/atomic-openshift-master-{{ item }}.service.j2"
  35. dest: "{{ containerized_svc_dir }}/{{ openshift.common.service_type }}-master-{{ item }}.service"
  36. when:
  37. - openshift.master.ha is defined and openshift.master.ha | bool and openshift_master_cluster_method == "native"
  38. - not openshift.common.is_master_system_container | bool
  39. with_items:
  40. - api
  41. - controllers
  42. register: create_ha_unit_files
  43. - command: systemctl daemon-reload
  44. when: create_ha_unit_files | changed
  45. # end workaround for missing systemd unit files
  46. - name: Preserve Master API Proxy Config options
  47. command: grep PROXY /etc/sysconfig/{{ openshift.common.service_type }}-master-api
  48. register: master_api_proxy
  49. when: openshift.master.ha is defined and openshift.master.ha | bool and openshift_master_cluster_method == "native"
  50. failed_when: false
  51. changed_when: false
  52. - name: Preserve Master API AWS options
  53. command: grep AWS_ /etc/sysconfig/{{ openshift.common.service_type }}-master-api
  54. register: master_api_aws
  55. when: openshift.master.ha is defined and openshift.master.ha | bool and openshift_master_cluster_method == "native"
  56. failed_when: false
  57. changed_when: false
  58. - name: Create the master api service env file
  59. template:
  60. src: "{{ ha_svc_template_path }}/atomic-openshift-master-api.j2"
  61. dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-api
  62. backup: true
  63. when: openshift.master.ha is defined and openshift.master.ha | bool and openshift_master_cluster_method == "native"
  64. notify:
  65. - restart master api
  66. - name: Restore Master API Proxy Config Options
  67. when: openshift.master.ha is defined and openshift.master.ha | bool and openshift_master_cluster_method == "native"
  68. and master_api_proxy.rc == 0 and 'http_proxy' not in openshift.common and 'https_proxy' not in openshift.common
  69. lineinfile:
  70. dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-api
  71. line: "{{ item }}"
  72. with_items: "{{ master_api_proxy.stdout_lines | default([]) }}"
  73. - name: Restore Master API AWS Options
  74. when: openshift.master.ha is defined and openshift.master.ha | bool and openshift_master_cluster_method == "native"
  75. and master_api_aws.rc == 0 and
  76. 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)
  77. lineinfile:
  78. dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-api
  79. line: "{{ item }}"
  80. with_items: "{{ master_api_aws.stdout_lines | default([]) }}"
  81. - name: Preserve Master Controllers Proxy Config options
  82. command: grep PROXY /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
  83. register: master_controllers_proxy
  84. when: openshift.master.ha is defined and openshift.master.ha | bool and openshift_master_cluster_method == "native"
  85. failed_when: false
  86. changed_when: false
  87. - name: Preserve Master Controllers AWS options
  88. command: grep AWS_ /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
  89. register: master_controllers_aws
  90. when: openshift.master.ha is defined and openshift.master.ha | bool and openshift_master_cluster_method == "native"
  91. failed_when: false
  92. changed_when: false
  93. - name: Create the master controllers service env file
  94. template:
  95. src: "{{ ha_svc_template_path }}/atomic-openshift-master-controllers.j2"
  96. dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
  97. backup: true
  98. when: openshift.master.ha is defined and openshift.master.ha | bool and openshift_master_cluster_method == "native"
  99. notify:
  100. - restart master controllers
  101. - name: Restore Master Controllers Proxy Config Options
  102. lineinfile:
  103. dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
  104. line: "{{ item }}"
  105. with_items: "{{ master_controllers_proxy.stdout_lines | default([]) }}"
  106. when: openshift.master.ha is defined and openshift.master.ha | bool and openshift_master_cluster_method == "native"
  107. and master_controllers_proxy.rc == 0 and 'http_proxy' not in openshift.common and 'https_proxy' not in openshift.common
  108. - name: Restore Master Controllers AWS Options
  109. lineinfile:
  110. dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
  111. line: "{{ item }}"
  112. with_items: "{{ master_controllers_aws.stdout_lines | default([]) }}"
  113. when: openshift.master.ha is defined and openshift.master.ha | bool and openshift_master_cluster_method == "native"
  114. and master_controllers_aws.rc == 0 and
  115. 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)
  116. - name: Install Master docker service file
  117. template:
  118. dest: "/etc/systemd/system/{{ openshift.common.service_type }}-master.service"
  119. src: master_docker/master.docker.service.j2
  120. register: install_result
  121. 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
  122. - name: Preserve Master Proxy Config options
  123. command: grep PROXY /etc/sysconfig/{{ openshift.common.service_type }}-master
  124. register: master_proxy_result
  125. failed_when: false
  126. changed_when: false
  127. - set_fact:
  128. master_proxy: "{{ master_proxy_result.stdout_lines | default([]) }}"
  129. - name: Preserve Master AWS options
  130. command: grep AWS_ /etc/sysconfig/{{ openshift.common.service_type }}-master
  131. register: master_aws_result
  132. failed_when: false
  133. changed_when: false
  134. - set_fact:
  135. master_aws: "{{ master_aws_result.stdout_lines | default([]) }}"
  136. - name: Create the master service env file
  137. template:
  138. src: "atomic-openshift-master.j2"
  139. dest: /etc/sysconfig/{{ openshift.common.service_type }}-master
  140. backup: true
  141. notify:
  142. - restart master