File.exists? validation failure when trying to create file in same catalogue

69 views
Skip to first unread message

Gavin Williams

unread,
Feb 5, 2014, 12:04:02 PM2/5/14
to puppet...@googlegroups.com
Afternoon all

I'm currently doing some final testing on my Glassfish module[1] before I look to release it.

However I've just stumbled across an issue where-by Puppet fails the run based on some File.exists? validation in one of the types, which is trying to use a file that is being created earlier in the catalogue...

E.g:
$ cat glassfish.pp
package { 'unzip': ensure => present }

include glassfish

file { '/tmp/asadmin.pass':
  ensure => present,
#  path => '/tmp/asadmin.pass',
  content => 'AS_ADMIN_PASSWORD=adminadmin',
  mode => '0644',
  require => Class['glassfish']
}

glassfish::create_domain {'test':
  asadmin_passfile => '/tmp/asadmin.pass',
  require => File['/tmp/asadmin.pass']
}

The exception I'm getting is:
$ sudo puppet apply --modulepath=~/modules/ glassfish.pp -v
Info: Loading facts in /home/vagrant/modules/stdlib/lib/facter/pe_version.rb
Info: Loading facts in /home/vagrant/modules/stdlib/lib/facter/puppet_vardir.rb
Info: Loading facts in /home/vagrant/modules/stdlib/lib/facter/facter_dot_d.rb
Info: Loading facts in /home/vagrant/modules/stdlib/lib/facter/root_home.rb
Warning: Config file /etc/puppet/hiera.yaml not found, using Hiera defaults
Notice: Compiled catalog for glassfish-ubuntu.dt0388.test in environment production in 0.40 seconds
Error: Parameter passwordfile failed on Domain[test]: /tmp/asadmin.pass does not exist at /home/vagrant/modules/glassfish/manifests/create_domain.pp:41
Wrapped exception:
/tmp/asadmin.pass does not exist

And that exception is being thrown from here[2].

Is there any way of working around this? I've tried putting in autorequire behaviour like so:
  # Autorequire the password file
  autorequire(:file) do
    self[:passwordfile]
  end
However I still get the same failure on testing...

Thoughts/comments welcome.

Regards
Gavin

[1] https://github.com/fatmcgav/puppet-glassfish
[2] https://github.com/fatmcgav/puppet-glassfish/blob/master/lib/puppet/type/domain.rb#L46-L54

Denmat

unread,
Feb 5, 2014, 11:50:10 PM2/5/14
to puppet...@googlegroups.com
Hi,

What's the code on that line?

> On 6 Feb 2014, at 4:04, Gavin Williams <fatm...@gmail.com> wrote:
>
> /home/vagrant/modules/glassfish/manifests/create_domain.pp:41

fatmcgav

unread,
Feb 6, 2014, 2:08:34 AM2/6/14
to puppet...@googlegroups.com

Line 41 is the end of the domain resource in the create_domain defined type. [1]

Cheers
Gav

[1] https://github.com/fatmcgav/puppet-glassfish/blob/master/manifests/create_domain.pp#L41

--
You received this message because you are subscribed to a topic in the Google Groups "Puppet Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/puppet-users/YQQAo9CK9As/unsubscribe.
To unsubscribe from this group and all its topics, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/523AB043-FAB6-4A2D-9D88-BEEACB790B8C%40gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.

Felix Frank

unread,
Feb 6, 2014, 4:09:14 AM2/6/14
to puppet...@googlegroups.com
Hi,

the issue is (I believe) that the validation logic is run during the
prefetch phase. Your type is making sure its environment is in an
appropriate state. (Auto)Requiring any resources from the catalog will
not help you here, because those will still only be synced after all
prefetching and validation is complete.

You may have to perform this check at a later stage, e.g. raise an
exception right before taking the action that actually depends on the
file. Am I right to assume that ensure is the only actual property of
this type? Then the check may be tied into that.

HTH,
Felix

On 02/05/2014 06:04 PM, Gavin Williams wrote:
> Is there any way of working around this? I've tried putting in
> /autorequire /behaviour like so:

Gavin Williams

unread,
Feb 6, 2014, 4:32:54 AM2/6/14
to puppet...@googlegroups.com
Felix

Damn, ok... Will see if I can move the check further down the process...

And yes, ensure is the only property on this type, the rest are all params...

Cheers
Gav
Reply all
Reply to author
Forward
0 new messages