I use ansible to operate Windows, there are many problems!
As follows:
- Use win_copy to copy the Shared directory or the middle file times of the network drive disk!
My Syntax is here ,
tasks:
- name: copy file
win_copy:
src: \192.168.227.181\2.0.0\pys
dest: C:\tools
remote_src: True
The execution result:
ubuntu@xll-ubuntu:~$ ansible-playbook /etc/ansible/test.yml -vvv
ansible-playbook 2.4.3.0
config file = /etc/ansible/ansible.cfg
configured module search path = [u’/home/ubuntu/.ansible/plugins/modules’, u’/usr/share/ansible/plugins/modules’]
ansible python module location = /home/ubuntu/.local/lib/python2.7/site-packages/ansible
executable location = /usr/bin/ansible-playbook
python version = 2.7.12 (default, Dec 4 2017, 14:50:18) [GCC 5.4.0 20160609]
Using /etc/ansible/ansible.cfg as config file
Parsed /etc/ansible/hosts inventory source with ini plugin
PLAYBOOK: test.yml ********************************************************************************************************************************************************************************************
1 plays in /etc/ansible/test.yml
PLAY [dbServer] ***********************************************************************************************************************************************************************************************
TASK [Gathering Facts] ****************************************************************************************************************************************************************************************
Using module file /home/ubuntu/.local/lib/python2.7/site-packages/ansible/modules/windows/setup.ps1
<192.168.227.196> ESTABLISH WINRM CONNECTION FOR USER: administrator on PORT 5986 TO 192.168.227.196
EXEC (via pipeline wrapper)
ok: [192.168.227.196]
META: ran handlers
TASK [拷贝文件 到目标服务器上] *******************************************************************************************************************************************************************************************
task path: /etc/ansible/test.yml:4
Using module file /home/ubuntu/.local/lib/python2.7/site-packages/ansible/modules/windows/win_copy.ps1
<192.168.227.196> ESTABLISH WINRM CONNECTION FOR USER: administrator on PORT 5986 TO 192.168.227.196
EXEC (via pipeline wrapper)
fatal: [192.168.227.196]: FAILED! => {
“changed”: false,
“dest”: “C:\tools”,
“module_stderr”: “Exception calling "Run" with "1" argument(s): "Exception calling "Invoke" with \r\n"0" argument(s): "The running command stopped because the preference variable "\r\nErrorActionPreference" or common parameter is set to Stop: 拒绝访问。""\r\nAt line:47 char:5\r\n+ $output = $entrypoint.Run($payload)\r\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n + CategoryInfo : NotSpecified: ( , ParentContainsErrorRecordE \r\n xception\r\n + FullyQualifiedErrorId : ScriptMethodRuntimeException\r\n \r\n”,
“module_stdout”: “”,
“msg”: “MODULE FAILURE”,
“rc”: 1,
“src”: “\\192.168.227.181\2.0.0\pys”
}
to retry, use: --limit @/etc/ansible/test.retry
PLAY RECAP ****************************************************************************************************************************************************************************************************
192.168.227.196 : ok=1 changed=0 unreachable=0 failed=1
- It is not possible to call python script replication through win_command, without error messages.(it’s okay to do python on Windows)