Skip to content

Instantly share code, notes, and snippets.

View Craigson's full-sized avatar

Craig Pickard Craigson

View GitHub Profile
@Craigson
Craigson / play_recap
Created January 12, 2021 22:42
Play recap for deploy_services.yaml
PLAY RECAP ************************************************************************************************************
broker : ok=9 changed=3 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
publisher : ok=12 changed=5 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
subscriber : ok=12 changed=5 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
@Craigson
Craigson / main.yaml
Last active January 14, 2021 04:35
create_syntropy_network
---
# tasks file for create_syntropy_network
- name: Create Syntropy Network
syntropynet.syntropy.syntropy_network:
name: "{{network_name}}"
state: present
topology: p2m
connections:
mqt_2_broker:
state: present
@Craigson
Craigson / main.yaml
Last active January 12, 2021 01:49
provision hosts
PLAY RECAP ***********************************************************************************************************
broker : ok=8 changed=4 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
publisher : ok=8 changed=4 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
subscriber : ok=8 changed=4 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0
@Craigson
Craigson / provision_hosts.yaml
Created January 12, 2021 00:24
Provision VM hosts
---
- name: Configure Hosts
hosts: all
roles:
- update_cache
- install_wireguard
- install_docker
- install_python_deps
@Craigson
Craigson / syntropyhosts.ini
Created January 12, 2021 00:07
syntropy hosts inventory
[all:vars]
ansible_ssh_private_key_file=<pem_file_location>
[broker]
broker ansible_host=<broker_vm_ip> ansible_connection=ssh ansible_user=<broker_user>
[publisher]
publisher ansible_host=<publisher_vm_ip> ansible_connection=ssh ansible_user=<publisher_user>
@Craigson
Craigson / main.yaml
Created January 12, 2021 00:05
launch_mosquitto
---
# tasks file for launch_mosquitto
- debug:
msg: "Launching Mosquito"
# copy the mosquito config
- name: Copy Mosquitto conf file
copy:
src: mosquitto.conf
@Craigson
Craigson / main.yaml
Created January 11, 2021 23:27
launch_syntropy_agent
---
# tasks file for launch_syntropy_agent
- include_vars: ../../../secrets.yaml
- debug:
msg: creating "{{agent_name}}"
- name: Launch Syntropy Agent
docker_container:
image: syntropynet/agent:stable
@Craigson
Craigson / main.yaml
Created January 11, 2021 23:20
create_docker_network
---
# tasks file for create_docker_network
- debug:
msg: Create docker network on subnet - {{subnet}}"
- name: Create Docker network
docker_network:
name: syntropynet
driver: bridge
ipam_config:
@Craigson
Craigson / deploy_broker.yaml
Created January 11, 2021 23:07
Build an MQTT network with Syntropy Stack and Ansible.
---
- name: Deploy Broker
hosts: broker
vars:
subnet: 172.20.0.0/24
agent_name: "mqt_2_broker"
agent_tags: "mqtt"
agent_provider: "6"
roles:
- create_docker_network
@Craigson
Craigson / publisher.js
Created January 8, 2021 05:13
Publisher NodeJS app for the Syntropy Stack MQTT NodeJS example
const mqtt = require("mqtt");
const moment = require("moment");
const client = mqtt.connect("mqtt://172.20.0.2:1883");
const CronJob = require("cron").CronJob;
// publish a message at 5minute intervals
const job = new CronJob(
"5 * * * * *",
function () {