CircleCIでPHPのプロジェクトをDeployerを使用してデプロイメントしようとすると、下記のエラーが出る場合があります。
Deploying master on 11.22.33.44
done on [11.22.33.44]
Executing task deploy:prepare
[11.22.33.44] > echo $0
[11.22.33.44] < ssh multiplexing initialization
The authenticity of host '11.22.33.44 (11.22.33.44)' can't be established.
ECDSA key fingerprint is SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
Are you sure you want to continue connecting (yes/no)? Build timed out
これは、CircleCIのサーバからデプロイ先サーバにSSH接続が初めてとなる時、接続先確認のプロンプト(Are you sure you want to continue connecting (yes/no))が出ているにも関わらず、yesの入力が行えないためです。
解決方法
この問題を解決するためには、Deployerの設定ファイルであるdeploy.phpの設定を変更します。
以下のようにhost定義に対して、addSshOption('StrictHostKeyChecking', 'no');のメソッド呼び出しを行うことで、初めてSSH接続するサーバに対しても、確認のプロンプトが出ないようになり、結果として自動のデプロイメントが行えるようになります。
# 変更前
host('11.22.33.44')->set('deploy_path', '/path/to/dest');
# 変更後
host('11.22.33.44')
->set('deploy_path', '/path/to/dest');
->addSshOption('StrictHostKeyChecking', 'no');
inventory()メソッドを使っている場合
inventory()メソッドを使って、サーバの接続先を管理している場合は、以下のようにyamlファイルへsshOptionsの定義を追加すれば良いです。
deploy.php
inventory('setting.yml');
setting.yml
production:
hostname: 11.22.33.44
user: ec2-user
sshOptions:
StrictHostKeyChecking: no
...
こちらもおススメ