config.yml 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. - sysctl:
  12. name: net.ipv4.ip_forward
  13. value: 1
  14. sysctl_file: "/etc/sysctl.d/99-openshift.conf"
  15. reload: yes
  16. - name: Setting sebool container_manage_cgroup
  17. seboolean:
  18. name: container_manage_cgroup
  19. state: yes
  20. persistent: yes
  21. - name: create temp directory
  22. tempfile:
  23. state: directory
  24. register: tempfile
  25. - name: Wait for bootstrap endpoint to show up
  26. uri:
  27. url: "{{ openshift_node_bootstrap_endpoint }}"
  28. validate_certs: false
  29. delay: 10
  30. retries: 60
  31. register: result
  32. until:
  33. - "'status' in result"
  34. - result.status == 200
  35. - name: Fetch bootstrap ignition file locally
  36. uri:
  37. url: "{{ openshift_node_bootstrap_endpoint }}"
  38. dest: "{{ tempfile.path }}/bootstrap.ign"
  39. validate_certs: false
  40. - name: Copy pull secret in the directory
  41. copy:
  42. src: "{{ openshift_pull_secret_path }}"
  43. dest: "{{ tempfile.path }}/pull-secret.json"
  44. - name: Get release image
  45. k8s_facts:
  46. kubeconfig: "{{ openshift_kubeconfig_path }}"
  47. kind: ClusterVersion
  48. name: version
  49. delegate_to: localhost
  50. register: clusterversion
  51. until:
  52. - clusterversion.resources is defined
  53. - clusterversion.resources | length > 0
  54. - clusterversion.resources[0].status is defined
  55. - clusterversion.resources[0].status.desired is defined
  56. - clusterversion.resources[0].status.desired.image is defined
  57. retries: 36
  58. delay: 5
  59. - name: Set openshift_release_image fact
  60. set_fact:
  61. openshift_release_image: "{{ clusterversion.resources[0].status.desired.image }}"
  62. - name: Pull release image
  63. command: "podman pull --tls-verify={{ openshift_node_tls_verify }} --authfile {{ tempfile.path }}/pull-secret.json {{ openshift_release_image }}"
  64. - name: Get machine controller daemon image from release image
  65. command: "podman run --rm {{ openshift_release_image }} image machine-config-daemon"
  66. register: release_image_mcd
  67. - block:
  68. - name: Pull MCD image
  69. command: "podman pull --tls-verify={{ openshift_node_tls_verify }} --authfile {{ tempfile.path }}/pull-secret.json {{ release_image_mcd.stdout }}"
  70. - name: Apply ignition manifest
  71. command: "podman run {{ podman_mounts }} {{ podman_flags }} {{ mcd_command }}"
  72. vars:
  73. podman_flags: "--privileged --rm -ti {{ release_image_mcd.stdout }}"
  74. podman_mounts: "-v /:/rootfs -v /var/run/dbus:/var/run/dbus -v /run/systemd:/run/systemd"
  75. mcd_command: "start --node-name {{ ansible_hostname }} --once-from {{ tempfile.path }}/bootstrap.ign"
  76. # MCD reboots the machine, run the task but do not wait for completion
  77. register: manifest_apply
  78. async: 900 # 15 minutes
  79. poll: 0
  80. # Wait for the host to come back
  81. - wait_for_connection: {}
  82. # If the job fails, the async job status will find rc != 1 and will fail here
  83. # When the job is successful, Ansible does not update this job status due to
  84. # the host rebooting
  85. - name: Check manifest apply status
  86. async_status:
  87. jid: "{{ manifest_apply.ansible_job_id }}"
  88. rescue:
  89. - fail:
  90. msg: "Ignition apply failed"