Reputation: 764
Ansible 2.1, control host under centos7, number of windows 10 as clients.
I need to clone git reposritory on remote side, but no idea how to do this:
I've tried something like:
- name: clone repositories
git:
repo: "{{ item.repo }}"
dest: "C:\openserver\domains\{{ domain_name }}\{{ item.value.path }}"
version: "{{ item.version | default('HEAD') }}"
with_items: "{{ repositories }}"
Upvotes: 3
Views: 10046
Reputation: 41
if not too late, you can use something like this
- name: clone repositories
win_command: >
"C:\Program Files\Git\bin\git.exe"
"--no-pager"
"clone"
"http://user:[email protected]/OpenCorpora/opencorpora.git"
"C:\OPenserver\domains\opencorpora.local\www"
"--branch"
"master"
"--recursive"
reference https://docs.ansible.com/ansible/latest/user_guide/windows_usage.html
Upvotes: 2
Reputation: 444
I have found win_git
module to use from @tivrobo:
https://github.com/tivrobo/ansible-win_git
Upvotes: 4
Reputation: 764
Ansible recommends to use script module, i used raw module instead (is this way less secure than script module?):
- name: clone repositories
raw: C:\OpenServer\modules\git\cmd\git.exe clone https://github.com/OpenCorpora/opencorpora.git C:\OPenserver\domains\opencorpora.local\www
Prerequirements: msysgit installed (C:\OpenServer\modules\git\
in my case ), or native git client for windows (see here: https://git-scm.com/download/win)
PS Unfortunately, i don't know today how to use native client with default install path (with whitespaces):
- name: clone repositories
raw: C:\Program Files\Git\cmd\git.exe clone https://github.com/OpenCorpora/opencorpora.git C:\OPenserver\domains\opencorpora.local\www
It fails with error:
TASK [website_win : clone repositories] ****************************************
fatal: [192.168.1.43]: FAILED! => {"changed": false, "failed": true, "rc": 1, "stderr": "C:\\Program : The term 'C:\\Program' is not recognized as the name of a cmdlet, function, script file, or operable progra\r\nm. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.\r\nAt line:1 char:1\r\n+ C:\\Program Files\\Git\\cmd\\git.exe clone https://github.com/OpenCorpora ...\r\n+ ~~~~~~~~~~\r\n+ CategoryInfo : ObjectNotFound: (C:\\Program:String) [], CommandNotFoundException\r\n+ FullyQualifiedErrorId : CommandNotFoundException\r\n", "stdout": "", "stdout_lines": []}
NO MORE HOSTS LEFT *************************************************************
Upvotes: 0