Select Page

Clones given repo to remote instance into home directory of user specified in hosts file as “ansible_user”.

- name: clone git repository
  hosts: newinstance
  gather_facts: yes

  tasks:
  - debug: msg="user={{ansible_user}}"
  
  - name: clone repo
    git:
      repo: git@github.com:githubuser/{{upcload_repo}}.git
      dest: "/home/{{ansible_user}}/{{upcload_repo}}/"
      version: master
      accept_hostkey: yes
      key_file: "/home/{{ansible_user}}/.ssh/id_rsa"