Skip to content

Commit

Permalink
Merge pull request #277 from stevekeay/workflows-use-id-instead-of-ho…
Browse files Browse the repository at this point in the history
…stname

Update workflows to identify devices by id instead of hostname
  • Loading branch information
stevekeay authored Sep 18, 2024
2 parents b5b99d6 + ca15bba commit 78e4455
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 54 deletions.
6 changes: 3 additions & 3 deletions containers/argo_utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ however they will likely fail until a proper get-obm-creds Workflow is created.

## Example
```bash
argo -n argo-events submit --from workflowtemplate/get-device-nautobot --parameter hostname=host.domain.local
argo -n argo-events submit --from workflowtemplate/get-device-nautobot --parameter device_id=1de4f169-9848-4d8e-921b-65338c1e00ca

Name: get-device-nautobot-g5wlz
Namespace: argo-events
Expand All @@ -33,7 +33,7 @@ Status: Pending
Created: Tue Apr 23 13:50:57 -0400 (now)
Progress:
Parameters:
hostname: some-host.domain.local
device_id: 1de4f169-9848-4d8e-921b-65338c1e00ca
```

```bash
Expand All @@ -52,7 +52,7 @@ Finished: Tue Apr 23 13:51:27 -0400 (8 seconds ago)
Duration: 30 seconds
Progress: 1/1
Parameters:
hostname: some-host.domain.local
device_id: 1de4f169-9848-4d8e-921b-65338c1e00ca

STEP TEMPLATE PODNAME DURATION MESSAGE
✔ get-device-nautobot-g5wlz main
Expand Down
2 changes: 1 addition & 1 deletion containers/argo_utils/code/argo_python/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def create_secret(self, name: str, data: Dict, persist=False) -> str:
try:
# if KUBERNETES_POD_UID is not explicitly defined in the container env, pod get permissions will need
# be set for the service account running this workflow
owner_name = os.environ["HOSTNAME"]
owner_name = os.environ["DEVICE_ID"]
owner_id = os.getenv("KUBERNETES_POD_UID")
if not owner_id:
owner_metadata = self.get_pod(owner_name)
Expand Down
6 changes: 3 additions & 3 deletions containers/obm-utils/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The WorkflowTemplates provided in this directory were created to provide common

## Example
```bash
argo -n argo-events submit --from workflowtemplate/obm-sync-creds --parameter hostname=host.domain.local
argo -n argo-events submit --from workflowtemplate/obm-sync-creds --parameter device_id=1de4f169-9848-4d8e-921b-65338c1e00ca

Name: obm-sync-creds-wrn2c
Namespace: argo-events
Expand All @@ -17,7 +17,7 @@ Status: Pending
Created: Tue Apr 23 14:24:07 -0400 (now)
Progress:
Parameters:
hostname: host.domain.local
device_id: 1de4f169-9848-4d8e-921b-65338c1e00ca
```

```bash
Expand All @@ -34,7 +34,7 @@ Duration: 58 seconds
Progress: 2/3
ResourcesDuration: 0s*(1 cpu),5s*(100Mi memory)
Parameters:
hostname: host.domain.local
device_id: 1de4f169-9848-4d8e-921b-65338c1e00ca

STEP TEMPLATE PODNAME DURATION MESSAGE
● obm-sync-creds-wrn2c main
Expand Down
16 changes: 8 additions & 8 deletions docs/component-argo-workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ set of WorkflowTemplates below.

| WorkflowTemplate | Description | Input | Output | |
|---------------------- |-----------------------------------------------------------|-------------------------|------------|---|
| get-device-nautobot | Return Device Information from Nautobot | hostname | device | |
| get-obm-creds | Get the credentials for the target Device | hostname | secret | * |
| get-obm-ip | Get OBM IP address for target Device | hostname | ip | |
| get-device-nautobot | Return Device Information from Nautobot | device_id | device | |
| get-obm-creds | Get the credentials for the target Device | device_id | secret | * |
| get-obm-ip | Get OBM IP address for target Device | device_id | ip | |
| nautobot-api | HTTP Template Workflow to query the Nautobot API | method,nautobot_url,uri | result | |
| obm-firmware-update | Update OBM firmware on target Device | hostname | | |
| obm-sync-creds | Sync's a devices OBM password with what we have on record | hostname | | |
| obm-firmware-update | Update OBM firmware on target Device | device_id | | |
| obm-sync-creds | Sync's a devices OBM password with what we have on record | device_id | | |

