build_docker.yml 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. ---
  2. - hosts: docker_hosts
  3. become: true
  4. tasks:
  5. - name: Install required system packages
  6. apt:
  7. name: "{{item}}"
  8. state: present
  9. update_cache: yes
  10. loop:
  11. - apt-transport-https
  12. - ca-certificates
  13. - curl
  14. - gnupg-agent
  15. - software-properties-common
  16. - name: Add Docker GPG apt Key
  17. apt_key:
  18. url: https://download.docker.com/linux/ubuntu/gpg
  19. state: present
  20. - name: Add Docker Repository
  21. apt_repository:
  22. repo: deb https://download.docker.com/linux/ubuntu focal stable
  23. state: present
  24. - name: installa docker
  25. apt:
  26. name: "{{item}}"
  27. state: latest
  28. update_cache: yes
  29. loop:
  30. - docker-ce
  31. - docker-ce-cli
  32. - containerd.io
  33. - docker-compose-plugin
  34. - name: Creates directory
  35. file:
  36. path: /etc/systemd/system/docker.service.d
  37. state: directory
  38. # - name: copy config files
  39. - name: copying files
  40. copy:
  41. src: nebula-v2/remote-api.conf
  42. dest: /etc/systemd/system/docker.service.d/remote-api.conf
  43. - name: Allow TCP 4243
  44. ansible.builtin.iptables:
  45. action: insert
  46. chain: INPUT
  47. protocol: tcp
  48. match: tcp
  49. destination_port: 4243
  50. jump: ACCEPT
  51. - name: assicurati che docker sia attivo
  52. service:
  53. name: docker
  54. state: started
  55. enabled: yes