clarifies that vars can begin with _, with a warning (#69749)

Co-authored-by: Sayee <57951841+sayee-jadhav@users.noreply.github.com>

Co-authored-by: Alicia Cozine <acozine@users.noreply.github.com>
Co-authored-by: Sayee <57951841+sayee-jadhav@users.noreply.github.com>
pull/70021/head
Alicia Cozine 5 years ago committed by GitHub
parent 8d93ba9120
commit 851e8e18b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -18,7 +18,9 @@ Once you understand the concepts and examples on this page, read about :ref:`Ans
Creating valid variable names Creating valid variable names
============================= =============================
Not all strings are valid Ansible variable names. A variable name must start with a letter, and can only include letters, numbers, and underscores. `Python keywords`_ and :ref:`playbook keywords<playbook_keywords>` are not valid variable names. Not all strings are valid Ansible variable names. A variable name can only include letters, numbers, and underscores. `Python keywords`_ and :ref:`playbook keywords<playbook_keywords>` are not valid variable names. A variable name cannot begin with a number.
Variable names can begin with an underscore. In many programming languages, variables that begin with an underscore are private. This is not true in Ansible. Variables that begin with an underscore are treated exactly the same as any other variable. Do not rely on this convention for privacy or security.
.. table:: .. table::
:class: documentation-table :class: documentation-table
@ -32,7 +34,7 @@ Not all strings are valid Ansible variable names. A variable name must start wit
``foo_port`` ``foo-port``, ``foo port``, ``foo.port`` ``foo_port`` ``foo-port``, ``foo port``, ``foo.port``
``foo5`` ``5foo``, ``12`` ``foo5``, ``_foo`` ``5foo``, ``12``
====================== ==================================================================== ====================== ====================================================================
.. _Python keywords: https://docs.python.org/3/reference/lexical_analysis.html#keywords .. _Python keywords: https://docs.python.org/3/reference/lexical_analysis.html#keywords

Loading…
Cancel
Save