エラー内容
================================================================================
Error executing action `add` on resource 'apt_repository[node.js]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
execute[install-key 1655a0ab68576280] (/var/chef/cache/cookbooks/apt/providers/repository.rb line 28) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '2'
---- Begin output of apt-key adv --keyserver keyserver.ubuntu.com --recv 1655a0ab68576280 ----
STDOUT: Executing: gpg --ignore-time-conflict --no-options --no-default-keyring --secret-keyring /tmp/tmp.yuuCkD6HSP --trustdb-name /etc/apt/trustdb.gpg --keyring /etc/apt/trusted.gpg --primary-keyring /etc/apt/trusted.gpg --keyring /etc/apt/trusted.gpg.d//zabbix-official-repo.gpg --keyserver keyserver.ubuntu.com --recv 1655a0ab68576280
STDERR: gpg: requesting key 68576280 from hkp server keyserver.ubuntu.com
gpg: keyserver timed out
gpg: keyserver receive failed: keyserver error
---- End output of apt-key adv --keyserver keyserver.ubuntu.com --recv 1655a0ab68576280 ----
Ran apt-key adv --keyserver keyserver.ubuntu.com --recv 1655a0ab68576280 returned 2
原因
gpgコマンドはデフォルトで11371番ポート使用するのですが、chef-clientを実行したサーバの11371番ポートが空いていなかったせいで、インストールが失敗しました。
解決方法
chefのroleの設定ファイルで、nodejsのkeyserverを「hkp://keyserver.ubuntu.com:80」に変更します。
# roles/my-role.json
{
"name": "my-role",
"default_attributes": {
"nodejs": {
"keyserver": "hkp://keyserver.ubuntu.com:80"
}
},
"json_class": "Chef::Role",
"description": "",
"chef_type": "role",
"run_list": [
"recipe[nodejs]"
]
}