-
Notifications
You must be signed in to change notification settings - Fork 240
Add ability to rename host inventory variables using patterns #1273
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
Merged
rodvand
merged 1 commit into
netbox-community:devel
from
cloudscale-ch:denis/rename-inventory-variables
Jul 2, 2024
Merged
Add ability to rename host inventory variables using patterns #1273
rodvand
merged 1 commit into
netbox-community:devel
from
cloudscale-ch:denis/rename-inventory-variables
Jul 2, 2024
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This looks like a sensible change - could you:
|
Sure, let me get back to you on that. |
201e80a
to
fb0b7ef
Compare
Certain environments may have conflicts with the variables given by Netbox, and the variables used in the existing Ansible codebase. With this change, such cases can be worked around by renaming individual variables, or whole groups of them. For example, this will rename all `cluster*` variables to have a `netbox__` prefix instead (e.g., `cluster_group` -> `netbox__cluster_group`): ```yaml rename_variables: - pattern: 'cluster(.*)' repl: 'netbox__cluster\1' ``` Uses a list, instead of a dict, to ensure that the order of evaluation is strictly defined across all Python versions, and to add the ability to exclude certain variables from being rewritten. For example: ```yaml rename_variables: # Keep cluster_type the same - pattern: 'cluster_type' repl: 'cluster_type' # Rename all other cluster* variables - pattern: 'cluster(.*)' repl: 'netbox__cluster\1' ```
fb0b7ef
to
2de8321
Compare
Please take another look, I've got the tests to pass and added a simple unit test. |
href
added a commit
to cloudscale-ch/netbox-community.ansible_modules
that referenced
this pull request
Jul 3, 2024
…-community#1273) Certain environments may have conflicts with the variables given by Netbox, and the variables used in the existing Ansible codebase. With this change, such cases can be worked around by renaming individual variables, or whole groups of them. For example, this will rename all `cluster*` variables to have a `netbox__` prefix instead (e.g., `cluster_group` -> `netbox__cluster_group`): ```yaml rename_variables: - pattern: 'cluster(.*)' repl: 'netbox__cluster\1' ``` Uses a list, instead of a dict, to ensure that the order of evaluation is strictly defined across all Python versions, and to add the ability to exclude certain variables from being rewritten. For example: ```yaml rename_variables: # Keep cluster_type the same - pattern: 'cluster_type' repl: 'cluster_type' # Rename all other cluster* variables - pattern: 'cluster(.*)' repl: 'netbox__cluster\1' ```
href
added a commit
to cloudscale-ch/netbox-community.ansible_modules
that referenced
this pull request
Jul 5, 2024
…-community#1273) Certain environments may have conflicts with the variables given by Netbox, and the variables used in the existing Ansible codebase. With this change, such cases can be worked around by renaming individual variables, or whole groups of them. For example, this will rename all `cluster*` variables to have a `netbox__` prefix instead (e.g., `cluster_group` -> `netbox__cluster_group`): ```yaml rename_variables: - pattern: 'cluster(.*)' repl: 'netbox__cluster\1' ``` Uses a list, instead of a dict, to ensure that the order of evaluation is strictly defined across all Python versions, and to add the ability to exclude certain variables from being rewritten. For example: ```yaml rename_variables: # Keep cluster_type the same - pattern: 'cluster_type' repl: 'cluster_type' # Rename all other cluster* variables - pattern: 'cluster(.*)' repl: 'netbox__cluster\1' ``` (cherry picked from commit a271a54)
k-304
pushed a commit
to cloudscale-ch/netbox-community.ansible_modules
that referenced
this pull request
Apr 1, 2025
…-community#1273) Certain environments may have conflicts with the variables given by Netbox, and the variables used in the existing Ansible codebase. With this change, such cases can be worked around by renaming individual variables, or whole groups of them. For example, this will rename all `cluster*` variables to have a `netbox__` prefix instead (e.g., `cluster_group` -> `netbox__cluster_group`): ```yaml rename_variables: - pattern: 'cluster(.*)' repl: 'netbox__cluster\1' ``` Uses a list, instead of a dict, to ensure that the order of evaluation is strictly defined across all Python versions, and to add the ability to exclude certain variables from being rewritten. For example: ```yaml rename_variables: # Keep cluster_type the same - pattern: 'cluster_type' repl: 'cluster_type' # Rename all other cluster* variables - pattern: 'cluster(.*)' repl: 'netbox__cluster\1' ``` (cherry picked from commit a271a54)
k-304
pushed a commit
to cloudscale-ch/netbox-community.ansible_modules
that referenced
this pull request
Apr 1, 2025
…-community#1273) Certain environments may have conflicts with the variables given by Netbox, and the variables used in the existing Ansible codebase. With this change, such cases can be worked around by renaming individual variables, or whole groups of them. For example, this will rename all `cluster*` variables to have a `netbox__` prefix instead (e.g., `cluster_group` -> `netbox__cluster_group`): ```yaml rename_variables: - pattern: 'cluster(.*)' repl: 'netbox__cluster\1' ``` Uses a list, instead of a dict, to ensure that the order of evaluation is strictly defined across all Python versions, and to add the ability to exclude certain variables from being rewritten. For example: ```yaml rename_variables: # Keep cluster_type the same - pattern: 'cluster_type' repl: 'cluster_type' # Rename all other cluster* variables - pattern: 'cluster(.*)' repl: 'netbox__cluster\1' ``` (cherry picked from commit a271a54)
k-304
pushed a commit
to cloudscale-ch/netbox-community.ansible_modules
that referenced
this pull request
Apr 7, 2025
…-community#1273) Certain environments may have conflicts with the variables given by Netbox, and the variables used in the existing Ansible codebase. With this change, such cases can be worked around by renaming individual variables, or whole groups of them. For example, this will rename all `cluster*` variables to have a `netbox__` prefix instead (e.g., `cluster_group` -> `netbox__cluster_group`): ```yaml rename_variables: - pattern: 'cluster(.*)' repl: 'netbox__cluster\1' ``` Uses a list, instead of a dict, to ensure that the order of evaluation is strictly defined across all Python versions, and to add the ability to exclude certain variables from being rewritten. For example: ```yaml rename_variables: # Keep cluster_type the same - pattern: 'cluster_type' repl: 'cluster_type' # Rename all other cluster* variables - pattern: 'cluster(.*)' repl: 'netbox__cluster\1' ```
k-304
pushed a commit
to cloudscale-ch/netbox-community.ansible_modules
that referenced
this pull request
Apr 7, 2025
…-community#1273) Certain environments may have conflicts with the variables given by Netbox, and the variables used in the existing Ansible codebase. With this change, such cases can be worked around by renaming individual variables, or whole groups of them. For example, this will rename all `cluster*` variables to have a `netbox__` prefix instead (e.g., `cluster_group` -> `netbox__cluster_group`): ```yaml rename_variables: - pattern: 'cluster(.*)' repl: 'netbox__cluster\1' ``` Uses a list, instead of a dict, to ensure that the order of evaluation is strictly defined across all Python versions, and to add the ability to exclude certain variables from being rewritten. For example: ```yaml rename_variables: # Keep cluster_type the same - pattern: 'cluster_type' repl: 'cluster_type' # Rename all other cluster* variables - pattern: 'cluster(.*)' repl: 'netbox__cluster\1' ``` (cherry picked from commit a271a54)
k-304
pushed a commit
to cloudscale-ch/netbox-community.ansible_modules
that referenced
this pull request
Apr 7, 2025
…-community#1273) Certain environments may have conflicts with the variables given by Netbox, and the variables used in the existing Ansible codebase. With this change, such cases can be worked around by renaming individual variables, or whole groups of them. For example, this will rename all `cluster*` variables to have a `netbox__` prefix instead (e.g., `cluster_group` -> `netbox__cluster_group`): ```yaml rename_variables: - pattern: 'cluster(.*)' repl: 'netbox__cluster\1' ``` Uses a list, instead of a dict, to ensure that the order of evaluation is strictly defined across all Python versions, and to add the ability to exclude certain variables from being rewritten. For example: ```yaml rename_variables: # Keep cluster_type the same - pattern: 'cluster_type' repl: 'cluster_type' # Rename all other cluster* variables - pattern: 'cluster(.*)' repl: 'netbox__cluster\1' ```
k-304
pushed a commit
to cloudscale-ch/netbox-community.ansible_modules
that referenced
this pull request
Apr 7, 2025
…-community#1273) Certain environments may have conflicts with the variables given by Netbox, and the variables used in the existing Ansible codebase. With this change, such cases can be worked around by renaming individual variables, or whole groups of them. For example, this will rename all `cluster*` variables to have a `netbox__` prefix instead (e.g., `cluster_group` -> `netbox__cluster_group`): ```yaml rename_variables: - pattern: 'cluster(.*)' repl: 'netbox__cluster\1' ``` Uses a list, instead of a dict, to ensure that the order of evaluation is strictly defined across all Python versions, and to add the ability to exclude certain variables from being rewritten. For example: ```yaml rename_variables: # Keep cluster_type the same - pattern: 'cluster_type' repl: 'cluster_type' # Rename all other cluster* variables - pattern: 'cluster(.*)' repl: 'netbox__cluster\1' ``` (cherry picked from commit a271a54)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related Issue
None.
New Behavior
Certain environments may have conflicts with the variables given by Netbox, and the variables used in the existing Ansible codebase.
With this change, such cases can be worked around by renaming individual variables, or whole groups of them.
For example, this will rename all
cluster*
variables to have anetbox__
prefix instead (e.g.,cluster_group
->netbox__cluster_group
):Uses a list, instead of a dict, to ensure that the order of evaluation is strictly defined across all Python versions, and to add the ability to exclude certain variables from being rewritten. For example:
Contrast to Current Behavior
Currently, the variable names are hard-coded and cannot be modified.
Discussion: Benefits and Drawbacks
With this change, it becomes easier to adapt Netbox to code-bases where some of the variables found in Netbox already have a meaning.
The change is purely optional, so anyone that does not need it, can just ignore it.
Changes to the Documentation
The documentation is updated in the module. I assume this will be published once merged.
Proposed Release Note Entry
Add ability to rename host inventory variables using patterns, to avoid conflicts with existing variables.
...
Double Check
devel
branch.