Skip to content

Deployment with Ansible

Oren Lederman edited this page Oct 11, 2016 · 6 revisions

We provide an Ansible playbook that can be used for deploying the (python) hubs.

Setup master server

  • generate a key that will be used

    • Example: ssh-keygen -t rsa -b 2048 -C "badgepi-key" -f badgepi-key
    • You get two files:
      • badgepi-key - this one you keep on the man server
      • badgepi-key.pub - this goes to the hub
  • Install ansible:

sudo pip install ansible
sudo mkdir -p /etc/ansible
  • Add your servers to ansible config file (sudo vi /etc/ansible/hosts):
[pi]
hub1 ansible_user=pi ansible_private_key_file=/path_to/badgepi-key.pub
hub2 ansible_user=pi ansible_private_key_file=/path_to/badgepi-key.pub
  • Create an .env file to be sent to the hubs. Set your server ip address, etc:
sudo mkdir /etc/ansible/openbadge-hub-py
sudo touch /etc/ansible/openbadge-hub-py/.env
sudo chmod a+w /etc/ansible/openbadge-hub-py/.env
echo "BADGE_SERVER_ADDR=1.1.1.1" > /etc/ansible/openbadge-hub-py/.env 
echo "BADGE_SERVER_PORT=8000" >> /etc/ansible/openbadge-hub-py/.env
  • Prepare you hubs (see below)

  • go to openbadge/playbook and run: ansible-playbook main.yml

Configure hubs

  • Download the Raspbian lite (2016-05-27-raspbian-jessie-lite.img) and install. Instructions can be found here. In linux:
    • unmount volumes
    • sudo dd bs=4M if=2016-09-23-raspbian-jessie-lite.img of=/dev/mmcblk0
    • sync
  • Connect to raspberry pi and run config tool: sudo raspi-config
    • Change hostname (badgepi-xx)
    • Change password
    • Expand space
  • sudo apt-get update
  • sudo apt-get upgrade
  • sudo dpkg-reconfigure tzdata
  • Put keys on hub (run these command on the main server). For example:
scp badgepi-key.pub pi@hub1:.ssh/authorized_keys
ssh pi@hub1 "chmod 550 .ssh; chmod 600 .ssh/authorized_keys"
Clone this wiki locally