config.yml 3.4 KB

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