how to add a user to docker group if docker group is there?

4,339 views
Skip to first unread message

Robert Chen

unread,
Jul 13, 2017, 1:59:59 PM7/13/17
to Ansible Project
default user add to users group, if docker group is there, also add to docker group.

How to write this snabile-playbook?

Larry Smith

unread,
Jul 14, 2017, 12:48:31 AM7/14/17
to Ansible Project
This may be of some help for you. https://github.com/mrlesmithjr/ansible-docker/blob/master/tasks/users.yml

Basically this should work for you as a playbook.

---
- hosts: docker_hosts
  vars:
    docker_users:
      - 'vagrant'
  tasks:
    - name: users | adding docker users (for use without sudo)
      user:
        name: "{{ item }}"
        append: yes
        groups: docker
      become: true
      with_items: '{{ docker_users }}'
Reply all
Reply to author
Forward
0 new messages