From 2bf1b29d3f9f14dbc1d19ddd9c936c11c0328f23 Mon Sep 17 00:00:00 2001 From: James McCallum Date: Sun, 3 Sep 2017 19:21:17 +1000 Subject: [PATCH] Add user to docker group functionality --- README.md | 6 ++++++ defaults/main.yml | 3 +++ tasks/docker-users.yml | 6 ++++++ 3 files changed, 15 insertions(+) create mode 100644 tasks/docker-users.yml diff --git a/README.md b/README.md index efe0421..4edabe7 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,12 @@ Docker Compose installation options. (Used only for RedHat/CentOS.) You can enable the Edge or Test repo by setting the respective vars to `1`. +Set the docker_users variable to allow those users to run docker (these users are added to the docker group) + + docker_users: + - Guy + - James + ## Use with Ansible (and `docker` Python library) Many users of this role wish to also use Ansible to then _build_ Docker images and manage Docker containers on the server where Docker is installed. In this case, you can easily add in the `docker` Python library using the `geerlingguy.pip` role: diff --git a/defaults/main.yml b/defaults/main.yml index 14e91a7..21fdbf1 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -17,3 +17,6 @@ docker_apt_repository: "deb https://download.docker.com/linux/{{ ansible_distrib docker_yum_repo_url: https://download.docker.com/linux/centos/docker-{{ docker_edition }}.repo docker_yum_repo_enable_edge: 0 docker_yum_repo_enable_test: 0 + +# Docker users +docker_users: [] diff --git a/tasks/docker-users.yml b/tasks/docker-users.yml new file mode 100644 index 0000000..6b35881 --- /dev/null +++ b/tasks/docker-users.yml @@ -0,0 +1,6 @@ +--- +- name: Add users to docker group + user: + name: "{{ item }}" + group: docker + with_items: "{{ docker_users }}"