systemd_units.yml 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. ---
  2. # input variables
  3. # - openshift.node.node_image
  4. # - openshift_image_tag
  5. # - openshift.common.is_containerized
  6. # - openshift.node.ovs_image
  7. # - openshift.common.use_openshift_sdn
  8. # - openshift.common.service_type
  9. # - openshift.node.debug_level
  10. # - openshift.common.config_base
  11. # - openshift.common.http_proxy
  12. # - openshift.common.portal_net
  13. # - openshift.common
  14. # - openshift.common.http_proxy
  15. # notify:
  16. # - restart openvswitch
  17. # - restart node
  18. # This file is included both in the openshift_master role and in the upgrade
  19. # playbooks.
  20. - name: Pre-pull node image
  21. command: >
  22. docker pull {{ openshift.node.node_image }}:{{ openshift_image_tag }}
  23. register: pull_result
  24. changed_when: "'Downloaded newer image' in pull_result.stdout"
  25. when: openshift.common.is_containerized | bool
  26. - name: Pre-pull openvswitch image
  27. command: >
  28. docker pull {{ openshift.node.ovs_image }}:{{ openshift_image_tag }}
  29. register: pull_result
  30. changed_when: "'Downloaded newer image' in pull_result.stdout"
  31. when: openshift.common.is_containerized | bool and openshift.common.use_openshift_sdn | bool
  32. - name: Install Node dependencies docker service file
  33. template:
  34. dest: "/etc/systemd/system/{{ openshift.common.service_type }}-node-dep.service"
  35. src: openshift.docker.node.dep.service
  36. register: install_node_dep_result
  37. when: openshift.common.is_containerized | bool
  38. - name: Install Node docker service file
  39. template:
  40. dest: "/etc/systemd/system/{{ openshift.common.service_type }}-node.service"
  41. src: openshift.docker.node.service
  42. register: install_node_result
  43. when: openshift.common.is_containerized | bool
  44. - name: Create the openvswitch service env file
  45. template:
  46. src: openvswitch.sysconfig.j2
  47. dest: /etc/sysconfig/openvswitch
  48. when: openshift.common.is_containerized | bool
  49. register: install_ovs_sysconfig
  50. notify:
  51. - restart openvswitch
  52. # May be a temporary workaround.
  53. # https://bugzilla.redhat.com/show_bug.cgi?id=1331590
  54. - name: Create OpenvSwitch service.d directory
  55. file: path=/etc/systemd/system/openvswitch.service.d/ state=directory
  56. when: openshift.common.use_openshift_sdn | default(true) | bool
  57. - name: Install OpenvSwitch service OOM fix
  58. template:
  59. dest: "/etc/systemd/system/openvswitch.service.d/01-avoid-oom.conf"
  60. src: openvswitch-avoid-oom.conf
  61. when: openshift.common.use_openshift_sdn | default(true) | bool
  62. register: install_oom_fix_result
  63. notify:
  64. - restart openvswitch
  65. - name: Install OpenvSwitch docker service file
  66. template:
  67. dest: "/etc/systemd/system/openvswitch.service"
  68. src: openvswitch.docker.service
  69. when: openshift.common.is_containerized | bool and openshift.common.use_openshift_sdn | default(true) | bool
  70. notify:
  71. - restart openvswitch
  72. - name: Configure Node settings
  73. lineinfile:
  74. dest: /etc/sysconfig/{{ openshift.common.service_type }}-node
  75. regexp: "{{ item.regex }}"
  76. line: "{{ item.line }}"
  77. create: true
  78. with_items:
  79. - regex: '^OPTIONS='
  80. line: "OPTIONS=--loglevel={{ openshift.node.debug_level | default(2) }}"
  81. - regex: '^CONFIG_FILE='
  82. line: "CONFIG_FILE={{ openshift.common.config_base }}/node/node-config.yaml"
  83. - regex: '^IMAGE_VERSION='
  84. line: "IMAGE_VERSION={{ openshift_image_tag }}"
  85. notify:
  86. - restart node
  87. - name: Configure Proxy Settings
  88. lineinfile:
  89. dest: /etc/sysconfig/{{ openshift.common.service_type }}-node
  90. regexp: "{{ item.regex }}"
  91. line: "{{ item.line }}"
  92. create: true
  93. with_items:
  94. - regex: '^HTTP_PROXY='
  95. line: "HTTP_PROXY={{ openshift.common.http_proxy | default('') }}"
  96. - regex: '^HTTPS_PROXY='
  97. line: "HTTPS_PROXY={{ openshift.common.https_proxy | default('') }}"
  98. - regex: '^NO_PROXY='
  99. line: "NO_PROXY={{ openshift.common.no_proxy | default([]) }},{{ openshift.common.portal_net }},{{ hostvars[groups.oo_first_master.0].openshift.master.sdn_cluster_network_cidr }}"
  100. when: ('http_proxy' in openshift.common and openshift.common.http_proxy != '')
  101. notify:
  102. - restart node
  103. - name: Reload systemd units
  104. command: systemctl daemon-reload
  105. when: (openshift.common.is_containerized | bool and (install_node_result | changed or install_ovs_sysconfig | changed or install_node_dep_result | changed)) or install_oom_fix_result | changed
  106. notify:
  107. - restart node