systemd_units.yml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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. - name: Create the ha systemd unit files
  22. template:
  23. src: "{{ ha_svc_template_path }}/atomic-openshift-master-{{ item }}.service.j2"
  24. dest: "{{ containerized_svc_dir }}/{{ openshift.common.service_type }}-master-{{ item }}.service"
  25. when:
  26. - openshift.master.cluster_method == "native"
  27. - not openshift.common.is_master_system_container | bool
  28. with_items:
  29. - api
  30. - controllers
  31. register: create_ha_unit_files
  32. - command: systemctl daemon-reload
  33. when: create_ha_unit_files | changed
  34. # end workaround for missing systemd unit files
  35. - name: Preserve Master API Proxy Config options
  36. command: grep PROXY /etc/sysconfig/{{ openshift.common.service_type }}-master-api
  37. register: master_api_proxy
  38. when: openshift.master.cluster_method == "native"
  39. failed_when: false
  40. changed_when: false
  41. - name: Preserve Master API AWS options
  42. command: grep AWS_ /etc/sysconfig/{{ openshift.common.service_type }}-master-api
  43. register: master_api_aws
  44. when: openshift.master.cluster_method == "native"
  45. failed_when: false
  46. changed_when: false
  47. - name: Create the master api service env file
  48. template:
  49. src: "{{ ha_svc_template_path }}/atomic-openshift-master-api.j2"
  50. dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-api
  51. backup: true
  52. when: openshift.master.cluster_method == "native"
  53. notify:
  54. - restart master api
  55. - name: Restore Master API Proxy Config Options
  56. when: openshift.master.cluster_method == "native"
  57. and master_api_proxy.rc == 0 and 'http_proxy' not in openshift.common and 'https_proxy' not in openshift.common
  58. lineinfile:
  59. dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-api
  60. line: "{{ item }}"
  61. with_items: "{{ master_api_proxy.stdout_lines | default([]) }}"
  62. - name: Restore Master API AWS Options
  63. when: bool and openshift.master.cluster_method == "native"
  64. and master_api_aws.rc == 0 and
  65. 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)
  66. lineinfile:
  67. dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-api
  68. line: "{{ item }}"
  69. with_items: "{{ master_api_aws.stdout_lines | default([]) }}"
  70. no_log: True
  71. - name: Preserve Master Controllers Proxy Config options
  72. command: grep PROXY /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
  73. register: master_controllers_proxy
  74. when: openshift.master.cluster_method == "native"
  75. failed_when: false
  76. changed_when: false
  77. - name: Preserve Master Controllers AWS options
  78. command: grep AWS_ /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
  79. register: master_controllers_aws
  80. when: openshift.master.cluster_method == "native"
  81. failed_when: false
  82. changed_when: false
  83. - name: Create the master controllers service env file
  84. template:
  85. src: "{{ ha_svc_template_path }}/atomic-openshift-master-controllers.j2"
  86. dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
  87. backup: true
  88. when: openshift.master.cluster_method == "native"
  89. notify:
  90. - restart master controllers
  91. - name: Restore Master Controllers Proxy Config Options
  92. lineinfile:
  93. dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
  94. line: "{{ item }}"
  95. with_items: "{{ master_controllers_proxy.stdout_lines | default([]) }}"
  96. when: openshift.master.cluster_method == "native"
  97. and master_controllers_proxy.rc == 0 and 'http_proxy' not in openshift.common and 'https_proxy' not in openshift.common
  98. - name: Restore Master Controllers AWS Options
  99. lineinfile:
  100. dest: /etc/sysconfig/{{ openshift.common.service_type }}-master-controllers
  101. line: "{{ item }}"
  102. with_items: "{{ master_controllers_aws.stdout_lines | default([]) }}"
  103. when: openshift.master.cluster_method == "native"
  104. and master_controllers_aws.rc == 0 and
  105. 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)