config.yml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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. - name: Pull release image
  84. command: "podman pull --tls-verify={{ openshift_node_tls_verify }} --authfile {{ temp_dir.path }}/pull-secret.json {{ l_release_image }}"
  85. - name: Get machine controller daemon image from release image
  86. command: "podman run --rm {{ l_release_image }} image machine-config-operator"
  87. register: release_image_mcd
  88. - block:
  89. - name: Pull MCD image
  90. command: "podman pull --tls-verify={{ openshift_node_tls_verify }} --authfile {{ temp_dir.path }}/pull-secret.json {{ release_image_mcd.stdout }}"
  91. - name: Apply ignition manifest
  92. command: "podman run {{ podman_mounts }} {{ podman_flags }} {{ mcd_command }}"
  93. vars:
  94. podman_flags: "--privileged --rm --entrypoint=/usr/bin/machine-config-daemon -ti {{ release_image_mcd.stdout }}"
  95. podman_mounts: "-v /:/rootfs -v /var/run/dbus:/var/run/dbus -v /run/systemd:/run/systemd"
  96. mcd_command: "start --node-name {{ ansible_nodename | lower }} --once-from {{ temp_dir.path }}/bootstrap.ign --skip-reboot"
  97. - name: Remove temp directory
  98. file:
  99. path: "{{ temp_dir.path }}"
  100. state: absent
  101. - name: Reboot the host and wait for it to come back
  102. reboot:
  103. # reboot_timeout: 600 # default, 10 minutes
  104. rescue:
  105. - fail:
  106. msg: "Ignition apply failed"
  107. - name: Wait for nodes to report ready
  108. command: >
  109. oc get node {{ hostvars[item].ansible_nodename | lower }}
  110. --config={{ openshift_node_kubeconfig_path }}
  111. --output=jsonpath='{.status.conditions[?(@.type=="Ready")].status}'
  112. loop: "{{ ansible_play_batch }}"
  113. delegate_to: localhost
  114. run_once: true
  115. register: oc_get
  116. until:
  117. - oc_get.stdout == "True"
  118. retries: 36
  119. delay: 5