Puppet Community Roles and Profiles

76 views
Skip to first unread message

Joe

unread,
Jan 11, 2017, 5:52:52 PM1/11/17
to Puppet Users
Hello All,

Does Puppet Community support Roles and Profiles? The Puppet Community does section does not appear to have documentation on them, just looking for confirmation.

Thanks

Thomas Müller

unread,
Jan 12, 2017, 1:16:22 AM1/12/17
to Puppet Users
Hey Joe

Roles and profiles isnt tied to puppet enterprise. Works great with non-enterprise edition.

Original blogpost about the concept: http://www.craigdunn.org/2012/05/239/

Thomas

Steve Button

unread,
Jan 12, 2017, 6:32:38 AM1/12/17
to Puppet Users
As well as the comment from Thomas, also see the follow up post from Gary Larizza


Here's a video from Puppet Conf 2016


And from Puppet Conf 2014


That last one is very long, and the link I posted kicks in about 33 minutes in when he talks about Roles and Profiles. 

It's worth watching the whole thing, probably in three sittings (bring popcorn) as you'll learn all about Hiera, refactoring, modules. Take notes - you won't remember it all.

I'm sure other speakers are available, but Gary is possibly the most entertaining and funny. Which is quite an achievement on such a dry subject. 

So, in answer to your original question the community very much does use Roles and Profiles and I've personally found it a very useful pattern. 

Steve

Joe

unread,
Jan 12, 2017, 1:23:33 PM1/12/17
to Puppet Users
Thank you guys very much, will read up on this.

Joe

unread,
Jan 14, 2017, 10:18:11 PM1/14/17
to Puppet Users
Hello again,

So I read up and watched the wonderful presentations suggested here. I am certain this is the direction for our environment.

I have a question regarding the functionality of the profiles in regards to file resources using the "source" option that replaces a file if it has changed.. When looking at the example on the official documentation on how to use profiles to set module data it shows this.

# /etc/puppetlabs/code/environments/production/site/profile/manifests/jenkins/master.pp
class profile::jenkins::master (
  String $jenkins_port = '9091',
  String $java_dist    = 'jdk',
  String $java_version = 'latest',
) {

  class { 'jenkins':
    configure_firewall => true,
    install_java       => false,
    port               => $jenkins_port,
    config_hash        => {
      'HTTP_PORT'    => { 'value' => $jenkins_port },
      'JENKINS_PORT' => { 'value' => $jenkins_port },
    },
It is clear that the profile::jenkins::master class is declaring the jenkins class and setting the install_java param to false as well as setting the configure_firewall to true.

In my case I have a module let's call it "file_config" where I am declaring 2 separate file resources where if they change, I will copy them from the modules files directory.

Here is an example. Both of these file resources are in the same manifest, so init.pp of the file_config class.

 class file_config (
    $firstfile      = undef,
    $secondfile = undef,
) {
  file { '/etc/siteconf/file1':
        ensure   => file,
        mode     => '0644',
        owner    => 'root',
        checksum => 'md5',
        source   => $firstfile,
      }

      file { '/etc/siteconf/file2':
        ensure   => file,
        mode     => '0644',
        owner    => 'root',
        checksum => 'md5',
        source   => $secondfile,
      }
}
 For both I store the values in Hiera and without profiles this works exactly how I need it to. However with profiles while I am trying to abstract this and I am having difficulty understanding how to configure the profile so that each file resource "source" value should be set. Since the values I am trying to set are both named "source" I am stuck.

So for example.
##PROFILE
class profiles::base::config1 {

  
  $source1 = hiera('profiles::base::config1::file1') ## file1 '/etc/siteconf/file1': 
  $source2 = hiera('profiles::base::config1::file2') ## file2 '/etc/siteconf/file2': 
##both files are in 'puppet:///modules/file_config/' as file1 and file2, they are set pulled into source1 and source2 above.
   ## And now trying to set the values through the profile for file1 and file2...this is where i get lost since the values I am trying to set are both named "source"

   class file_config: {
     source => $source1 ## this would be for file1 declared file resource in the file_config class/module
     source => $source2 ## this would be for file2 declared file resource in the file_config class/module
   }

I am trying to set the "source" value on both of these file resources which seems impossible..
Is the way to do this to put the file resources in their own classes like file_config::file1 and file_config::file2 located in modules/file_config/manifests/file1.pp and file2.pp?

I hope this is clear and I am 99.9% sure I am approaching this incorrectly.

Thanks

Rob Nelson

unread,
Jan 14, 2017, 10:35:24 PM1/14/17
to puppet...@googlegroups.com
Joe,

Roles and profiles don't change your hiera usage much. In your profile just `include file_config` and in hiera keep the same keys you already have working. Hiera will do the legwork of automatic parameter lookup no matter how the class is included, so your results should be the same.

--


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/6605356c-6956-4be2-b354-58c58a95bc7e%40googlegroups.com.


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


--
Rob Nelson

Joe

unread,
Jan 15, 2017, 12:36:21 AM1/15/17
to Puppet Users
Ahh ok , so i am overthinking this..instead of declaring this class in resource like fashion just use the "include class" method ... If so that simple concept makes perfect sense.

Thank you very much


On Wednesday, January 11, 2017 at 3:52:52 PM UTC-7, Joe wrote:
Reply all
Reply to author
Forward
0 new messages