Ask Your Question
0

I get a lot of: "failed: You cannot specify more than one of content, source, target at.."

asked 2017-06-28 04:16:52 -0500

h.safe gravatar image

Hi all, I am trying to write a module that it depends to multiple files. now while my code is parser validated and it essentially comprises of:

class elkstack {
  package { 'filebeat' :
    ensure => 'installed',
    source => " puppet:///modules/elkstack/filebeat-1.3.1-x86_64.rpm ",
  }
  service { 'filebeat' :
    ensure   => 'running',
    enable   =>  'true',
    require => Package['filebeat'],
  }
  file { '/etc/pki/tls/certs/logstash-forwarder.crt':
    ensure => 'present',
    content  => "puppet:///modules/elkstack/logstash-forwarder.crt",
  }
  file { '/etc/filebeat/filebeat.yml' :
    ensure  => 'presnet',
    content => "puppet:///modules/elkstack/filebeat.yml",
    require =>  Package['filebeat'],
  }

I am getting the subject error on the second file resource declaration that refer basically to the same dir as /modules/elkstack/files/... I tried to search the Internet for any same case scenario but non existed. Note that I run puppet apply /modules/elkstack/example/init.pp --noop on the puppet master when getting this error...Can somebody help? as it has been bugging me for the last hour or two please...

edit retag flag offensive close merge delete

Comments

1

Looks like you're mixing your source and content params there, you'll want source for each one of them. content is used to provide the actual contents of the file rather than a file location. Not sure if it would solve the error, it would be useful if you posted the full error.

nikdoof gravatar imagenikdoof ( 2017-06-28 08:11:00 -0500 )edit

2 Answers

Sort by » oldest newest most voted
1

answered 2017-06-29 10:24:29 -0500

DarylW gravatar image

I think you are missing something fundamental about the file resource, that will make nikdoof's answer much clearer..

Above, you are using the content parameter. If you look at the docs for the content parameter of the file resource, you will see the following description:

The desired contents of a file, as a string. This attribute is mutually exclusive with source and target.

what you seem to actually want to do is use the source parameter, described here:

A source file, which will be copied into place on the local system. This attribute is mutually exclusive with content and target. Allowed values are:

•puppet: URIs, which point to files in modules or Puppet file server mount points.

•Fully qualified paths to locally available files (including files on NFS shares or Windows mapped drives).

•file: URIs, which behave the same as local file paths.

•http: URIs, which point to files served by common web servers

If you notice in the definition for content, it mentions that it's mutually exclusive with source and target. I don't directly see you using multiple source/target in the above definition. do you happen to have a 'global' value set for one of those values somewhere else in your code base? something like

File {
  source => '/some/path'
}

or

File {
  target=> '/some/path'
}

If you have one of those defined somewhere in your scope, then that 'global' assignment of a parameter is interfering with your specific file resource, for the one that is failing, try explicitly assigning them with undef, like this

  file { '/etc/filebeat/filebeat.yml' :
    ensure  => 'presnet',
    content => "puppet:///modules/elkstack/filebeat.yml",
    target => undef,
    source => undef,
    require =>  Package['filebeat'],
  }

If that fixes your 'error', then something else is setting the parameters by default. You still probably don't want the 'content' of the file to be the string puppet:///modules/elkstack/filebeat.yml, so you'll probably need to switch that to source instead of content

edit flag offensive delete link more

Comments

DarylW, Thanks for clarifications.However, as the error suggests it mutually address content and source the same way...what I tried to replicate was changing the 'content' parameter with 'source' to double-check and added the undef ...result was the same :(

h.safe gravatar imageh.safe ( 2017-06-30 23:20:14 -0500 )edit
0

answered 2017-06-29 03:45:09 -0500

h.safe gravatar image

Nikdoof, The more I searched reviewed the docs.puppet.com, the closer I got to your answer. Although I would not call myself an expert in puppet, could say that the culprit will be the directory addressing in puppet where the granulation ends there and not to the file level ...Is that right ? But again there are a lot of scenarios that under one single class declaration you may require more than one file to declare ...I can give numerous examples but enough to say the<package> .conf and <package>.service files of a package; or configs that will go for places like var or tweaks that you need to have under /etc/sysctl.conf ...all in all chances that you get more than a file to declare is hugely possible...a feature request? Maybe ...</package></package>

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-06-28 02:57:56 -0500

Seen: 71 times

Last updated: Jun 29