@ansible-flow/assets 0.86.0 → 0.87.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/README.md +3 -3
  2. package/contract/server-api.json +24 -0
  3. package/index.d.ts +2 -0
  4. package/index.js +1 -0
  5. package/package.json +4 -3
  6. package/samples/edge-baseline.flow.yaml +188 -0
  7. package/samples/edge-baseline.scenarios.yaml +21 -0
  8. package/samples/firewall-upgrade.flow.yaml +376 -0
  9. package/samples/hello.flow.yaml +110 -0
  10. package/samples/hello.scenarios.yaml +19 -0
  11. package/samples/inventory.ini +3 -0
  12. package/samples/playbooks/edge-baseline/ansible.cfg +7 -0
  13. package/samples/playbooks/edge-baseline/baseline.yml +80 -0
  14. package/samples/playbooks/edge-baseline/inventory.ini +6 -0
  15. package/samples/playbooks/edge-baseline/prechecks.yml +31 -0
  16. package/samples/playbooks/edge-baseline/roles/netops_backup/defaults/main.yml +1 -0
  17. package/samples/playbooks/edge-baseline/roles/netops_backup/tasks/main.yml +6 -0
  18. package/samples/playbooks/edge-baseline/roles/push_baseline/meta/argument_specs.yml +9 -0
  19. package/samples/playbooks/edge-baseline/roles/push_baseline/tasks/aaa.yml +5 -0
  20. package/samples/playbooks/edge-baseline/roles/push_baseline/tasks/main.yml +5 -0
  21. package/samples/playbooks/edge-baseline/roles/push_baseline/tasks/ntp.yml +5 -0
  22. package/samples/playbooks/edge-baseline/roles/push_baseline/templates/aaa.j2 +2 -0
  23. package/samples/playbooks/edge-baseline/rollback.yml +8 -0
  24. package/samples/playbooks/edge-baseline/site.yml +3 -0
  25. package/samples/playbooks/edge-baseline/tasks/verify.yml +11 -0
  26. package/samples/playbooks/edge-baseline/templates/motd.j2 +1 -0
  27. package/samples/playbooks/edge-baseline/vars/baseline.yml +8 -0
  28. package/samples/projects.json +34 -0
package/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # @ansible-flow/assets
2
2
 
3
- Ansible Flow Designer files a host passes by path: the Python probe, the run events callback, the JSON schemas and the contract with Ansible Flow Server.
3
+ Ansible Flow Designer files a host passes by path: the Python probe, the run events callback, the JSON schemas, the contract with Ansible Flow Server and the sample projects.
4
4
 
5
- Built from [Ansible Flow Designer](https://github.com/ChistokhinSV/ansible-flow-designer) 0.86.0
6
- and released with it. The folders are found by path: `import { probeDir, schemaDir, contractDir } from '@ansible-flow/assets'`.
5
+ Built from [Ansible Flow Designer](https://github.com/ChistokhinSV/ansible-flow-designer) 0.87.0
6
+ and released with it. The folders are found by path: `import { probeDir, schemaDir, contractDir, samplesDir } from '@ansible-flow/assets'`.
7
7
 
8
8
  What is in the package, which entry points are documented and what may change:
9
9
  [docs/packages.md](https://github.com/ChistokhinSV/ansible-flow-designer/blob/main/docs/packages.md).
@@ -92,6 +92,30 @@
92
92
  }
93
93
  }
94
94
  },
