Skip to content

Commit

Permalink
First steps in a possible testing and programming rig. Part of #15
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian McEwen committed Mar 10, 2021
1 parent e7802d1 commit 639a1ff
Show file tree
Hide file tree
Showing 10 changed files with 138 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tap-rig/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Test and Programming Rig

A set-up for a Raspberry Pi plus a jig with pogo pins to make it easier to flash and test a My Baby's Got LED board.

## Steps:

1. Install [Ansible](https://www.ansible.com/get-started) on your computer
1. Install the latest [Raspbian lite image](https://www.raspberrypi.org/downloads/raspbian/) onto a micro-SD card
1. Create a file called `ssh` on the `/boot` partition of the SD card. The contents don't matter, it's just to enable the SSH server. E.g. on Ubuntu `touch /media/myusername/boot/ssh`
1. Boot the Raspberry Pi with the micro-SD card, while plugged into a network via Ethernet
1. Find out the IP address of the Raspberry Pi
* Use nmap (eg: `nmap -p 22 192.168.0.* --open`), router or monitor to find IP address of Pi once booted.
1. Copy your SSH credentials onto the Pi
```ssh-copy-id pi@<ip-address-of-the-pi>```
1. Edit the ```hosts``` file so ansible knows which computer to configure. Change the IP address in it to match the one you just found out.
1. Check you can run commands on the Pi using Ansible
```ansible test-rig -i hosts -a "hostname" -u pi```
1. Update the Pi, using the playbook you customised in the last step, e.g.
```ansible-playbook test-and-programming-rig.yml -i hosts```

2 changes: 2 additions & 0 deletions tap-rig/hosts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[test-rig]
192.168.1.72
16 changes: 16 additions & 0 deletions tap-rig/roles/nm-wireless/defaults/example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# UUIDs generated with uuidgen

FirstNetwork:
SSID: one-network-name
password: PASSWORD-FOR-WIFI
UUID: 28dfb545-0eb1-4bf0-9a79-ebff4e1bc08b

SecondNetwork:
SSID: AnotherNetworkName
password: PASSWORD-FOR-THIS-WIFI
UUID: 7830f565-ed75-4f94-9e72-e52cb5f4cd28

wifi_networks:
- "{{ FirstNetwork }}"
- "{{ SecondNetwork }}"

3 changes: 3 additions & 0 deletions tap-rig/roles/nm-wireless/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
- name: Restart network-manager
service: name=network-manager state=restarted
18 changes: 18 additions & 0 deletions tap-rig/roles/nm-wireless/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Configure wireless settings for network-manager
# Assumes the network(s) to be configured are listed in the variable wifi_networks.
# For an example, see defaults/example.yml.
# Copy that into vars/main.yml and modify it for the easiest way to set things up
---
- name: Ensure network-manager is installed
apt: name=network-manager state=present update_cache=yes

- name: Create the connection config files
template:
src: templates/connection.j2
dest: /etc/NetworkManager/system-connections/{{ item.SSID }}
owner: root
group: root
mode: 0600
with_items: "{{ wifi_networks }}"
notify:
- Restart network-manager
22 changes: 22 additions & 0 deletions tap-rig/roles/nm-wireless/templates/connection.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[connection]
id={{ item.SSID }}
uuid={{ item.UUID }}
type=wifi
autoconnect=true
#interface-name=wlxfcb4e6bfab85
permissions=

[wifi]
mode=infrastructure
ssid={{ item.SSID }}

[wifi-security]
key-mgmt=wpa-psk
auth-alg=open
psk={{ item.password }}

[ipv4]
method=auto

[ipv6]
method=auto
Empty file.
16 changes: 16 additions & 0 deletions tap-rig/roles/nm-wireless/vars/main-example.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# UUIDs generated with uuidgen

OneWifiNetwork:
SSID: mywifinetwork
password: supersecretpassword
UUID: 28dfb545-0eb1-4bf0-9a79-ebff4e1bc08b

AnotherNetwork:
SSID: AnotherNetworkName
password: differentsecretpassword
UUID: 7830f565-ed75-4f94-9e72-e52cb5f4cd28

wifi_networks:
- "{{ OneWifiNetwork }}"
- "{{ AnotherNetwork }}"

13 changes: 13 additions & 0 deletions tap-rig/roles/renamed-pi/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Change hostname (on a Raspberry Pi)
# Assumes you define the role with the name as a variable, e.g.
# vars:
# pi_name: REPLACE-THIS-WITH-THE-NAME
# roles:
# - { role: renamed-pi }
---
- name: Change Pis name
hostname: name="{{ pi_name }}"
- name: Update hosts file too
replace: dest=/etc/hosts regexp='raspberrypi' replace="{{ pi_name }}"
- name: Install mDNS so we can connect as {{ pi_name }}.local
apt: name=libnss-mdns state=present
28 changes: 28 additions & 0 deletions tap-rig/test-and-programming-rig.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
- name: My Babys Got LED Test and Programming Rig for a Raspberry Pi
hosts: test-rig
vars:
pi_name: mbgl-tap
remote_user: pi
become: yes
become_method: sudo
# Include whichever roles make sense here
roles:
- nm-wireless
# - base-nodered
# - ssh-tunnel

pre_tasks:
- name: Update apt
apt: upgrade=dist update_cache=yes
become: true

tasks:
- name: Change Pis name
hostname: name="{{ pi_name }}"
- name: Update hosts file too
replace: dest=/etc/hosts regexp='raspberrypi' replace="{{ pi_name }}"
- name: Install git
apt: name=git state=present
- name: Ready for you to customise!
debug: msg='Replace this step with the ones you need to set up the Raspberry Pi to do what you want it to do'

0 comments on commit 639a1ff

Please sign in to comment.