title: How to install ansible 2.9+ on ubuntu 18.04 and utilize python3?
body: <p>I'm trying to install <em>minimal</em> ansible 2.9.x on Ubuntu Bionic (18.04 LTS).</p>
  
  <p>The final goal is to build new disk image (using packer) on every commit and want the process to be as fast as possible.</p>
  
  <h1>Using default Ubuntu ansible</h1>
  
  <p>Default ansible in <a href="https://packages.ubuntu.com/search?keywords=ansible&amp;searchon=names&amp;suite=bionic&amp;section=all" rel="noreferrer">bionic is 2.5.x</a>.</p>
  
  <p>This is too old, all ansible scripts are written for 2.9+.</p>
  
  <h1>Using official PPA</h1>
  
  <p>Using <a href="https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#installing-ansible-on-debian" rel="noreferrer">recommended way to install</a> suggests adding following line to <code>/etc/apt/sources.list</code>:</p>
  
  <pre><code>deb http://ppa.launchpad.net/ansible/ansible/ubuntu trusty main
  </code></pre>
  
  <p>and running following commands:</p>
  
  <pre><code>$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 93C4A3FD7BB9C367
  $ sudo apt update
  $ sudo apt install ansible
  </code></pre>
  
  <p>but it still requires python2 packages:</p>
  
  <pre><code>$ sudo apt install ansible
  Reading package lists... Done
  Building dependency tree       
  Reading state information... Done
  The following additional packages will be installed:
    libpython-stdlib libpython2.7-minimal libpython2.7-stdlib python python-asn1crypto
    python-cffi-backend python-crypto python-cryptography python-enum34 python-httplib2
    python-idna python-ipaddress python-jinja2 python-markupsafe python-minimal
    python-paramiko python-pkg-resources python-pyasn1 python-setuptools python-six
    python-yaml python2.7 python2.7-minimal sshpass
  Suggested packages:
    python-doc python-tk python-crypto-doc python-cryptography-doc
    python-cryptography-vectors python-enum34-doc python-jinja2-doc python-gssapi
    python-setuptools-doc python2.7-doc binutils binfmt-support
  The following NEW packages will be installed:
    ansible libpython-stdlib libpython2.7-minimal libpython2.7-stdlib python
    python-asn1crypto python-cffi-backend python-crypto python-cryptography python-enum34
    python-httplib2 python-idna python-ipaddress python-jinja2 python-markupsafe
    python-minimal python-paramiko python-pkg-resources python-pyasn1 python-setuptools
    python-six python-yaml python2.7 python2.7-minimal sshpass
  0 upgraded, 25 newly installed, 0 to remove and 33 not upgraded.
  Need to get 11.3 MB of archives.
  After this operation, 83.3 MB of additional disk space will be used.
  Do you want to continue? [Y/n]
  </code></pre>
  
  <h1>Using pip</h1>
  
  <p>This is my current approach but installing pip3 and then <a href="https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html#installing-ansible-with-pip" rel="noreferrer">installing ansible via pip</a> is another extra step:</p>
  
  <pre><code>$ sudo apt install python3-pip
  Reading package lists... Done
  Building dependency tree       
  Reading state information... Done
  The following additional packages will be installed:
    binutils binutils-common binutils-x86-64-linux-gnu build-essential cpp cpp-7 dh-python dpkg-dev fakeroot g++ g++-7 gcc gcc-7 gcc-7-base libalgorithm-diff-perl
    libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan4 libatomic1 libbinutils libc-dev-bin libc6-dev libcc1-0 libcilkrts5 libdpkg-perl libexpat1-dev libfakeroot
    libfile-fcntllock-perl libgcc-7-dev libgomp1 libisl19 libitm1 liblsan0 libmpc3 libmpx2 libpython3-dev libpython3.6-dev libquadmath0 libstdc++-7-dev libtsan0 libubsan0
    linux-libc-dev make manpages-dev python-pip-whl python3-crypto python3-dev python3-distutils python3-keyring python3-keyrings.alt python3-lib2to3
    python3-secretstorage python3-setuptools python3-wheel python3-xdg python3.6-dev
  Suggested packages:
    binutils-doc cpp-doc gcc-7-locales debian-keyring g++-multilib g++-7-multilib gcc-7-doc libstdc++6-7-dbg gcc-multilib autoconf automake libtool flex bison gdb gcc-doc
    gcc-7-multilib libgcc1-dbg libgomp1-dbg libitm1-dbg libatomic1-dbg libasan4-dbg liblsan0-dbg libtsan0-dbg libubsan0-dbg libcilkrts5-dbg libmpx2-dbg libquadmath0-dbg
    glibc-doc bzr libstdc++-7-doc make-doc python-crypto-doc gnome-keyring libkf5wallet-bin gir1.2-gnomekeyring-1.0 python-secretstorage-doc python-setuptools-doc
  The following NEW packages will be installed:
    binutils binutils-common binutils-x86-64-linux-gnu build-essential cpp cpp-7 dh-python dpkg-dev fakeroot g++ g++-7 gcc gcc-7 gcc-7-base libalgorithm-diff-perl
    libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan4 libatomic1 libbinutils libc-dev-bin libc6-dev libcc1-0 libcilkrts5 libdpkg-perl libexpat1-dev libfakeroot
    libfile-fcntllock-perl libgcc-7-dev libgomp1 libisl19 libitm1 liblsan0 libmpc3 libmpx2 libpython3-dev libpython3.6-dev libquadmath0 libstdc++-7-dev libtsan0 libubsan0
    linux-libc-dev make manpages-dev python-pip-whl python3-crypto python3-dev python3-distutils python3-keyring python3-keyrings.alt python3-lib2to3 python3-pip
    python3-secretstorage python3-setuptools python3-wheel python3-xdg python3.6-dev
  0 upgraded, 57 newly installed, 0 to remove and 33 not upgraded.
  Need to get 85.3 MB of archives.
  After this operation, 248 MB of additional disk space will be used.
  Do you want to continue? [Y/n]
  </code></pre>
  
  <p>...which adds unnecessary time to the packer process :(</p>
  
  <h1>Any hints?</h1>
  
  <p>Ubuntu 18.04 comes with python3 already installed and ansible can be easily configured to use python3.
  Does anyone know a way how to install ansible 2.9 without the need to install python2 or pip3?</p>