So I am writing an ansible collection for node-red so that one can control multiple node-red instances without writing complicated code.
For the initial test case I developed a Lookup Plugin that will provide me the current list of flows on an instance:
This makes the ansible playbook:
- name: localhost
tasks:
- name: Get all flows from an instance
set_fact:
nodered_flows: "{{ lookup('nodered_flow', 'nodered_url=http://localhost/nodered nodered_user=admin nodered_password=admin') }}"
- name: flows
debug: var=nodered_flows
Which works really nicely at the moment:
ok: [localhost] =>
msg:
- disabled: false
env: []
id: 44a1586775b5aa07
info: ''
label: tester_flow
type: tab
- crontab: ''
id: c8695be143cd18a3
name: ''
once: false
onceDelay: '5'
payload: ''
payloadType: date
props:
- p: payload
- p: topic
vt: str
repeat: '10'
topic: ''
type: inject
wires:
- - 6225429b84c5b433
x: 290
y: 100
z: 44a1586775b5aa07
- active: true
complete: 'false'
console: false
id: 6225429b84c5b433
name: debug 1
statusType: auto
statusVal: ''
tosidebar: true
tostatus: false
type: debug
wires: []
x: 660
y: 120
z: 44a1586775b5aa07
This essentially is the value when Node-RED-API-Version: v2
on HTTP API /flows
and the plugin returns flows
list. This is nice and all, but for an end-user the resultant is not very intuitive. All the elements in the list do not give a lot of intuitive information about the flows and neither does it state which element actually provides the list a better overview of what the current state is.