systemd_units.yml 5.6 KB

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