0

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]

1 Answer 1

0

Your findings are confusing. require should really get you there.

package {
  "oracle-java8-installer":
    ensure  => 'installed',
    require => Apt::Ppa['ppa:webupd8team/java'],
}
5
  • Yes that's what I tried. The result was that the source was added, the Java installation failed (package not found) and then the update was run.
    – Granolaboy
    Jan 11, 2016 at 20:21
  • The reason is likely that the udpate exec is included from yet another class, which is not targeted by the require. What's the result with require => Exec['apt::update::apt_update'] in the package resource? Jan 12, 2016 at 11:10
  • I tried it with your solution and added the error message to the original post.
    – Granolaboy
    Jan 19, 2016 at 7:42
  • @Pulz This is weird because your original snippet alleges to notify just that resource. Apparently, it should just be require => Exec[apt_update]. Jan 19, 2016 at 9:24
  • It seems to work in the first try, I'll stay in touch in case other nodes have errors. Thanks a lot!
    – Granolaboy
    Jan 19, 2016 at 10:29

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .