systemd_units.yml 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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:
  14. - openshift.common.is_containerized | bool
  15. # This is the image used for both HA and non-HA clusters:
  16. - name: Pre-pull master image
  17. command: >
  18. docker pull {{ openshift.master.master_image }}:{{ openshift_image_tag }}
  19. register: l_pull_result
  20. changed_when: "'Downloaded newer image' in l_pull_result.stdout"
  21. when:
  22. - openshift.common.is_containerized | bool
  23. - not openshift.common.is_master_system_container | bool
  24. - name: Create the ha systemd unit files
  25. template:
  26. src: "{{ ha_svc_template_path }}/atomic-openshift-master-{{ item }}.service.j2"
  27. dest: "{{ containerized_svc_dir }}/{{ openshift.common.service_type }}-master-{{ item }}.service"
  28. when:
  29. - openshift.master.cluster_method == "native"
  30. - not openshift.common.is_master_system_container | bool
  31. with_items:
  32. - api
  33. - controllers
  34. register: l_create_ha_unit_files
  35. - command: systemctl daemon-reload
  36. when:
  37. - l_create_ha_unit_files | changed
  38. # end workaround for missing systemd unit files
  39. - name: Preserve Master API Proxy Config options
  40. command: grep PROXY /etc/sysconfig/{{ openshift.common.service_type }}-master-api
  41. register: l_master_api_proxy
  42. when:
  43. - openshift.master.cluster_method == "native"
  44. failed_when: false
  45. changed_when: false
  46. - name: Preserve Master API AWS options
  47. command: grep AWS_ /etc/sysconfig/{{ openshift.common.service_type }}-master-api
  48. register: master_api_aws
  49. when:
  50. - openshift.master.cluster_method == "native"
  51. failed_when: false
  52. changed_when: false
  53. - name: Create the master api service env file
  54. template:
  55. src: "{{ ha_svc_template_path }}/atomic-openshift-master-api.j2"
  56. dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-api
  57. backup: true
  58. when:
  59. - openshift.master.cluster_method == "native"
  60. notify:
  61. - restart master api
  62. - name: Restore Master API Proxy Config Options
  63. when:
  64. - openshift.master.cluster_method == "native"
  65. - l_master_api_proxy.rc == 0
  66. - "'http_proxy' not in openshift.common"
  67. - "'https_proxy' not in openshift.common"
  68. lineinfile:
  69. dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-api
  70. line: "{{ item }}"
  71. with_items: "{{ l_master_api_proxy.stdout_lines | default([]) }}"
  72. - name: Restore Master API AWS Options
  73. when:
  74. - openshift.master.cluster_method == "native"
  75. - master_api_aws.rc == 0
  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. no_log: True
  82. - name: Preserve Master Controllers Proxy Config options
  83. command: grep PROXY /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
  84. register: master_controllers_proxy
  85. when:
  86. - openshift.master.cluster_method == "native"
  87. failed_when: false
  88. changed_when: false
  89. - name: Preserve Master Controllers AWS options
  90. command: grep AWS_ /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
  91. register: master_controllers_aws
  92. when:
  93. - openshift.master.cluster_method == "native"
  94. failed_when: false
  95. changed_when: false
  96. - name: Create the master controllers service env file
  97. template:
  98. src: "{{ ha_svc_template_path }}/atomic-openshift-master-controllers.j2"
  99. dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
  100. backup: true
  101. when:
  102. - openshift.master.cluster_method == "native"
  103. notify:
  104. - restart master controllers
  105. - name: Restore Master Controllers Proxy Config Options
  106. lineinfile:
  107. dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
  108. line: "{{ item }}"
  109. with_items: "{{ master_controllers_proxy.stdout_lines | default([]) }}"
  110. when:
  111. - openshift.master.cluster_method == "native"
  112. - master_controllers_proxy.rc == 0
  113. - "'http_proxy' not in openshift.common"
  114. - "'https_proxy' not in openshift.common"
  115. - name: Restore Master Controllers AWS Options
  116. lineinfile:
  117. dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
  118. line: "{{ item }}"
  119. with_items: "{{ master_controllers_aws.stdout_lines | default([]) }}"
  120. when:
  121. - openshift.master.cluster_method == "native"
  122. - master_controllers_aws.rc == 0
  123. - 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)