The Python3 dev doc is more general than just modules (#22950)

The Python3 dev doc is more general than just modules

* Rename it to make that obvious.
* Move generally applicable Python3 information to the Controller section
* Add a Py3/Py2 section on formatting strings
* Fix code-blocks to highlight as python
* Enhance python3 support page
* Add Python3/Python2 compat note
This commit is contained in:
Toshio Kuratomi
2017-04-04 11:18:19 -07:00
committed by GitHub
parent 6f40cb9647
commit 3180b4757e
6 changed files with 195 additions and 76 deletions

View File

@@ -15,26 +15,56 @@ Testing Python 3 with commands and playbooks
* `Install Ansible 2.2+ <http://docs.ansible.com/ansible/intro_installation.html>`_
* To test Python 3 on the controller, run your ansible command via
`python3`. For example::
`python3`. For example:
.. code-block:: shell
$ python3 /usr/bin/ansible localhost -m ping
$ python3 /usr/bin/ansible-playbook sample-playbook.yml
python3 /usr/bin/ansible localhost -m ping
python3 /usr/bin/ansible-playbook sample-playbook.yml
Testing Python 3 module support
--------------------------------
* Set the ansible_python_interpreter configuration option to
`/usr/bin/python3`. The `ansible_python_interpreter` configuration option is usually set per-host as inventory variable associated with a host or set of hosts. See the `inventory documentation <http://docs.ansible.com/ansible/intro_inventory.html>`_ for more information.
* Run your command or playbook.::
:command:`/usr/bin/python3`. The ``ansible_python_interpreter`` configuration option is
usually set per-host as an inventory variable associated with a host or group of hosts:
$ ansible localhost -m ping
$ ansible-playbook sample-playbook.yml
.. code-block:: ini
# Example inventory that makes an alias for localhost that uses python3
[py3-hosts]
localhost-py3 ansible_host=localhost ansible_connection=local
[py3-hosts:vars]
ansible_python_interpreter=/usr/bin/python3
See the :ref:`inventory documentation <inventory>` for more information.
* Run your command or playbook:
.. code-block:: shell
ansible localhost-py3 -m ping
ansible-playbook sample-playbook.yml
Note that you can also use the `-e` command line option to manually set the python interpreter when you run a command. For example::
$ ansible localhost -m ping -e 'ansible_python_interpreter=/usr/bin/python3'
$ ansible-playbook sample-playbook.yml -e 'ansible_python_interpreter=/usr/bin/python3'
Note that you can also use the :option:`-e` command line option to manually
set the python interpreter when you run a command. For example:
.. code-block:: shell
ansible localhost -m ping -e 'ansible_python_interpreter=/usr/bin/python3'
ansible-playbook sample-playbook.yml -e 'ansible_python_interpreter=/usr/bin/python3'
What to do if an incompatibility is found
-----------------------------------------
If you find a bug while testing modules with Python3 you can submit a bug
report on `Ansible's GitHUb project
<https://github.com/ansible/ansible/issues/>_`. Be sure to mention Python3 in
the bug report so that the right people look at it.
If you would like to fix the code and submit a pull request on github, you can
refer to :doc:`dev_guide/developing_python3` for information on how we fix
common Python3 compatibility issues in the Ansible codebase.