ansibleで作成したWindowsサーバー(aws:ec2)のサーバ名(hostname)を変更し、サーバの再起動を実行したい内容のplaybookを作成しました。
・ansible 2.6.1
・Ansibleインスタンス:Centos7.5
・管理対象インスタンス:Win2012R2
# cat hosts localhost ansible_host=127.0.0.1 ansible_connection=local [windows] ec2-11-222-33-444.ap-northeast-1.compute.amazonaws.com ansible_ssh_host=11.222.33.444 ansible_ssh_user=Administrator ansible_ssh_pass=xxxxxxxxxx ansible_ssh_port=5985 ansible_connection=winrm
$ cat site.yml --- - hosts: windows roles: - ini_set
.
初期設定を実施しているplaybook ↓ です。ホスト名変更以外にも複数の処理を実行していますがスルーで。
$ cat roles/ini_set/tasks/main.yml - name: Install IIS win_feature: name: "Web-Server" state: present restart: yes include_sub_features: yes include_management_tools: yes - name: Setup Timezones win_timezone: timezone: "Tokyo Standard Time" - name: disabled windows firewall service win_service: name: "Windows Firewall" start_mode: disabled - name: Change the hostname to new_hostname win_hostname: name: win-test-svr register: win_hostname - name: Reboot win_reboot: when: win_hostname.reboot_required
.
playbookを実行した時の状況です。
# ansible-playbook -l windows site.yml -vvvvv (途中省略) TASK [ini_set : Change the hostname to new_hostname] ******************************************************************* task path: /etc/ansible/roles/ini_set/tasks/main.yml:18 Using module file /usr/lib/python2.7/site-packages/ansible/modules/windows/win_hostname.ps1 <11.222.33.444> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5985 TO 11.222.33.444 checking if winrm_host 11.222.33.444 is an IPv6 address <11.222.33.444> WINRM CONNECT: transport=plaintext endpoint=http://11.222.33.444:5985/wsman <11.222.33.444> WINRM OPEN SHELL: B627CE20-ADDD-480A-B4F3-2E11D28CB49C EXEC (via pipeline wrapper) <11.222.33.444> WINRM EXEC 'PowerShell' ['-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Unrestricted', '-'] <11.222.33.444> WINRM RESULT u'<Response code 0, out "{"changed":true,"old", err "">' <11.222.33.444> WINRM CLOSE SHELL: B627CE20-ADDD-480A-B4F3-2E11D28CB49C changed: [ec2-11-222-33-444.ap-northeast-1.compute.amazonaws.com] => { "changed": true, "old_name": "WIN-G9P8SPSN37M", "reboot_required": true } TASK [ini_set : Reboot] ************************************************************************************************ task path: /etc/ansible/roles/ini_set/tasks/main.yml:23 skipping: [ec2-11-222-33-444.ap-northeast-1.compute.amazonaws.com] => { "changed": false, "skip_reason": "Conditional result was False" } <11.222.33.444> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5985 TO 11.222.33.444 checking if winrm_host 11.222.33.444 is an IPv6 address <11.222.33.444> WINRM CONNECT: transport=plaintext endpoint=http://11.222.33.444:5985/wsman <11.222.33.444> WINRM OPEN SHELL: EC7761B5-D68A-4676-A865-78B579B5E212 EXEC (via pipeline wrapper) <11.222.33.444> WINRM EXEC 'PowerShell' ['-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Unrestricted', '-EncodedCommand', u'KABHAGUAdAAtAFcAbQBpAE8AYgBqAGUAYwB0ACAALQBDAGwAYQBzAHMATgBhAG0AZQAgAFcAaQBuADMAMgBfAE8AcABlAHIAYQB0AGkAbgBnAFMAeQBzAHQAZQBtACkALgBMAGEAcwB0AEIAbwBvAHQAVQBwAFQAaQBtAGUA'] <11.222.33.444> WINRM RESULT u'<Response code 0, out "20180724105429.49088", err "">' rebooting server EXEC (via pipeline wrapper) <11.222.33.444> WINRM EXEC 'PowerShell' ['-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Unrestricted', '-EncodedCommand', u'cwBoAHUAdABkAG8AdwBuACAALwByACAALwB0ACAAMgAgAC8AYwAgACIAUgBlAGIAbwBvAHQAIABpAG4AaQB0AGkAYQB0AGUAZAAgAGIAeQAgAEEAbgBzAGkAYgBsAGUALgAiAA=='] <11.222.33.444> WINRM RESULT u'<Response code 0, out "", err "">' attempting to get system uptime attempting to get system uptime attempting to get system uptime ・ ・ ※「attempting to get system uptime」が続く ・ attempting to get system uptime attempting to get system uptime attempting to get system uptime <inventory_hostname> WINRM CLOSE SHELL: EC7761B5-D68A-4676-A865-78B579B5E212 fatal: [ec2-11-222-33-444.ap-northeast-1.compute.amazonaws.com]: FAILED! => { "changed": false, "elapsed": 600, "msg": "timed out waiting for reboot uptime check success: Invalid settings supplied for _extras: Requested option _extras was not defined in configuration", "rebooted": true } META: ran handlers PLAY RECAP ************************************************************************************************************* ec2-11-222-33-444.ap-northeast-1.compute.amazonaws.com : ok=5 changed=4 unreachable=0 failed=1
この後、対象のサーバーにリモートデスクトップログインしてみると、hostname は意図したものに変更されていました。
処理としてはFatalになっているので、上記の「attempting to get system uptime」を回避したいのですが、その方法がわからず…。
足りない情報は追記していきますので、よろしくお願いします。

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。