-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Update all examples to assume Python 3 by default #93
Comments
@ss10sb - Good idea! Right now the only OSes where this is a concern are Ubuntu 16 and 18... but it will become more and more important. I think I'll add a note/warning in there about it. Hopefully Ansible itself will eventually get more intelligent about detecting Python 3 installed on a system :/ See related issue upstream: ansible/ansible#26163 |
It's now an issue on Debian 10, which includes Python 3 as the default (though I think it aliases So yes, I think at some point I'm going to try to figure out how to introduce this a little more gently. Otherwise, I wonder if support is now better, as according to the docs, Ansible will automatically use python3 on certain managed OSes... https://docs.ansible.com/ansible/latest/reference_appendices/python_3_support.html I'll have to do some testing to see if I still need to do my hacky hack:
|
Hi! I have found an issue installing pip via apt on Debian 10 (apt-get install python3-pip) A solution for this is to install your ansible node with only pip(3)-packages.
Upgrade of all pip-installed packages is now easy:
Command taken from Stack Overflow: How to upgrade all Python packages with pip? This way your ansible-server is installed with only python3, no python2 needed at all. ansible 2.8.7 When you install ansible via pip, you will not get the default ansible.cfg in /etc/ansible. |
Updating issue title, and also noting changes from closed PR #148. |
Through various other issues, I've actually updated almost everything to default to Python 3 now, especially after updating examples to use Debian 10 and Ubuntu 20.04 (both of which have Python 3 by default and make it slightly harder to use Python 2). So I think I can confidently close out this issue after removing one more change that is not necessary anymore (see commit coming soon). There are still a few places in the book where Python 2 is used for CentOS 7 examples, but a couple of those have issues open for them or I'll work on updating them (e.g. switching to CentOS 8) at a later date. |
I think it might be worth adding a blurb early on (maybe in the 'creating a basic inventory file' part) about setting ansible to use python 3 by default (for distros that no longer come with 2.7).
For [example], it could be as simple as mentioning you can add a couple of lines to the inventory file like:
[example:vars]
ansible_python_interpreter=/usr/bin/python3
Or even directly to the host line. Just to get things started and not fail immediately on the ping example :)
The text was updated successfully, but these errors were encountered: