拖拖拖,,,这个ansible多种连接方式6月就写了部分总结,终于来搞完它了。。。
ansible有多种连接方式,一般大多使用OpenSSH,类似的还有Paramiko SSH(基于python)、smart、local,这几种比较简单。重点讲一下WinRM和Docker连接,主要是因为官网对于windows连接讲的不清楚,国内的资料也不多。
WinRM连接
1、系统/软件信息
Windows OS: windows7 64bit
Linux OS:CentOS 7.3
Ansible version: 2.3
Powershell version:3.0
官网要求powershell升级到3.0,注意一下。
2、windows设置
1)以管理员身份运行PowerShell,执行下列命令设置允许执行脚本。
PS C:\Windows\system32> set-executionpolicy remotesigned
执行策略更改
执行策略可帮助你防止执行不信任的脚本。更改执行策略可能会产生安全风险,如 http://go.microsoft.com/fwlink/?LinkID=135170
中的 about_Execution_Policies 帮助主题所述。是否要更改执行策略?
[Y] 是(Y) [N] 否(N) [S] 挂起(S) [?] 帮助 (默认值为“Y”): y
2)下载ConfigureRemotingForAnsible.ps1脚本。
Ansible官网提供链接:https://github.com/ansible/ansible/blob/devel/examples/scripts/ConfigureRemotingForAnsible.ps1
3)使用ansible官网提供的四个命令执行ps脚本,每个命令的注释写在#后面:
#Pass the -CertValidityDays option to customize the expiration date of the generated certificate:
PS C:\Windows\system32> powershell.exe -File 'E:\ansible\ConfigureRemotingForAnsible.ps1' -CertValidityDays 100
#Pass the -EnableCredSSP switch to enable CredSSP as an authentication option:
PS C:\Windows\system32> powershell.exe -File 'E:\ansible\ConfigureRemotingForAnsible.ps1' -EnableCredSSP
cfg : http://schemas.microsoft.co