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

Extend boolean values section in playbooks_variables #1285

Open
wants to merge 5 commits into
base: devel
Choose a base branch
from

Conversation

skilyazhnev
Copy link

Hello!

in continuation of this issue

#1279

@ansible-documentation-bot ansible-documentation-bot bot added the new_contributor This PR is the first contribution by a new community member. label Apr 18, 2024
@ansible-documentation-bot
Copy link
Contributor

Thanks for your Ansible docs contribution! We talk about Ansible documentation on matrix at #docs:ansible.im and on libera IRC at #ansible-docs if you ever want to join us and chat about the docs! We meet there on Tuesdays (see the Ansible calendar) and welcome additions to our weekly agenda items - scroll down to find the upcoming agenda and add a comment to put something new on that agenda.

@oraNod oraNod added backport-2.15 Automatically create a backport for the stable-2.15 branch backport-2.16 Automatically create a backport for the stable-2.16 branch backport-2.17 Automatically create a backport for the stable-2.17 branch labels Apr 19, 2024
@skilyazhnev skilyazhnev requested a review from bcoca April 22, 2024 10:55
@oraNod oraNod added the backport-2.14 Automatically create a backport for the stable-2.14 branch label Apr 22, 2024
Copy link
Contributor

@oraNod oraNod left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks @skilyazhnev

While documentation examples focus on ``true/false`` to be compatible with ``ansible-lint`` default settings, you can use any of the following:
While documentation examples focus on ``true/false`` to be compatible with ``ansible-lint`` default settings. You can use any of the following values:

Native Boolean
Copy link
Member

Choose a reason for hiding this comment

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

I would avoid using "native boolean" for anything else than true/false because the only values that are native booleans in all versions of YAML specification.

Maybe we should mention that bit. Currently Ansible uses a YAML 1.1 loader, but when it will move to a 1.2 loader, only these values will remain booleans. This might help people understand better the long term implications.

Copy link
Member

Choose a reason for hiding this comment

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

the issue is not only YAML, Ansible has internal functions to convert booleans that follow the YAML 1.1 spec, so this can apply to JSON and Jinja2.

Copy link
Author

Choose a reason for hiding this comment

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

I would avoid using "native boolean" for anything else than true/false because the only values that are native booleans in all versions of YAML specification.

I can change header to Recognizable as Boolean (or smth like that) for that section, to separate it from Native boolean definition in yaml 1.2

And as I see, that section of Recognizable as Boolean\Native boolean still has to to be present here for new ansible version with new loader if it will support Core Schema of yml 1.2 because there still several valid variants of inputs true | True | TRUE | false | False | FALSE.
If not (It will wotk only with Json Schema) - in new version ofk make sense to reduce it to only two values.

PS: We can add some note like: just use true\false because that easier for everyone around

Copy link
Author

Choose a reason for hiding this comment

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

@ssbarnea
Could u plz clarify about yaml schema and name of segment to change PR

Copy link
Contributor

Choose a reason for hiding this comment

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

@skilyazhnev Thanks for keeping at this one.

How about we keep the "Native boolean" heading but put only true / false underneath that to reflect what @ssbarnea has mentioned about the spec: https://yaml.org/spec/1.2-old/spec.html#id2803629

For the other values in the current table, maybe we could rename the heading to "Implicit boolean"? Something like this:

Native boolean
--------------

Ansible treats these values as native booleans:

<table goes here>

Implicit boolean
------------------------

Ansible recognizes these values as booleans:

<table goes here>

@skilyazhnev skilyazhnev requested a review from ssbarnea May 7, 2024 08:03
docs/docsite/rst/playbook_guide/playbooks_variables.rst Outdated Show resolved Hide resolved
docs/docsite/rst/playbook_guide/playbooks_variables.rst Outdated Show resolved Hide resolved
``'false'`` , ``'f'`` , ``'no'`` , ``'n'`` , ``'off'`` , ``'0'`` , ``0`` Falsy values

================================================================================= ====================================================================

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's consider giving an example here with the | bool filter.

Co-authored-by: Don Naro <dnaro@redhat.com>
Co-authored-by: Don Naro <dnaro@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-2.14 Automatically create a backport for the stable-2.14 branch backport-2.15 Automatically create a backport for the stable-2.15 branch backport-2.16 Automatically create a backport for the stable-2.16 branch backport-2.17 Automatically create a backport for the stable-2.17 branch new_contributor This PR is the first contribution by a new community member.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants