ansible / ansible-documentation

Ansible community documentation
https://docs.ansible.com/
GNU General Public License v3.0
74 stars 442 forks source link

Extend boolean values section in playbooks_variables #1279

Open skilyazhnev opened 4 months ago

skilyazhnev commented 4 months ago

Hello!

The table presents boolean values and their interpretations within Ansible. https://github.com/ansible/ansible-documentation/blob/adb97e4daa2b0d1a155b6707dca0f160d2de2993/docs/docsite/rst/playbook_guide/playbooks_variables.rst?plain=1#L106-L116

However, the distinction between native boolean values and those interpretable as boolean could be clearer. This lack of distinction might lead users to misunderstand how Ansible processes certain values.

When I look at that table, it's obvious to me that I can run the play, and the "check" task within the play won't execute. (ansible-core)

- hosts: all
  connection: local
  vars:
    check: 'false'
  tasks:
    - name: check 
      debug:
        msg: "{{ check }}"
      when: check
      delegate_to: localhost

But it will execute because it will be interpreted as True (not an empty string). And I have to use | bool to force work it right.

There is some note about "Native" bool values and intetpritation in test article

https://github.com/ansible/ansible-documentation/blob/adb97e4daa2b0d1a155b6707dca0f160d2de2993/docs/docsite/rst/playbook_guide/playbooks_tests.rst?plain=1#L505-L521

But looks like better to clarify that in Boolean variables section.

To address this, I propose splitting the section into two subsections:

Native Boolean: This subsection would outline values natively recognized as boolean by Ansible, such as yes, true, false, etc.

Interpretable as Bool: Here, we could elaborate on values that may not be natively recognized but can be interpreted as boolean ('false', 'f' etc...), emphasizing the usage of the bool filter for proper conversion.

How do you think?

Tested on

$ ansible --version
ansible [core 2.15.9]
  config file = None
  python version = 3.9.6
  jinja version = 3.1.3
  libyaml = True
ansible-documentation-bot[bot] commented 4 months ago

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 commented 4 months ago

Hi @skilyazhnev Thanks for opening this issue! I've used your example and can observe the behaviour you mention. It's interesting and the proposal to split the section seems reasonable to me. There's always room for more nuance in the docs, I find. However I'm also mindful that folks from the core team or some of the super knowledgeable community folks could see things differently and have other recommendations.

The best way to find out is usually a PR. Do you want to make the changes you're suggesting and submit a PR to this repo?

skilyazhnev commented 4 months ago

@oraNod Sure, I will prepare PR with proposal for that section.