Ansible 2.1,控制主机在centos7下,windows 10的数量作为客户端。
我需要在远程端克隆git reposritory,但不知道如何执行此操作:
我尝试过类似的事情:
- name: clone repositories
git:
repo: "{{ item.repo }}"
dest: "C:\openserver\domains\{{ domain_name }}\{{ item.value.path }}"
version: "{{ item.version | default('HEAD') }}"
with_items: "{{ repositories }}"
答案 0 :(得分:3)
我在@tivrobo中找到了library(data.table)
i1 <- setDT(foo)[ , if(any(frame_type == "start")) .I[which(frame_type ==
"start"):which(frame_type == "end")], cumsum(frame_type == "start")]$V1
foo[i1, LC := paste0("LC", cumsum(frame_type == "start")), id
][is.na(LC), LC := "."][]
# id frame_type LC
# 1: 1 . .
# 2: 1 . .
# 3: 1 . .
# 4: 1 start LC1
# 5: 1 . LC1
# 6: 1 lcf LC1
# 7: 1 . LC1
# 8: 1 . LC1
# 9: 1 end LC1
#10: 1 . .
#11: 1 . .
#12: 1 . .
#13: 1 . .
#14: 1 start LC2
#15: 1 . LC2
#16: 1 lcf LC2
#17: 1 . LC2
#18: 1 . LC2
#19: 1 end LC2
#20: 1 . .
#21: 2 . .
#22: 2 . .
#23: 2 . .
#24: 2 start LC1
#25: 2 . LC1
#26: 2 lcf LC1
#27: 2 . LC1
#28: 2 . LC1
#29: 2 end LC1
#30: 2 . .
模块:
答案 1 :(得分:1)
如果还不算太晚,您可以使用类似的方法
- name: clone repositories
win_command: >
"C:\Program Files\Git\bin\git.exe"
"--no-pager"
"clone"
"http://user:pass@github.com/OpenCorpora/opencorpora.git"
"C:\OPenserver\domains\opencorpora.local\www"
"--branch"
"master"
"--recursive"
参考https://docs.ansible.com/ansible/latest/user_guide/windows_usage.html
答案 2 :(得分:0)
Ansible recommends使用script模块,我使用了raw模块(这种方式不如脚本模块安全吗?):
- name: clone repositories
raw: C:\OpenServer\modules\git\cmd\git.exe clone https://github.com/OpenCorpora/opencorpora.git C:\OPenserver\domains\opencorpora.local\www
预先要求:已安装msysgit(在我的情况下为C:\OpenServer\modules\git\
),或用于Windows的本机git客户端(请参阅此处:https://git-scm.com/download/win)
PS很遗憾,我今天不知道如何使用默认安装路径(带有空格)的原生客户端:
- name: clone repositories
raw: C:\Program Files\Git\cmd\git.exe clone https://github.com/OpenCorpora/opencorpora.git C:\OPenserver\domains\opencorpora.local\www
失败并显示错误:
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 *************************************************************