systemd_units.yml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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: Preserve Master API Proxy Config options
  53. command: grep PROXY /etc/sysconfig/{{ openshift.common.service_type }}-master-api
  54. register: l_master_api_proxy
  55. when:
  56. - openshift.master.cluster_method == "native"
  57. failed_when: false
  58. changed_when: false
  59. - name: Preserve Master API AWS options
  60. command: grep AWS_ /etc/sysconfig/{{ openshift.common.service_type }}-master-api
  61. register: master_api_aws
  62. when:
  63. - 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:
  72. - openshift.master.cluster_method == "native"
  73. notify:
  74. - restart master api
  75. - name: Restore Master API Proxy Config Options
  76. when:
  77. - openshift.master.cluster_method == "native"
  78. - l_master_api_proxy.rc == 0
  79. - "'http_proxy' not in openshift.common"
  80. - "'https_proxy' not in openshift.common"
  81. lineinfile:
  82. dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-api
  83. line: "{{ item }}"
  84. with_items: "{{ l_master_api_proxy.stdout_lines | default([]) }}"
  85. - name: Restore Master API AWS Options
  86. when:
  87. - openshift.master.cluster_method == "native"
  88. - master_api_aws.rc == 0
  89. - 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)
  90. lineinfile:
  91. dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-api
  92. line: "{{ item }}"
  93. with_items: "{{ master_api_aws.stdout_lines | default([]) }}"
  94. no_log: True
  95. - name: Preserve Master Controllers Proxy Config options
  96. command: grep PROXY /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
  97. register: master_controllers_proxy
  98. when:
  99. - openshift.master.cluster_method == "native"
  100. failed_when: false
  101. changed_when: false
  102. - name: Preserve Master Controllers AWS options
  103. command: grep AWS_ /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
  104. register: master_controllers_aws
  105. when:
  106. - openshift.master.cluster_method == "native"
  107. failed_when: false
  108. changed_when: false
  109. - name: Create the master controllers service env file
  110. template:
  111. src: "{{ ha_svc_template_path }}/atomic-openshift-master-controllers.j2"
  112. dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
  113. backup: true
  114. when:
  115. - openshift.master.cluster_method == "native"
  116. notify:
  117. - restart master controllers
  118. - name: Restore Master Controllers Proxy Config Options
  119. lineinfile:
  120. dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
  121. line: "{{ item }}"
  122. with_items: "{{ master_controllers_proxy.stdout_lines | default([]) }}"
  123. when:
  124. - openshift.master.cluster_method == "native"
  125. - master_controllers_proxy.rc == 0
  126. - "'http_proxy' not in openshift.common"
  127. - "'https_proxy' not in openshift.common"
  128. - name: Restore Master Controllers AWS Options
  129. lineinfile:
  130. dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
  131. line: "{{ item }}"
  132. with_items: "{{ master_controllers_aws.stdout_lines | default([]) }}"
  133. when:
  134. - openshift.master.cluster_method == "native"
  135. - master_controllers_aws.rc == 0
  136. - 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)