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

Bootstrap ssot integration #541

Merged
merged 21 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
ddb25f6
fix: 🐛 nautobot_ssot requires nautobot >= 2.1.0
bile0026 Sep 9, 2024
63fffc4
fix: 🐛 nautobot_ssot requires nautobot >= 2.1.0
bile0026 Sep 9, 2024
2550e86
feat: ✨ add bootstrap ssot code
bile0026 Sep 9, 2024
a80a0ca
fix: 🚨 Correct complaint from pylint
jdrew82 Sep 10, 2024
f9285f3
docs: 📝 Fix documentation
jdrew82 Sep 10, 2024
dd36475
chore: 📝 add change fragment
bile0026 Sep 10, 2024
b64457b
docs: 📝 Add changelog fragment for documentation changes.
jdrew82 Sep 10, 2024
69923d6
fix: 🐛 adjust data type
bile0026 Sep 10, 2024
435a758
fix: 🐛 logging debug messages obey debug toggle on job
bile0026 Sep 11, 2024
66ab39c
docs: 📝 update plugin options for combined app and some spelling fixes
bile0026 Sep 11, 2024
0f4436c
fix: 🐛 code cleanup
bile0026 Sep 11, 2024
ce1727b
fix: 🐛 fix indentation
bile0026 Sep 11, 2024
9f9636e
style: 📝 update spellings
bile0026 Sep 11, 2024
e5e68f9
fix: 📝 remove duplicate entry
bile0026 Sep 12, 2024
38e7281
docs: 📝 update documentation
bile0026 Sep 12, 2024
e210b2c
Update docs/admin/integrations/bootstrap_setup.md
bile0026 Sep 19, 2024
0b42e7b
fix: 🐛 fix bug tagging tenants
bile0026 Sep 27, 2024
c059e6e
Merge branch 'develop' into bootstrap_ssot_integration
bile0026 Oct 3, 2024
e889dc3
chore: 👷 add codeowner for bootstrap integration
bile0026 Oct 3, 2024
9b02f04
docs: 📝 update installation instructions
bile0026 Oct 3, 2024
23d4110
Merge branch 'bootstrap_ssot_integration' of github.com:nautobot/naut…
bile0026 Oct 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/541.added
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add Bootstrap SSoT to Nautobot SSoT Nautobot application
1 change: 1 addition & 0 deletions changes/541.documentation
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixed documentation errors with 1.5 release notes and missing links to integration setup and user sections.
4 changes: 1 addition & 3 deletions development/app_config_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ def _main():
**SchemaBuilder().to_json_schema(app_config), # type: ignore
}
app_config = import_module(package_name).config
_enrich_object_schema(
schema, app_config.default_settings, app_config.required_settings
)
_enrich_object_schema(schema, app_config.default_settings, app_config.required_settings)
schema_path.write_text(json.dumps(schema, indent=4) + "\n")
print(f"\n==================\nGenerated schema:\n\n{schema_path}\n")
print(
Expand Down
4 changes: 4 additions & 0 deletions development/creds.example.env
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,7 @@ NAUTOBOT_APIC_VERIFY_DEVNET=False
SERVICENOW_PASSWORD="changeme"

IPFABRIC_API_TOKEN=secrettoken

NAUTOBOT_SSOT_ENABLE_BOOTSTRAP="False"
NAUTOBOT_BOOTSTRAP_SSOT_ENVIRONMENT_BRANCH=develop
NAUTOBOT_BOOTSTRAP_SSOT_LOAD_SOURCE=file # or git
46 changes: 37 additions & 9 deletions development/nautobot_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@

if "debug_toolbar" not in INSTALLED_APPS: # noqa: F405
INSTALLED_APPS.append("debug_toolbar") # noqa: F405
if (
"debug_toolbar.middleware.DebugToolbarMiddleware" not in MIDDLEWARE
): # noqa: F405
MIDDLEWARE.insert(
0, "debug_toolbar.middleware.DebugToolbarMiddleware"
) # noqa: F405
if "debug_toolbar.middleware.DebugToolbarMiddleware" not in MIDDLEWARE: # noqa: F405
MIDDLEWARE.insert(0, "debug_toolbar.middleware.DebugToolbarMiddleware") # noqa: F405

#
# Misc. settings
Expand Down Expand Up @@ -55,9 +51,7 @@
"NAUTOBOT_DB_PORT",
default_db_settings[nautobot_db_engine]["NAUTOBOT_DB_PORT"],
), # Database port, default to postgres
"CONN_MAX_AGE": int(
os.getenv("NAUTOBOT_DB_TIMEOUT", "300")
), # Database timeout
"CONN_MAX_AGE": int(os.getenv("NAUTOBOT_DB_TIMEOUT", "300")), # Database timeout
"ENGINE": nautobot_db_engine,
}
}
Expand Down Expand Up @@ -192,8 +186,42 @@
"atl01": "Atlanta",
},
"aristacv_verify": is_truthy(os.getenv("NAUTOBOT_ARISTACV_VERIFY", "true")),
"bootstrap_nautobot_environment_branch": os.getenv("NAUTOBOT_BOOTSTRAP_SSOT_ENVIRONMENT_BRANCH", "develop"),
"bootstrap_models_to_sync": {
"secret": True,
"secrets_group": True,
"git_repository": True,
"dynamic_group": True,
"computed_field": True,
"tag": True,
"graph_ql_query": True,
"software": False,
"software_image": False,
"validated_software": False,
"tenant_group": True,
"tenant": True,
"role": True,
"manufacturer": True,
"platform": True,
"location_type": True,
"location": True,
"team": True,
"contact": True,
"provider": True,
"provider_network": True,
"circuit_type": True,
"circuit": True,
"circuit_termination": True,
"namespace": True,
"rir": True,
"vlan_group": True,
"vlan": True,
"vrf": True,
"prefix": True,
},
"enable_aci": is_truthy(os.getenv("NAUTOBOT_SSOT_ENABLE_ACI")),
"enable_aristacv": is_truthy(os.getenv("NAUTOBOT_SSOT_ENABLE_ARISTACV")),
"enable_bootstrap": is_truthy(os.getenv("NAUTOBOT_SSOT_ENABLE_BOOTSTRAP", "false")),
"enable_device42": is_truthy(os.getenv("NAUTOBOT_SSOT_ENABLE_DEVICE42")),
"enable_dna_center": is_truthy(os.getenv("NAUTOBOT_SSOT_ENABLE_DNA_CENTER")),
"enable_infoblox": is_truthy(os.getenv("NAUTOBOT_SSOT_ENABLE_INFOBLOX")),
Expand Down
95 changes: 95 additions & 0 deletions docs/admin/integrations/bootstrap_setup.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Bootstrap


