LoginSignup
4
2

More than 5 years have passed since last update.

X.X.X.X | FAILED => failed to transfer file to の解決

Posted at

はじめに

  • VMにAnsibleで環境構築しようと思ったら、エラーが出た。
  • 合計1時間くらい格闘(ちょっと勘違いしていたのもあり)して、解決したのでメモ

エラー

$ ansible -i .ansible/hosts -u hogehoge machines -m command -a "uptime" -vvvv
<snip>
<X.X.X.X> PUT /var/folders/sq/4z9p9_lj6pv0dy28dmg4lch00000gn/T/tmpA6scow TO /home/hogehoge/.ansible/tmp/ansible-tmp-1451955543.98-160272147550416/command
X.X.X.X | FAILED => failed to transfer file to /home/hogehoge/.ansible/tmp/ansible-tmp-1451955543.98-160272147550416/command:

Connection closed

原因

  • はじめは、SSH周りの設定ミスかと思って、鍵とか、IPアドレスとか、ユーザ名とか基本的なところはチェック。しても解決しない。
  • ちょっとまじめに検索したら、stackoverflowを発見。
  • ssh_configの設定で、sftpが無効になってる場合のエラーの様子。この前立てたVMはデフォルトで有効になっていたのに、今回のVMは無効になってた模様。。これは気づきにくい。。

対処

  • stackoverflowのとおり、ansible.cfgで、sftpではなく、scpを利用するように編集して、再実行して成功した。
$ vi .ansible.cfg
<snip>
[ssh_connection]
scp_if_ssh=True

$ ansible -i .ansible/hosts -u hogehoge machines -m command -a "uptime" -vvvv

おわりに

  • ansibleはなぜかハマりやすいな…
4
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
2