Skip installing puppetlabs repos if they exist

Currently ansible fails on most puppet4 hosts with

 TASK [puppet-install : Install puppetlabs repo] ********************************
 fatal: [...]: FAILED! => {"changed": false, "msg": "A later version is already installed"}

As described inline, the version at the "top level" we are installing
via ansible here is actualy lower than the version in the repo this
package installs (inception).  Thus once an upgrade has been run on
the host, we are now trying to *downgrade* the puppetlabs-release
package.  This stops the ansible run and makes everything unhappy.

If we have the puppet repo, just skip trying to install it again.

We do this for just trusty and xenial; at this point we don't have any
puppet5 hosts (and none are planned) and I haven't checked if it has
the same issues.

Change-Id: I55ea8bfbfc40befb1d138e9bc0f95b120f8f5dbd
This commit is contained in:
Ian Wienand 2019-04-09 14:11:12 +10:00
parent 713b98298e
commit 72b4b868ab
2 changed files with 28 additions and 0 deletions

View File

@ -24,9 +24,23 @@
when: puppet_install_version == 4
become: true
block:
# The puppetlabs-release-pc1 deb install below unfortunatley isn't
# idempotent. If you install the puppet repo with this deb and
# then upgrade, you pull in a new version of
# puppetlabs-release-pc1 ... now ansible gets upset because we're
# trying to downgrade the package. This could be fixed by puppet
# symlinking the version at the top-level to the latest .deb
# ... or we just skip installing it if we seem to have the repo
# already.
- name: "Check for puppet 4 repo"
stat:
path: /etc/apt/sources.list.d/puppetlabs-pc1.list
register: puppet4_repo
- name: Install puppetlabs repo
apt:
deb: http://apt.puppetlabs.com/puppetlabs-release-pc1-trusty.deb
when: not puppet4_repo.stat.exists
- name: Install puppet packages
apt:

View File

@ -19,9 +19,23 @@
when: puppet_install_version == 4
become: true
block:
# The puppetlabs-release-pc1 deb install below unfortunatley isn't
# idempotent. If you install the puppet repo with this deb and
# then upgrade, you pull in a new version of
# puppetlabs-release-pc1 ... now ansible gets upset because we're
# trying to downgrade the package. This could be fixed by puppet
# symlinking the version at the top-level to the latest .deb
# ... or we just skip installing it if we seem to have the repo
# already.
- name: "Check for puppet 4 repo"
stat:
path: /etc/apt/sources.list.d/puppetlabs-pc1.list
register: puppet4_repo
- name: Install puppetlabs repo
apt:
deb: https://apt.puppetlabs.com/puppetlabs-release-pc1-xenial.deb
when: not puppet4_repo.stat.exists
- name: Install puppet packages
apt: