9
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ansibleで踏み台を突破する

9
Posted at
# 踏み台
Host step
  HostName xxx.xxx.xxx.xxx
  User xyz
  IdentityFile ~/.ssh/id_rsa
# 踏み台経由でslogin(ssh)するホスト
Host ip-10-0-0-100
  HostName 10.0.0.100
  ProxyCommand ssh -W %h:%p step
  User ubuntu
  IdentityFile ~/.ssh/aws.pem

~/.ssh/configで書くと上記の様な場合、ansibleをip-10-0-0-100で実行するにはどうするか?

ansibleのinventoryをhostsと言う名前で用意しておいて

cat hosts
...
[host]
10.0.0.100
10.0.0.101
...

ansible-playbookを実行する例

export ANSIBLE_SSH_ARGS="-o ProxyCommand=\"ssh -W %h:%p step\" -o User=ubuntu -o StrictHostKeyChecking=no"
ansible-playbook -i hosts example.yml -l 10.0.0.100 --private-key=~/.ssh/aws.pem
9
13
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
9
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?