Ansible 从1.7+版本开始支持Windows,但前提是管理机必须为Linux系统,远程主机的通信方式也由SSH变更为PowerShell,同时管理机必须预安装Python的Winrm模块,方可和远程Windows主机正常通信,但PowerShell需3.0+版本且Management Framework 3.0+版本。 简单总结如下: (1)管理机必须为Linux
ansible windows -m win_user -a "name=user1 password=123 groups='Administrators,Remote Desktop Users'" 重启的第一种方式 ansible windows -m win_shell -a "shutdown -r -t 1" 重启的第二种方式 ansible windows -m win_reboot 获取ip地址 ansible windows -m raw -a "ipconfig" 获取身份 ansible...
下脚本保存至本地后,右键选择“使用PowerShell运行”,执行完毕重启系统后,在PowerShell执行Get-Host命令结果如下图所示PowerShell版本为3.0为正常。 1#Powershell script to upgrade a PowerShell 2.0 system to PowerShell 3.02#based on http://occasionalutility.blogspot.com/2013/11/everyday-powershell-part-7-...
https://gallery.technet.microsoft.com/scriptcenter/2d191bcd-3308-4edd-9de2-88dff796b0bc 下载完ZIP压缩包以后需要解压,并将这个文件夹放到两个地方 %USERPROFILE%\Documents\WindowsPowerShell\Modules(这个路径后面部分需要自己手动创建的) %WINDIR%\System32\WindowsPowerShell\v1.0\Modules 然后执行PS > Impor...
一、首先在Powershell窗口执行get-host命令查看版本 二、配置winrm服务 Windows上winrm服务默认是未启用的,使用如下命令可以查看状态。 1 winrm enumerate winrm/config/listener 使用如下命令配置winrm服务 1 2 3 winrm quickconfig winrm set winrm/config/service/auth '@{Basic="true"}' winrm set winrm...
#运行powershell脚本 tasks: - name: run test script script: files/test_script.ps1 #用raw运行独立命令 tasks: - name: run ipconfig raw: ipconfig register: ipconfig - debug: var=ipconfig inventory内容如下: [windows] 10.1.170.134 ansible_ssh_user="xxx" ansible_ssh_pass="xxx" ansible_ssh_...
自从1.7版本开始,Ansible同样包含了对Windows机器管理的支持。这是用本地的powershell远程,而不是SSH。 Ansible仍然在Linux控制机上运行,并且使用“winrm” Python模块来与远端主机通信。尽管不被微软或者Ansible支持,Linux控制机可以是一个Windows subsystem for linux(WSL) bash shell 支持。
Ansible要求在Windows主机上安装PowerShell 3.0或更高版本,并且至少要安装.NET 4.0。 应创建并激活WinRM侦听器。可以在下面找到更多详细信息。 注意 这些是Ansible连接的基本要求,但某些Ansible模块具有其他要求,例如较新的OS或PowerShell版本。请查阅模块的文档页面以确定主机是否满足那些要求。
http://docs.ansible.com/ansible/list_of_windows_modules.html 可以使用script模块来运行powershell脚本,也可以在playbook中使用,如下: -hosts: windows tasks: -script: foo.ps1 --argument --other-argument 注意有的模块并不以win开头,如下: “slurp”, “raw”, and “setup” ...
下脚本保存至本地后,右键选择“使用PowerShell运行”,执行完毕重启系统后,在PowerShell执行Get-Host命令结果如下图所示PowerShell版本为3.0为正常。 1 # Powershell script to upgrade a PowerShell 2.0 system to PowerShell 3.0 2 # based on http:///2013/11/everyday-powershell-part-7-powershell.html ...