Ansible Test - Playbook-Windows Server - Registry Update


複数のサーバの環境構成をAnableで管理し、ファイル管理を最小時間+自動化+Human Error 0%に処理


ウィンドウ・サーバー・レジストリの更新


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

テストターゲット


ソースサーバ上でwindows-serverが属するサーバのレジストリを作成し、値を設定します.
[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

準備状況(Windows Server)

  • OpenSSH取付
  • 55986ポートwinrm ssl
  • を実行
  • ファイアウォール5986ポートOPEN
  • Python取付
  • winrmモジュールのインストール(Windows Server)


    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
    }
    winrm 5986ポートはwindowsサーバで傍受されていません.
    -->winrm sslが実行されていません

    Windows server>PowerShellの実行

    $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