Do not install Ansible PPA on Ubuntu 20.04 00/65100/3
authorThanh Ha <zxiiro@gmail.com>
Fri, 14 Aug 2020 17:29:30 +0000 (13:29 -0400)
committerThanh Ha <zxiiro@gmail.com>
Fri, 14 Aug 2020 18:10:09 +0000 (14:10 -0400)
Unfortunately the Ansible PPA is not yet available on Ubuntu 20.04 so
do not install it. Also add a TODO note to go back and figure out if
we really still need the PPA. This was added because we wanted to get
a more recent version of Ansible on Ubuntu 16.04 but perhaps the distro
packaged version is sufficient with newer Ubuntu versions.

Ref: https://github.com/ansible/ansible/pull/69161
Signed-off-by: Thanh Ha <zxiiro@gmail.com>
Change-Id: I7a02a6e0e95b148c640dfd41f3ea3d50dfff17d9

molecule/default/molecule.yml
molecule/default/prepare.yml
tasks/main.yml

index 572361f..0d1e519 100644 (file)
@@ -12,6 +12,10 @@ platforms:
     image: centos:7
   - name: ubuntu1604
     image: ubuntu:16.04
+  - name: ubuntu1804
+    image: ubuntu:18.04
+  - name: ubuntu2004
+    image: ubuntu:20.04
 provisioner:
   name: ansible
 scenario:
index 96d1571..cbdf698 100644 (file)
@@ -3,6 +3,11 @@
   hosts: all
   gather_facts: true
   tasks:
+    - name: Update APT cache
+      apt:
+        update_cache: yes
+      when: ansible_distribution == 'Ubuntu'
+      become: true
     - name: Install EPEL repository
       yum:
         name: https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
index 533a294..fec45d9 100644 (file)
@@ -7,9 +7,19 @@
     - "{{ ansible_os_family }}.yaml"
 
 - name: Setup Ansible PPA
-  apt_repository:
-    repo: ppa:ansible/ansible
-  when: ansible_distribution == 'Ubuntu'
+  block:
+    # gnupg2 is required to install the PPA and is missing on Ubuntu 18.04
+    - name: Install gnupg2
+      apt:
+        name: gnupg2
+        state: present
+    - name: Setup Ansible PPA
+      apt_repository:
+        repo: ppa:ansible/ansible
+  # Ubuntu 20.04 PPA is not yet available so skip installing it for now.
+  # TODO: Figure out if recent versions of Ansible in Ubuntu is sufficient for
+  #.      our use without the need to pull in from PPA.
+  when: ansible_distribution == 'Ubuntu' and ansible_facts['distribution_major_version'] is version('20', '<')
   become: true
 
 - name: Install LF Recommended Tools