-
Notifications
You must be signed in to change notification settings - Fork 0
Add a new CHIP
Ansible seems to be the right way to do this.
Some additional references:
- [Good RPi Ansible Example] (https://github.com/Condla/ansible-playground/tree/master/raspbian-bootstrap)
- [Good Ansible tutorial] (https://serversforhackers.com/an-ansible-tutorial)
We need to setup password-less ssh like this or this. The process involves:
-
Generate ssh keys if you don't have them:
ssh-keygen -t rsa
-
If you see two files called "id_rsa" when you run:
ls -l ~/.ssh
-
Copy your public ssh key (from the controller computer) to all hosts, one by one; easiest way is to install ssh-copy-id with brew and run it:
brew install ssh-copy-id
ssh-copy-id [email protected]
-
Install Ansible:
brew install ansible
To setup wifi, we have to first connect to the CHIP over USB, and tell it what network to use.
NOTE: don't mess with /etc/network/interfaces like it says some places on the net..
Use this to connect to your chip for the first time, before networking is setup:
- connect chip to computer with USB; Important to use a "good" USB cable, not one that's only for charging.
- open terminal on computer, and run
ls /dev/tty*
- look for the item that has a name that's different than the others (!), usually
tty.usbmodem...
- in computer's terminal, type 'screen /dev/tty.usbmodem...', where the 'tty.usbmodem...' is whatever you saw in step 3.
-
list all connections:
sudo nmcli co
-
list all available networks:
nmcli device wifi list
-
connect to a wifi network; will reconnect to it on reboot:
nmcli device wifi connect '(your wifi network name/SSID)' password '(your wifi password)' ifname wlan0
-
in our case with network called "Chipchestra" with password "jengajenga", it would be:
nmcli device wifi connect 'Chipchestra' password 'jengajenga' ifname wlan0
- Edit the file called "hosts" to your new chip
[chipchestra]
chip1 ansible_ssh_host=192.168.1.101 ansible_ssh_user=root ansible_ssh_pass=chip host_key_checking=false
chip4 ansible_ssh_host=192.168.1.104 ansible_ssh_user=root ansible_ssh_pass=chip host_key_checking=false
This creates a "group" called chipchestra
with two hosts called chip1
and chip4
; IP address and login credentials follow
-
Ping all servers in "Chipchestra" group:
ansible chipchestra -m ping
-
Execute shell command on all hosts:
ansible chipchestra -s -m shell -a 'ls -l'
-
Use RSync to synchronize a folder on the controller computer with one on remote hosts:
ansible chipchestra -m synchronize -a "src=/Users/ali/Documents/Development/chip-party/chip-ansible/files/pd-patches dest=/samba-share/"
- Run a playbook from the controller computer:
ansible-playbook playbook.yml