Multiple resource bodies?

17 views
Skip to first unread message

dkoleary

unread,
May 30, 2016, 5:09:12 PM5/30/16
to Puppet Users
Hey;

According to the puppet language resource guide at https://docs.puppet.com/puppet/latest/reference/lang_resources_advanced.html:

If a resource expression includes more than one resource body, the expression will declare multiple resources of that resource type. (A resource body is a title and a set of attributes; each body must be separated from the next one with a semicolon.)

With that, can someone take a peek and tell me what I'm messing up with this manifest?

file {
 
default:
   
ensure   => 'directory',
    owner    
=> 'root',
   
group    => 'root',
 
;


 
'/'        : mode  => '0755' ;
 
'/home'    : mode  => '0755' ;
 
'/opt'     : mode  => '0755' ;
 
'/usr'     : mode  => '0755' ;
 
'/var'     : mode  => '0755' ;
 
'/tmp'     : mode  => '1777' ;
 
'/var/tmp' : mode  => '1777' ;


 
'/etc/passwd':
   
ensure   => 'file',
    mode    
=> '0644',
 
;
 
'/etc/group':
   
ensure   => 'file',
    mode    
=> '0644',
 
;


 
'/etc/shadow':
   
ensure   => 'file',
    mode    
=> '0000',
 
;


 
'/etc/rc.d/init.d':
    mode    
=> '0755',
    recurse  
=> true,
 
;
}


I'm not seeing the error; but, when I try to apply it, I get:

$ sudo puppet apply ./file.pp
Notice: Compiled catalog for node1.olearycomputers.com in environment production in 0.04 seconds
Error: Parameter path failed on File[/]: File paths must be fully qualified, not '' at /ignite/dkoleary/mpi_git/puppet/modules/mpicommon/manifests/file.pp:1

Any pointers, greatly appreciated.

Doug O'Leary

Arpin Dominique (Nter)

unread,
May 30, 2016, 5:15:41 PM5/30/16
to Puppet Users

Hi,

 

Maybe you can regroup each item with the same configuration, like this:

 

$file_system_list = [‘/’,’/home’,’/opt’]

 

$file_system_list.each | String $file_system| {

  file {“$file_system”:

    ensure => ‘directory’,

    owner => ‘root’,

    group => ‘root’

  }

}

 

 

 

Dominique Arpin

Tél. Interne: 140-4156

Tél. 514 285.2929 Poste: 140-4156


De : puppet...@googlegroups.com [mailto:puppet...@googlegroups.com] De la part de dkoleary
Envoyé : 30 mai, 2016 13:09
À : Puppet Users
Objet : [Puppet Users] Multiple resource bodies?

--
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/f284439e-d1d8-49f0-a77e-d0c07ce61239%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Mise en garde concernant la confidentialité : Le présent message, comprenant tout fichier qui y est joint, est envoyé à l'intention exclusive de son destinataire; il est de nature confidentielle et peut constituer une information protégée par le secret professionnel. Si vous n'êtes pas le destinataire, nous vous avisons que toute impression, copie, distribution ou autre utilisation de ce message est strictement interdite. Si vous avez reçu ce courriel par erreur, veuillez en aviser immédiatement l'expéditeur par retour de courriel et supprimer le courriel. Merci!

Confidentiality Warning: This message, including any attachment, is sent only for the use of the intended recipient; it is confidential and may constitute privileged information. If you are not the intended recipient, you are hereby notified that any printing, copying, distribution or other use of this message is strictly prohibited. If you have received this email in error, please notify the sender immediately by return email, and delete it. Thank you!

dkoleary

unread,
May 30, 2016, 5:43:54 PM5/30/16
to Puppet Users, Dominiq...@casino.qc.ca
Hey;

Thanks for the response.  I'm trying to work my way into iteration a bit slower than my fourth manifest :)  If all else fails, I'm pretty sure I can set up separate file resource declarations; but, this multiple resource bodies, in this case, seems like this is cleaner.

Thanks

Doug O'Leary

Rob Nelson

unread,
May 30, 2016, 5:46:06 PM5/30/16
to puppet...@googlegroups.com
I would be willing to bet '/' is somewhat special and may be the problem. I've never actually tried to manage the root of the FS directly and I think the need to may indicate some more significant issues than puppet should be handling.

You could also look at pl_training/dirtree, which lets you manage a single directory and it will create intermediate directories as needed with the same owner/group/mode. 

For more options, visit https://groups.google.com/d/optout.


--

Henrik Lindberg

unread,
May 30, 2016, 5:46:36 PM5/30/16
to puppet...@googlegroups.com
From what I can tell by reading through that, your manifest looks ok in
terms of multiple bodies and use of defaults.

The problem is known. See https://tickets.puppetlabs.com/browse/PUP-1796
which has a work around using '/.' (which may or may not work according
to the comments on that ticket).

- henrik

> Doug O'Leary
>
> --
> 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>.
> <https://groups.google.com/d/msgid/puppet-users/f284439e-d1d8-49f0-a77e-d0c07ce61239%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/

Henrik Lindberg

unread,
May 30, 2016, 5:50:47 PM5/30/16
to puppet...@googlegroups.com
On 30/05/16 19:45, Rob Nelson wrote:
> I would be willing to bet '/' is somewhat special and may be the
> problem. I've never actually tried to manage the root of the FS directly
> and I think the need to may indicate some more significant issues than
> puppet should be handling.
>

Yes, known problem.
See https://tickets.puppetlabs.com/browse/PUP-1796

> You could also look at pl_training/dirtree, which lets you manage a
> single directory and it will create intermediate directories as needed
> with the same owner/group/mode.
>

That may work around the problem in PUP-1796.

- henrik

dkoleary

unread,
May 30, 2016, 6:31:12 PM5/30/16
to Puppet Users
Hey;

Thank you all for the information.  That was definitely the issue.  I'm not overly worried about '/' so I just took it out - primarily had it in there for completeness.  In nigh on 30 years of admin, I think I've had someone change the ownership of root maybe twice.  Those other directories - that tends to happen more often.  

Any rate, thanks again.  I appreciate it.

Doug O'Leary
Reply all
Reply to author
Forward
0 new messages