Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 0.5.0

- Convert mistral workflows to orquesta

## 0.4.1

- Restrict napalm dependency to < 3.0 to preserve Python 2.7 support
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ credentials:

The devices configuration is so that credentials and drivers for each device
don't have to be entered manually. This is useful for automated action chains
or mistral workflows where (most of the time) only the hostname is known
or orquesta workflows where (most of the time) only the hostname is known
(for example from a syslog logsource field.)

```YAML
Expand Down Expand Up @@ -171,7 +171,7 @@ being set to the IP address of the host and the logsoure being set to the hostna
received from the box. The example rsyslog configuration example details more
on this.

- **configuration_change_workflow**: Webhook trigger to run a remote backup mistral workflow when a configuration change is detected on a device.
- **configuration_change_workflow**: Webhook trigger to run a remote backup orquesta workflow when a configuration change is detected on a device.
- **interface_down_chain**: Webhook trigger to run an action chain when an interface goes down.
- **bgp_prefix_exceeded_chain**: Webhook trigger to run an action chain when a bgp neighbor exceeds its prefix limit.

Expand All @@ -189,8 +189,8 @@ st2 key set napalm_actionerror_mailto "stackstorm_errors@example.com"
st2 key set napalm_actionerror_mailfrom "stackstorm@example.com"

# HTML header and footer files which get read in by some of the workflows to send nice emails.
st2 key set napalm_html_mail_header_file "/opt/stackstorm/packs/napalm/examples/html_header.html"
st2 key set napalm_html_mail_footer_file "/opt/stackstorm/packs/napalm/examples/html_footer.html"
st2 key set napalm_html_mail_header_file "/opt/stackstorm/packs/napalm/examples/html_templates/html_header.html"
st2 key set napalm_html_mail_footer_file "/opt/stackstorm/packs/napalm/examples/html_templates/html_footer.html"
```

For the remote backup action chain the following commands will create the datastore key value pairs needed.
Expand Down
2 changes: 1 addition & 1 deletion actions/configuration_change_workflow.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: "configuration_change_workflow"
description: "Workflow to process a configuration change on a device."
runner_type: "mistral-v2"
runner_type: "orquesta"
pack: napalm
enabled: true
entry_point: "workflows/configuration_change_workflow.yaml"
Expand Down
2 changes: 1 addition & 1 deletion actions/interface_down_workflow.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
name: "interface_down_workflow"
description: "Workflow to process an interface down event on a device."
runner_type: "mistral-v2"
runner_type: "orquesta"
pack: napalm
enabled: true
entry_point: "workflows/interface_down_workflow.yaml"
Expand Down
71 changes: 0 additions & 71 deletions actions/workflows/check_consistency_chatops.yaml

This file was deleted.

120 changes: 62 additions & 58 deletions actions/workflows/configuration_change_workflow.yaml
Original file line number Diff line number Diff line change
@@ -1,66 +1,70 @@
---
version: '2.0'
version: 1.0

napalm.configuration_change_workflow:
description: Configuration Change Workflow

input:
- hostname
- driver
- message
- username

type: direct
input:
- hostname
- driver
- message
- username

task-defaults:
on-error:
- notify_on_error
vars:
- stdout: ""
- stderr: ""

tasks:
send_detected_email:
action: core.sendmail
input:
to: "<% st2kv('system.napalm_remotebackup_mailto') %>"
from: "<% st2kv('system.napalm_remotebackup_mailfrom') %>"
# Will work when this is in the code: https://github.com/StackStorm/st2/pull/3177
#subject: "Stackstorm detected a configuration change on <% $.hostname %> {% if _.username %} by {{ _.username }} {% endif %}."
subject: "Stackstorm detected a configuration change on <% $.hostname %> by <% $.username %>."
content_type: "text/plain"
body: "\r\n\r\nThe following syslog triggered this event: <% $.message %>\r\n\r\n"
on-success:
- backup_device
tasks:
send_detected_email:
action: core.sendmail
input:
to: "{{ st2kv('system.napalm_remotebackup_mailto') }}"
from: "{{ st2kv('system.napalm_remotebackup_mailfrom') }}"
subject: "Stackstorm detected a configuration change on {{ ctx('hostname') }} by {{ ctx('username') }}."
content_type: "text/plain"
body: "\r\n\r\nThe following syslog triggered this event: {{ ctx('message') }}\r\n\r\n"
next:
- when: "{{ succeeded() }}"
do: backup_device
- when: "{{ failed() }}"
do: notify_on_error

