I use the official Puppet apt module to add this Java launchpad and to install Oracle Java 8.
apt::ppa{ 'ppa:webupd8team/java': }
package {
"oracle-java8-installer":
ensure => 'installed',
}
When the apt module adds the launchpad it notifies another manifest to run 'apt-get update'.
apt/manifests/ppa.pp
exec { "add-apt-repository-${name}":
environment => $_proxy_env,
command => "/usr/bin/add-apt-repository ${options} ${name}",
unless => "/usr/bin/test -s ${::apt::sources_list_d}/${sources_list_d_filename}",
user => 'root',
logoutput => 'on_failure',
notify => Exec['apt::update::apt_update'],
require => $_require,
}
The problem is that I can't get make sure that the source update is run before the install begins.
Using 'require' or 'before' the update is run after the install (add source -> install Java -> apt-get update), subscribe returns a dependency cycle and using no relationships it installs before updating my sources.
What's the solution?
Using Frank's code:
apt::ppa{ 'ppa:webupd8team/java': }
package {
"oracle-java8-installer":
ensure => 'installed',
require => Apt::Ppa['ppa:webupd8team/java'],
}
I get this error message:
==> xxx: Notice: /Stage[main]/Main/Node[xxx]/Apt::Ppa[ppa:webupd8team/java]/Exec[add-apt-repository-ppa:webupd8team/java]/returns: executed successfully
==> xxx: Error: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install oracle-java8-installer' returned 100: Reading package lists...
==> xxx: Building dependency tree...
==> xxx: Reading state information...
==> xxx: E: Unable to locate package oracle-java8-installer
==> xxx: Error: /Stage[main]/Main/Node[xxx]/Package[oracle-java8-installer]/ensure: change from purged to present failed: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install oracle-java8-installer' returned 100: Reading package lists...
==> xxx: Building dependency tree...
==> xxx: Reading state information...
==> xxx: E: Unable to locate package oracle-java8-installer
==> xxx: Notice: /Stage[main]/Apt::Update/Exec[apt_update]: Dependency Package[oracle-java8-installer] has failures: true
==> xxx: Warning: /Stage[main]/Apt::Update/Exec[apt_update]: Skipping because of failed dependencies
==> xxx: Notice: /Stage[main]/Apt::Update/Exec[apt_update]: Triggered 'refresh' from 1 events
Using this:
package {
"oracle-java8-installer":
ensure => 'installed',
require => Exec['apt::update::apt_update'],
}
I get this error:
Error: Failed to apply catalog: Could not find dependency Exec[apt::update::apt_update] for Package[oracle-java8-installer]