Search code examples
vagrantpuppetlibrarian-puppet

Puppet - Unable to locate package oracle-java8-installer


I am installing Java 8 in a Vagrant hashicorp/precise32 machine using Puppet spantree/java8 module. While installing I am getting below exception:

==> default: Notice: /Stage[main]/Java8/File[/tmp/java.preseed]/ensure: defined content as '{md5}1b89c67b59fa03a9210a7b22a6b51b92'
==> default: Notice: /Stage[main]/Apache/Package[apache2]/ensure: ensure changed 'purged' to 'present'
==> default: Notice: /Stage[main]/Java8/Apt::Ppa[ppa:webupd8team/java]/Exec[add-apt-repository-ppa:webupd8team/java]/returns: executed successfully
==> default: Notice: /Stage[main]/Java8/File[/etc/profile.d/set_java_home.sh]: Dependency Package[oracle-java8-installer] has failures: true
==> default: Error: Execution of '/usr/bin/apt-get -q -y -o DPkg::Options::=--force-confold install oracle-java8-installer' returned 100: Reading package lists...
==> default: Building dependency tree...
==> default: Reading state information...
==> default: E: Unable to locate package oracle-java8-installer
==> default: Error: /Stage[main]/Java8/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...
==> default: Building dependency tree...
==> default: Reading state information...
==> default: E: Unable to locate package oracle-java8-installer
==> default: Warning: /Stage[main]/Java8/File[/etc/profile.d/set_java_home.sh]: Skipping because of failed dependencies

I predict something wrong in line no. - 48 in file init.pp:

  ubuntu: {
      include apt

      apt::ppa { 'ppa:webupd8team/java': }

      package { 'oracle-java8-installer':
        responsefile => '/tmp/java.preseed',
        require      => [
          Apt::Ppa['ppa:webupd8team/java'],
          File['/tmp/java.preseed']
        ],
      }

Any idea how can I fix it?

P.S: I am using librarian-puppet to download the spantree/java8 module from Puppet forge.


Solution

  • Was finally able to pass through the error by making sure apt-get update runs after the the new ppa is added - this was my change in java8/manifests/init.pp :

    ubuntu: {
      include apt
    
      apt::ppa { 'ppa:webupd8team/java': }
    
      exec { 'apt-update':
          command => "/usr/bin/apt-get update",
          require      => [
            Apt::Ppa['ppa:webupd8team/java']
          ],
      }
    
      package { 'oracle-java8-installer':
        responsefile => '/tmp/java.preseed',
        require      => [
          Exec['apt-update'],
          File['/tmp/java.preseed']
        ],
      }
    }