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

correct the Python 3 virtualenv pip environment setup instructions #30988

Merged
merged 1 commit into from
Sep 28, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 18 additions & 11 deletions docs/docsite/rst/python_3_support.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,26 @@ Testing Python 3 with commands and playbooks

.. 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

You can also install Ansible using :program:`pip` for Python3 which will make the default
:command:`/usr/bin/ansible` run with Python3:

.. code-block:: shell

$ virtualenv py3-ansible
$ source ./bin/activate
$ virtualenv --python=python3 py3-ansible
$ source ./py3-ansible/bin/activate
$ pip3 install ansible
$ ansible --version|grep python
python version = 3.5.3 (default, May 10 2017, 15:05:55) [GCC 6.3.1 20161221 (Red Hat 6.3.1-1)]
$ ansible --version | grep "python version"
python version = 3.6.2 (default, Sep 22 2017, 08:28:09) [GCC 7.2.1 20170915 (Red Hat 7.2.1-2)]

On systems with SELinux installed, such as Red Hat Enterprise Linux or Fedora, the SELinux Python libraries also need to be copied over.

.. code-block:: shell

$ cp -r -v /usr/lib64/python3.*/site-packages/selinux/ ./py3-ansible/lib64/python3.*/site-packages/
$ cp -v /usr/lib64/python3.*/site-packages/*selinux*.so ./py3-ansible/lib64/python3.*/site-packages/

.. note:: Individual Linux distribution packages may be packaged for Python2 or Python3. When running from
distro packages you'll only be able to use Ansible with the Python version for which it was
Expand All @@ -58,23 +65,23 @@ Testing Python 3 module support
[py3-hosts:vars]
ansible_python_interpreter=/usr/bin/python3

See the :ref:`inventory documentation <inventory>` for more information.
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
$ ansible localhost-py3 -m ping
$ ansible-playbook sample-playbook.yml


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'
$ 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
-----------------------------------------
Expand Down