systemd_units.yml 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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'
  10. when: openshift_master_config_dir is not defined
  11. - name: Remove the legacy master service if it exists
  12. include: clean_systemd_units.yml
  13. - name: Init HA Service Info
  14. set_fact:
  15. containerized_svc_dir: "/usr/lib/systemd/system"
  16. ha_svc_template_path: "native-cluster"
  17. - name: Set HA Service Info for containerized installs
  18. set_fact:
  19. containerized_svc_dir: "/etc/systemd/system"
  20. ha_svc_template_path: "docker-cluster"
  21. when:
  22. - openshift.common.is_containerized | bool
  23. # This is the image used for both HA and non-HA clusters:
  24. - name: Pre-pull master image
  25. command: >
  26. docker pull {{ openshift.master.master_image }}:{{ openshift_image_tag }}
  27. register: l_pull_result
  28. changed_when: "'Downloaded newer image' in l_pull_result.stdout"
  29. when:
  30. - openshift.common.is_containerized | bool
  31. - not openshift.common.is_master_system_container | bool
  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.cluster_method == "native"
  38. - not openshift.common.is_master_system_container | bool
  39. with_items:
  40. - api
  41. - controllers
  42. register: l_create_ha_unit_files
  43. - command: systemctl daemon-reload
  44. when:
  45. - l_create_ha_unit_files | changed
  46. # end workaround for missing systemd unit files
  47. - name: Preserve Master API Proxy Config options
  48. command: grep PROXY /etc/sysconfig/{{ openshift.common.service_type }}-master-api
  49. register: l_master_api_proxy
  50. when:
  51. - openshift.master.cluster_method == "native"
  52. failed_when: false
  53. changed_when: false
  54. - name: Preserve Master API AWS options
  55. command: grep AWS_ /etc/sysconfig/{{ openshift.common.service_type }}-master-api
  56. register: master_api_aws
  57. when:
  58. - openshift.master.cluster_method == "native"
  59. failed_when: false
  60. changed_when: false
  61. - name: Create the master api service env file
  62. template:
  63. src: "{{ ha_svc_template_path }}/atomic-openshift-master-api.j2"
  64. dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-api
  65. backup: true
  66. when:
  67. - openshift.master.cluster_method == "native"
  68. notify:
  69. - restart master api
  70. - name: Restore Master API Proxy Config Options
  71. when:
  72. - openshift.master.cluster_method == "native"
  73. - l_master_api_proxy.rc == 0
  74. - "'http_proxy' not in openshift.common"
  75. - "'https_proxy' not in openshift.common"
  76. lineinfile:
  77. dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-api
  78. line: "{{ item }}"
  79. with_items: "{{ l_master_api_proxy.stdout_lines | default([]) }}"
  80. - name: Restore Master API AWS Options
  81. when:
  82. - openshift.master.cluster_method == "native"
  83. - master_api_aws.rc == 0
  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:
  94. - openshift.master.cluster_method == "native"
  95. failed_when: false
  96. changed_when: false
  97. - name: Preserve Master Controllers AWS options
  98. command: grep AWS_ /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
  99. register: master_controllers_aws
  100. when:
  101. - openshift.master.cluster_method == "native"
  102. failed_when: false
  103. changed_when: false
  104. - name: Create the master controllers service env file
  105. template:
  106. src: "{{ ha_svc_template_path }}/atomic-openshift-master-controllers.j2"
  107. dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
  108. backup: true
  109. when:
  110. - openshift.master.cluster_method == "native"
  111. notify:
  112. - restart master controllers
  113. - name: Restore Master Controllers Proxy Config Options
  114. lineinfile:
  115. dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
  116. line: "{{ item }}"
  117. with_items: "{{ master_controllers_proxy.stdout_lines | default([]) }}"
  118. when:
  119. - openshift.master.cluster_method == "native"
  120. - master_controllers_proxy.rc == 0
  121. - "'http_proxy' not in openshift.common"
  122. - "'https_proxy' not in openshift.common"
  123. - name: Restore Master Controllers AWS Options
  124. lineinfile:
  125. dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
  126. line: "{{ item }}"
  127. with_items: "{{ master_controllers_aws.stdout_lines | default([]) }}"
  128. when:
  129. - openshift.master.cluster_method == "native"
  130. - master_controllers_aws.rc == 0
  131. - 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)