## Description

This App will sync data from YAML files into Nautobot to create baseline environments. Most items will receive a custom field associated with them called "System of Record", which will be set to "Bootstrap". These items are then the only ones managed by the Bootstrap SSoT App. Other items within the Nautobot instance will not be affected unless there's items with overlapping names. There is currently two exceptions to this and those are the ComputedField, and GraphQLQuery models since they can't have a custom field associated. If you choose to manage ComputedField or GraphQLQuery objects with the Bootstrap SSoT App, make sure to define them all within the YAML file, since any "locally defined" Computed Fields and GraphQL Queries within Nautobot will end up getting deleted when the job runs. If an item exists in Nautobot by it's identifiers but it does not have the "System of Record" custom field on it, the item will be updated with "Bootstrap" (or `SYSTEM_OF_RECORD` environment variable value) when the App runs. This way no duplicates are created, and the App will not delete any items that are not defined in the Bootstrap data but were manually created in Nautobot.

## Installation

Add the Nautobot SSoT App to your poetry environment `poetry install nautobot-ssot`, then configure your `nautobot_config.py` to include the app and the settings.
bile0026 marked this conversation as resolved.
Show resolved Hide resolved


### nautobot_config.py

The settings here are pretty straightforward, `nautobot_environment_branch` will be loaded from the environment variable `NAUTOBOT_BOOTSTRAP_SSOT_ENVIRONMENT_BRANCH`, or default to develop. The rest of the settings define which models/objects you want to have the App sync to Nautobot. There are a couple of caveats to these. For example, for DynamicGroup objects to sync, the filter criteria need to already exist in Nautobot. So, if you are going to have groups that are filtered on platforms/regions/sites/etc make sure not to include DynamicGroup objects in the "models_to_sync" until those items exist. Same for Git Repositories when you want to sync Golden Config-related repositories. The Golden Config App needs to be installed, for the `provided_contents` items to be able to be found. This also goes for the Lifecycle Management app with `Software/ValidatedSoftware` models.

