---
- name: Create SSH Proxy Directory
  become: yes
  become_user: jingrow
  file:
    dest: /home/jingrow/ssh
    state: directory

- name: Login to Docker Registry
  become: yes
  become_user: jingrow
  command: "docker login -u {{ registry_username }} -p {{ registry_password }} {{ registry_url }}"

- name: Copy home directory from SSH Image
  become: yes
  become_user: jingrow
  command: "docker run --rm --net none -v /home/jingrow/ssh/home:/homemount {{ docker_image }} cp -RL /home/. /homemount"

- name: Copy etc directory from SSH Image
  become: yes
  become_user: jingrow
  command: "docker run --rm --net none -v /home/jingrow/ssh/etc:/etcmount {{ docker_image }} cp -RL /etc/. /etcmount"

- name: Start SSH Proxy
  become: yes
  become_user: jingrow
  command: "docker run -d --name ssh --restart always -p 2222:22 -v /home/jingrow/ssh/etc:/etc -v /home/jingrow/ssh/home:/home --hostname ssh {{ docker_image }}"
