3
votes

I am using Puppet for doing my Vagrant provisioning. I used the archive module at https://forge.puppet.com/puppet/archive/types to download and extract glassfish like this:

archive { '/tmp/glassfish-4.1.1.zip':
  ensure        => present,
  extract       => true,
  extract_path  => '/opt/',
  source        => 'http://download.java.net/glassfish/4.1.1/release/glassfish-4.1.1.zip',
  cleanup       => true,
  creates       => '/opt/glassfish4',
}

After that resource is applied, I want to move a file into the newly created glassfish directory like this

file { 'domain.xml':
  ensure  => file,
  path    => '/opt/glassfish4/glassfish/domains/domain1/config/domain.xml',
  source  => 'puppet:///modules/glassfish/domain.xml',
}

I want to require in the file move resource that the extraction was already done, since the extraction is not creating a file, but rather a directory. Something like

require => FILE['..']

is not working.

1
If you could do it with a File resource, the syntax would be require => File['/full/path/to/managed/file']. Note capitalization, and also that you must refer to the resource by its name or title. Moreover, this only works for resources that are actually under Puppet management. That might actually be the case here, but since it's hard to be sure, establishing a relationship with the Archive resource instead, as Frédéric Henri suggested, is a much better approach. - John Bollinger

1 Answers

5
votes

You should add a require on the archive task so your file task will be something like

  file { 'domain.xml':
    ensure  => file,
    path    => '/opt/glassfish4/glassfish/domains/domain1/config/domain.xml',
    source  => 'puppet:///modules/glassfish/domain.xml',
    require => Archive['/tmp/glassfish-4.1.1.zip'],
  }

so that the copy of the domain.xml file will be done after the archive task.