\* WorkflowTemplate which requires a manual / custom implementation.

Expand Down Expand Up @@ -62,7 +62,7 @@ Argo Workflows has a CLI and the installation instrucutions can be found [here](
Usage:

```bash
argo -n argo-events submit --from workflowtemplate/get-device-nautobot --parameter hostname=host.domain.local
argo -n argo-events submit --from workflowtemplate/get-device-nautobot --parameter device_id=1de4f169-9848-4d8e-921b-65338c1e00ca

Name: get-device-nautobot-g5wlz
Namespace: argo-events
Expand All @@ -71,7 +71,7 @@ Status: Pending
Created: Tue Apr 23 13:50:57 -0400 (now)
Progress:
Parameters:
hostname: host.domain.local
device_id: 1de4f169-9848-4d8e-921b-65338c1e00ca
```

```bash
Expand All @@ -90,7 +90,7 @@ Finished: Tue Apr 23 13:51:27 -0400 (8 seconds ago)
Duration: 30 seconds
Progress: 1/1
Parameters:
hostname: host.domain.local
device_id: 1de4f169-9848-4d8e-921b-65338c1e00ca

STEP TEMPLATE PODNAME DURATION MESSAGE
✔ get-device-nautobot-g5wlz main
Expand Down
2 changes: 0 additions & 2 deletions workflows/argo-events/sensors/nb-oob-interface-update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ spec:
value: Some nautobot interface has changed
- name: device_id
value: device id that event is for
- name: hostname
value: to support other workflows that references hostname
entrypoint: start
serviceAccountName: workflow
templates:
Expand Down
10 changes: 5 additions & 5 deletions workflows/argo-events/workflowtemplates/get-device-nautobot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ metadata:
name: get-device-nautobot
namespace: argo-events
annotations:
workflows.argoproj.io/title: Output JSON blob of Nautobot data for given device hostname
workflows.argoproj.io/title: Output JSON blob of Nautobot data for given device_id
workflows.argoproj.io/description: |
Defined in `workflows/argo-events/workflowtemplates/get-device-nautobot.yaml`. Return Device Information from Nautobot
spec:
serviceAccountName: workflow
entrypoint: main
arguments:
parameters:
- name: hostname
- name: device_id
templates:
- name: main
inputs:
parameters:
- name: hostname
value: "{{workflow.parameters.hostname}}"
- name: device_id
value: "{{workflow.parameters.device_id}}"
outputs:
parameters:
- name: device
Expand All @@ -34,4 +34,4 @@ spec:
arguments:
parameters:
- name: uri
value: "/dcim/devices/?name={{inputs.parameters.hostname}}"
value: "/dcim/devices/{{inputs.parameters.device_id}}/"
6 changes: 3 additions & 3 deletions workflows/argo-events/workflowtemplates/get-obm-creds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: get-obm-creds
namespace: argo-events
annotations:
workflows.argoproj.io/title: Create a k8s secret containing OBM creds for given device hostname
workflows.argoproj.io/title: Create a k8s secret containing OBM creds for given device_id
workflows.argoproj.io/description: |
Defined in `workflows/argo-events/workflowtemplates/get-obm-creds.yaml`.
An example template to return the name of a Kubernetes Secret which containing device's OBM credentials.
Expand All @@ -17,12 +17,12 @@ spec:
entrypoint: main
arguments:
parameters:
- name: hostname
- name: device_id
templates:
- name: main
inputs:
parameters:
- name: hostname
- name: device_id
outputs:
parameters:
- name: secret
Expand Down
8 changes: 4 additions & 4 deletions workflows/argo-events/workflowtemplates/get-obm-ip.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: get-obm-ip
namespace: argo-events
annotations:
workflows.argoproj.io/title: Output OBM IP address for the Device with the given hostname
workflows.argoproj.io/title: Output OBM IP address for the Device with the given device_id
workflows.argoproj.io/description: |
Defined in `workflows/argo-events/workflowtemplates/get-obm-ip.yaml`.
Get OBM IP address for target Device
Expand All @@ -13,12 +13,12 @@ spec:
entrypoint: main
arguments:
parameters:
- name: hostname
- name: device_id
templates:
- name: main
inputs:
parameters:
- name: hostname
- name: device_id
outputs:
parameters:
- name: ip
Expand All @@ -32,4 +32,4 @@ spec:
arguments:
parameters:
- name: uri
value: "/ipam/ip-addresses/?device={{inputs.parameters.hostname}}&interfaces=iDRAC&interfaces=iLO"
value: "/ipam/ip-addresses/?device_id={{inputs.parameters.device_id}}&interfaces=iDRAC&interfaces=iLO"
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ metadata:
spec:
arguments:
parameters:
- name: hostname
- name: device_id
serviceAccountName: workflow
entrypoint: main
templates:
Expand All @@ -24,16 +24,16 @@ spec:
template: main
arguments:
parameters:
- name: hostname
value: "{{workflow.parameters.hostname}}"
- name: device_id
value: "{{workflow.parameters.device_id}}"
- name: get-obm-creds
templateRef:
name: get-obm-creds
template: main
arguments:
parameters:
- name: hostname
value: "{{workflow.parameters.hostname}}"
- name: device_id
value: "{{workflow.parameters.device_id}}"
- name: idrac-enable-network-boot
dependencies: [get-obm-ip, get-obm-creds]
template: idrac-enable-network-boot
Expand Down
10 changes: 5 additions & 5 deletions workflows/argo-events/workflowtemplates/obm-firmware-update.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ spec:
entrypoint: main
arguments:
parameters:
- name: hostname
- name: device_id
- name: firmware-url
templates:
- name: main
Expand All @@ -24,16 +24,16 @@ spec:
template: main
arguments:
parameters:
- name: hostname
value: "{{workflow.parameters.hostname}}"
- name: device_id
value: "{{workflow.parameters.device_id}}"
- name: get-obm-creds
templateRef:
name: get-obm-creds
template: main
arguments:
parameters:
- name: hostname
value: "{{workflow.parameters.hostname}}"
- name: device_id
value: "{{workflow.parameters.device_id}}"
- name: update-firmware
dependencies: [get-obm-ip, get-obm-creds]
template: obm-firmware-update
Expand Down
10 changes: 5 additions & 5 deletions workflows/argo-events/workflowtemplates/obm-sync-creds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ metadata:
spec:
arguments:
parameters:
- name: hostname
- name: device_id
serviceAccountName: workflow
entrypoint: main
templates:
Expand All @@ -24,16 +24,16 @@ spec:
template: main
arguments:
parameters:
- name: hostname
value: "{{workflow.parameters.hostname}}"
- name: device_id
value: "{{workflow.parameters.device_id}}"
- name: get-obm-creds
templateRef:
name: get-obm-creds
template: main
arguments:
parameters:
- name: hostname
value: "{{workflow.parameters.hostname}}"
- name: device_id
value: "{{workflow.parameters.device_id}}"
- name: obm-sync-creds
dependencies: [get-obm-ip, get-obm-creds]
template: obm-sync-creds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ spec:
parameters:
- name: interface_update_event
value: Some nautobot interface has changed
- name: hostname
value: hostname of the device that event is for
- name: device_id
value: device_id that event is for
templates:
- name: main
steps:
Expand Down
4 changes: 2 additions & 2 deletions workflows/argo-events/workflowtemplates/sync-obm-creds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ spec:
template: main
arguments:
parameters:
- name: hostname
value: '{{workflow.parameters.hostname}}'
- name: device_id
value: '{{workflow.parameters.device_id}}'
- - name: sync-obm-creds
template: sync-obm-creds
arguments:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ spec:
parameters:
- name: device_id
value: "{}"
- name: hostname
value: "{}"
templates:
- name: main
steps:
Expand All @@ -23,16 +21,16 @@ spec:
template: main
arguments:
parameters:
- name: hostname
value: "{{workflow.parameters.hostname}}"
- name: device_id
value: "{{workflow.parameters.device_id}}"
- - name: get-obm-creds-secret
templateRef:
name: get-obm-creds
template: main
arguments:
parameters:
- name: hostname
value: "{{workflow.parameters.hostname}}"
- name: device_id
value: "{{workflow.parameters.device_id}}"
- - name: sync-interfaces-to-nautobot
templateRef:
name: sync-interfaces-to-nautobot
Expand Down

0 comments on commit 78e4455

Please sign in to comment.