From 56285b1d2bd6dd4ae8ec63fcabcbdba76c4a1cf5 Mon Sep 17 00:00:00 2001 From: prayatharth <73949575+prayatharth@users.noreply.github.com> Date: Tue, 4 Oct 2022 19:59:26 +0530 Subject: [PATCH] Docs: true/false with boolean values (#78980) * Adding FQCN community.postgresql. to postgresql modules --- .../collection_integration_about.rst | 7 +++--- .../collection_integration_add.rst | 6 ++--- .../collection_integration_updating.rst | 24 +++++++++---------- .../developing_modules_general_windows.rst | 2 +- docs/docsite/rst/plugins/inventory.rst | 2 +- docs/docsite/rst/tips_tricks/sample_setup.rst | 6 ++--- 6 files changed, 22 insertions(+), 25 deletions(-) diff --git a/docs/docsite/rst/community/collection_contributors/collection_integration_about.rst b/docs/docsite/rst/community/collection_contributors/collection_integration_about.rst index 2e2bccb1927..652b11f631c 100644 --- a/docs/docsite/rst/community/collection_contributors/collection_integration_about.rst +++ b/docs/docsite/rst/community/collection_contributors/collection_integration_about.rst @@ -27,7 +27,7 @@ Let's say we want to test the ``postgresql_user`` module invoked with the ``name .. code-block:: yaml - name: Create PostgreSQL user and store module's output to the result variable - postgresql_user: + community.postgresql.postgresql_user: name: test_user register: result @@ -37,7 +37,7 @@ Let's say we want to test the ``postgresql_user`` module invoked with the ``name - result is changed - name: Check actual system state with another module, in other words, that the user exists - postgresql_query: + community.postgresql.postgresql_query: query: SELECT * FROM pg_authid WHERE rolename = 'test_user' register: query_result @@ -129,7 +129,7 @@ To check a task: 2. If the module changes the system state, check the actual system state using at least one other module. For example, if the module changes a file, we can check that the file has been changed by checking its checksum with the :ref:`stat ` module before and after the test tasks. 3. Run the same task with ``check_mode: yes`` if check-mode is supported by the module. Check with other modules that the actual system state has not been changed. -4. Cover cases when the module must fail. Use the ``ignore_errors: yes`` option and check the returned message with the ``assert`` module. +4. Cover cases when the module must fail. Use the ``ignore_errors: true`` option and check the returned message with the ``assert`` module. Example: @@ -139,7 +139,6 @@ Example: abstract_module: ... register: result - ignore_errors: yes - name: Check the task fails and its error message assert: diff --git a/docs/docsite/rst/community/collection_contributors/collection_integration_add.rst b/docs/docsite/rst/community/collection_contributors/collection_integration_add.rst index 6d1ce4d3ece..b73c0326608 100644 --- a/docs/docsite/rst/community/collection_contributors/collection_integration_add.rst +++ b/docs/docsite/rst/community/collection_contributors/collection_integration_add.rst @@ -189,7 +189,7 @@ With all of the targets now removed, the current state is as if we do not have a creates: /etc/postgresql/12/ - name: Start PostgreSQL service - service: + ansible.builtin.service: name: postgresql state: started @@ -213,9 +213,9 @@ That is enough for our very basic example. .. code-block:: yaml - name: Test postgresql_info module - become: yes + become: true become_user: postgres - postgresql_info: + community.postgresql.postgresql_info: login_user: postgres login_db: postgres register: result diff --git a/docs/docsite/rst/community/collection_contributors/collection_integration_updating.rst b/docs/docsite/rst/community/collection_contributors/collection_integration_updating.rst index a8f89dfd8af..eb115ae2939 100644 --- a/docs/docsite/rst/community/collection_contributors/collection_integration_updating.rst +++ b/docs/docsite/rst/community/collection_contributors/collection_integration_updating.rst @@ -44,7 +44,7 @@ We will add the following code to the file. # https://github.com/ansible-collections/community.postgresql/issues/NUM - name: Test user name containing underscore - postgresql_user: + community.postgresql.postgresql_user: name: underscored_user register: result @@ -54,7 +54,7 @@ We will add the following code to the file. - result is changed - name: Query the database if the user exists - postgresql_query: + community.postgresql.postgresql_query: query: SELECT * FROM pg_authid WHERE rolename = 'underscored_user' register: result @@ -108,9 +108,8 @@ We will add the following code to the file. # https://github.com/ansible-collections/community.postgresql/issues/NUM # We should also run the same tasks with check_mode: yes. We omit it here for simplicity. - name: Test for new_option, create new user WITHOUT the attribute - postgresql_user: - name: test_user - add_attribute: no + community.postgresql.postgresql_user: + name: test_user register: result - name: Check the module returns what we expect @@ -119,7 +118,7 @@ We will add the following code to the file. - result is changed - name: Query the database if the user exists but does not have the attribute (it is NULL) - postgresql_query: + community.postgresql.postgresql_query: query: SELECT * FROM pg_authid WHERE rolename = 'test_user' AND attribute = NULL register: result @@ -129,9 +128,8 @@ We will add the following code to the file. - result.query_result.rowcount == 1 - name: Test for new_option, create new user WITH the attribute - postgresql_user: + community.postgresql.postgresql_user: name: test_user - add_attribute: yes register: result - name: Check the module returns what we expect @@ -140,7 +138,7 @@ We will add the following code to the file. - result is changed - name: Query the database if the user has the attribute (it is TRUE) - postgresql_query: + community.postgresql.postgresql_query: query: SELECT * FROM pg_authid WHERE rolename = 'test_user' AND attribute = 't' register: result @@ -153,16 +151,16 @@ Then we :ref:`run the tests` with ``postgresql In reality, we would alternate the tasks above with the same tasks run with the ``check_mode: yes`` option to be sure our option works as expected in check-mode as well. See :ref:`Recommendations on coverage` for details. -If we expect a task to fail, we use the ``ignore_errors: yes`` option and check that the task actually failed and returned the message we expect: +If we expect a task to fail, we use the ``ignore_errors: true`` option and check that the task actually failed and returned the message we expect: .. code-block:: yaml - name: Test for fail_when_true option - postgresql_user: + community.postgresql.postgresql_user: name: test_user - fail_when_true: yes + fail_when_true: true register: result - ignore_errors: yes + ignore_errors: true - name: Check the module fails and returns message we expect assert: diff --git a/docs/docsite/rst/dev_guide/developing_modules_general_windows.rst b/docs/docsite/rst/dev_guide/developing_modules_general_windows.rst index 4b742a2c52d..b5b8c4a62cb 100644 --- a/docs/docsite/rst/dev_guide/developing_modules_general_windows.rst +++ b/docs/docsite/rst/dev_guide/developing_modules_general_windows.rst @@ -695,7 +695,7 @@ idempotent and does not report changes. For example: path: C:\temp state: absent register: remove_file_check - check_mode: yes + check_mode: true - name: get result of remove a file (check mode) win_command: powershell.exe "if (Test-Path -Path 'C:\temp') { 'true' } else { 'false' }" diff --git a/docs/docsite/rst/plugins/inventory.rst b/docs/docsite/rst/plugins/inventory.rst index 3328af62e48..046effa42f3 100644 --- a/docs/docsite/rst/plugins/inventory.rst +++ b/docs/docsite/rst/plugins/inventory.rst @@ -134,7 +134,7 @@ Inventory plugins that support caching can use the general settings for the fact # demo.aws_ec2.yml plugin: amazon.aws.aws_ec2 - cache: yes + cache: true cache_plugin: ansible.builtin.jsonfile cache_timeout: 7200 cache_connection: /tmp/aws_inventory diff --git a/docs/docsite/rst/tips_tricks/sample_setup.rst b/docs/docsite/rst/tips_tricks/sample_setup.rst index 068677ac1db..fc8c477169b 100644 --- a/docs/docsite/rst/tips_tricks/sample_setup.rst +++ b/docs/docsite/rst/tips_tricks/sample_setup.rst @@ -188,10 +188,10 @@ Ansible loads any file called ``main.yml`` in a role sub-directory. This sample tags: ntp - name: be sure ntpd is running and enabled - service: + ansible.builtin.service: name: ntpd state: started - enabled: yes + enabled: true tags: ntp Here is an example handlers file. Handlers are only triggered when certain tasks report changes. Handlers run at the end of each play: @@ -201,7 +201,7 @@ Here is an example handlers file. Handlers are only triggered when certain tasks --- # file: roles/common/handlers/main.yml - name: restart ntpd - service: + ansible.builtin.service: name: ntpd state: restarted