|
1 | | ---- |
2 | | - version: '2.0' |
| 1 | +version: 1.0 |
3 | 2 |
|
4 | | - napalm.configuration_change_workflow: |
| 3 | +description: Configuration Change Workflow |
5 | 4 |
|
6 | | - input: |
7 | | - - hostname |
8 | | - - driver |
9 | | - - message |
10 | | - - username |
11 | | - |
12 | | - type: direct |
| 5 | +input: |
| 6 | + - hostname |
| 7 | + - driver |
| 8 | + - message |
| 9 | + - username |
13 | 10 |
|
14 | | - task-defaults: |
15 | | - on-error: |
16 | | - - notify_on_error |
| 11 | +vars: |
| 12 | + - stdout: "" |
| 13 | + - stderr: "" |
17 | 14 |
|
18 | | - tasks: |
19 | | - send_detected_email: |
20 | | - action: core.sendmail |
21 | | - input: |
22 | | - to: "<% st2kv('system.napalm_remotebackup_mailto') %>" |
23 | | - from: "<% st2kv('system.napalm_remotebackup_mailfrom') %>" |
24 | | - # Will work when this is in the code: https://github.com/StackStorm/st2/pull/3177 |
25 | | - #subject: "Stackstorm detected a configuration change on <% $.hostname %> {% if _.username %} by {{ _.username }} {% endif %}." |
26 | | - subject: "Stackstorm detected a configuration change on <% $.hostname %> by <% $.username %>." |
27 | | - content_type: "text/plain" |
28 | | - body: "\r\n\r\nThe following syslog triggered this event: <% $.message %>\r\n\r\n" |
29 | | - on-success: |
30 | | - - backup_device |
| 15 | +tasks: |
| 16 | + send_detected_email: |
| 17 | + action: core.sendmail |
| 18 | + input: |
| 19 | + to: "{{ st2kv('system.napalm_remotebackup_mailto') }}" |
| 20 | + from: "{{ st2kv('system.napalm_remotebackup_mailfrom') }}" |
| 21 | + subject: "Stackstorm detected a configuration change on {{ ctx('hostname') }} by {{ ctx('username') }}." |
| 22 | + content_type: "text/plain" |
| 23 | + body: "\r\n\r\nThe following syslog triggered this event: {{ ctx('message') }}\r\n\r\n" |
| 24 | + next: |
| 25 | + - when: "{{ succeeded() }}" |
| 26 | + do: backup_device |
| 27 | + - when: "{{ failed() }}" |
| 28 | + do: notify_on_error |
31 | 29 |
|
32 | | - backup_device: |
33 | | - action: "core.remote" |
34 | | - wait-before: 60 |
35 | | - input: |
36 | | - cmd: "<% st2kv('system.napalm_remotebackup_cmd') %> <% $.hostname %> <% $.driver %>" |
37 | | - username: "<% st2kv('system.napalm_remotebackup_user') %>" |
38 | | - private_key: "/home/stanley/.ssh/stanley_rsa" |
39 | | - hosts: "<% st2kv('system.napalm_remotebackup_host') %>" |
| 30 | + backup_device: |
| 31 | + action: "core.remote" |
| 32 | + input: |
| 33 | + cmd: "{{ st2kv('system.napalm_remotebackup_cmd') }} {{ ctx('hostname') }} {{ ctx('driver') }}" |
| 34 | + username: "{{ st2kv('system.napalm_remotebackup_user') }}" |
| 35 | + private_key: "/home/stanley/.ssh/stanley_rsa" |
| 36 | + hosts: "{{ st2kv('system.napalm_remotebackup_host') }}" |
| 37 | + next: |
| 38 | + - when: "{{ succeeded() }}" |
40 | 39 | publish: |
41 | | - stdout: <% task(backup_device).result.get(st2kv('system.napalm_remotebackup_host')).stdout %> |
42 | | - stderr: <% task(backup_device).result.get(st2kv('system.napalm_remotebackup_host')).stderr %> |
43 | | - on-success: |
44 | | - - send_complete_email |
| 40 | + - stdout: "{{ result()[st2kv('system.napalm_remotebackup_host')].stdout }}" |
| 41 | + - sterr: "{{ result()[st2kv('system.napalm_remotebackup_host')].stdout }}" |
| 42 | + do: send_complete_email |
| 43 | + - when: "{{ failed() }}" |
| 44 | + do: notify_on_error |
45 | 45 |
|
46 | | - send_complete_email: |
47 | | - action: core.sendmail |
48 | | - input: |
49 | | - to: "<% st2kv('system.napalm_remotebackup_mailto') %>" |
50 | | - from: "<% st2kv('system.napalm_remotebackup_mailfrom') %>" |
51 | | - subject: "Stackstorm completed a backup of <% $.hostname %>." |
52 | | - content_type: "text/plain" |
53 | | - body: "\r\nThe following syslog triggered this event: <% $.message %>\r\n\r\n |
54 | | - \r\n<% $.stderr %>\r\n |
55 | | - \r\n<% $.stdout %>\r\n |
56 | | - \r\n\r\n" |
| 46 | + send_complete_email: |
| 47 | + action: core.sendmail |
| 48 | + input: |
| 49 | + to: "{{ st2kv('system.napalm_remotebackup_mailto') }}" |
| 50 | + from: "{{ st2kv('system.napalm_remotebackup_mailfrom') }}" |
| 51 | + subject: "Stackstorm completed a backup of {{ ctx('hostname') }}." |
| 52 | + content_type: "text/plain" |
| 53 | + body: "\r\nThe following syslog triggered this event: {{ ctx('message') }}\r\n\r\n |
| 54 | + \r\n{{ ctx('stderr') }}\r\n |
| 55 | + \r\n{{ ctx('stdout') }}\r\n |
| 56 | + \r\n\r\n" |
| 57 | + |
| 58 | + notify_on_error: |
| 59 | + action: core.sendmail |
| 60 | + input: |
| 61 | + to: "{{ st2kv('system.napalm_actionerror_mailto') }}" |
| 62 | + from: "{{ st2kv('system.napalm_actionerror_mailfrom') }}" |
| 63 | + subject: "Stackstorm device backup workflow error" |
| 64 | + 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" |
| 65 | + next: |
| 66 | + - do: fail |
57 | 67 |
|
58 | | - notify_on_error: |
59 | | - action: core.sendmail |
60 | | - input: |
61 | | - to: "<% st2kv('system.napalm_actionerror_mailto') %>" |
62 | | - from: "<% st2kv('system.napalm_actionerror_mailfrom') %>" |
63 | | - subject: "Stackstorm device backup workflow error" |
64 | | - body: "Something went wrong with the device backup workflow. Check stackstorm for the error. Execution ID <% env().st2_execution_id %>\r\n\r\n" |
65 | | - on-complete: |
66 | | - - fail |
| 68 | +output: |
| 69 | + - stdout: "{{ ctx('stdout') }}" |
| 70 | + - stderr: "{{ ctx('stderr') }}" |
0 commit comments