Reputation: 69
Friends,
I need to write an ansible task, which clones a git repository on a remote machine. I tryed like this:
- name: CLONING EMPTY REPOSITORY
ansible.builtin.shell:
chdir: /home/marcio/devdir
cmd: git clone ssh://[email protected]/home/marcio/devdir/fresco.git fresco.local
Ansible is configured to become sudo when necessary and this is working fine, the above task, however, never finishes executing because the password of the user "marcio" must be provided after the git clone
command is ran.
Since the original repository is located on the same machine where it will be cloned, I tryed generating a public key and storing it on the authorized_keys file of the server, but it didn't work as well.
Does anybody know a way to pass this password as a variable or another way to work around this problem?
Upvotes: 0
Views: 958
Reputation: 231
Use expect:
- name: CLONING EMPTY REPOSITORY
ansible.builtin.expect:
chdir: /home/marcio/devdir
command: git clone ssh://[email protected]/home/marcio/devdir/fresco.git fresco.local
responses:
"YOUR ACTUAL LOGIN PROMPT": username
"YOUR ACTUAL PASSWORD PROMPT": password
Upvotes: 1