Skip to content

Instantly share code, notes, and snippets.



Last active Jun 13, 2018
What would you like to do?
Ansible Playbook for Configuring BeagleBone Black on Debian (wheezy) from MacOS X 10.10.x w/ setup for Edimax EW-7811Un
# 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 <>
- hosts: bbb
remote_user: root
distro: wheezy
rcn_keyring: /tmp/rcn-ee-archive-keyring.deb
wifi_reset: /tmp/wifi-reset
default_hostname: beaglebone
# To get encryption working, see
- 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
- 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: ./ 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
- name: Remove deb repo
apt_repository: update_cache=no repo='deb [arch=armhf] {{ distro }}-bbb main' state=absent
# seems to be the replacement for now.
- name: Retrieve keyring
get_url: url={{ rcn_keyring_url }} dest={{ rcn_keyring }} validate_certs=no
- name: Install keyring
command: dpkg -i {{ rcn_keyring }}
- name: Add deb Repo
apt_repository: update_cache=no repo='deb [arch=armhf] {{ 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] {{ distro }} main'
- name: Add Nodesource deb-src Repo
apt_repository: update_cache=no repo='deb-src [arch=armf] {{ distro }} main'
- name: Add Nodesource Key
apt_key: url=
# 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
- name: Clone WiFi Reset Service
git: repo= dest={{ wifi_reset }}
- name: Install WiFi Reset Service
command: bash ./ 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"
- 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/') }}"
- 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
auto wlan0
iface wlan0 inet dhcp
wpa-ssid "YOUR NETWORK"
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
You can’t perform that action at this time.