LoginSignup
10
10

More than 5 years have passed since last update.

Raspberry Piの初期設定をAnsible on Macでやる

Last updated at Posted at 2015-01-22

久しぶりにやると完全に忘れているので備忘録。なお、この記事で扱うのはpingが通るところまでです。

/etc/hosts on Mac

名前を付ける:

/etc/hosts
192.168.2.3     weed-raspbmc

ちなみに私はMacを「インターネット共有」させて、イーサネットケーブルでMacとRaspberry Piをつなげています。Mac側のIPアドレスを「手動で設定」で「192.168.2.1」にすると、ぶら下がるマシンにはIPアドレス「192.168.2.2」、「192.168.2.3」・・・と順番に割り振られます。

hostsを反映させる:

$ dscacheutil -flushcache

ssh on Mac

raspbmcにsshするときはユーザはpiであることを設定する:

.ssh/config
Host weed-raspbmc
        User pi
        Hostname 192.168.2.3

鍵を作って転送する等:

ubuntu at u-aizu | SSHを使ってパスワードなしで接続

ただし、鍵をRaspberry Piに送るには以下のようにする:

$ scp ~/.ssh/id_dsa.pub pi@192.168.2.3:~/

Ansible on Mac

MacにAnsibleを入れるやり方は以下の生地^H^H記事が丁寧です:

Ansible使ってVagrantのゲストOSの構成管理する【Playbook: jenkins, node.js】 - yutaponのブログ

無事Ansibleをインストールできたら、プロジェクトフォルダにhostsというファイルを作る:

hosts
[target]
weed-raspbmc

ここでIPアドレスを指定するとユーザpiでログインしてくれず、Ansibleが動かない。

最後にpingする:

$ ansible -i hosts servers -m ping

うまくいけばpongと返ってくる:

weed-raspbmc | success >> {
    "changed": false, 
    "ping": "pong"
}

ブログやってます:Weed software

10
10
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
10
10