This is a set of Ansible scripts which automate installation of Azure IoT Edge.
The scripts are based on the original guide here.
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'
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
If you are working with Revolution Pi Core 3 there are additional steps to take.
- Download Raspbian Stretch image here
- 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) - The first time you SSH into the device you will have to configure the serial number and MAC - the steps are described here
- 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
- 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