config.yml 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 in lib_utils that comments out swap entries in
  5. # /etc/fstab and runs swapoff -a, if necessary.
  6. - name: Disable swap
  7. swapoff: {}
  8. when: openshift_disable_swap | default(true) | bool
  9. # The atomic-openshift-node service will set this parameter on
  10. # startup, but if the network service is restarted this setting is
  11. # lost. Reference: https://bugzilla.redhat.com/show_bug.cgi?id=1372388
  12. - sysctl:
  13. name: net.ipv4.ip_forward
  14. value: 1
  15. sysctl_file: "/etc/sysctl.d/99-openshift.conf"
  16. reload: yes
  17. - name: Setting sebool container_manage_cgroup
  18. seboolean:
  19. name: container_manage_cgroup
  20. state: yes
  21. persistent: yes
  22. - name: create temp directory
  23. tempfile:
  24. state: directory
  25. register: tempfile
  26. - name: Copy pull secret in the directory
  27. copy:
  28. src: "{{ pull_secret }}"
  29. dest: "{{ tempfile.path }}/pull-secret.json"
  30. - name: Pull release image
  31. command: "podman pull --tls-verify={{ tls_verify }} --authfile {{ tempfile.path }}/pull-secret.json {{ openshift_release_image }}"
  32. - name: Get machine controller daemon image from release image
  33. command: "podman run --rm {{ openshift_release_image }} image machine-config-daemon"
  34. register: release_image_mcd
  35. - name: Copy bootstrap ignition file locally
  36. copy:
  37. src: "{{ openshift_ignition_file_path }}"
  38. dest: "{{ ign_file }}"
  39. when: openshift_ignition_file_path is defined
  40. - name: Fetch bootstrap ignition file locally
  41. uri:
  42. url: "{{ openshift_bootstrap_endpoint }}"
  43. dest: "{{ ign_file }}"
  44. validate_certs: false
  45. when: openshift_bootstrap_endpoint is defined
  46. - block:
  47. - name: Pull MCD image
  48. command: "podman pull --tls-verify={{ tls_verify }} --authfile {{ tempfile.path }}/pull-secret.json {{ release_image_mcd.stdout }}"
  49. - name: Apply ignition manifest
  50. command: "podman run {{ podman_mounts }} {{ podman_flags }} {{ mcd_command }}"
  51. vars:
  52. podman_flags: "--privileged --rm -ti {{ release_image_mcd.stdout }}"
  53. podman_mounts: "-v /:/rootfs -v /var/run/dbus:/var/run/dbus -v /run/systemd:/run/systemd"
  54. mcd_command: "start --node-name {{ ansible_hostname }} --once-from {{ ign_file }}"
  55. # MCD reboots the machine, run the task but do not wait for completion
  56. register: manifest_apply
  57. async: 900 # 15 minutes
  58. poll: 0
  59. # Wait for the host to come back
  60. - wait_for_connection: {}
  61. # If the job fails, the async job status will find rc != 1 and will fail here
  62. # When the job is successful, Ansible does not update this job status due to
  63. # the host rebooting
  64. - name: Check manifest apply status
  65. async_status:
  66. jid: "{{ manifest_apply.ansible_job_id }}"
  67. rescue:
  68. - fail:
  69. msg: "Ignition apply failed"