config.yml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. ---
  2. #### Disable SWAP #####
  3. # https://docs.openshift.com/container-platform/3.4/admin_guide/overcommit.html#disabling-swap-memory
  4. # swapoff is a custom module that comments out swap entries in
  5. # /etc/fstab and runs swapoff -a, if necessary.
  6. - name: Disable swap
  7. swapoff: {}
  8. # The atomic-openshift-node service will set this parameter on
  9. # startup, but if the network service is restarted this setting is
  10. # lost. Reference: https://bugzilla.redhat.com/show_bug.cgi?id=1372388
  11. - name: Enable IP Forwarding
  12. sysctl:
  13. name: net.ipv4.ip_forward
  14. value: 1
  15. sysctl_file: "/etc/sysctl.d/99-openshift.conf"
  16. reload: yes
  17. # The base OS RHEL with "Minimal" installation option is
  18. # enabled firewalld serivce by default, it denies unexpected 10250 port.
  19. # Reference: https://bugzilla.redhat.com/show_bug.cgi?id=1740439
  20. - name: Disable firewalld service
  21. systemd:
  22. name: "firewalld.service"
  23. enabled: false
  24. register: service_status
  25. failed_when:
  26. - service_status is failed
  27. - not ('Could not find the requested service' in service_status.msg)
  28. - name: Setting sebool container_manage_cgroup
  29. seboolean:
  30. name: container_manage_cgroup
  31. state: yes
  32. persistent: yes
  33. - name: Create temp directory
  34. tempfile:
  35. state: directory
  36. register: temp_dir
  37. - name: Wait for bootstrap endpoint to show up
  38. uri:
  39. url: "{{ openshift_node_bootstrap_endpoint }}"
  40. validate_certs: false
  41. delay: 10
  42. retries: 60
  43. register: result
  44. until:
  45. - result.status is defined
  46. - result.status == 200
  47. - name: Fetch bootstrap ignition file locally
  48. uri:
  49. url: "{{ openshift_node_bootstrap_endpoint }}"
  50. dest: "{{ temp_dir.path }}/bootstrap.ign"
  51. validate_certs: false
  52. - name: Get cluster pull-secret
  53. command: >
  54. oc get secret pull-secret
  55. --config={{ openshift_node_kubeconfig_path }}
  56. --namespace=openshift-config
  57. --output=jsonpath='{.data.\.dockerconfigjson}'
  58. delegate_to: localhost
  59. register: oc_get
  60. until:
  61. - oc_get.stdout != ''
  62. retries: 36
  63. delay: 5
  64. - name: Write pull-secret to file
  65. copy:
  66. content: "{{ oc_get.stdout | b64decode }}"
  67. dest: "{{ temp_dir.path }}/pull-secret.json"
  68. - name: Get cluster release image
  69. command: >
  70. oc get clusterversion
  71. --config={{ openshift_node_kubeconfig_path }}
  72. --output=jsonpath='{.items[0].status.desired.image}'
  73. delegate_to: localhost
  74. register: oc_get
  75. until:
  76. - oc_get.stdout is defined
  77. - oc_get.stdout != ''
  78. retries: 36
  79. delay: 5
  80. - name: Set l_release_image fact
  81. set_fact:
  82. l_release_image: "{{ oc_get.stdout }}"
  83. - import_tasks: proxy.yml
  84. - block:
  85. - name: Pull release image
  86. command: "podman pull --tls-verify={{ openshift_node_tls_verify }} --authfile {{ temp_dir.path }}/pull-secret.json {{ l_release_image }}"
  87. - name: Get machine controller daemon image from release image
  88. command: "podman run --rm {{ l_release_image }} image machine-config-operator"
  89. register: release_image_mcd
  90. environment:
  91. http_proxy: "{{ http_proxy | default('')}}"
  92. https_proxy: "{{https_proxy | default('')}}"
  93. no_proxy: "{{ no_proxy | default('')}}"
  94. - block:
  95. - name: Pull MCD image
  96. command: "podman pull --tls-verify={{ openshift_node_tls_verify }} --authfile {{ temp_dir.path }}/pull-secret.json {{ release_image_mcd.stdout }}"
  97. - name: Apply ignition manifest
  98. command: "podman run {{ podman_mounts }} {{ podman_flags }} {{ mcd_command }}"
  99. vars:
  100. podman_flags: "--privileged --rm --entrypoint=/usr/bin/machine-config-daemon -ti {{ release_image_mcd.stdout }}"
  101. podman_mounts: "-v /:/rootfs -v /var/run/dbus:/var/run/dbus -v /run/systemd:/run/systemd"
  102. mcd_command: "start --node-name {{ ansible_nodename | lower }} --once-from {{ temp_dir.path }}/bootstrap.ign --skip-reboot"
  103. - name: Remove temp directory
  104. file:
  105. path: "{{ temp_dir.path }}"
  106. state: absent
  107. - name: Reboot the host and wait for it to come back
  108. reboot:
  109. # reboot_timeout: 600 # default, 10 minutes
  110. environment:
  111. http_proxy: "{{ http_proxy | default('')}}"
  112. https_proxy: "{{ https_proxy | default('')}}"
  113. no_proxy: "{{ no_proxy | default('')}}"
  114. rescue:
  115. - fail:
  116. msg: "Ignition apply failed"
  117. - name: Wait for nodes to report ready
  118. command: >
  119. oc get node {{ hostvars[item].ansible_nodename | lower }}
  120. --config={{ openshift_node_kubeconfig_path }}
  121. --output=jsonpath='{.status.conditions[?(@.type=="Ready")].status}'
  122. loop: "{{ ansible_play_batch }}"
  123. delegate_to: localhost
  124. run_once: true
  125. register: oc_get
  126. until:
  127. - oc_get.stdout == "True"
  128. retries: 36
  129. delay: 5