backup_device:
action: "core.remote"
wait-before: 60
input:
cmd: "<% st2kv('system.napalm_remotebackup_cmd') %> <% $.hostname %> <% $.driver %>"
username: "<% st2kv('system.napalm_remotebackup_user') %>"
private_key: "/home/stanley/.ssh/stanley_rsa"
hosts: "<% st2kv('system.napalm_remotebackup_host') %>"
backup_device:
action: "core.remote"
input:
cmd: "{{ st2kv('system.napalm_remotebackup_cmd') }} {{ ctx('hostname') }} {{ ctx('driver') }}"
username: "{{ st2kv('system.napalm_remotebackup_user') }}"
private_key: "/home/stanley/.ssh/stanley_rsa"
hosts: "{{ st2kv('system.napalm_remotebackup_host') }}"
next:
- when: "{{ succeeded() }}"
publish:
stdout: <% task(backup_device).result.get(st2kv('system.napalm_remotebackup_host')).stdout %>
stderr: <% task(backup_device).result.get(st2kv('system.napalm_remotebackup_host')).stderr %>
on-success:
- send_complete_email
- stdout: "{{ result()[st2kv('system.napalm_remotebackup_host')].stdout }}"
- sterr: "{{ result()[st2kv('system.napalm_remotebackup_host')].stdout }}"
do: send_complete_email
- when: "{{ failed() }}"
do: notify_on_error

send_complete_email:
action: core.sendmail
input:
to: "<% st2kv('system.napalm_remotebackup_mailto') %>"
from: "<% st2kv('system.napalm_remotebackup_mailfrom') %>"
subject: "Stackstorm completed a backup of <% $.hostname %>."
content_type: "text/plain"
body: "\r\nThe following syslog triggered this event: <% $.message %>\r\n\r\n
\r\n<% $.stderr %>\r\n
\r\n<% $.stdout %>\r\n
\r\n\r\n"
send_complete_email:
action: core.sendmail
input:
to: "{{ st2kv('system.napalm_remotebackup_mailto') }}"
from: "{{ st2kv('system.napalm_remotebackup_mailfrom') }}"
subject: "Stackstorm completed a backup of {{ ctx('hostname') }}."
content_type: "text/plain"
body: "\r\nThe following syslog triggered this event: {{ ctx('message') }}\r\n\r\n
\r\n{{ ctx('stderr') }}\r\n
\r\n{{ ctx('stdout') }}\r\n
\r\n\r\n"

notify_on_error:
action: core.sendmail
input:
to: "{{ st2kv('system.napalm_actionerror_mailto') }}"
from: "{{ st2kv('system.napalm_actionerror_mailfrom') }}"
subject: "Stackstorm device backup workflow error"
body: "Something went wrong with the device backup workflow. Check stackstorm for the error. Execution ID {{ ctx('st2').action_execution_id }}\r\n\r\n"
next:
- do: fail

notify_on_error:
action: core.sendmail
input:
to: "<% st2kv('system.napalm_actionerror_mailto') %>"
from: "<% st2kv('system.napalm_actionerror_mailfrom') %>"
subject: "Stackstorm device backup workflow error"
body: "Something went wrong with the device backup workflow. Check stackstorm for the error. Execution ID <% env().st2_execution_id %>\r\n\r\n"
on-complete:
- fail
output:
- stdout: "{{ ctx('stdout') }}"
- stderr: "{{ ctx('stderr') }}"
Loading