From 85f6f599701a58fdbd8ad789bca5abcce41e31b1 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Mon, 2 Mar 2020 19:37:11 +0000 Subject: [PATCH] Use ansible galaxy to install docker --- .gitignore | 1 + ansible/ansible.cfg | 1 + ansible/main.yml | 6 ++++++ ansible/requirements.yaml | 1 + ansible/roles/docker/tasks/setup-docker.yml | 23 ++------------------- scripts/ansible/setup.sh | 4 ++++ 6 files changed, 15 insertions(+), 21 deletions(-) create mode 100644 ansible/requirements.yaml diff --git a/.gitignore b/.gitignore index aa6016e..6cceb00 100644 --- a/.gitignore +++ b/.gitignore @@ -113,6 +113,7 @@ dmypy.json # End of https://www.gitignore.io/api/python,ansible env/ ansible/.vault_pass +ansible/galaxy_roles # Created by https://www.gitignore.io/api/terraform # Edit at https://www.gitignore.io/?templates=terraform diff --git a/ansible/ansible.cfg b/ansible/ansible.cfg index d4e4c55..2dbda43 100644 --- a/ansible/ansible.cfg +++ b/ansible/ansible.cfg @@ -2,6 +2,7 @@ nocows = 1 host_key_checking = False retry_files_enabled = False +roles_path = $PWD/galaxy_roles:$PWD/roles inventory = ./hosts become_ask_pass = True diff --git a/ansible/main.yml b/ansible/main.yml index 26c8e49..3b9d78e 100644 --- a/ansible/main.yml +++ b/ansible/main.yml @@ -10,4 +10,10 @@ - hosts: intersect roles: - ssh + - role: geerlingguy.docker + become: true + vars: + docker_install_compose: false # This role installs the binary directly, which is kinda nasty + docker_users: + - "{{ user }}" - docker diff --git a/ansible/requirements.yaml b/ansible/requirements.yaml new file mode 100644 index 0000000..120ca60 --- /dev/null +++ b/ansible/requirements.yaml @@ -0,0 +1 @@ +- src: geerlingguy.docker diff --git a/ansible/roles/docker/tasks/setup-docker.yml b/ansible/roles/docker/tasks/setup-docker.yml index 60d855e..1c7cc05 100644 --- a/ansible/roles/docker/tasks/setup-docker.yml +++ b/ansible/roles/docker/tasks/setup-docker.yml @@ -1,27 +1,8 @@ -- name: Add docker apt key - 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 +- name: Install docker-compose apt: - name: "{{ item }}" + name: "docker-compose" become: true become_user: root - loop: - - docker-ce - - docker-ce-cli - - containerd.io - - docker-compose - name: Create docker user user: diff --git a/scripts/ansible/setup.sh b/scripts/ansible/setup.sh index cfca652..897bcb2 100755 --- a/scripts/ansible/setup.sh +++ b/scripts/ansible/setup.sh @@ -5,3 +5,7 @@ set -ex python -m venv env env/bin/pip install -r dev-requirements.txt + +cd ansible/ + +../env/bin/ansible-galaxy install -r requirements.yaml