Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Netbox to own device/site existence #108

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ananace
Copy link

@ananace ananace commented Jul 21, 2023

For us, Netbox is the source of truth in regards to device/site existence, so letting Foreman create or delete those objects would break our inventory. This then adds options for if devices should be created or removed, or only found and updated, as well as expanding the site sync variable to skip orchestration of the site objects themselves.

Tests still need to be updated for it, and I'm not sure if the settings are the best delineation. Maybe deletion - as one example - should also support setting the device status to something like Decommissioning/Offline/Inventory instead, to allow marking the hardware as no longer in use on deletion in Foreman.

@@ -11,7 +11,7 @@ class Organizer
end

after do
context.raw_data[:device] = context.device.raw_data!
context.raw_data[:device] = context.device.raw_data! if context.device
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so the device may be nil if it is not found in the Netbox and devices creation is disabled, right?

Suggested change
context.raw_data[:device] = context.device.raw_data! if context.device
context.raw_data[:device] = context.device&.raw_data!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did it this way to not mess with the cached parameters, since that service uses key existence to decide what data to generate.

Also adds tests for site upsert as well as device creation
@ananace ananace requested a review from kamils-iRonin August 21, 2023 07:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants