LoginSignup
3
1

More than 5 years have passed since last update.

macで Ansibleを使ってパスワード認証方式で ssh接続する

Last updated at Posted at 2017-09-07

少し工夫がいりましたのでメモ

1. sshpassのインストール

$ brew install ansible
$ brew install http://git.io/sshpass.rb

2. ansible.cfgファイルの設定

ubuntuでは/etc/ansible/ansible.cfgに書くらしいが、macには無いので~/.ansible.cfgに書けば良いらしい

$ nano ~/.ansible.cfg
.ansible.cfg
[ssh_connection]
ssh_args = -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null

書込む内容はこちらを参考にしました

[option]動作確認

$ cat hosts 

[child]
192.168.11.[111:112] ansible_ssh_user=pi ansible_ssh_pass=raspberry
$ ansible -i hosts child -m ping

192.168.11.112 | SUCCESS => {
    "changed": false, 
    "ping": "pong"
}
192.168.11.111 | SUCCESS => {
    "changed": false, 
    "ping": "pong"
}
3
1
2

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