Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@boneskull
Last active June 3, 2021 11:26
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save boneskull/5ce5fcf2b2417e5b8a0b to your computer and use it in GitHub Desktop.
Save boneskull/5ce5fcf2b2417e5b8a0b to your computer and use it in GitHub Desktop.
Ansible Playbook for Configuring BeagleBone Black on Debian (wheezy) from MacOS X 10.10.x w/ setup for Edimax EW-7811Un
# CHANGELOG
# 3/22/15:
# - updated keyring
#
# To setup ansible on Mac:
# brew install ansible
# mkdir -p /usr/local/etc/ansible
# mkdir -p /usr/local/share/ansible
#
# To run:
# ansible-playbook /usr/local/share/ansible/bbb.yml -i /usr/local/etc/ansible/hosts
#
# TODO: multiple wifi network support
# TODO: automate restart of internet connection sharing between reboots
# TODO: isolate apt installs
# TODO: clone dotfiles repo
#
# Author: Christopher Hiller <chiller@badwing.com>
# http://boneskull.com
- hosts: bbb
remote_user: root
vars:
rcn_keyring_url: https://repos.rcn-ee.net/debian/pool/main/r/rcn-ee-archive-keyring/rcn-ee-archive-keyring_2015.03.12~bpo80+20150312+1_all.deb
distro: wheezy
rcn_keyring: /tmp/rcn-ee-archive-keyring.deb
wifi_reset: /tmp/wifi-reset
default_hostname: beaglebone
# To get encryption working, see http://goo.gl/ZiML6U
vars_prompt:
- name: hostname
prompt: New hostname
when: ansible_hostname == default_hostname
private: no
- name: rootpw
prompt: New root pw
private: yes
encrypt: sha512_crypt
confirm: yes
salt_size: 7
- name: username
prompt: New user name
private: no
- name: userpw
prompt: New user pw
private: yes
encrypt: sha512_crypt
confirm: yes
salt_size: 7
tasks:
- include: /usr/local/share/ansible/tasks/dhclient.yml
# to update kernel, you need a proper time due to GPG stuff
- name: Install NTP
apt: name=ntp state=present update_cache=no
# this will give us working Edimax drivers
- name: Update Kernel
command: ./update_kernel.sh chdir=/opt/scripts/tools/
- name: Restart
command: shutdown -r now "Kernel rebuilt; restarting"
async: 0
poll: 0
ignore_errors: true
- name: Wait for Restart
local_action: wait_for port=22 host={{ inventory_hostname }}
sudo: false
- include: /usr/local/share/ansible/tasks/dhclient.yml
# In order to use the Nodesource repos, we must enable https over apt.
- name: Install apt-transport-https
apt: name=apt-transport-https state=present update_cache=no force=yes
# This is no longer valid; the key expired. see http://goo.gl/bNzlEJ
- name: Remove beagleboard.org deb repo
apt_repository: update_cache=no repo='deb [arch=armhf] http://debian.beagleboard.org/packages {{ distro }}-bbb main' state=absent
# rcn-ee.net seems to be the replacement for now.
- name: Retrieve rcn-ee.net keyring
get_url: url={{ rcn_keyring_url }} dest={{ rcn_keyring }} validate_certs=no
- name: Install rcn-ee.net keyring
command: dpkg -i {{ rcn_keyring }}
- name: Add rcn-ee.net deb Repo
apt_repository: update_cache=no repo='deb [arch=armhf] http://repos.rcn-ee.net/debian {{ distro }} main'
# to upgrade NodeJS to something resembling the current version, you'll want this
- name: Add Nodesource deb Repo
apt_repository: update_cache=no repo='deb [arch=armhf] https://deb.nodesource.com/node {{ distro }} main'
- name: Add Nodesource deb-src Repo
apt_repository: update_cache=no repo='deb-src [arch=armf] https://deb.nodesource.com/node {{ distro }} main'
- name: Add Nodesource Key
apt_key: url=https://deb.nodesource.com/gpgkey/nodesource.gpg.key
# finally, we can update the package cache
- name: Update apt cache
apt: update_cache=yes cache_valid_time=120
# upgrade everything
- name: dist-upgrade
apt: upgrade=full
# I'm not sure if dist-upgrade will cause this to happen.
- name: Install NodeJS
apt: name=nodejs state=latest
# install global modules (optional)
- include: /usr/local/share/ansible/tasks/npm-global.yml
- name: Install git-extras
apt: name=git-extras state=latest
# You want this if you have a WiFi USB dongle. See http://goo.gl/AIhmTv
- name: Clone WiFi Reset Service
git: repo=https://github.com/adafruit/wifi-reset.git dest={{ wifi_reset }}
- name: Install WiFi Reset Service
command: bash ./install.sh chdir={{ wifi_reset }}
# This is the recommended config, I think (see file below). Does not support multiple networks.
- name: Copy /etc/network/interfaces
copy: src=/usr/local/share/ansible/resources/etc_network_interfaces dest=/etc/network/interfaces owner=root group=root mode=0644
# Just in case
- name: Update resolv.conf
lineinfile: dest=/etc/resolv.conf line="nameserver 8.8.8.8"
- name: Set root PW
user: name=root password={{ rootpw }}
# Adds a plain user account (but also a sudoer)
- name: Add User
user: name={{ username }} shell=/bin/bash generate_ssh_key=yes ssh_key_bits=2048 ssh_key_file=.ssh/id_rsa password={{ userpw }} append=yes groups=admin
- name: Add Authorized Keys
authorized_key: user={{ item }} key="{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
with_items:
- root
- "{{ username }}"
- name: Update Hostname
hostname: name={{ hostname }}
- name: Final Restart
command: shutdown -r now "Setup complete; restarting"
async: 0
poll: 0
ignore_errors: true
# Starts dhclient. Not necessary after setup.
- name: Get Internet
command: dhclient usb0
# The IP of beaglebone.local will have changed, so we must flush the cache.
- name: Flush Local DNS Cache
local_action: command dscacheutil -flushcache
sudo: true
auto lo
iface lo inet loopback
auto eth0
allow-hotplug eth0
iface eth0 inet dhcp
auto usb0
allow-hotplug usb0
iface usb0 inet static
address 192.168.7.2
netmask 255.255.255.0
network 192.168.7.0
gateway 192.168.7.1
auto wlan0
iface wlan0 inet dhcp
wpa-ssid "YOUR NETWORK"
wpa-psk "YOUR PASSWORD"
[bbb]
beaglebone.local ansible_ssh_user=root
# Upgrade npm to lastest version
- name: Upgrade npm
npm: name=npm global=yes
# These are just some packages I use
- name: Install grunt-cli
npm: name=grunt-cli global=yes
- name: Install nesh
npm: name=nesh global=yes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment