network-automation-github-actions

Network Automation Using GitHub Actions and Unimus

Project Overview

Network automation framework based on the following GitOps Principles:

Solution Components

Reference Architecture

Usage

Workflow steps

Build

Download and run Ubuntu on the NAS appliance

sudo -i
docker pull ubuntu
docker run -it ubuntu

Install required packages

apt update && apt upgrade -y

apt install apt-utils curl git iputils-ping nano tftpd-hpa -y
apt install software-properties-common -y

Install GitHub CLI, login to GitHub and store GH credentials in git

gh auth login (GitHub.com > HTTPS > n > Paste an authentication token)

git config –global credential.helper store #confirm if this is still required


**Create a new user and directories**

useradd -ms /bin/bash siteadmin && su siteadmin mkdir /home/siteadmin/actions-runner && mkdir /home/siteadmin/actions-runner/network-automation-github-actions


**Configure and start the TFTP service as root**

cat /etc/default/tftpd-hpa nano /etc/default/tftpd-hpa

TFTP_USERNAME=”siteadmin” TFTP_DIRECTORY=”/home/siteadmin/actions-runner/network-automation-github-actions” TFTP_ADDRESS=”:69” TFTP_OPTIONS=”–secure”

start the TFTP service

/etc/init.d/tftpd-hpa start

and verify that it’s running

service –status-all


**Clone this repo**

su siteadmin cd /home/siteadmin/actions-runner/ git clone https://github.com/gdmoney/network-automation-github-actions.git


**Modify file permissions**

cd network-automation-github-actions chmod 755 _access.sh _core.sh _router_1.sh _router_2.sh


**Download, extract, configure, and run the GitHub Actions self-hosted runner**
- *Get the version number and the token from: github.com > repo > Settings > Actions > Runners > New runner > New self-hosted runner*

curl -o actions-runner-linux-x64-2.305.0.tar.gz -L https://github.com/actions/runner/releases/download/v2.305.0/actions-runner-linux-x64-2.305.0.tar.gz tar xzf ./actions-runner-linux-x64-2.305.0.tar.gz ./config.sh –url https://github.com/gdmoney/network-automation-github-actions –token

if you get a Libicu dependency error, exit to root and run: ‘cd /home/siteadmin/actions-runner && ./bin/installdependencies.sh’ and then re-run the above command

./run.sh

Connected to GitHub Listening for Jobs



## Troubleshooting
**After NAS appliance reboot**
- *Verify the Datadog container has the .6 IP address*
- *Verify the TFTP service and the GitHub Actions runner are running*

service –status-all

If not running

/etc/init.d/tftpd-hpa start

Repo > Settings > Actions > Runners > Status: Idle

If not connected

su siteadmin cd /home/siteadmin/actions-runner/ ./run.sh

**Reconfigure self-hosted runner after deleting it on GitHub**

rm .runner ./config.sh –url https://github.com/gdmoney/network-automation-github-actions –token ./run.sh


**Get Unimus tag UUIDs**

curl -s -H “Authorization: Bearer " \ "http://192.168.255.5:8085/api/v3/tags" | jq ```