```python
PLUGINS = ["nautobot_ssot"]

PLUGINS_CONFIG = {
"nautobot_ssot": {
# Other nautobot_ssot settings ommitted.
"bootstrap_nautobot_environment_branch": os.getenv("NAUTOBOT_BOOTSTRAP_SSOT_ENVIRONMENT_BRANCH", "develop"),
"bootstrap_models_to_sync": {
"secret": True,
"secrets_group": True,
"git_repository": True,
"dynamic_group": True,
"computed_field": True,
"tag": True,
"graph_ql_query": True,
"software": False,
"software_image": False,
"validated_software": False,
"tenant_group": True,
"tenant": True,
"role": True,
"manufacturer": True,
"platform": True,
"location_type": True,
"location": True,
"team": True,
"contact": True,
"provider": True,
"provider_network": True,
"circuit_type": True,
"circuit": True,
"circuit_termination": True,
"namespace": True,
"rir": True,
"vlan_group": True,
"vlan": True,
"vrf": True,
"prefix": True,
},
"enable_bootstrap": is_truthy(os.getenv("NAUTOBOT_SSOT_ENABLE_BOOTSTRAP", "false")),
}
}
```

## Configuration

### Bootstrap data

Bootstrap data can be stored in 2 fashions. Firstly, it can be stored within the `nautobot_ssot_bootstrap/fixtures` directory, or you may create a Git Repository within an existing Nautobot instance that contains the word `Bootstrap` in the name and provides `config context` data. Using local files is not recommended as this requires a fork of the plugin and locally editing the YAML data files in the fixtures folder. The suggested method is to use the Git Datasource. The data structure is flat files, and there is a naming scheme to these files. The first one required is `global_settings.yml`. This contains the main data structures of what data can be loaded `Secrets,SecretsGroups,GitRepository,DynamicGroup,Tag,etc`. You can then create additional `.yml` files with naming of your CI environments, i.e. production, development, etc. This is where the environment variables described below would be matched to pull in additional data from the other YAML files defined in the directory. A simple structure would look something like this:

```text
global_settings.yml
develop.yml
prod.yml
staging.yml
```

There are 2 environment variables that control how certain things are loaded in the app.

1. `NAUTOBOT_BOOTSTRAP_SSOT_LOAD_SOURCE` - defines whether to load from the local `fixtures` folder or a GitRepository already present in Nautobot. This setting will get overridden if the user selects something other than `env_var` in the job's GUI settings.
- Acceptable options are `file` or `git`.
2. `NAUTOBOT_BOOTSTRAP_SSOT_ENVIRONMENT_BRANCH` - Defines the environment and settings you want to import. I.e. production, develop, staging.

## Process
bile0026 marked this conversation as resolved.
Show resolved Hide resolved

### Bootstrap as DataSource

Synchronization of data follows this workflow:
1. Load data from Bootstrap YAML file (limited to `models_to_sync`)
2. Load data from Nautobot (limited to `models_to_sync`, and objects that also have the `CustomField` `system_of_record` set to "Bootstrap".)
3. DiffSync determines Creates, Updates, Deletes
4. If an object is being created (an object loaded from Bootstrap was not loaded from Nautobot) Bootstrap will first check to see if an object with the same name exists in Nautobot but does not have the `system_of_record` field set. If it finds an object, it will update it with the Bootstrap values and set the `system_of_record` field to "Bootstrap".
5. If an object needs to be updated it will be updated with the values provided by Bootstrap data.
6. If an object needs to be deleted it will be deleted.


### Bootstrap as DataTarget

NotYetImplemented
1 change: 1 addition & 0 deletions docs/admin/integrations/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
This Nautobot app supports the following integrations:

- [Cisco ACI](./aci_setup.md)
- [Bootstrap](./bootstrap_setup.md)
- [Arista CloudVision](./aristacv_setup.md)
- [Device42](./device42_setup.md)
- [Infoblox](./infoblox_setup.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/admin/release_notes/version_1.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
## Changed

- [206](https://github.com/nautobot/nautobot-app-ssot/pull/206) - Update docs pins for py3.7 compatibility by @cmsirbu
- [207][https://github.com/nautobot/nautobot-app-ssot/pull/207] Drop Python 3.7 Support by @jdrew82
- [207](https://github.com/nautobot/nautobot-app-ssot/pull/207) Drop Python 3.7 Support by @jdrew82
Loading