Skip to content

Latest commit

 

History

History

iot-edge-with-ansible

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

Introduction

This is a set of Ansible scripts which automate installation of Azure IoT Edge.

The scripts are based on the original guide here.

Assumptions

It is assumed that:

  • The IP address of the target machine is placed in the file inventory in the main directory of this cloned repository
  • SSH server is installed and accessible from outside of the target machine
  • Your public SSH key was copied to the target machine (see here for details)

Here is an example inventory file if you decide to use the included Vagrantfile:

machine ansible_ssh_host=127.0.0.1 ansible_ssh_port=2222 ansible_ssh_user='vagrant' ansible_ssh_private_key_file='~/.vagrant.d/insecure_private_key'

Installation

First, register an Azure IoT Edge Device (here are details).

Caution: For a Raspberry Pi remember to set OptimizeForPerformance to false (see here for more details; see here for an example)

An example script to automate the above steps can be found here.

Then, once you have connection string, run these commands (here, assuming a Raspberry Pi as the target machine):

read -s -p "Please enter IoT Edge Device connection string: " AZURE_IOT_EDGE_CONNECTION_STRING
cd ansible
ansible-galaxy install geerlingguy.docker
ansible-galaxy install geerlingguy.docker_arm
export ANSIBLE_ROLES_PATH=$(pwd)/roles
ansible-playbook -u pi -i ../inventory --extra-vars "ansible_dir=$(pwd) ansible_ssh_user=pi azure_iot_edge_connection_string=$AZURE_IOT_EDGE_CONNECTION_STRING" books/provision.yml

Here is the variant of the last command for the included Vagrantfile:

ansible-playbook -u vagrant -i ../inventory --key-file=~/.vagrant.d/insecure_private_key --extra-vars "ansible_user=vagrant azure_iot_edge_connection_string=$AZURE_IOT_EDGE_CONNECTION_STRING" books/provision.yml

Notes

If you are working with Revolution Pi Core 3 there are additional steps to take.

  1. Download Raspbian Stretch image here
  2. Flash the image following the instructions listed here (mind that rpiboot may have issues running on Windows 7 so it is best to use Linux)
  3. The first time you SSH into the device you will have to configure the serial number and MAC - the steps are described here
  4. The image runs a web-based interface which will conflict with Azure IoT Edge, this can be disabled with the following commands (source information can be found here):
sudo systemctl stop apache2
sudo systemctl disable apache2
  1. There is also a firewall in place, to remove all restrictions run the following commands:
sudo iptables -F
sudo iptables-save | sudo tee /etc/iptables.conf