質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Ansible

Ansibleは、Python で書かれたサーバーの設定を管理するための 構成管理ツールです。

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

Q&A

解決済

1回答

1215閲覧

Ansible:playbookで指定したサーバ再起動を正常処理したい

th0167

総合スコア12

Ansible

Ansibleは、Python で書かれたサーバーの設定を管理するための 構成管理ツールです。

AWS(Amazon Web Services)

Amazon Web Services (AWS)は、仮想空間を機軸とした、クラスター状のコンピュータ・ネットワーク・データベース・ストーレッジ・サポートツールをAWSというインフラから提供する商用サービスです。

0グッド

0クリップ

投稿2018/07/24 05:17

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」を回避したいのですが、その方法がわからず…。

足りない情報は追記していきますので、よろしくお願いします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

自己解決

このGithubページに記載していましたが、ansible 2.6.1 の不具合だった様です。
こちらのページを参考に、2.6.2 にアップグレードしたら解決しました。

$ sudo pip uninstall ansible $ sudo pip install ansible\==2.6.2 $ ansible --version ansible 2.6.2
# ansible-playbook -l windows site.yml -vvvvv (途中省略) TASK [ini_set : Reboot] ************************************************************************************************ task path: /etc/ansible/roles/ini_set/tasks/main.yml:37 [WARNING]: Since Ansible 2.5, shutdown_timeout_sec is no longer used with win_reboot <11.222.33.444> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5985 TO 11.222.33.444 EXEC (via pipeline wrapper) rebooting server EXEC (via pipeline wrapper) attempting to get system uptime <11.222.33.444> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5985 TO 11.222.33.444 EXEC (via pipeline wrapper) attempting to get system uptime <11.222.33.444> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5985 TO 11.222.33.444 EXEC (via pipeline wrapper) attempting to get system uptime <11.222.33.444> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5985 TO 11.222.33.444 EXEC (via pipeline wrapper) attempting to get system uptime <11.222.33.444> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5985 TO 11.222.33.444 attempting to get system uptime <11.222.33.444> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5985 TO 11.222.33.444 attempting to get system uptime <11.222.33.444> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5985 TO 11.222.33.444 attempting to get system uptime <11.222.33.444> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5985 TO 11.222.33.444 attempting to get system uptime <11.222.33.444> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5985 TO 11.222.33.444 attempting to get system uptime <11.222.33.444> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5985 TO 11.222.33.444 attempting to get system uptime <11.222.33.444> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5985 TO 11.222.33.444 attempting to get system uptime <11.222.33.444> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5985 TO 11.222.33.444 attempting to get system uptime <11.222.33.444> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5985 TO 11.222.33.444 attempting to get system uptime <11.222.33.444> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5985 TO 11.222.33.444 EXEC (via pipeline wrapper) <11.222.33.444> ESTABLISH WINRM CONNECTION FOR USER: Administrator on PORT 5985 TO 11.222.33.444 attempting post-reboot test command 'whoami' EXEC (via pipeline wrapper) changed: [ec2-11-222-33-444.ap-northeast-1.compute.amazonaws.com] => { "changed": true, "elapsed": 43, "rebooted": true } META: ran handlers META: ran handlers PLAY RECAP ************************************************************************************************************* ec2-11-222-33-444.ap-northeast-1.compute.amazonaws.com : ok=9 changed=4 unreachable=0 failed=0

投稿2018/07/30 06:24

th0167

総合スコア12

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問