diff options
Diffstat (limited to 'playbooks/docker.yaml')
| -rw-r--r-- | playbooks/docker.yaml | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/playbooks/docker.yaml b/playbooks/docker.yaml new file mode 100644 index 0000000..9ac5499 --- /dev/null +++ b/playbooks/docker.yaml @@ -0,0 +1,88 @@ +--- +- name: "Install docker" + hosts: target + tasks: + - name: "Install kernel extras" + apt: + pkg: "{{ item }}" + state: present + with_items: + - "linux-image-extra-{{ ansible_kernel }}" + - linux-image-extra-virtual + - apt-transport-https + - ca-certificates + - software-properties-common + when: ansible_distribution == "Ubuntu" + + - name: "Install docker apt key" + shell: curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - + when: ansible_distribution == "Ubuntu" + + - name: "Configure docker.list" + copy: + src: "../files/{{ item }}" + dest: "/etc/apt/sources.list.d/{{ item }}" + mode: 0644 + owner: root + group: root + with_items: + - docker.list + when: ansible_distribution == "Ubuntu" + + - name: "Update apt" + apt: + update_cache: yes + when: ansible_distribution == "Ubuntu" + + - name: "Install docker packages" + apt: + pkg: "{{ item }}" + state: present + with_items: + - docker-ce + when: ansible_distribution == "Ubuntu" + + - name: "Install required packages" + yum: + name: "{{ item }}" + state: present + with_items: + - yum-utils + - device-mapper-persistent-data + - lvm2 + when: ansible_distribution == "RedHat" or ansible_distribution == "CentOS" + + - name: "Add docker repository" + shell: yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo + when: ansible_distribution == "RedHat" or ansible_distribution == "CentOS" + + - name: "Update yum cache" + yum: + update_cache: yes + when: ansible_distribution == "RedHat" or ansible_distribution == "CentOS" + + - name: "Install required packages" + yum: + name: "{{ item }}" + state: present + with_items: + - docker-ce + when: ansible_distribution == "RedHat" or ansible_distribution == "CentOS" + + - name: "Install docker" + portage: + package: "{{ item }}" + update: yes + changed_use: yes + with_items: + - app-emulation/docker + when: ansible_distribution == "Gentoo" + + - name: "Enable docker" + service: + name: "{{ item.name }}" + enabled: yes + state: started + runlevel: "{{ item.runlevel }}" + with_items: + - { name: docker, runlevel: default } |
