Compare commits
5 commits
Author | SHA1 | Date | |
---|---|---|---|
Michael Hope | 17b185e58b | ||
Michael Hope | a8d83547f1 | ||
Michael Hope | 50136ca9f0 | ||
Michael Hope | 2b61618f08 | ||
Michael Hope | 9e7758603e |
12
README.md
12
README.md
|
@ -2,15 +2,11 @@
|
||||||
|
|
||||||
* Copy `/boot/*` to `/boot` on the SD card
|
* Copy `/boot/*` to `/boot` on the SD card
|
||||||
* Edit `/boot/wpa_supplicant.conf` for your network
|
* Edit `/boot/wpa_supplicant.conf` for your network
|
||||||
* Boot the pi
|
* Boot the pi, log in
|
||||||
* Create `hosts`
|
* `sudo apt update && sudo apt install ansible git`
|
||||||
|
* Run the playbook `ansible-pull --purge -C dev -U https://juju.nz/src/juju/pibase.git`
|
||||||
[pis]
|
|
||||||
192.168.0.222
|
|
||||||
|
|
||||||
* Run the playbook `ansible-playbook -i hosts -k playbook.yml`
|
|
||||||
|
|
||||||
# Note
|
# Note
|
||||||
This is not an official Google product.
|
This is not an official Google product.
|
||||||
|
|
||||||
-- Michael Hope <michaelh@juju.net.nz> <mlhx@google.com>
|
-- Michael Hope <michaelh@juju.nz> <mlhx@google.com>
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
---
|
---
|
||||||
- name: Ansible Playbook for configuring brand new Raspberry Pi
|
- name: Ansible Playbook for configuring brand new Raspberry Pi
|
||||||
hosts: pis
|
hosts: localhost
|
||||||
|
user: root
|
||||||
|
connection: local
|
||||||
vars:
|
vars:
|
||||||
- wlan: wlan0
|
- wlan: wlan0
|
||||||
- hostid: "{{ansible_ssh_host_key_rsa_public | hash('sha1') | regex_replace('(...).*', '\\1')}}"
|
- hostid: "{{ansible_ssh_host_key_rsa_public | hash('sha1') | regex_replace('(...).*', '\\1')}}"
|
||||||
- user: juju
|
- user: juju
|
||||||
roles:
|
roles:
|
||||||
- pi
|
- pi
|
||||||
remote_user: pi
|
|
||||||
become: yes
|
|
|
@ -2,20 +2,20 @@
|
||||||
- name: Set the hostname
|
- name: Set the hostname
|
||||||
hostname: name="pi-{{hostid}}"
|
hostname: name="pi-{{hostid}}"
|
||||||
- name: Put the hostname in /etc/hosts
|
- 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}}
|
- name: Add the user {{user}}
|
||||||
user:
|
user:
|
||||||
name: "{{user}}"
|
name: "{{user}}"
|
||||||
# TODO(michaelh): change to a public password
|
password: '*'
|
||||||
password: '$6$3/nNUZfJvg9V9$9OkDm4wO25wyuNJq0Iw3Pw15uCmcUoLBkq/8C0HuRR2vRtrcJVXU6VU6k0d9/gSCWkoEBNDAkHAubZ.wrT43H.'
|
|
||||||
groups: sudo,dialout,video,audio
|
groups: sudo,dialout,video,audio
|
||||||
state: present
|
state: present
|
||||||
|
update_password: on_create
|
||||||
- name: Set authorized keys for pi and {{user}}
|
- name: Set authorized keys for pi and {{user}}
|
||||||
authorized_key:
|
authorized_key:
|
||||||
user: "{{ item }}"
|
user: "{{ item }}"
|
||||||
state: present
|
state: present
|
||||||
# TODO(michaelh): pull the invoking users public key
|
# TODO(michaelh): make configurable
|
||||||
key: "{{ lookup('file', '/home/michaelh/.ssh/id_rsa.pub') }}"
|
key: https://juju.nz/src/michaelh.keys
|
||||||
with_items:
|
with_items:
|
||||||
- "{{ user }}"
|
- "{{ user }}"
|
||||||
- pi
|
- pi
|
||||||
|
@ -28,7 +28,7 @@
|
||||||
- pi
|
- pi
|
||||||
- "{{ user }}"
|
- "{{ user }}"
|
||||||
- name: Modify config.txt
|
- name: Modify config.txt
|
||||||
lineinfile: path=/boot/config.txt line={{ item }}
|
lineinfile: name=/boot/config.txt line={{ item }}
|
||||||
with_items:
|
with_items:
|
||||||
- "gpu_mem=16"
|
- "gpu_mem=16"
|
||||||
- "hdmi_mode=1"
|
- "hdmi_mode=1"
|
||||||
|
@ -36,12 +36,13 @@
|
||||||
- "disable_splash=1"
|
- "disable_splash=1"
|
||||||
- name: Disable docs and man pages
|
- name: Disable docs and man pages
|
||||||
template: src=01-nodoc dest=/etc/dpkg/dpkg.cfg.d/01-nodoc
|
template: src=01-nodoc dest=/etc/dpkg/dpkg.cfg.d/01-nodoc
|
||||||
- include: i2c.yml
|
|
||||||
- include: swap.yml
|
|
||||||
- name: Update the package cache
|
- name: Update the package cache
|
||||||
action: apt update_cache=yes cache_valid_time=3600
|
action: apt update_cache=yes cache_valid_time=3600
|
||||||
- name: Install the basics
|
- name: Install the basics
|
||||||
apt: name=jed,git,psmisc,unzip,f2fs-tools,python3
|
apt: name=jed,git,psmisc,unzip,f2fs-tools,python3
|
||||||
- name: Install the dev bits
|
- name: Install the dev bits
|
||||||
apt: name=build-essential,man,manpages-posix-dev,ack-grep,screen,f2fs-tools
|
apt: name=build-essential,man,manpages-posix-dev,ack-grep,screen
|
||||||
- include: node_exporter.yml
|
- name: Install node-exporter
|
||||||
|
apt: name=prometheus-node-exporter
|
||||||
|
- name: Remove the extras
|
||||||
|
apt: name=lightdm,triggerhappy,gvfsd,bluealsa,exim4-base,chromium state=absent
|
||||||
|
|
|
@ -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
|
|
|
@ -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>
|
|
|
@ -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
|
|
Loading…
Reference in a new issue