diff --git a/README.md b/README.md index b54fa7f..f348fe5 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,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`. + docker_users: + - user1 + - user2 + +Set the docker_users variable to allow those users to run docker (these users are added to the docker group) + ## 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 905618a..1df94b1 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -20,3 +20,6 @@ docker_apt_ignore_key_error: True docker_yum_repo_url: https://download.docker.com/linux/{{ (ansible_distribution == "Fedora") | ternary("fedora","centos") }}/docker-{{ docker_edition }}.repo docker_yum_repo_enable_edge: 0 docker_yum_repo_enable_test: 0 + +# A list of users who will be added to the docker group. +docker_users: [] diff --git a/tasks/docker-users.yml b/tasks/docker-users.yml new file mode 100644 index 0000000..ccc1ac7 --- /dev/null +++ b/tasks/docker-users.yml @@ -0,0 +1,7 @@ +--- +- name: Ensure docker users are added to the docker group. + user: + name: "{{ item }}" + group: docker + append: yes + with_items: "{{ docker_users }}" diff --git a/tasks/main.yml b/tasks/main.yml index bbbc141..01895d4 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -23,3 +23,6 @@ - include_tasks: docker-compose.yml when: docker_install_compose + +- include: docker-users.yml + when: docker_users