1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Ansible + Bastion(踏み台) + rsyncでStrictHostKeyChecking=noを実現する方法

1
Last updated at Posted at 2026-04-10

はじめに

状況

AnsibleでBastion(踏み台)経由でrsync(ansible.builtin.synchronize)を使用してファイルをデプロイしたいが、なぜかrsyncの段階でHost Key Verification Failedになってタスクが進行しなくなる。

やったこと

  • ansible.cfg
    • ssh_connection
      • ssh_args = -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/nullを入れる
    • defaults
      • host_key_checking = Falseを入れる
  • ansible_ssh_common_args
    • -JProxyJumpなどの踏み台オプションを使用する
  • ansible.builtin.synchronize
    • use_ssh_args: yesを入れる
    • rsync_optsに各種sshオプションを追加する

しかし、いずれも効果なし

解決方法

all.yml
ansible_ssh_common_args: >-
  -o ProxyCommand="ssh -i {{ ansible_ssh_private_key_file}} -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null {{ bastion_username }}@{{ bastion_host }} -W %h:%p"
task.yml
- name: rsyncする
  ansible.builtin.synchronize:
    src: "{{ srcpath }}"
    dest: "{{ destpath }}"
    recursive: yes
    compress: yes
    use_ssh_args: yes

とすることで、ホスト鍵検証をrsyncでも無効化出来ました。
どうも-JProxyJumpではrsyncまでオプションがちゃんと渡らないみたいです。

1
0
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
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?