I’ve been digging around the forums and docs for a bit but haven’t come up with a good solution for this yet aside from replacing an action.
I’ve got the following workflow currently able to request very basic approval, and then push commands to a single host via the napalm.cli pack action. However, when using a different netbox inventory output, it’s not reiterating over the multiple names pushed in output, but doing the first and stopping.
I thought it’d be a quick “with items” fix to get the task to repeat over resulting hosts however the napalm.cli action does not support “with items” and causes an error stoppage. I can’t think of a decent method around this aside from replacing the napalm.cli task with an ansible playbook doing the legwork in it’s place.
If there’s another way to do this that I’m looking over - any push to a doc/kb article or assistance would be great!
Here’s my workflow being used, debug output of the “json” output parameter is simply a list of hostnames in string format for the action input.
#version: 1.0
input:
- site
- tag
- commands
tasks:
# [116, 137]
get_approval:
action: core.ask
input:
schema:
type: object
properties:
approved:
type: boolean
description: "Do you have Approval?"
required: True
ticket_id:
type: string
description: "Ticket (CR/IR) ID:"
required: True
ttl: 90
next:
- when: <% task(get_approval).result.response.approved = true %>
publish:
- approver_department_id: <% task(get_approval).result.response.ticket_id %>
do: get_inventory
- when: <% task(get_approval).result.response.approved = false %>
do: fail
# [116, 314]
get_inventory:
action: netbox.get.dcim.devices
next:
- publish:
- stdout: <% result().exit_code %>
- stderr: <% result().stderr %>
- json: <% result().result.raw.results.name %>
do:
- push_commands
input:
log_level: DEBUG
site: <% ctx().site %>
tag: <% ctx().tag %>
save_in_key_store: false
# [116, 493]
push_commands:
action: napalm.cli
input:
log_level: DEBUG
commands:
- <% ctx().commands %>
hostname: <% ctx().json[0] %>
driver: junos
next:
- do:
- notify
# [116, 629]
notify:
action: ansible.playbook
input:
cwd: {{ Redacted }}/notify/
playbook: main.yml
extra_vars:
- '@extras/napalm_nbx_success.json'
# remove success.json and get actual input next (low priority)