ansible控制windows 2019
1.在ansible端安装pywinrm
[root@ansible ansible]# wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
[root@ansible ansible]# yum -y install python-pip
[root@ansible ansible]# pip install pywinrm
2.配置/etc/ansible/hosts文件,加入需要被接管的windows系统
[windows]
192.168.56.105 ansible_ssh_user="Administrator" ansible_ssh_pass="S@34eapt12" ansible_ssh_port=5985 ansible_connection="winrm" ansible_winrm_server_cert_validation=ignore
3.在windows服务器设置winrm
在windows开启winrm
winrm service 默认都是未启用的状态,先查看状态;如无返回信息,则是没有启动;
winrm enumerate winrm/config/listener
针对winrm service 进行基础配置:https://www.cndba.cn/hbhe0316/article/5015
winrm quickconfig
查看winrm service listener:
winrm e winrm/config/listener
为winrm service 配置auth:
winrm set winrm/config/service/auth @{Basic=“true”}
为winrm service 配置加密方式为允许非加密:
winrm set winrm/config/service @{AllowUnencrypted=“true”}
4.测试ansible是否可用Ping通windowshttps://www.cndba.cn/hbhe0316/article/5015
[root@ansible ansible]# ansible windows -m win_ping
192.168.56.105 | UNREACHABLE! => {
"changed": false,
"msg": "plaintext: the specified credentials were rejected by the server",
"unreachable": true
}
5.使用ansible执行命令拷贝/etc/hosts文件至windows C盘https://www.cndba.cn/hbhe0316/article/5015https://www.cndba.cn/hbhe0316/article/5015
[root@ansible ansible]# ansible windows -m win_copy -a "src=/etc/hosts dest=c:/ owner=administrator"
192.168.56.105 | CHANGED => {
"changed": true,
"checksum": "c57fa92967f442aefae1b01f907318e9f658b271",
"dest": "c://hosts",
"operation": "file_copy",
"original_basename": "hosts",
"size": 181,
"src": "/etc/hosts"
}
6.使用ansible获取ipconfig信息https://www.cndba.cn/hbhe0316/article/5015
[root@ansible ansible]# ansible -i hosts windows -m win_shell -a "ipconfig /all"
192.168.56.105 | CHANGED | rc=0 >>
Windows IP Configuration
Host Name . . . . . . . . . . . . : WIN-SU8A4VM4R4L
Primary Dns Suffix . . . . . . . :
Node Type . . . . . . . . . . . . : Hybrid
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
Ethernet adapter 锟斤拷太锟斤拷:
Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Intel(R) PRO/1000 MT Desktop Adapter
Physical Address. . . . . . . . . : 08-00-27-8C-15-66
DHCP Enabled. . . . . . . . . . . : No
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::ad24:705f:d4ba:6eef%9(Preferred)
IPv4 Address. . . . . . . . . . . : 192.168.56.105(Preferred)
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.56.1
DHCPv6 IAID . . . . . . . . . . . : 67633191
DHCPv6 Client DUID. . . . . . . . : 00-01-00-01-29-0F-11-3B-08-00-27-8C-15-66
DNS Servers . . . . . . . . . . . : fec0:0:0:ffff::1%1
fec0:0:0:ffff::2%1
fec0:0:0:ffff::3%1
NetBIOS over Tcpip. . . . . . . . : Enabled
7.使用ansible获取hotname信息https://www.cndba.cn/hbhe0316/article/5015
[root@ansible ansible]# ansible -i hosts windows -m win_shell -a "hostname"
192.168.56.105 | CHANGED | rc=0 >>
WIN-SU8A4VM4R4L
版权声明:本文为博主原创文章,未经博主允许不得转载。
ansible
ansible控制windows 2019相关推荐
- 【Ansible】Ansible控制windows插件安装及运行error与解决方法
一. 问:因pip版本问题无法安装kerberos 答:安装提示需要先安装pip升级包 下载pip9.0.1升级包: ![1_2] 二.问:安装kerberos报错 答:需要先安装libkrb5开发包 ...
- python项目实战:控制Windows电脑桌面壁纸
2019独角兽企业重金招聘Python工程师标准>>> 前言 今天为大家介绍一个控制Windows电脑桌面壁纸的案例,具有很好的参考价值,是在电脑上的注册表做手脚,一直刷新桌面,可以 ...
- Centos7上的Ansible管理Windows主机的部署
提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录 前言 一.Windows主机上的配置 1.检查windows客户机powershell版本 2.下载并安装Microsoft ...
- 如何使用netsh advfirewall firewall而不是netsh firewall控制Windows Server 2008的防火墙行为
如何使用"netsh advfirewall firewall"上下文,而不是"netsh firewall"上下文控制Windows Vista 和 Wind ...
- 05-01-部署 WSUS on Windows 2019 Core
<系统工程师实战培训> -05-部署补丁管理服务器 -01-部署 WSUS on Windows 2019 Core 1. 加域/退域 //加域 netdom join 031-W ...
- asp.net 控制windows服务
asp.net 控制windows服务 最近做一个小的项目,经理要求winform与web都可操作.于是将其做成服务,winform下调用很简单.asp.net下大部分过程是一样的.但需要涉及到用户的 ...
- 设置计算机关机静音,Shortcuts 捷径控制 Windows 电脑:静音开关、音量调节、待机、关机...
在 iPhone 上通过 Shortcuts 捷径控制 Windows 电脑:静音开关.音量调节.待机.关机 演示视频 : 教程: 一.使用方法: 1.Windows 上安装一个 SSH 服务器软件并 ...
- C#使用ServiceController控制windows服务
C#中,使用ServiceController类控制windows服务,使用之前要先添加引用:System.ServiceProcess,然后在命名空间中引用:using System.Service ...
- java控制系统音量_Java 控制 Windows 系统音量-Go语言中文社区
目录 1.使用 Java 来控制 Windows 系统音量,使用 JNA 调用 windows 底层 API 因为有点麻烦,所以这里采用纯 Java API结合 VBS 脚本的方式进行控制. 2.可以 ...
最新文章
- python基础之常用模块
- 第1个实验:用汇编语言点亮一盏LED
- Tfs 2010使用小技巧
- javap使用实例图解
- 彩色RGB图像转为灰度图像
- python scipy模块文档_scipy模块stats文档
- 3D建模行业内幕及“钱”景
- java知识点3(null、引用相关知识(自己理解))
- post .php程序,php程序内部post数据的方法
- opengl 如何加阴影_一步步学OpenGL(23) -《阴影贴图1》
- 暴几个用明文在网上传输用户名密码的网站
- 现代通信理论与新技术 PPT笔记整理
- GWT(Google Web Toolkit)是干嘛用的
- PyCharm设置背景颜色为白色
- linux wifi设置端口号,Linux 下wifi 驱动开发(四)—— USB接口WiFi驱动浅析
- logo设计的忌讳与要点有哪些
- 怎么清洁计算机主机内部,机箱怎么防尘 机箱清灰步骤【教程】
- mysql删除重复的数据保留一条
- spark官网配套的代码数据在哪儿
- 交通工程造价管理站文件