Confusing error with file resource...

143 views
Skip to first unread message

Sean

unread,
Oct 3, 2017, 12:41:05 PM10/3/17
to Puppet Users
Hi,

I have a strange puppet error (v4.10.1) with a file resource that creates a cron job...

  file { '/etc/cron.daily/aide':
    ensure  => $mymodule::ensure_aide,
    owner   => 'root',
    group   => 'root',
    mode    => '0755',
    source  => 'puppet:///modules/mymodule/cron/daily-aide-check.sh',
    require => Package['aide'],
  }

The error is:

Error: Failed to apply catalog: Validation of File[/etc/cron.daily/aide] failed: You cannot specify more than one of content, source, target at <source file>:line#



The ensure param is a Variant - either boolean or enum of true, false, present, absent, latest.  The code passes the puppet parser and checking puppet lookup for $mymodule::ensure_aide for the test node returns a 'true' value from the module's hiera data.

Any ideas?

Henrik Lindberg

unread,
Oct 3, 2017, 2:23:11 PM10/3/17
to puppet...@googlegroups.com
On 03/10/17 09:41, Sean wrote:
> Hi,
>
> I have a strange puppet error (v4.10.1) with a file resource that
> creates a cron job...
>
> |
>   file { '/etc/cron.daily/aide':
>     ensure  => $mymodule::ensure_aide,
>     owner   => 'root',
>     group   => 'root',
>     mode    => '0755',
>     source  => 'puppet:///modules/mymodule/cron/daily-aide-check.sh',
>     require => Package['aide'],
>   }
> |
>
> The error is:
>
> |
> Error:Failedto apply catalog:Validationof
> File[/etc/cron.daily/aide]failed:Youcannot specify more than one of
> content,source,target at <source file>:line#
>
>
> |
>
> The ensure param is a Variant - either boolean or enum of true, false,
> present, absent, latest.  The code passes the puppet parser and checking
> puppet lookup for $mymodule::ensure_aide for the test node returns a
> 'true' value from the module's hiera data.
>
> Any ideas?

Check that you do not have any defaults or overrides that sets one of
the other attributes that also specifies the contents of the file.

Compile the catalog and inspect the contents of the resource in
question. If the catalog contains conflicting information about the file
contents, then the problem is most likely a default/override problem in
your code. If the resource is what you shown (no conflict) then it looks
like a possible bug on the agent side. If so, please file a ticket with
a reproducible example.

Best,
- henrik

>
> --
> You received this message because you are subscribed to the Google
> Groups "Puppet Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to puppet-users...@googlegroups.com
> <mailto:puppet-users...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/puppet-users/64776827-6fe1-49c0-89b1-fc532faa211a%40googlegroups.com
> <https://groups.google.com/d/msgid/puppet-users/64776827-6fe1-49c0-89b1-fc532faa211a%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.


--

Visit my Blog "Puppet on the Edge"
http://puppet-on-the-edge.blogspot.se/

David Schmitt

unread,
Oct 4, 2017, 5:46:28 AM10/4/17
to puppet...@googlegroups.com
File's ensure doesn't take boolean values. If the ensure value is not one of present, absent, file, directory, or link, the value gets interpreted as a link target name:

david@davids:~$ puppet apply -e 'file {"/tmp/test_file": ensure => true, content => "bar" }'
Notice: Compiled catalog for davids.corp.puppetlabs.net in environment production in 0.07 seconds
Error: Validation of File[/tmp/test_file] failed: You cannot specify more than one of content, source, target at line 1
david@davids:~$ puppet apply -e 'file {"/tmp/test_file": ensure => true }'
Notice: Compiled catalog for davids.corp.puppetlabs.net in environment production in 0.07 seconds
Error: Could not set 'link' on ensure: FileSystem implementation expected Pathname, got: 'TrueClass' at line 1
Error: Could not set 'link' on ensure: FileSystem implementation expected Pathname, got: 'TrueClass' at line 1
Wrapped exception:
FileSystem implementation expected Pathname, got: 'TrueClass'
Error: /Stage[main]/Main/File[/tmp/test_file]/ensure: change from absent to link failed: Could not set 'link' on ensure: FileSystem implementation expected Pathname, got: 'TrueClass' at line 1
Notice: Applied catalog in 0.03 seconds
david@davids:~$


Cheers, David

 

Any ideas?

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to puppet-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/puppet-users/64776827-6fe1-49c0-89b1-fc532faa211a%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages