---
- name: Create admin group
  group: name=admin state=present

- name: Allow admin group to sudo without password
  lineinfile:
    dest=/etc/sudoers
    state=present
    regexp='^%admin ALL\='
    line='%admin ALL=(ALL) NOPASSWD:ALL'
    validate='visudo -cf %s'

- name: Create development environment user
  user:
    name={{ docker_dev_user }}
    shell=/bin/bash
    groups=admin
    append=yes
    generate_ssh_key=yes
    ssh_key_bits=2048
    ssh_key_file=.ssh/id_rsa_git_host
    ssh_key_comment={{ docker_dev_user }}.git@docker
    password=$6$rounds=100000$aeToEWdpYROoxarJ$6PVPIT5dwxFJ1lnGD28K4n2zUj1SGPQCoBmrKh4lbLng3y0/Wlb/t4x9JPGTva/Q9MOIRzNF3vKQsrdF1o.YS0 # add a (long, encrypted) password or key based ssh login does not work

- name: Add public key for dev environment user
  authorized_key: user=vagrant key="{{ lookup('file', '/home/vagrant/.ssh/docker-dev.pub') }}"



---
- name: Create admin group
  group: name=admin state=present

- name: Allow admin group to sudo without password
  lineinfile:
    dest=/etc/sudoers
    state=present
    regexp='^%admin ALL\='
    line='%admin ALL=(ALL) NOPASSWD:ALL'
    validate='visudo -cf %s'

- name: Create development environment user
  user:
    name={{ docker_dev_user }}
    shell=/bin/bash
    groups=admin
    append=yes
    generate_ssh_key=yes
    ssh_key_bits=2048
    ssh_key_file=.ssh/id_rsa_git_host
    ssh_key_comment={{ docker_dev_user }}.git@docker
    password=$6$rounds=100000$aeToEWdpYROoxarJ$6PVPIT5dwxFJ1lnGD28K4n2zUj1SGPQCoBmrKh4lbLng3y0/Wlb/t4x9JPGTva/Q9MOIRzNF3vKQsrdF1o.YS0 # add a (long, encrypted) password or key based ssh login does not work

- name: Add public key for dev environment user
  authorized_key: user=vagrant key="{{ lookup('file', '/home/vagrant/.ssh/docker-dev.pub') }}"

- name: Add container git only ssh key to authorized keys on host
  local_action:
    authorized_key
    user=vagrant
    key="{{ docker_dev_user_git_key.ssh_public_key }}"
    key_options='no-port-forwarding,no-agent-forwarding,command="git-shell -c \"$SSH_ORIGINAL_COMMAND\""'
    state=present

Add container git ssh key to authorized keys on host
Add container git ssh key to authorized keys on host
