clean_image.yml 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. ---
  2. - name: Reboot instance
  3. hosts: localhost
  4. connection: local
  5. gather_facts: no
  6. tasks:
  7. # After installing certain packages rebooting the instance is a must before all
  8. # changes (e.g. new Selinux rules) get properly applied and propagated.
  9. # Must be done before the cloud-init is cleaned.
  10. # Otherwise, the cloud-init will be run again.
  11. - name: Reboot instance
  12. import_role:
  13. name: openshift_aws
  14. tasks_from: reboot_instance.yml
  15. when: openshift_node_reboot_instance_before_cleanup | default(false)
  16. - name: Configure nodes
  17. hosts: oo_nodes_to_config
  18. tasks:
  19. - name: Remove any ansible facts created during AMI creation
  20. file:
  21. path: "/etc/ansible/facts.d/{{ item }}"
  22. state: absent
  23. with_items:
  24. - openshift.fact
  25. - name: Clean cloud-init path
  26. file:
  27. state: absent
  28. path: "/var/lib/cloud/"
  29. - when: openshift_aws_ami_set_gquota_on_slash | default(false)
  30. block:
  31. - name: fetch uuid of root vol
  32. command: blkid /dev/xvda2 -s UUID -o value
  33. register: rootvoluuid
  34. - name: ensure gquota option for root vol in /etc/fstab
  35. lineinfile:
  36. line: "UUID={{ rootvoluuid.stdout }} / xfs defaults,gquota 0 0"
  37. path: /etc/fstab
  38. regexp: "^UUID={{ rootvoluuid.stdout }}"
  39. state: present
  40. - name: set rootvol flags in grub conf
  41. lineinfile:
  42. line: 'GRUB_CMDLINE_LINUX="console=ttyS0,115200n8 console=tty0 net.ifnames=0 crashkernel=auto rootflags=gquota"'
  43. path: /etc/default/grub
  44. regexp: 'GRUB_CMDLINE_LINUX="console=ttyS0,115200n8 console=tty0 net.ifnames=0 crashkernel=auto"'
  45. state: present
  46. register: etcdefaultgrub
  47. - name: recreate grub2 config
  48. command: grub2-mkconfig -o /boot/grub2/grub.cfg
  49. when: etcdefaultgrub.changed