- name: Create websimdev user
  user: name=websimdev shell=/bin/bash
  tags: users
  sudo: yes

- name: Copy ubuntu user authorized_keys
  command: cp /home/ubuntu/.ssh/authorized_keys /home/websimdev/.ssh/
  sudo: yes


- name: Give websimdev passwordless sudo
  lineinfile: "dest=/etc/sudoers state=present regexp='^websimdev' line='websimdev ALL=(ALL) NOPASSWD: ALL'"
  tags: users
  sudo: yes

- name: Add authorized keys for websimdev
  sudo: yes
  authorized_key: user=websimdev
                  key="{{ lookup('file', item)}}"
  with_fileglob:
    - ../public_keys/*
  tags: users

- name: Create websimdev user
  user: name=websimdev shell=/bin/bash
  tags: users
  sudo: yes

- name: Get ubuntu user authorized_keys
  command: cat /home/ubuntu/.ssh/authorized_keys
  register: ubuntu_public_key

- name: Copy ubuntu user authorized_keys
  authorized_key: user=websimdev
                  key="{{ ubuntu_public_key.stdout }}"
  sudo: yes


- name: Give websimdev passwordless sudo
  lineinfile: "dest=/etc/sudoers state=present regexp='^websimdev' line='websimdev ALL=(ALL) NOPASSWD: ALL'"
  tags: users
  sudo: yes

- name: Add authorized keys for websimdev
  sudo: yes
  authorized_key: user=websimdev
                  key="{{ lookup('file', item)}}"
  with_fileglob:
    - ../public_keys/*
  tags: users

Fix copying ubuntu user's public key to websimdev
Fix copying ubuntu user's public key to websimdev

use authorized_keys command under websimdev with output from cat
/home/ubuntu/.ssh/authorized_keys
