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

Add ability to rename host inventory variables using patterns (#1273) #5

Closed
wants to merge 1 commit into from

Conversation

href
Copy link

@href href commented Jul 3, 2024

We use this already, but this is the upstream commit, which should make it easier to rebase in the future.

…-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 href requested a review from k-304 July 3, 2024 15:09
@href href self-assigned this Jul 3, 2024
Copy link

@k-304 k-304 left a comment

Choose a reason for hiding this comment

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

Tested with selected tests of #4 (comment) . Seems to return the same (correct) data.

@href
Copy link
Author

href commented Jul 5, 2024

Merged manually.

@href href closed this Jul 5, 2024
@href href deleted the denis/upstream-rename branch July 5, 2024 08:53
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