詳細(xì)介紹Windows下如何使用Ansible應(yīng)用的實(shí)例

環(huán)境需求:

* Controller 一定要是 Linux?

* windows ?需要:

????1.Framework 4.5

????2.PowerShell 3.0

原料:

? ? Ansible Master (CentOS)

? ? Anisble Slave (Windows SP1)

步驟:

? ? [Linux]

yum?-y?install?python-kerberos.x86_64?python2-winrm.noarch

? ??? ? [Windows]

下載?Framework 4.5

http://download.microsoft.com/download/B/A/4/BA4A7E71-2906-4B2D-A0E1-80CF16844F5F/dotNetFx45_Full_x86_x64.exe

? ? 下載 PowerShell 3.0

https://download.microsoft.com/download/E/7/6/E76850B8-DA6E-4FF5-8CCE-A24FC513FD16/Windows6.1-KB2506143-x64.msu

?安裝完成后會(huì)重啟一次

????下載?Remoting Script for Ansible

https://github.com/ansible/ansible/blob/devel/examples/scripts/ConfigureRemotingForAnsible.ps1

? 使用管理員身份運(yùn)行腳本

????使用管理員身份打開PowerShell?

winrm?qc

?會(huì)出現(xiàn)以下錯(cuò)誤

????這個(gè)其實(shí)也不算是錯(cuò)誤,只需要求改網(wǎng)絡(luò)的屬性:在網(wǎng)絡(luò)和共享中心中把公共網(wǎng)絡(luò),切換成家庭網(wǎng)絡(luò)

????再次執(zhí)行

winrm?qc

? ? 接下來需要開啟windows 遠(yuǎn)程操作的相關(guān)屬性:

winrm?set?winrm/config/service?'@{AllowUnencrypted="true"}'
winrm?set?winrm/config/service/auth?'@{Basic="true"}'

? ? 以上就可以看到端口5985 已經(jīng)起來了

????netstat?-ano?|?findstr?5985

? ? 使用ansible 測試windows 主機(jī)

cat?/etc/ansible/hosts

[windows]

10.0.50.100?ansible_ssh_user="Administrator"?ansible_ssh_pass="123456"?ansible_ssh_port=5986?ansible_connection="winrm"

? 版權(quán)聲明
THE END
喜歡就支持一下吧
點(diǎn)贊13 分享