main.yml 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. ---
  2. - name: Ensure docker is installed
  3. action: "{{ ansible_pkg_mgr }} name={{ item }} state=present"
  4. with_items:
  5. - docker
  6. # Docker doesn't seem to start cleanly the first time run
  7. # when loopback (not directlvm) is configured. Putting in an
  8. # ignore errors, and then sleeping till it can come up cleanly
  9. - name: Try to start docker. This might fail (loopback startup issue)
  10. service:
  11. name: docker
  12. state: started
  13. ignore_errors: yes
  14. - name: Pause for 1 minute
  15. pause:
  16. seconds: 30
  17. - name: Ensure docker is started
  18. service:
  19. name: docker
  20. state: started
  21. - name: Determine if loopback
  22. shell: docker info | grep 'Data file:.*loop'
  23. register: loop_device_check
  24. ignore_errors: yes
  25. - debug:
  26. var: loop_device_check
  27. - name: fail if we don't detect loopback
  28. fail:
  29. msg: loopback not detected! Please investigate manually.
  30. when: loop_device_check.rc == 1
  31. - name: "check to see if {{ dss_docker_device }} exists"
  32. command: "test -e {{ dss_docker_device }}"
  33. register: docker_dev_check
  34. ignore_errors: yes
  35. - debug: var=docker_dev_check
  36. - name: "fail if {{ dss_docker_device }} doesn't exist"
  37. fail:
  38. msg: "{{ dss_docker_device }} doesn't exist. Please investigate"
  39. when: docker_dev_check.rc != 0
  40. - name: stop docker
  41. service:
  42. name: docker
  43. state: stopped
  44. - name: delete /var/lib/docker
  45. command: rm -rf /var/lib/docker
  46. - name: remove /var/lib/docker
  47. command: rm -rf /var/lib/docker
  48. - name: copy the docker-storage-setup config file
  49. copy:
  50. content: >
  51. DEVS={{ dss_docker_device }}\n
  52. VG=docker_vg
  53. dest: /etc/sysconfig/docker-storage-setup
  54. owner: root
  55. group: root
  56. mode: 0664
  57. - name: docker storage setup
  58. command: docker-storage-setup
  59. register: docker_storage_setup_output
  60. - debug:
  61. msg: "{{ docker_storage_setup_output }}"
  62. - name: extend the vg
  63. command: lvextend -l 90%VG /dev/docker_vg/docker-pool
  64. register: lvextend_output
  65. - debug:
  66. msg: "{{ lvextend_output }}"
  67. - name: start docker
  68. service:
  69. name: docker
  70. state: restarted
  71. - name: docker info
  72. command: docker info
  73. register: dockerinfo
  74. - debug:
  75. msg: "{{ dockerinfo }}"