From 72b4b868abac557a078dca87754f56e217330cd7 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Tue, 9 Apr 2019 14:11:12 +1000 Subject: [PATCH] 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 --- .../tasks/puppet-install/trusty.yaml | 14 ++++++++++++++ .../tasks/puppet-install/xenial.yaml | 14 ++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/roles/puppet-install/tasks/puppet-install/trusty.yaml b/roles/puppet-install/tasks/puppet-install/trusty.yaml index cf6f1c1d7f..3dc9aadddd 100644 --- a/roles/puppet-install/tasks/puppet-install/trusty.yaml +++ b/roles/puppet-install/tasks/puppet-install/trusty.yaml @@ -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: diff --git a/roles/puppet-install/tasks/puppet-install/xenial.yaml b/roles/puppet-install/tasks/puppet-install/xenial.yaml index ea64ebd7aa..d9258699b9 100644 --- a/roles/puppet-install/tasks/puppet-install/xenial.yaml +++ b/roles/puppet-install/tasks/puppet-install/xenial.yaml @@ -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: