Variable prefix
Prefix variable names with role or project prefix.
Categories:
Prefix variables in Ansible roles / collections with the role name. For example
harbor_hostname
. Prefix other / project variables with a project prefix for examplec2_cacerts2_ca_dir
.
Problem
Without a project of role prefix it is not always clear where variables are used. Without a prefix there is also a chance of conflicting duplicating variables.
Context
In a typical project typically all kinds of variables are created / used. Some variables are used in Ansible roles but some do not. This can be confusing and lead to mistakes / problems.
Solution
- Prefix all variables used in an Ansible role with the role name for example
harbor_
. - Prefix all other / project variables - that only exists in
group_vars
orhost_vars
folder - with a project prefix for examplec2_
.
Examples and implementation
- For example
harbor_hostname
for the hostname of the Harbor instance. The prefix isharbor_
because this is a variable that is part of thec2platform.mgmt.harbor
Ansible role. - In C2 Inventory project
c2platform/ansible
c2_
is used as a prefix see for examplec2_cacerts2_ca_dir
ingroup_vars/all/smallca.yml
. - In the RWS Inventory project
c2platform/rws/ansible-gis
gs_
is used as prefix. See Configuring a Web Proxy Server Example for MS Windows Hosts for an example on howgs_proxy_regedit
is utilized to configure a web proxy.
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.
Last modified June 24, 2024: rws firefox profile for gsd / gst with landing pages and community website RWS-895 (014856f)