Skip to content

Commit

Permalink
Backport/2.11/docs1 (#74457)
Browse files Browse the repository at this point in the history
* Fix issue with version 3 in docs version list (#74089)

Previously would subsitute the "3" in "s3" instead of the version location in the URL

(cherry picked from commit 325ccf2)

* corrected epmhasis line (#74254)

need to be careful when adding lines as you create a different offset

(cherry picked from commit 7b39ee3)

* correct how to install Docker SDK for Python (#74288)

* docs: correct guide for the latest Docker SDK for Python
Co-authored-by: Felix Fontein <felix@fontein.de>
Co-authored-by: Sandra McCann <samccann@redhat.com>
Co-authored-by: Daeseok Youn <daeseok.youn@navercorp.com>
Co-authored-by: Alicia Cozine <879121+acozine@users.noreply.github.com>

(cherry picked from commit 9369bd6)

* Provide results to examples (#73984)

(cherry picked from commit 99a2b5f)

* remove deprecated ansible.module_utils._text from documentation (#73211)

According to comment in ansible.module_utils._text it is deprecated and
should not be used. This is now reflected in the documentation.

(cherry picked from commit 5e5bfa8)

* Update playbooks_filters.rst (#74242)

##### SUMMARY
Make the `random` filter description more clear.

(cherry picked from commit 5f391a7)

* Docs: Fix k8s_config_resource_name YAML example (#74129)

The `name` key should be beneath `metadata`:

(cherry picked from commit c9c8459)

* Update lookup.rst (#73716)

Document that users must pass `allow_unsafe=True` as an option in the lookup to allow templating, with a note about security implications.

Co-authored-by: Alicia Cozine <879121+acozine@users.noreply.github.com>
Co-authored-by: Sandra McCann <samccann@redhat.com>
(cherry picked from commit c0cc574)

* vmware: Add a note about known issue (#73273)

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Co-authored-by: Sandra McCann <samccann@redhat.com>
Co-authored-by: Alicia Cozine <879121+acozine@users.noreply.github.com>
(cherry picked from commit 6e56e72)

Co-authored-by: Scott Sinclair <252082+pwae@users.noreply.github.com>
Co-authored-by: Brian Coca <bcoca@users.noreply.github.com>
Co-authored-by: daeseokyoun <daeseok.youn@gmail.com>
Co-authored-by: Baptiste Mille-Mathias <baptiste.millemathias@gmail.com>
Co-authored-by: schurzi <github@drachen-server.de>
Co-authored-by: yuri <1969yuri1969@gmail.com>
Co-authored-by: ml <6209465+ml-@users.noreply.github.com>
Co-authored-by: sry9681 <sry9681@users.noreply.github.com>
Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com>
  • Loading branch information
10 people committed Apr 28, 2021
1 parent 4e3f422 commit 8d03c2d
Show file tree
Hide file tree
Showing 12 changed files with 76 additions and 35 deletions.
6 changes: 3 additions & 3 deletions docs/docsite/_themes/sphinx_rtd_theme/ansible_versions.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
if ( "{{ slug }}" == "{{ current_version }}" ) {
option.selected = true;
}
if (current_url.search("{{ current_version }}") > -1) {
option.value = current_url.replace("{{ current_version }}","{{ slug }}");
if (current_url.search("/{{ current_version }}/") > -1) {
option.value = current_url.replace("/{{ current_version }}/","/{{ slug }}/");
} else {
option.value = current_url.replace("latest","{{ slug }}");
option.value = current_url.replace("/latest/","/{{ slug }}/");
}
x.add(option);
</script>
Expand Down
2 changes: 1 addition & 1 deletion docs/docsite/rst/dev_guide/developing_collections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ In the Python example the ``module_util`` in question is called ``qradar`` such
.. code-block:: python
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils._text import to_text
from ansible.module_utils.common.text.converters import to_text
from ansible.module_utils.six.moves.urllib.parse import urlencode, quote_plus
from ansible.module_utils.six.moves.urllib.error import HTTPError
Expand Down
4 changes: 2 additions & 2 deletions docs/docsite/rst/dev_guide/developing_plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ You should return errors encountered during plugin execution by raising ``Ansibl

.. code-block:: python
from ansible.module_utils._text import to_native
from ansible.module_utils.common.text.converters import to_native
try:
cause_an_exception()
Expand All @@ -45,7 +45,7 @@ You must convert any strings returned by your plugin into Python's unicode type.

.. code-block:: python
from ansible.module_utils._text import to_text
from ansible.module_utils.common.text.converters import to_text
result_string = to_text(result_string)
Plugin configuration & documentation standards
Expand Down
10 changes: 5 additions & 5 deletions docs/docsite/rst/dev_guide/developing_python_3.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ to yield text but instead do the conversion explicitly ourselves. For example:

.. code-block:: python
from ansible.module_utils._text import to_text
from ansible.module_utils.common.text.converters import to_text
with open('filename-with-utf8-data.txt', 'rb') as my_file:
b_data = my_file.read()
Expand All @@ -136,7 +136,7 @@ Writing to files is the opposite process:

.. code-block:: python
from ansible.module_utils._text import to_bytes
from ansible.module_utils.common.text.converters import to_bytes
with open('filename.txt', 'wb') as my_file:
my_file.write(to_bytes(some_text_string))
Expand All @@ -160,7 +160,7 @@ works on both versions:
import os.path
from ansible.module_utils._text import to_bytes
from ansible.module_utils.common.text.converters import to_bytes
filename = u'/var/tmp/くらとみ.txt'
f = open(to_bytes(filename), 'wb')
Expand Down Expand Up @@ -246,9 +246,9 @@ In ``module_utils`` code:
* Functions that return strings **must** document whether they return strings of the same type as they were given or native strings.

Module-utils functions are therefore often very defensive in nature.
They convert their string parameters into text (using ``ansible.module_utils._text.to_text``)
They convert their string parameters into text (using ``ansible.module_utils.common.text.converters.to_text``)
at the beginning of the function, do their work, and then convert
the return values into the native string type (using ``ansible.module_utils._text.to_native``)
the return values into the native string type (using ``ansible.module_utils.common.text.converters.to_native``)
or back to the string type that their parameters received.

Tips, tricks, and idioms for Python 2/Python 3 compatibility
Expand Down
2 changes: 1 addition & 1 deletion docs/docsite/rst/dev_guide/migrating_roles.rst
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ In the Python example the ``module_utils`` is ``helper`` and the :abbr:`FQCN (Fu
.. code-block:: text
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils._text import to_text
from ansible.module_utils.common.text.converters import to_text
from ansible.module_utils.six.moves.urllib.parse import urlencode
from ansible.module_utils.six.moves.urllib.error import HTTPError
from ansible_collections.ansible_example.community.plugins.module_utils.helper import HelperRequest
Expand Down
4 changes: 2 additions & 2 deletions docs/docsite/rst/dev_guide/testing/sanity/no-basestring.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ from ``ansible.module_utils.six`` and then use ``isinstance(s, string_types)``
or ``isinstance(s, (binary_type, text_type))`` instead.

If this is part of code to convert a string to a particular type,
``ansible.module_utils._text`` contains several functions that may be even
better for you: ``to_text``, ``to_bytes``, and ``to_native``.
``ansible.module_utils.common.text.converters`` contains several functions
that may be even better for you: ``to_text``, ``to_bytes``, and ``to_native``.
4 changes: 2 additions & 2 deletions docs/docsite/rst/dev_guide/testing_units_modules.rst
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ variable is set it will be treated as if the input came on ``STDIN`` to the modu

import json
from units.modules.utils import set_module_args
from ansible.module_utils._text import to_bytes
from ansible.module_utils.common.text.converters import to_bytes

def test_already_registered(self):
set_module_args({
Expand Down Expand Up @@ -388,7 +388,7 @@ mock for :meth:`Ansible.get_bin_path`::
from units.compat import unittest
from units.compat.mock import patch
from ansible.module_utils import basic
from ansible.module_utils._text import to_bytes
from ansible.module_utils.common.text.converters import to_bytes
from ansible.modules.namespace import my_module


Expand Down
1 change: 1 addition & 0 deletions docs/docsite/rst/plugins/lookup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Lookup plugins are an Ansible-specific extension to the Jinja2 templating langua
- Lookups are executed with a working directory relative to the role or play,
as opposed to local tasks, which are executed relative the executed script.
- Pass ``wantlist=True`` to lookups to use in Jinja2 template "for" loops.
- By default, lookup return values are marked as unsafe for security reasons. If you trust the outside source your lookup accesses, pass ``allow_unsafe=True`` to allow Jinja2 templates to evaluate lookup values.

.. warning::
- Some lookups pass arguments to a shell. When using variables from a remote/untrusted source, use the `|quote` filter to ensure safe usage.
Expand Down
10 changes: 8 additions & 2 deletions docs/docsite/rst/scenario_guides/guide_docker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,19 @@ Most of the modules and plugins in community.docker require the `Docker SDK for

Note that plugins (inventory plugins and connection plugins) are always executed in the context of Ansible itself. If you use a plugin that requires the Docker SDK for Python, you need to install it on the machine running ``ansible`` or ``ansible-playbook`` and for the same Python interpreter used by Ansible. To see which Python is used, run ``ansible --version``.

You can install the Docker SDK for Python for Python 2.7 or Python 3 as follows:
You can install the Docker SDK for Python for Python 3.6 or later as follows:

.. code-block:: bash
$ pip install docker
For Python 2.6, you need a version before 2.0. For these versions, the SDK was called ``docker-py``, so you need to install it as follows:
For Python 2.7, you need to use a version between 2.0.0 and 4.4.4 since the Python package for Docker removed support for Python 2.7 on 5.0.0. You can install the specific version of the Docker SDK for Python as follows:

.. code-block:: bash
$ pip install 'docker==4.4.4'
For Python 2.6, you need a version before 2.0.0. For these versions, the SDK was called ``docker-py``, so you need to install it as follows:

.. code-block:: bash
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,5 @@ For example, if ``/var/vmware/certs/vcenter1.crt`` is the SSL certificate for yo
password: '{{ vcenter_password }}'
environment:
REQUESTS_CA_BUNDLE: /var/vmware/certs/vcenter1.crt
There is a `known issue <https://github.com/psf/requests/issues/3829>`_ in ``requests`` library (version 2) which you may want to consider when using this environment variable. Basically, setting ``REQUESTS_CA_BUNDLE`` environment variable on managed nodes overrides the ``validate_certs`` value. This may result in unexpected behavior while running the playbook. Please see `community.vmware issue 601 <https://github.com/ansible-collections/community.vmware/issues/601>`_ and `vmware issue 254 <https://github.com/vmware/vsphere-automation-sdk-python/issues/254>`_ for more information.
6 changes: 3 additions & 3 deletions docs/docsite/rst/user_guide/complex_data_manipulation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ The Python equivalent code would be:
There are several ways to do it in Ansible, this is just one example:

.. code-block:: YAML+Jinja
:emphasize-lines: 3
:emphasize-lines: 4
:caption: Way to extract matching keys from a list of dictionaries

tasks:
Expand Down Expand Up @@ -110,7 +110,7 @@ In this case, we want to find the mount point for a given path across our machin

.. code-block:: YAML+Jinja
:caption: Use selectattr to filter mounts into list I can then sort and select the last from
:emphasize-lines: 7
:emphasize-lines: 8

- hosts: all
gather_facts: True
Expand All @@ -131,7 +131,7 @@ The special ``omit`` variable ONLY works with module options, but we can still u

.. code-block:: YAML+Jinja
:caption: Inline list filtering when feeding a module option
:emphasize-lines: 3, 7
:emphasize-lines: 3, 6

- name: Enable a list of Windows features, by name
ansible.builtin.set_fact:
Expand Down

0 comments on commit 8d03c2d

Please sign in to comment.