95
+ {
96
+ "name": "the flows changed since a commit (AFD-284): none since the one the project is at",
97
+ "request": {
98
+ "method": "GET",
99
+ "path": "/api/v1/projects/${project}/changes?from=${commit}",
100
+ "token": "omar"
101
+ },
102
+ "response": {
103
+ "status": 200,
104
+ "body": { "from": "${commit}", "to": "${commit}", "flows": [] }
105
+ }
106
+ },
107
+ {
108
+ "name": "the flows changed since a commit the server does not have (one not pushed yet)",
109
+ "request": {
110
+ "method": "GET",
111
+ "path": "/api/v1/projects/${project}/changes?from=0000000000000000000000000000000000000000",
112
+ "token": "omar"
113
+ },
114
+ "response": {
115
+ "status": 409,
116
+ "body": { "error": "unknown_commit", "message": "$string" }
117
+ }
118
+ },
95
119
  {
96
120
  "name": "a project's launch configurations",
97
121
  "request": {
package/index.d.ts CHANGED
@@ -4,3 +4,5 @@ export declare const probeDir: string;
4
4
  export declare const schemaDir: string;
5
5
  /** The folder `contract/` of this package, as a path. */
6
6
  export declare const contractDir: string;
7
+ /** The folder `samples/` of this package, as a path. */
8
+ export declare const samplesDir: string;
package/index.js CHANGED
@@ -3,3 +3,4 @@ import { fileURLToPath } from 'node:url';
3
3
  export const probeDir = fileURLToPath(new URL('./probe', import.meta.url));
4
4
  export const schemaDir = fileURLToPath(new URL('./schema', import.meta.url));
5
5
  export const contractDir = fileURLToPath(new URL('./contract', import.meta.url));
6
+ export const samplesDir = fileURLToPath(new URL('./samples', import.meta.url));
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@ansible-flow/assets",
3
- "version": "0.86.0",
4
- "description": "Ansible Flow Designer files a host passes by path: the Python probe, the run events callback, the JSON schemas and the contract with Ansible Flow Server.",
3
+ "version": "0.87.0",
4
+ "description": "Ansible Flow Designer files a host passes by path: the Python probe, the run events callback, the JSON schemas, the contract with Ansible Flow Server and the sample projects.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://github.com/ChistokhinSV/ansible-flow-designer/blob/main/docs/packages.md",
7
7
  "repository": {
@@ -24,7 +24,8 @@
24
24
  "index.d.ts",
25
25
  "probe",
26
26
  "schema",
27
- "contract"
27
+ "contract",
28
+ "samples"
28
29
  ],
29
30
  "engines": {
30
31
  "node": ">=22.13"
@@ -0,0 +1,188 @@
1
+ # Example flow document. IDs are sample ULIDs. Values in [BRACKETS] are placeholders.
2
+ schema_version: 2
3
+ flow:
4
+ id: 01JBM9S346Q3D25VT4F5V37E3S
5
+ key: edge-baseline
6
+ name: Edge baseline
7
+ version: 3
8
+ goal: All edge switches at a site get the NTP, AAA and syslog baseline, with a backup taken first and automatic
9
+ rollback if validation fails.
10
+ owner: netops
11
+ runtime:
12
+ template: 'AFD · edge-baseline'
13
+ inputs:
14
+ site:
15
+ type: string
16
+ required: true
17
+ devices:
18
+ type: host_list
19
+ required: true
20
+ dry_run:
21
+ type: boolean
22
+ default: false
23
+ nodes:
24
+ - id: 01JB3E28JT97KB6CQ643DZVMXX
25
+ key: start
26
+ type: start
27
+ title: Start
28
+ - id: 01JBQKFBF5KZNWJ47TAN9ZT24M
29
+ key: precheck
30
+ type: task
31
+ title: Pre-checks
32
+ status: specified
33
+ intent: Verify reachability and current OS version
34
+ inputs:
35
+ devices:
36
+ type: host_list
37
+ from: flow.devices
38
+ outputs:
39
+ precheck_report:
40
+ type: dict
41
+ impl: null
42
+ - id: 01JBNPZX45HY43KWJRP1XPA7Z3
43
+ key: backup-config
44
+ type: task
45
+ title: Backup config
46
+ status: specified
47
+ intent: Save running config to Git
48
+ inputs:
49
+ devices:
50
+ type: host_list
51
+ from: flow.devices
52
+ outputs:
53
+ backup_ref:
54
+ type: string
55
+ impl: null
56
+ - id: 01JBDJ8FSSZ5AWSH8VHTPRE95B
57
+ key: push-baseline
58
+ type: subflow
59
+ title: Push baseline
60
+ status: implemented
61
+ intent: Apply NTP, AAA and syslog baseline
62
+ inputs:
63
+ devices:
64
+ type: host_list
65
+ backup_ref:
66
+ type: string
67
+ from: backup-config.backup_ref
68
+ outputs:
69
+ change_report:
70
+ type: dict
71
+ impl:
72
+ kind: role
73
+ ref: netops.baseline.push_ntp_aaa
74
+ - id: 01JB9EE0ZBGJ09TQM83XSSSS6Y
75
+ key: validate
76
+ type: task
77
+ title: Validate
78
+ status: specified
79
+ intent: Compare running config with desired state
80
+ inputs:
81
+ devices:
82
+ type: host_list
83
+ change_report:
84
+ type: dict
85
+ from: push-baseline.change_report
86
+ impl: null
87
+ - id: 01JBS3C4DWA7N36096Q14DR9GP
88
+ key: rollback
89
+ type: task
90
+ title: Rollback
91
+ status: specified
92
+ intent: Restore backup on failed hosts
93
+ inputs:
94
+ backup_ref:
95
+ type: string
96
+ from: backup-config.backup_ref
97
+ impl: null
98
+ - id: 01JBQY77ZXYYK596NGYA1DQ91K
99
+ key: done
100
+ type: end
101
+ title: Done
102
+ outcome: success
103
+ - id: 01JB5GQAPENECFSECZP11HYGCP
104
+ key: failed
105
+ type: end
106
+ title: Failed
107
+ outcome: failed
108
+ edges:
109
+ - id: 01JBWPQ5E6EYCNDY0YP57RCYBV
110
+ from:
111
+ node: 01JB3E28JT97KB6CQ643DZVMXX
112
+ port: ok_hosts
113
+ to:
114
+ node: 01JBQKFBF5KZNWJ47TAN9ZT24M
115
+ port: in
116
+ - id: 01JBN5SXS5AA819X9YP981068V
117
+ from:
118
+ node: 01JBQKFBF5KZNWJ47TAN9ZT24M
119
+ port: ok_hosts
120
+ to:
121
+ node: 01JBNPZX45HY43KWJRP1XPA7Z3
122
+ port: in
123
+ - id: 01JBCD1GDJFMGT83PXT891WB09
124
+ from:
125
+ node: 01JBNPZX45HY43KWJRP1XPA7Z3
126
+ port: ok_hosts
127
+ to:
128
+ node: 01JBDJ8FSSZ5AWSH8VHTPRE95B
129
+ port: in
130
+ - id: 01JBB9Y73MY63FCH26W14WMCHW
131
+ from:
132
+ node: 01JBDJ8FSSZ5AWSH8VHTPRE95B
133
+ port: ok_hosts
134
+ to:
135
+ node: 01JB9EE0ZBGJ09TQM83XSSSS6Y
136
+ port: in
137
+ - id: 01JBYFGCW8T7SWM4FV4DK79Q9G
138
+ from:
139
+ node: 01JB9EE0ZBGJ09TQM83XSSSS6Y
140
+ port: ok_hosts
141
+ to:
142
+ node: 01JBQY77ZXYYK596NGYA1DQ91K
143
+ port: in
144
+ - id: 01JB8XE6SZAEAVSNTCPM5Q1NXW
145
+ from:
146
+ node: 01JBDJ8FSSZ5AWSH8VHTPRE95B
147
+ port: failed_hosts
148
+ to:
149
+ node: 01JBS3C4DWA7N36096Q14DR9GP
150
+ port: in
151
+ - id: 01JB1RNJ47E65GH2BH8VGS9ZM5
152
+ from:
153
+ node: 01JBS3C4DWA7N36096Q14DR9GP
154
+ port: ok_hosts
155
+ to:
156
+ node: 01JB5GQAPENECFSECZP11HYGCP
157
+ port: in
158
+ layout:
159
+ 01JB3E28JT97KB6CQ643DZVMXX:
160
+ x: 140
161
+ y: 64
162
+ 01JBQKFBF5KZNWJ47TAN9ZT24M:
163
+ x: 120
164
+ y: 160
165
+ 01JBNPZX45HY43KWJRP1XPA7Z3:
166
+ x: 120
167
+ y: 280
168
+ 01JBDJ8FSSZ5AWSH8VHTPRE95B:
169
+ x: 120
170
+ y: 400
171
+ 01JB9EE0ZBGJ09TQM83XSSSS6Y:
172
+ x: 120
173
+ y: 520
174
+ 01JBQY77ZXYYK596NGYA1DQ91K:
175
+ x: 160
176
+ y: 640
177
+ 01JBS3C4DWA7N36096Q14DR9GP:
178
+ x: 456
179
+ y: 400
180
+ 01JB5GQAPENECFSECZP11HYGCP:
181
+ x: 720
182
+ y: 412
183
+ decisions:
184
+ - kind: accepted
185
+ node: 01JBNPZX45HY43KWJRP1XPA7Z3
186
+ finding: port:failed_hosts
187
+ reason: Fails before any change; stopping is safe
188
+ by: '[USER]'
@@ -0,0 +1,21 @@
1
+ # Scenario tests for Edge baseline: where each switch must end when chosen steps fail. The
2
+ # designer's Scenarios tab shows them (the chip in the top bar); right-click a step to plant another.
3
+ flow: edge-baseline
4
+ scenarios:
5
+ - name: Every switch gets the baseline
6
+ inputs:
7
+ devices: [sw-01, sw-02]
8
+ site: lab
9
+ expect:
10
+ sw-01: done
11
+ sw-02: done
12
+ - name: A failed push rolls back that switch only
13
+ inputs:
14
+ devices: [sw-01, sw-02]
15
+ site: lab
16
+ force:
17
+ push-baseline:
18
+ failed: [sw-02]
19
+ expect:
20
+ sw-01: done
21
+ sw-02: failed
@@ -0,0 +1,376 @@
1
+ # Sample flow (Ansible Flow Designer): a firewall firmware upgrade with pre-checks, a backup, an
2
+ # approval, polling until the device is back, post-checks and rollback. Steps are drafts: a skeleton
3
+ # run works anywhere, and the tutorials bind them (docs/guide/tutorials/02-design-to-production.md).
4
+ schema_version: 2
5
+ flow:
6
+ id: 01M67T3CFH6SVM3YWJRWKZG530
7
+ key: firewall-upgrade
8
+ name: Firewall firmware upgrade
9
+ version: 1
10
+ goal: Upgrade firewalls to one target firmware with pre-checks, a configuration backup, an approval, post-checks and automatic rollback.
11
+ owner: netops
12
+ inputs:
13
+ devices:
14
+ type: host_list
15
+ required: true
16
+ targets: true
17
+ target_version:
18
+ type: string
19
+ required: true
20
+ backup_dir:
21
+ type: string
22
+ default: /srv/backups
23
+ nodes:
24
+ - id: 01M67T3CFKMVBF5BVBNRBM9F9M
25
+ key: start
26
+ type: start
27
+ title: Start
28
+ - id: 01M67T3CFKMVBF5BVBNRBM9F9N
29
+ key: precheck
30
+ type: subflow
31
+ title: Pre-checks
32
+ status: specified
33
+ intent: Read-only checks; hosts already on the target version leave as unchanged.
34
+ ports: [unchanged]
35
+ outputs:
36
+ fw_version:
37
+ type: string
38
+ subflow:
39
+ nodes:
40
+ - id: 01M67T3CFKMVBF5BVBNRBM9FA2
41
+ key: read-status
42
+ type: task
43
+ title: Read device status
44
+ status: specified
45
+ intent: One API call for version, model and HA state.
46
+ outputs:
47
+ status:
48
+ type: dict
49
+ - id: 01M67T3CFKMVBF5BVBNRBM9FA3
50
+ key: normalize
51
+ type: task
52
+ title: Normalize facts
53
+ status: specified
54
+ intent: Flatten the API answer into the values later checks read.
55
+ inputs:
56
+ status:
57
+ type: dict
58
+ from: read-status.status
59
+ outputs:
60
+ fw_version:
61
+ type: string
62
+ fw_model:
63
+ type: string
64
+ - id: 01M67T3CFKMVBF5BVBNRBM9FA4
65
+ key: on-target
66
+ type: decision
67
+ title: Already on target?
68
+ status: implemented
69
+ condition: fw_version == target_version
70
+ inputs:
71
+ fw_version:
72
+ type: string
73
+ from: normalize.fw_version
74
+ target_version:
75
+ type: string
76
+ from: flow.target_version
77
+ - id: 01M67T3CFKMVBF5BVBNRBM9FA5
78
+ key: check-path
79
+ type: task
80
+ title: Check the upgrade path
81
+ status: specified
82
+ intent: Only newer versions of the same major release; no downgrade.
83
+ inputs:
84
+ fw_version:
85
+ type: string
86
+ from: normalize.fw_version
87
+ target_version:
88
+ type: string
89
+ from: flow.target_version
90
+ edges:
91
+ - id: 01M67T3CFMH2JH0VY2WAQ83F6Y
92
+ from: {node: 01M67T3CFKMVBF5BVBNRBM9FA2, port: ok_hosts}
93
+ to: {node: 01M67T3CFKMVBF5BVBNRBM9FA3, port: in}
94
+ - id: 01M67T3CFMH2JH0VY2WAQ83F6Z
95
+ from: {node: 01M67T3CFKMVBF5BVBNRBM9FA3, port: ok_hosts}
96
+ to: {node: 01M67T3CFKMVBF5BVBNRBM9FA4, port: in}
97
+ - id: 01M67T3CFMH2JH0VY2WAQ83F70
98
+ from: {node: 01M67T3CFKMVBF5BVBNRBM9FA4, port: 'false'}
99
+ to: {node: 01M67T3CFKMVBF5BVBNRBM9FA5, port: in}
100
+ boundary:
101
+ in: 01M67T3CFKMVBF5BVBNRBM9FA2
102
+ outputs:
103
+ ok_hosts:
104
+ - node: 01M67T3CFKMVBF5BVBNRBM9FA5
105
+ port: ok_hosts
106
+ unchanged:
107
+ - node: 01M67T3CFKMVBF5BVBNRBM9FA4
108
+ port: 'true'
109
+ failed_hosts:
110
+ - node: 01M67T3CFKMVBF5BVBNRBM9FA2
111
+ port: failed_hosts
112
+ - node: 01M67T3CFKMVBF5BVBNRBM9FA3
113
+ port: failed_hosts
114
+ - node: 01M67T3CFKMVBF5BVBNRBM9FA5
115
+ port: failed_hosts
116
+ - id: 01M67T3CFKMVBF5BVBNRBM9F9P
117
+ key: backup
118
+ type: subflow
119
+ title: Backup
120
+ status: specified
121
+ intent: Export the running configuration and keep it off the device.
122
+ outputs:
123
+ backup_file:
124
+ type: string
125
+ subflow:
126
+ nodes:
127
+ - id: 01M67T3CFKMVBF5BVBNRBM9FA6
128
+ key: export
129
+ type: task
130
+ title: Export configuration
131
+ status: specified
132
+ outputs:
133
+ config:
134
+ type: string
135
+ - id: 01M67T3CFKMVBF5BVBNRBM9FA7
136
+ key: store
137
+ type: task
138
+ title: Store the backup
139
+ status: specified
140
+ intent: Save it as <host>_<version>.conf in the backup folder.
141
+ inputs:
142
+ config:
143
+ type: string
144
+ from: export.config
145
+ backup_dir:
146
+ type: string
147
+ from: flow.backup_dir
148
+ outputs:
149
+ backup_file:
150
+ type: string
151
+ edges:
152
+ - id: 01M67T3CFMH2JH0VY2WAQ83F71
153
+ from: {node: 01M67T3CFKMVBF5BVBNRBM9FA6, port: ok_hosts}
154
+ to: {node: 01M67T3CFKMVBF5BVBNRBM9FA7, port: in}
155
+ boundary:
156
+ in: 01M67T3CFKMVBF5BVBNRBM9FA6
157
+ outputs:
158
+ ok_hosts:
159
+ - node: 01M67T3CFKMVBF5BVBNRBM9FA7
160
+ port: ok_hosts
161
+ failed_hosts:
162
+ - node: 01M67T3CFKMVBF5BVBNRBM9FA6
163
+ port: failed_hosts
164
+ - node: 01M67T3CFKMVBF5BVBNRBM9FA7
165
+ port: failed_hosts
166
+ - id: 01M67T3CFKMVBF5BVBNRBM9F9Q
167
+ key: approve
168
+ type: approval
169
+ title: Change approval
170
+ status: implemented
171
+ intent: The engineer on duty confirms the pre-check report and the maintenance window.
172
+ - id: 01M67T3CFKMVBF5BVBNRBM9F9R
173
+ key: upgrade
174
+ type: subflow
175
+ title: Upgrade
176
+ status: specified
177
+ intent: Install the image, wait until the device answers on the target version.
178
+ settings:
179
+ serial: 1
180
+ subflow:
181
+ nodes:
182
+ - id: 01M67T3CFKMVBF5BVBNRBM9FA8
183
+ key: install
184
+ type: task
185
+ title: Install firmware
186
+ status: specified
187
+ intent: Upload the image and start the install; the device reboots.
188
+ inputs:
189
+ target_version:
190
+ type: string
191
+ from: flow.target_version
192
+ - id: 01M67T3CFKMVBF5BVBNRBM9FA9
193
+ key: wait-up
194
+ type: task
195
+ title: Wait for the target version
196
+ status: specified
197
+ intent: Poll the status API until the device answers on the target version.
198
+ inputs:
199
+ target_version:
200
+ type: string
201
+ from: flow.target_version
202
+ settings:
203
+ retries: 40
204
+ delay: 15
205
+ until: wait_up_result.status == 200 and wait_up_result.json.version == target_version
206
+ edges:
207
+ - id: 01M67T3CFMH2JH0VY2WAQ83F72
208
+ from: {node: 01M67T3CFKMVBF5BVBNRBM9FA8, port: ok_hosts}
209
+ to: {node: 01M67T3CFKMVBF5BVBNRBM9FA9, port: in}
210
+ boundary:
211
+ in: 01M67T3CFKMVBF5BVBNRBM9FA8
212
+ outputs:
213
+ ok_hosts:
214
+ - node: 01M67T3CFKMVBF5BVBNRBM9FA9
215
+ port: ok_hosts
216
+ failed_hosts:
217
+ - node: 01M67T3CFKMVBF5BVBNRBM9FA8
218
+ port: failed_hosts
219
+ - node: 01M67T3CFKMVBF5BVBNRBM9FA9
220
+ port: failed_hosts
221
+ - id: 01M67T3CFKMVBF5BVBNRBM9F9S
222
+ key: postcheck
223
+ type: subflow
224
+ title: Post-checks
225
+ status: specified
226
+ intent: Compare the device with what the pre-checks saw.
227
+ inputs:
228
+ fw_version:
229
+ type: string
230
+ from: precheck.fw_version
231
+ subflow:
232
+ nodes:
233
+ - id: 01M67T3CFKMVBF5BVBNRBM9FAA
234
+ key: compare
235
+ type: task
236
+ title: Compare with the pre-check state
237
+ status: specified
238
+ intent: Interfaces up, routes and VPN tunnels not worse than before the upgrade.
239
+ inputs:
240
+ before:
241
+ type: string
242
+ from: postcheck.fw_version
243
+ boundary:
244
+ in: 01M67T3CFKMVBF5BVBNRBM9FAA
245
+ outputs:
246
+ ok_hosts:
247
+ - node: 01M67T3CFKMVBF5BVBNRBM9FAA
248
+ port: ok_hosts
249
+ failed_hosts:
250
+ - node: 01M67T3CFKMVBF5BVBNRBM9FAA
251
+ port: failed_hosts
252
+ - id: 01M67T3CFKMVBF5BVBNRBM9F9T
253
+ key: rollback
254
+ type: subflow
255
+ title: Rollback
256
+ status: specified
257
+ purpose: rollback
258
+ intent: Restore the backup taken before the upgrade, for the failed hosts only.
259
+ inputs:
260
+ backup_file:
261
+ type: string
262
+ from: backup.backup_file
263
+ subflow:
264
+ nodes:
265
+ - id: 01M67T3CFKMVBF5BVBNRBM9FAB
266
+ key: restore
267
+ type: task
268
+ title: Restore the backup
269
+ status: specified
270
+ inputs:
271
+ file:
272
+ type: string
273
+ from: rollback.backup_file
274
+ boundary:
275
+ in: 01M67T3CFKMVBF5BVBNRBM9FAB
276
+ outputs:
277
+ ok_hosts:
278
+ - node: 01M67T3CFKMVBF5BVBNRBM9FAB
279
+ port: ok_hosts
280
+ failed_hosts:
281
+ - node: 01M67T3CFKMVBF5BVBNRBM9FAB
282
+ port: failed_hosts
283
+ - id: 01M67T3CFKMVBF5BVBNRBM9F9V
284
+ key: exclude
285
+ type: task
286
+ title: Exclude and report
287
+ status: draft
288
+ purpose: exclude
289
+ intent: Take hosts that failed the pre-checks or the backup out of the run and list them in the report.
290
+ - id: 01M67T3CFKMVBF5BVBNRBM9F9W
291
+ key: notify
292
+ type: task
293
+ title: Notify on-call
294
+ status: draft
295
+ purpose: notify
296
+ intent: The rollback failed; open a ticket and page on-call.
297
+ - id: 01M67T3CFKMVBF5BVBNRBM9F9X
298
+ key: done
299
+ type: end
300
+ title: Done
301
+ outcome: success
302
+ - id: 01M67T3CFKMVBF5BVBNRBM9F9Y
303
+ key: excluded
304
+ type: end
305
+ title: Excluded
306
+ outcome: failed
307
+ - id: 01M67T3CFKMVBF5BVBNRBM9F9Z
308
+ key: not-approved
309
+ type: end
310
+ title: Not approved
311
+ outcome: failed
312
+ - id: 01M67T3CFKMVBF5BVBNRBM9FA0
313
+ key: rolled-back
314
+ type: end
315
+ title: Rolled back
316
+ outcome: failed
317
+ - id: 01M67T3CFKMVBF5BVBNRBM9FA1
318
+ key: manual-recovery
319
+ type: end
320
+ title: Manual recovery
321
+ outcome: failed
322
+ edges:
323
+ - id: 01M67T3CFKMVBF5BVBNRBM9FAC
324
+ from: {node: 01M67T3CFKMVBF5BVBNRBM9F9M, port: ok_hosts}
325
+ to: {node: 01M67T3CFKMVBF5BVBNRBM9F9N, port: in}
326
+ - id: 01M67T3CFKMVBF5BVBNRBM9FAD
327
+ from: {node: 01M67T3CFKMVBF5BVBNRBM9F9N, port: ok_hosts}
328
+ to: {node: 01M67T3CFKMVBF5BVBNRBM9F9P, port: in}
329
+ - id: 01M67T3CFKMVBF5BVBNRBM9FAE
330
+ from: {node: 01M67T3CFKMVBF5BVBNRBM9F9N, port: unchanged}
331
+ to: {node: 01M67T3CFKMVBF5BVBNRBM9F9X, port: in}
332
+ - id: 01M67T3CFKMVBF5BVBNRBM9FAF
333
+ from: {node: 01M67T3CFKMVBF5BVBNRBM9F9N, port: failed_hosts}
334
+ to: {node: 01M67T3CFKMVBF5BVBNRBM9F9V, port: in}
335
+ - id: 01M67T3CFKMVBF5BVBNRBM9FAG
336
+ from: {node: 01M67T3CFKMVBF5BVBNRBM9F9P, port: ok_hosts}
337
+ to: {node: 01M67T3CFKMVBF5BVBNRBM9F9Q, port: in}
338
+ - id: 01M67T3CFKMVBF5BVBNRBM9FAH
339
+ from: {node: 01M67T3CFKMVBF5BVBNRBM9F9P, port: failed_hosts}
340
+ to: {node: 01M67T3CFKMVBF5BVBNRBM9F9V, port: in}
341
+ - id: 01M67T3CFKMVBF5BVBNRBM9FAJ
342
+ from: {node: 01M67T3CFKMVBF5BVBNRBM9F9Q, port: approved}
343
+ to: {node: 01M67T3CFKMVBF5BVBNRBM9F9R, port: in}
344
+ - id: 01M67T3CFKMVBF5BVBNRBM9FAK
345
+ from: {node: 01M67T3CFKMVBF5BVBNRBM9F9Q, port: rejected}
346
+ to: {node: 01M67T3CFKMVBF5BVBNRBM9F9Z, port: in}
347
+ - id: 01M67T3CFKMVBF5BVBNRBM9FAM
348
+ from: {node: 01M67T3CFKMVBF5BVBNRBM9F9R, port: ok_hosts}
349
+ to: {node: 01M67T3CFKMVBF5BVBNRBM9F9S, port: in}
350
+ - id: 01M67T3CFKMVBF5BVBNRBM9FAN
351
+ from: {node: 01M67T3CFKMVBF5BVBNRBM9F9R, port: failed_hosts}
352
+ to: {node: 01M67T3CFKMVBF5BVBNRBM9F9T, port: in}
353
+ - id: 01M67T3CFKMVBF5BVBNRBM9FAP
354
+ from: {node: 01M67T3CFKMVBF5BVBNRBM9F9S, port: ok_hosts}
355
+ to: {node: 01M67T3CFKMVBF5BVBNRBM9F9X, port: in}
356
+ - id: 01M67T3CFKMVBF5BVBNRBM9FAQ
357
+ from: {node: 01M67T3CFKMVBF5BVBNRBM9F9S, port: failed_hosts}
358
+ to: {node: 01M67T3CFKMVBF5BVBNRBM9F9T, port: in}
359
+ - id: 01M67T3CFMH2JH0VY2WAQ83F6R
360
+ from: {node: 01M67T3CFKMVBF5BVBNRBM9F9T, port: ok_hosts}
361
+ to: {node: 01M67T3CFKMVBF5BVBNRBM9FA0, port: in}
362
+ - id: 01M67T3CFMH2JH0VY2WAQ83F6S
363
+ from: {node: 01M67T3CFKMVBF5BVBNRBM9F9T, port: failed_hosts}
364
+ to: {node: 01M67T3CFKMVBF5BVBNRBM9F9W, port: in}
365
+ - id: 01M67T3CFMH2JH0VY2WAQ83F6T
366
+ from: {node: 01M67T3CFKMVBF5BVBNRBM9F9V, port: ok_hosts}
367
+ to: {node: 01M67T3CFKMVBF5BVBNRBM9F9Y, port: in}
368
+ - id: 01M67T3CFMH2JH0VY2WAQ83F6V
369
+ from: {node: 01M67T3CFKMVBF5BVBNRBM9F9V, port: failed_hosts}
370
+ to: {node: 01M67T3CFKMVBF5BVBNRBM9F9Y, port: in}
371
+ - id: 01M67T3CFMH2JH0VY2WAQ83F6W
372
+ from: {node: 01M67T3CFKMVBF5BVBNRBM9F9W, port: ok_hosts}
373
+ to: {node: 01M67T3CFKMVBF5BVBNRBM9FA1, port: in}
374
+ - id: 01M67T3CFMH2JH0VY2WAQ83F6X
375
+ from: {node: 01M67T3CFKMVBF5BVBNRBM9F9W, port: failed_hosts}
376
+ to: {node: 01M67T3CFKMVBF5BVBNRBM9FA1, port: in}
@@ -0,0 +1,110 @@
1
+ # Hello, Ansible: the smallest useful flow. Copy it with Open Sample Flow…, then Run as Skeleton on localhost.
2
+ schema_version: 2
3
+ flow:
4
+ id: 01M6GPM95NZM7QW2BDFB073CNN
5
+ key: hello
6
+ name: Hello, Ansible
7
+ version: 1
8
+ goal: 'The smallest useful flow: reach each host, read a few facts and say hello. Run it as a skeleton on localhost.'
9
+ inputs:
10
+ devices:
11
+ type: host_list
12
+ required: true
13
+ targets: true
14
+ nodes:
15
+ - id: 01M6GPM95RHBYFR7H44Z8GD2HB
16
+ key: start
17
+ type: start
18
+ title: Start
19
+ - id: 01M6GPM95RHBYFR7H44Z8GD2HC
20
+ key: done
21
+ type: end
22
+ title: Done
23
+ outcome: success
24
+ - id: 01M6GPM979RJPCDJ0XFF22GBSV
25
+ key: ping
26
+ type: task
27
+ title: Check the host answers
28
+ status: implemented
29
+ intent: 'Ping each host: Ansible can reach it and run Python there.'
30
+ impl:
31
+ kind: module
32
+ ref: ansible.builtin.ping
33
+ - id: 01M6GPM99KC9TX091MCH61REQV
34
+ key: facts
35
+ type: task
36
+ title: Read a few facts
37
+ status: implemented
38
+ intent: Gather a small set of facts about each host.
39
+ impl:
40
+ kind: module
41
+ ref: ansible.builtin.setup
42
+ params:
43
+ gather_subset:
44
+ - min
45
+ - id: 01M6GPM9B1D563X8PKD5041JHV
46
+ key: say-hello
47
+ type: task
48
+ title: Say hello
49
+ status: implemented
50
+ intent: Print a hello message with the name of each host.
51
+ impl:
52
+ kind: module
53
+ ref: ansible.builtin.debug
54
+ params:
55
+ msg: Hello from {{ inventory_hostname }}
56
+ - id: 01M6GPM9CA039FX7GVNYTH6JEP
57
+ key: stopped
58
+ type: end
59
+ title: Stopped
60
+ outcome: failed
61
+ edges:
62
+ - id: 01M6GPM95RHBYFR7H44Z8GD2HD
63
+ from:
64
+ node: 01M6GPM95RHBYFR7H44Z8GD2HB
65
+ port: ok_hosts
66
+ to:
67
+ node: 01M6GPM979RJPCDJ0XFF22GBSV
68
+ port: in
69
+ - id: 01M6GPM97W4B2AMEW6HFHXRBCG
70
+ from:
71
+ node: 01M6GPM979RJPCDJ0XFF22GBSV
72
+ port: ok_hosts
73
+ to:
74
+ node: 01M6GPM99KC9TX091MCH61REQV
75
+ port: in
76
+ - id: 01M6GPM9A7GQS7FR6FKHTWMKAF
77
+ from:
78
+ node: 01M6GPM99KC9TX091MCH61REQV
79
+ port: ok_hosts
80
+ to:
81
+ node: 01M6GPM9B1D563X8PKD5041JHV
82
+ port: in
83
+ - id: 01M6GPM9BGHTH5YB4114WK24SP
84
+ from:
85
+ node: 01M6GPM9B1D563X8PKD5041JHV
86
+ port: ok_hosts
87
+ to:
88
+ node: 01M6GPM95RHBYFR7H44Z8GD2HC
89
+ port: in
90
+ - id: 01M6GPM9CA039FX7GVNYTH6JEQ
91
+ from:
92
+ node: 01M6GPM979RJPCDJ0XFF22GBSV
93
+ port: failed_hosts
94
+ to:
95
+ node: 01M6GPM9CA039FX7GVNYTH6JEP
96
+ port: in
97
+ - id: 01M6GPM9CXF8DC6THEBZE6R4XM
98
+ from:
99
+ node: 01M6GPM99KC9TX091MCH61REQV
100
+ port: failed_hosts
101
+ to:
102
+ node: 01M6GPM9CA039FX7GVNYTH6JEP
103
+ port: in
104
+ - id: 01M6GPM9DHTDHEPP5YCJ04A8F5
105
+ from:
106
+ node: 01M6GPM9B1D563X8PKD5041JHV
107
+ port: failed_hosts
108
+ to:
109
+ node: 01M6GPM9CA039FX7GVNYTH6JEP
110
+ port: in
@@ -0,0 +1,19 @@
1
+ # Scenario tests for Hello, Ansible: where each host must end when chosen steps fail. The designer's
2
+ # Scenarios tab shows them (the chip in the top bar); right-click a step to plant another failure.
3
+ flow: hello
4
+ scenarios:
5
+ - name: Every host says hello
6
+ inputs:
7
+ devices: [host-01, host-02]
8
+ expect:
9
+ host-01: done
10
+ host-02: done
11
+ - name: A host that does not answer stops there
12
+ inputs:
13
+ devices: [host-01, host-02]
14
+ force:
15
+ ping:
16
+ failed: [host-02]
17
+ expect:
18
+ host-01: done
19
+ host-02: stopped
@@ -0,0 +1,3 @@
1
+ # The sample flows run as a skeleton on this machine: localhost with the local connection.
2
+ [local]
3
+ localhost ansible_connection=local
@@ -0,0 +1,7 @@
1
+ # Sample playbooks to import (Tutorial 5). Fictional edge switches, simulated with the local
2
+ # connection: runs write small files under /tmp/edge-baseline instead of configuring devices.
3
+ [defaults]
4
+ roles_path = roles
5
+ inventory = inventory.ini
6
+ host_key_checking = False
7
+ retry_files_enabled = False
@@ -0,0 +1,80 @@
1
+ - name: Edge baseline
2
+ hosts: edge
3
+ gather_facts: false
4
+ vars_files:
5
+ - vars/baseline.yml
6
+ vars_prompt:
7
+ - name: enable_secret
8
+ prompt: Enable secret of the switches
9
+ private: true
10
+ vars:
11
+ out_dir: /tmp/edge-baseline
12
+
13
+ roles:
14
+ - role: netops_backup
15
+
16
+ tasks:
17
+ - name: Push the baseline
18
+ block:
19
+ - name: Render the MOTD
20
+ ansible.builtin.template:
21
+ src: motd.j2
22
+ dest: "{{ out_dir }}/{{ inventory_hostname }}/motd.txt"
23
+ mode: "0644"
24
+ notify: Save config
25
+
26
+ - name: Configure the uplinks
27
+ ansible.builtin.copy:
28
+ content: "interface {{ item }}\n description uplink to the core\n"
29
+ dest: "{{ out_dir }}/{{ inventory_hostname }}/{{ item }}.cfg"
30
+ mode: "0644"
31
+ loop: "{{ uplinks }}"
32
+ notify: config changed
33
+
34
+ - name: Refuse the change on the canary switch
35
+ ansible.builtin.fail:
36
+ msg: the canary switch refused the baseline
37
+ when: inventory_hostname == canary_switch
38
+ rescue:
39
+ - name: Record the rollback
40
+ ansible.builtin.copy:
41
+ content: "rolled back\n"
42
+ dest: "{{ out_dir }}/{{ inventory_hostname }}/rollback.txt"
43
+ mode: "0644"
44
+ always:
45
+ - name: Record the attempt
46
+ ansible.builtin.copy:
47
+ content: "attempted\n"
48
+ dest: "{{ out_dir }}/{{ inventory_hostname }}/attempt.txt"
49
+ mode: "0644"
50
+
51
+ - name: Check the enable secret was given
52
+ ansible.builtin.assert:
53
+ that:
54
+ - enable_secret | length > 0
55
+ quiet: true
56
+
57
+ - name: Verify NTP
58
+ ansible.builtin.include_tasks: tasks/verify.yml
59
+
60
+ - name: Apply the NTP and AAA baseline
61
+ ansible.builtin.include_role:
62
+ name: push_baseline
63
+
64
+ handlers:
65
+ - name: Save config
66
+ ansible.builtin.copy:
67
+ content: "saved\n"
68
+ dest: "{{ out_dir }}/{{ inventory_hostname }}/saved.txt"
69
+ mode: "0644"
70
+ listen: config changed
71
+
72
+ - name: Report
73
+ hosts: local
74
+ gather_facts: true
75
+ tasks:
76
+ - name: Write the summary
77
+ ansible.builtin.copy:
78
+ content: "baseline done on {{ ansible_facts['hostname'] | default('localhost') }}\n"
79
+ dest: "{{ out_dir | default('/tmp/edge-baseline') }}/summary.txt"
80
+ mode: "0644"
@@ -0,0 +1,6 @@
1
+ # Fictional edge switches (example.net); the local connection stands in for the devices.
2
+ [edge]
3
+ sw-edge-0[1:4] ansible_connection=local
4
+
5
+ [local]
6
+ localhost ansible_connection=local
@@ -0,0 +1,31 @@
1
+ - name: Pre-checks
2
+ hosts: edge
3
+ gather_facts: false
4
+ vars:
5
+ out_dir: /tmp/edge-baseline
6
+ tasks:
7
+ - name: Create the report folder
8
+ ansible.builtin.file:
9
+ path: "{{ out_dir }}/{{ inventory_hostname }}"
10
+ state: directory
11
+ mode: "0755"
12
+ check_mode: false
13
+
14
+ - name: Read the software version
15
+ ansible.builtin.command: echo "17.9.4"
16
+ register: version_check
17
+ changed_when: false
18
+ check_mode: false
19
+
20
+ - name: Check the version is supported
21
+ ansible.builtin.assert:
22
+ that:
23
+ - version_check.stdout is version('17.0', '>=')
24
+ fail_msg: "Unsupported version {{ version_check.stdout }}"
25
+
26
+ - name: Record the pre-check
27
+ ansible.builtin.copy:
28
+ content: "version {{ version_check.stdout }}\n"
29
+ dest: "{{ out_dir }}/{{ inventory_hostname }}/precheck.txt"
30
+ mode: "0644"
31
+ when: version_check.stdout is version('17.0', '>=')
@@ -0,0 +1,6 @@
1
+ - name: Back up the running configuration
2
+ ansible.builtin.copy:
3
+ content: "backup of {{ inventory_hostname }}, keep {{ backup_keep }}\n"
4
+ dest: "{{ out_dir }}/{{ inventory_hostname }}/backup.cfg"
5
+ mode: "0644"
6
+ register: backup_result
@@ -0,0 +1,9 @@
1
+ argument_specs:
2
+ main:
3
+ short_description: Push the NTP and AAA baseline
4
+ options:
5
+ ntp_servers:
6
+ type: list
7
+ elements: str
8
+ required: true
9
+ description: NTP servers, in order of preference.
@@ -0,0 +1,5 @@
1
+ - name: Write the AAA settings
2
+ ansible.builtin.template:
3
+ src: aaa.j2
4
+ dest: "{{ out_dir }}/{{ inventory_hostname }}/aaa.cfg"
5
+ mode: "0644"
@@ -0,0 +1,5 @@
1
+ # One file per part of the baseline.
2
+ - name: NTP
3
+ ansible.builtin.include_tasks: ntp.yml
4
+ - name: AAA
5
+ ansible.builtin.include_tasks: aaa.yml
@@ -0,0 +1,5 @@
1
+ - name: Write the NTP servers
2
+ ansible.builtin.copy:
3
+ content: "{% for s in ntp_servers %}ntp server {{ s }}\n{% endfor %}"
4
+ dest: "{{ out_dir }}/{{ inventory_hostname }}/ntp.cfg"
5
+ mode: "0644"
@@ -0,0 +1,2 @@
1
+ aaa new-model
2
+ aaa authentication login default group tacacs+ local
@@ -0,0 +1,8 @@
1
+ # Run on its own after a failed change; site.yml does not import it.
2
+ - name: Roll back the baseline
3
+ hosts: edge
4
+ gather_facts: false
5
+ tasks:
6
+ - name: Restore the backup
7
+ ansible.builtin.debug:
8
+ msg: "restore {{ inventory_hostname }} from its last backup"
@@ -0,0 +1,3 @@
1
+ # Edge switch baseline: pre-checks, then the baseline itself (sample playbooks to import).
2
+ - import_playbook: prechecks.yml
3
+ - import_playbook: baseline.yml
@@ -0,0 +1,11 @@
1
+ - name: Read the NTP status
2
+ ansible.builtin.command: echo "synchronised to {{ ntp_servers | first }}"
3
+ register: ntp_status
4
+ changed_when: false
5
+ check_mode: false
6
+
7
+ - name: Record the NTP status
8
+ ansible.builtin.copy:
9
+ content: "{{ ntp_status.stdout }}\n"
10
+ dest: "{{ out_dir }}/{{ inventory_hostname }}/ntp.txt"
11
+ mode: "0644"
@@ -0,0 +1 @@
1
+ Authorised access only: {{ inventory_hostname }} (example.net)
@@ -0,0 +1,8 @@
1
+ ntp_servers:
2
+ - 192.0.2.10
3
+ - 192.0.2.11
4
+ uplinks:
5
+ - uplink1
6
+ - uplink2
7
+ # The switch that refuses the change, to show the rescue path.
8
+ canary_switch: sw-edge-04
@@ -0,0 +1,34 @@
1
+ {
2
+ "$comment": "Sample projects (AFD-290): what a new project gets when it starts from a sample, in a project's layout. `from` is a file or folder under samples/, `to` the path in the project (empty: the project's root). Ansible Flow Server reads this from @ansible-flow/assets.",
3
+ "projects": [
4
+ {
5
+ "key": "hello",
6
+ "name": "Hello, Ansible",
7
+ "description": "The smallest useful flow: reach each host, read a few facts and say hello. Runs on localhost.",
8
+ "files": [
9
+ { "from": "hello.flow.yaml", "to": "flows/hello/hello.flow.yaml" },
10
+ { "from": "hello.scenarios.yaml", "to": "flows/hello/hello.scenarios.yaml" },
11
+ { "from": "inventory.ini", "to": "inventory.ini" }
12
+ ]
13
+ },
14
+ {
15
+ "key": "edge-baseline",
16
+ "name": "Edge baseline",
17
+ "description": "NTP, AAA and syslog baseline for edge switches with a backup first and rollback, and the playbooks and roles it binds (fictional switches, simulated locally).",
18
+ "files": [
19
+ { "from": "edge-baseline.flow.yaml", "to": "flows/edge-baseline/edge-baseline.flow.yaml" },
20
+ { "from": "edge-baseline.scenarios.yaml", "to": "flows/edge-baseline/edge-baseline.scenarios.yaml" },
21
+ { "from": "playbooks/edge-baseline", "to": "" }
22
+ ]
23
+ },
24
+ {
25
+ "key": "firewall-upgrade",
26
+ "name": "Firewall firmware upgrade",
27
+ "description": "Pre-checks, a backup, an approval, polling until the device is back, post-checks and rollback. Steps are drafts: runs as a skeleton on localhost.",
28
+ "files": [
29
+ { "from": "firewall-upgrade.flow.yaml", "to": "flows/firewall-upgrade/firewall-upgrade.flow.yaml" },
30
+ { "from": "inventory.ini", "to": "inventory.ini" }
31
+ ]
32
+ }
33
+ ]
34
+ }