Update the devices in netbox, update the status to decommission if device not found in device.yaml file but exist in netbox server #19068
Unanswered
kodesam
asked this question in
Help Wanted!
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
How to sync the netbox devices using ansible script, devices.yaml file contain list of devices, if old devices deleted from new pull devices.yaml file, how to update the devices in netbox to change the status of devices to decommissioned
name: "Manage NetBox devices"
hosts: localhost
gather_facts: false
connection: local
vars_files:
tasks:
netbox.netbox.netbox_device:
netbox_url: "{{ netbox_url }}"
netbox_token: "{{ netbox_token }}"
data:
name: "{{ device.data.name }}"
device_role: "{{ device.data.device_role }}"
device_type: "{{ device.data.device_type }}"
site: "{{ device.data.site }}"
status: "{{ device.data.status }}"
face: "{{ device.data.face }}"
position: "{{ device.data.position | regex_replace('^U', '') | int }}"
rack: "{{ device.data.rack | default(omit) if device.data.rack | length > 0 else omit }}"
asset_tag: "{{ device.data.asset_tag | default(omit) if device.data.asset_tag | length > 0 else omit }}"
platform: "{{ device.data.platform | default(omit) if device.data.platform | length > 0 else omit }}"
serial: "{{ device.data.serial | default(omit) if device.data.serial | length > 0 else omit }}"
tenant: "{{ device.data.tenant | default(omit) if device.data.tenant | length > 0 else omit }}"
comments: "{{ device.data.comments | default(omit) if device.data.comments | length > 0 else omit }}"
state: "{{ device.state }}"
loop: "{{ devices }}"
loop_control:
loop_var: device
Beta Was this translation helpful? Give feedback.
All reactions