Skip to content

Instantly share code, notes, and snippets.

@beddari
Created September 1, 2020 11:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beddari/0ac2558f024ea500fcc95cfb6fb383b9 to your computer and use it in GitHub Desktop.
Save beddari/0ac2558f024ea500fcc95cfb6fb383b9 to your computer and use it in GitHub Desktop.
Role authors, don't do this in your role
# If you specify a variable for users to set outside your role
# DO NOT overwrite it later.
#
# Due to precedence rules the combined value here will
# never be set in some cases, e.g when using include_role
#
- name: Set netbox_config.SECRET_KEY to generated SECRET_KEY
set_fact:
netbox_config: "{{ netbox_config | combine({'SECRET_KEY': _netbox_secret_key_file['content'] | b64decode}) }}"
# Instead, use an "internal variable" if you need to do combines or similar
- name: Set netbox_config.SECRET_KEY to generated SECRET_KEY
set_fact:
_netbox_config: "{{ netbox_config | combine({'SECRET_KEY': _netbox_secret_key_file['content'] | b64decode}) }}"
# Use the internal fact from this point ...
# Pretty? No. Does it work? Yes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment