0
votes

Im trying to provision my development server using Vagrant and Puppet. Below is some of my Puppet Manifest at this point. The issue im having is that im ending up in a dependency loop which is ofcourse correct. The only problem is that i dont see a way to do it without so therefor i need some help.

Im using the latest version of the box provided by Puppetlabs named puppetlabs/ubuntu-14.04-64-puppet. While adding a PPA to the package manager i receive an error that apt-add-repository is not available. Therefor you need to install the software-properties-common package.

The only problem is that before installing this package, you need to run apt-get update. The second problem is that the manifest wont accept it and it will try to add the PPA before so that, ofcourse which is a logic conclusion, it only has to update the package manager once. But by picking this last solution i will end up in a loop which triggers an error:

==> default: Error: Failed to apply catalog: Found 1 dependency cycle: ==> default: (Exec[add-apt-repository-ppa:ondrej/php-7.0] => Class[Apt::Update] => Exec[apt_update] => Class[Apt::Update] => Package[git] => Class[Systempackages] => Apt::Ppa[ppa:ondrej/php-7.0] => Exec[add-apt-repository-ppa:ondrej/php-7.0])

class systempackages {
  package { [ 'git', 'curl', 'acl', 'unattended-upgrades', 'vim', 'software-properties-common']:
    ensure => "installed",
    require => [
        Class['apt::update'],
    ],
  }
}

/*===========================================*/

## System
Exec { path => [ "/bin/", "/sbin/" , "/usr/bin/", "/usr/sbin/" ] }

class{'systempackages':}

# APT
class { 'apt':
  update => {
    frequency => 'always',
  },
}
apt::ppa { 'ppa:ondrej/php-7.0':
  before => Package['php7.0-cli'],
  require => Class['systempackages'],
}

# PHP
package {'php7.0-cli':
  ensure => 'installed',
}
2

2 Answers

1
votes

Given that this is on vagrant, I suggest installing package software-properties-common manually as part of your Vagrantfile.

Something like config.vm.provision "shell", inline: "apt-get update && apt-get install software-properties-common should work.

1
votes

The circular dependency reflects the fact that Puppet is not a provisioning system. It can be used by a provisioning system or in conjunction with one, but it depends on a fairly substantial software stack being available before it can get off the ground. If Package 'software-properties-common' is necessary for full functioning of the Apt subsystem, then your best bet is to rely on your provisioning system to install it, so that it is available before Puppet ever runs, and to avoid declaring any relationship between that package and the classes and resources of the Apt module.

You are also impacted by the puppetlabs-apt module being quite good about declaring the relationships needed to ensure proper order of application. This is a double-edged sword, however: people cause themselves trouble with surprising frequency by declaring their own relationships with classes or defined types from that module that conflict with the ones it declares itself. In particular, it is asking for trouble to have your Apt::ppa resource require a class containing resources that themselves require any class or resource from the Apt module.

In any case, class apt::update is not a public class of the module. The main implication is that code outside the module should not reference it in any way. You should instead rely on the value you provided for class parameter $apt::update to instruct Puppet to perform an apt-get update at a suitable time.