Amazon-Web-Services

Cloud Init 中的 AWS Userdata 腳本未執行

  • June 7, 2017

在嘗試使用 AWSuserdata選項在實例啟動時執行腳本時,我注意到有時(並非總是)云初始化部分卡在中間某處,並且沒有到達執行使用者腳本的部分。

這是它在/var/log/cloud-init-output.log文件中的外觀:

Cloud-init v. 0.7.5 running 'init-local' at Tue, 30 May 2017 06:38:40 +0000. Up 18.56 seconds.
Cloud-init v. 0.7.5 running 'init' at Tue, 30 May 2017 06:38:45 +0000. Up 23.39 seconds.
SOME_NETWORK_AND_SSH_KEYS_INFO_HERE
Cloud-init v. 0.7.5 running 'modules:config' at Tue, 30 May 2017 06:38:51 +0000. Up 28.80 seconds.
Generating locales...
 en_US.UTF-8... up-to-date
Generation complete.
Cloud-init v. 0.7.5 running 'modules:final' at Tue, 30 May 2017 06:39:35 +0000. Up 73.20 seconds.
MY_USERDATA_SCRIPT_OUTPUT_HERE

但這是卡住時的樣子:

Cloud-init v. 0.7.5 running 'init-local' at Tue, 30 May 2017 06:36:43 +0000. Up 21.80 seconds.
Cloud-init v. 0.7.5 running 'init' at Tue, 30 May 2017 06:36:51 +0000. Up 30.13 seconds.
SOME_NETWORK_AND_SSH_KEYS_INFO_HERE
Cloud-init v. 0.7.5 running 'modules:config' at Tue, 30 May 2017 06:36:59 +0000. Up 37.66 seconds.
Generating locales...
 en_US.UTF-8... up-to-date
Generation complete.

如您所見,它卡在 the 之後,僅此Generation complete而已。

知道什麼會導致它以及我應該如何減輕它?

順便說一句,作業系統是 Ubuntu 14.04

所以問題是另一個被設置為在同一執行級別執行的不相關腳本被卡住了,這導致整個執行級別在開始下一個級別之前等待它完成(其中 module:final 是在)。

一旦我們修復了該腳本,問題就消失了。

引用自:https://serverfault.com/questions/852946