使用Command模块执行命令时,如果需要执行的命令是单一的命令那没什么,但如要需要使用含有管道符,重定向,等特殊字符,这些符号我们的Command是不能识别出来的,当你需要使用管道符的时候应该考虑shell模块来实现,如果远程节点是 windows 系统,则需要使用 win_command 模块. 下面来看它的几个常用参数: 首先通过root用户执行一
winrm set winrm/config/service/auth '@{Basic="true"}' winrm set winrm/config/service '@{AllowUnencrypted="true"}' //为winrm service 配置加密方式为允许非加密 winrm set winrm/config/service/auth '@{Basic="false"}' //关闭 winrm set winrm/config/service '@{AllowUnencrypted="false"}'...
ansible_password: Password ansible_connection: winrm ansible_winrm_transport: kerberos 1. 2. 3. 4. 从ansible2.3开始,kerberos ticket会基于ansible_user和ansible_password两个变量进行创建。如果运行在就版本的ansible上或者ansible_winrm_kinit_mode是手动的话,kerberos ticket必须是已经创建的状态。以下是需要的...
win_security_policy - changes local security policy settings win_service - Manage and query Windows services win_share - Manage Windows shares win_shell - Execute shell commands on target hosts. win_shortcut - Manage shortcuts on Windows win_stat - returns information about a Windows file win_...
先说原理ansible可以通过powershell与winrm远程管理服务实现对windows系统的控制,因为本身ansible就是为了管理linux系统所开发的,建议还是搭配powershell的脚本进行高效管理。 一.windows客户端配置 服务器下载并安装Microsoft .NET Framework 4.5和powershell5.1
win_ping: data: crash3.2、win_command —在win节点上执行口令一般执行单个命令,不支持管道符,例如查看一个ip ansible winserver -m win_command -a "ipconfig"1 2 3 4 5 6 7 8 9 10 11 12 13 14 - name: Save the result of 'whoami' in 'whoami_out' win_command: whoami register: whoami_...
ansible windows -m win_service -a "name=spooler state=restarted" 获取window主机信息: ansible windows -m setup 执行ps脚本: ansible windows -m script -a "E://test.ps1" 获取IP地址: ansible windows -m win_command -a "ipconfig" 查看文件状态: ansible windows -m win_stat -a "path='C:/...
windows可以用raw和win_command和psexec等模块。 我们使用的时候 ansible -i hosts_v2 all -m raw -a "show version" -k 调用了raw模块,传入了参数即执行的命令,一次一条。借助playbook可以实现多条。 这个ad-hoc模式每次只能执行一个ansible模块,raw这个模块我暂时没找到一次传入多条的方式。这种只是适合演示一...
SUMMARY All win_shell tasks, and many win_command' tasks, fail with following error when executed against a certain Windows Server 2012 R2: "Exception calling \"CreateProcess\" with \"5\" argument(s): \"CreateProcessW() failed (%1 is not...
win_command module –Executes a command on a remote Windows node win_computer_description module –Set windows description, owner and organization win_copy module –Copies files to remote locations on windows hosts win_credential module –Manages Windows Credentials in the Credential Manager win_dhcp_...