Ansible Managing Windows

Source: Internet
Author: User
Tags ansible windows

Ansible管理windows 安装步骤

First, the system requirements
1, the management machine must be a Linux system and pre-install the Python Winrm module (this time using the Linux version is the CentOS Linux release 7.3.1611 (Core)).
2, the underlying communication authentication some Kerberos-based, Windows uses a connection tool for PowerShell instead of SSH, and the version of Windows I'm testing here is the Win7-32bit Pro Edition.
3, the remote host PowerShell version for the 3.0+,management framework version is 3.0 +.
4, need to install automatic settings Windows Remote Management, English full name ws-management (WinRM)
Ii. installing ansible and related modules on the server side
Pre-installation work:
1,[[email protected]_3 ~]# yum-y Install Python-pip python-devel
Fix PYTHON-PIP failure without installation
Download and install Setuptools first
[Email protected]_3 ~]# wget--no-check-certificate https://bootstrap.pypa.io/ez_setup.py
[Email protected]_3 ~]# sudo python ez_setup.py--insecure
[Email protected]_3 ~]# wget https://pypi.python.org/packages/11/b6/ abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz#md5= 35f01da33009719497f01a4ba69d63c9
[Email protected]_3 ~] #tar-xf pip-9.0.1.tar.gz
[Email protected]_3 ~] #cd pip-8.0.0
[[Email protected]_3 ~] #python setup.py Install
[[Email protected]_3 ~] #yum install gcc glibc-devel zlib-devel
[[Email protected]_3 ~] #yum Install Rpm-build openssl-devel-y
2, formally installed Ansible
[[Email protected]_3 ~] #yum-y install Ansible
[Email protected]_3 ~]# ansible--version
Third, install on Windows side first. NET3.0 and above versions.

Iv. Check that your PowerShell version is not 3.0 not please upgrade to version 3.0.

If it is not possible to upgrade with a script;
Https://github.com/cchurch/ansible/blob/devel/examples/scripts/upgrade_to_ps3.ps1
The way to do this is to open the above link, the download saved in txt text after the file name Upgrade_to_ps3.ps1
Then use PowerShell to run a script upgrade, and then restart the Windows system after upgrading.

Setting up your PowerShell can be performed remotely, changing the value of the property in the registry. The specific directory is as follows.
1. Modify the Registry information:

Hkey_local_machine\software\microsoft\powershell\1\shellids\scripteddiagnostics

2, automatically set Windows Remote Management (WS-MANAGEMENT,WINRM) Download patch script:
HTTPS://GITHUB.COM/ANSIBLE/ANSIBLE/BLOB/DEVEL/EXAMPLES/SCRIPTS/CONFIGUREREMOTINGFORANSIBLE.PS1; In particular, open the link above, Download saved in txt text after the file name Configureremotingforansible.ps1 specific steps and the above similar;
3, often there are many problems during the previous operation, you also need to configure WinRM under Poweshell:

WinRM set Winrm/config/service ' @{allowunencrypted= "true"} '
WinRM set Winrm/config/service/auth ' @{basic= "true"} '

Vi. Configuring the host file in Linux
1,[[email protected]_3 ~] #vim/etc/ansible/hosts
Add a Windows Module host group on the last line
[Windows]
192.168.0.36 ansible_ssh_user= "Root" ansible_ssh_pass= "123456" ansible_ssh_port=5985 ansible_connection= "WinRM"
2. Test network connectivity in execution of commands
[Email protected]_3 ansible]# ansible windows-m win_ping

3. Test upload a WinRAR file to the Windows client
[Email protected]_3 ansible]# ansible windows-m win_copy-a ' Src=/data/winrar_x64_5.40.0.0.exe dest=d:\iso\ '

Seven, I encountered 2 small problems in the test when the configuration of WinRM when required private network, if your computer is not a private network please change the domain and home network as long as it is not a public network can be OH.

There is the use of ansible windows-m win_ping connection client prompt connection is denied, here I changed the port to solve, in the edit Vim/etc/ansible/hosts file port, the original is 5986 change it to 5985 can be used.

Ansible Managing Windows

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.