From 9d8e7cbc9ca6ea7809cae466a622330644ffdbd6 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Tue, 28 Jan 2020 21:32:29 +0000 Subject: [PATCH] Setup and install docker --- ansible/main.yml | 1 + ansible/roles/docker/tasks/main.yml | 5 ++++ ansible/roles/docker/tasks/setup-docker.yml | 31 +++++++++++++++++++++ ansible/roles/docker/vars/docker.yml | 3 ++ 4 files changed, 40 insertions(+) create mode 100644 ansible/roles/docker/tasks/main.yml create mode 100644 ansible/roles/docker/tasks/setup-docker.yml create mode 100644 ansible/roles/docker/vars/docker.yml diff --git a/ansible/main.yml b/ansible/main.yml index d63cc68..26c8e49 100644 --- a/ansible/main.yml +++ b/ansible/main.yml @@ -10,3 +10,4 @@ - hosts: intersect roles: - ssh + - docker diff --git a/ansible/roles/docker/tasks/main.yml b/ansible/roles/docker/tasks/main.yml new file mode 100644 index 0000000..ebd465f --- /dev/null +++ b/ansible/roles/docker/tasks/main.yml @@ -0,0 +1,5 @@ +- name: Include docker variables + include_vars: docker.yml + +- name: Install Docker + include: setup-docker.yml diff --git a/ansible/roles/docker/tasks/setup-docker.yml b/ansible/roles/docker/tasks/setup-docker.yml new file mode 100644 index 0000000..3ccb3aa --- /dev/null +++ b/ansible/roles/docker/tasks/setup-docker.yml @@ -0,0 +1,31 @@ +- name: Add an Apt signing key, uses whichever key is at the URL + apt_key: + url: https://download.docker.com/linux/ubuntu/gpg + state: present + become: true + become_user: root + +- name: Add docker repo + apt_repository: + repo: deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable + state: present + become: true + become_user: root + +- name: Install Docker and docker-compose + apt: + name: "{{ item }}" + become: true + become_user: root + loop: + - docker-ce + - docker-ce-cli + - containerd.io + - docker-compose + +- name: Create docker user + user: + name: "{{ docker_user.name }}" + uid: "{{ docker_user.id }}" + group: "{{ docker_user.name }}" + create_home: false diff --git a/ansible/roles/docker/vars/docker.yml b/ansible/roles/docker/vars/docker.yml new file mode 100644 index 0000000..1d68f11 --- /dev/null +++ b/ansible/roles/docker/vars/docker.yml @@ -0,0 +1,3 @@ +docker_user: + id: 3000 + name: dockeruser