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必须是已经创建的状态。以下是需要的...
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"}'...
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_...
[root@172 ansible]# ansible win -m win_shell -a 'net user test /add' 192.168.123.6 | CHANGED | rc=0 >> The command completed successfully. #这条是删除用户 [root@172 ansible]# ansible win -m win_shell -a 'net user test /del' 四.常见错误汇总 下面报错可能是账户被占用了,要注销服务...
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_...
帮助我们在远程主机上执行任意命令,但是需要注意的是,使用Command模块执行命令时,如果需要执行的命令是单一的命令那没什么,但如要需要使用含有管道符,重定向,等特殊字符,这些符号我们的Command是不能识别出来的,当你需要使用管道符的时候应该考虑shell模块来实现,如果远程节点是 windows 系统,则需要使用 win_command ...
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这个模块我暂时没找到一次传入多条的方式。这种只是适合演示一...
-name:Execute a command in the remote shell, stdout goes to the specified file on the remoteansible.windows.win_shell:C:\somescript.ps1 >> C:\somelog.txt-name:Change the working directory to somedir/ before executing the commandansible.windows.win_shell:C:\somescript.ps1 >> C:\somelog...
-name:remove a file (check mode)win_file:path:C:\tempstate:absentregister:remove_file_checkcheck_mode:true-name:get result of remove a file (check mode)win_command:powershell.exe "if (Test-Path -Path 'C:\temp') { 'true' } else { 'false' }"register:remove_file_actual_check-name:...