Target: windows-server Group
[Inventory]
[windows-server]
win1 ansible_host=172.22.0.39 ansible_connection=winrm ansible_password=ansible ansible_user=ansible ansible_winrm_server_cert_validation=ignore
소스 서버 (Ansible Engile)에서 windows-server 가 속한 서버의 Registry 생성 및 값 설정하기
[win-registry-playbook.yml]
- hosts: windows-server
tasks:
- name: Creating a registry
win_regedit:
path: HKLM:\SOFTWARE\ANSIBLE-TEST
- name: Modifying a registry, adding name and data
win_regedit:
path: HKLM:\SOFTWARE\ANSIBLE-TEST
name: TestYN
data: Yes
ansilbe 엔진에서 아래와 같이 명령할 때
[ansible@ansible-engine ~]# ansible -i /etc/ansible/hosts win -m win_ping
172.22.0.39 | UNREACHABLE! => {
"changed": false,
"msg": "ssl: HTTPSConnectionPool(host='172.22.0.39', port=5986): Max retries exceeded with url: /wsman (Caused by ConnectTimeoutError(, 'Connection to 172.22.0.39 timed out. (connect timeout=30)'))",
"unreachable": true
}
windows server에 winrm 5986 port를 listenling을 안하고 있다.
--> winrm ssl 실행이 안 되고 있음
$url = "https://raw.githubusercontent.com/ansible/ansible/devel/examples/scripts/ConfigureRemotingForAnsible.ps1"
$file = "$env:temp\ConfigureRemotingForAnsible.ps1"
(New-Object -TypeName System.Net.WebClient).DownloadFile($url, $file)
powershell.exe -ExecutionPolicy ByPass -File $file