Matrix Docker Ansible eploy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

88 lines
2.1 KiB

  1. ---
  2. - name: Ensure Docker repository is enabled (CentOS)
  3. template:
  4. src: "{{ role_path }}/files/yum.repos.d/{{ item }}"
  5. dest: "/etc/yum.repos.d/{{ item }}"
  6. owner: "root"
  7. group: "root"
  8. mode: 0644
  9. with_items:
  10. - docker-ce.repo
  11. when: ansible_distribution == 'CentOS'
  12. - name: Ensure Docker's RPM key is trusted
  13. rpm_key:
  14. state: present
  15. key: https://download.docker.com/linux/centos/gpg
  16. when: ansible_distribution == 'CentOS'
  17. - name: Ensure yum packages are installed (CentOS)
  18. yum:
  19. name:
  20. - bash-completion
  21. - docker-ce
  22. - docker-python
  23. - firewalld
  24. - ntp
  25. - fuse
  26. state: latest
  27. update_cache: yes
  28. when: ansible_distribution == 'CentOS'
  29. - name: Ensure APT usage dependencies are installed (Debian)
  30. apt:
  31. name:
  32. - apt-transport-https
  33. - ca-certificates
  34. state: present
  35. update_cache: yes
  36. when: ansible_os_family == 'Debian'
  37. - name: Ensure Docker's APT key is trusted (Debian)
  38. apt_key:
  39. url: https://download.docker.com/linux/ubuntu/gpg
  40. id: 9DC858229FC7DD38854AE2D88D81803C0EBFCD88
  41. state: present
  42. register: add_repository_key
  43. ignore_errors: true
  44. when: ansible_os_family == 'Debian'
  45. - name: Ensure Docker repository is enabled (Debian)
  46. apt_repository:
  47. repo: "deb https://download.docker.com/linux/{{ ansible_distribution|lower }} {{ ansible_distribution_release }} stable"
  48. state: present
  49. update_cache: yes
  50. when: ansible_os_family == 'Debian'
  51. - name: Ensure APT packages are installed (Debian)
  52. apt:
  53. name:
  54. - bash-completion
  55. - docker-ce
  56. - python-docker
  57. - ntp
  58. - fuse
  59. state: latest
  60. update_cache: yes
  61. when: ansible_os_family == 'Debian'
  62. - name: Ensure firewalld is started and autoruns
  63. service:
  64. name: firewalld
  65. state: started
  66. enabled: yes
  67. when: ansible_os_family == 'RedHat'
  68. - name: Ensure Docker is started and autoruns
  69. service:
  70. name: docker
  71. state: started
  72. enabled: yes
  73. - name: Ensure ntpd is started and autoruns
  74. service:
  75. name: "{{ 'ntpd' if ansible_os_family == 'RedHat' else 'ntp' }}"
  76. state: started
  77. enabled: yes