Compare commits

...

5 commits
master ... dev

6 changed files with 18 additions and 60 deletions

View file

@ -2,15 +2,11 @@
* Copy `/boot/*` to `/boot` on the SD card
* Edit `/boot/wpa_supplicant.conf` for your network
* Boot the pi
* Create `hosts`
[pis]
192.168.0.222
* Run the playbook `ansible-playbook -i hosts -k playbook.yml`
* Boot the pi, log in
* `sudo apt update && sudo apt install ansible git`
* Run the playbook `ansible-pull --purge -C dev -U https://juju.nz/src/juju/pibase.git`
# Note
This is not an official Google product.
-- Michael Hope <michaelh@juju.net.nz> <mlhx@google.com>
-- Michael Hope <michaelh@juju.nz> <mlhx@google.com>

View file

@ -1,11 +1,11 @@
---
- name: Ansible Playbook for configuring brand new Raspberry Pi
hosts: pis
hosts: localhost
user: root
connection: local
vars:
- wlan: wlan0
- hostid: "{{ansible_ssh_host_key_rsa_public | hash('sha1') | regex_replace('(...).*', '\\1')}}"
- user: juju
roles:
- pi
remote_user: pi
become: yes

View file

@ -2,20 +2,20 @@
- name: Set the hostname
hostname: name="pi-{{hostid}}"
- name: Put the hostname in /etc/hosts
lineinfile: path=/etc/hosts line="127.0.1.1 pi-{{hostid}}"
lineinfile: name=/etc/hosts line="127.0.1.1 pi-{{hostid}}"
- name: Add the user {{user}}
user:
name: "{{user}}"
# TODO(michaelh): change to a public password
password: '$6$3/nNUZfJvg9V9$9OkDm4wO25wyuNJq0Iw3Pw15uCmcUoLBkq/8C0HuRR2vRtrcJVXU6VU6k0d9/gSCWkoEBNDAkHAubZ.wrT43H.'
password: '*'
groups: sudo,dialout,video,audio
state: present
update_password: on_create
- name: Set authorized keys for pi and {{user}}
authorized_key:
user: "{{ item }}"
state: present
# TODO(michaelh): pull the invoking users public key
key: "{{ lookup('file', '/home/michaelh/.ssh/id_rsa.pub') }}"
# TODO(michaelh): make configurable
key: https://juju.nz/src/michaelh.keys
with_items:
- "{{ user }}"
- pi
@ -28,7 +28,7 @@
- pi
- "{{ user }}"
- name: Modify config.txt
lineinfile: path=/boot/config.txt line={{ item }}
lineinfile: name=/boot/config.txt line={{ item }}
with_items:
- "gpu_mem=16"
- "hdmi_mode=1"
@ -36,12 +36,13 @@
- "disable_splash=1"
- name: Disable docs and man pages
template: src=01-nodoc dest=/etc/dpkg/dpkg.cfg.d/01-nodoc
- include: i2c.yml
- include: swap.yml
- name: Update the package cache
action: apt update_cache=yes cache_valid_time=3600
- name: Install the basics
apt: name=jed,git,psmisc,unzip,f2fs-tools,python3
- name: Install the dev bits
apt: name=build-essential,man,manpages-posix-dev,ack-grep,screen,f2fs-tools
- include: node_exporter.yml
apt: name=build-essential,man,manpages-posix-dev,ack-grep,screen
- name: Install node-exporter
apt: name=prometheus-node-exporter
- name: Remove the extras
apt: name=lightdm,triggerhappy,gvfsd,bluealsa,exim4-base,chromium state=absent

View file

@ -1,13 +0,0 @@
---
- name: Install node-exporter
# TODO(michaelh): this is a hack. Remove once Raspbian adds node-exporter.
unarchive:
src: https://github.com/prometheus/node_exporter/releases/download/v0.14.0/node_exporter-0.14.0.linux-armv6.tar.gz
dest: /usr/local/lib
remote_src: yes
- name: Install the node-exporter service file
template: src=node-exporter.service dest=/etc/systemd/system/node-exporter.service
- name: Install the node-exporter DNS-SD file
template: src=node-exporter.avahi.service dest=/etc/avahi/services/node-exporter.service
- name: Enable node-exporter
systemd: name=node-exporter.service enabled=yes state=started

View file

@ -1,12 +0,0 @@
<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<service-group>
<name replace-wildcards="yes">%h</name>
<service>
<type>_node-exporter._tcp</type>
<port>9100</port>
</service>
</service-group>

View file

@ -1,14 +0,0 @@
[Unit]
Description=Prometheus exporter for machine metrics
Documentation=https://github.com/prometheus/node_exporter
[Service]
Restart=always
User=nobody
ExecStart=/usr/local/lib/node_exporter-0.14.0.linux-armv6/node_exporter $ARGS
ExecReload=/bin/kill -HUP $MAINPID
TimeoutStopSec=20s
SendSIGKILL=no
[Install]
WantedBy=multi-user.target