Ensure package installed after class

asked 2014-11-18 11:49:37 -0600

spuder gravatar image

updated 2014-11-18 16:13:08 -0600

How would you ensure that a package is installed after a class? According to this blog article by a puppetlabs employee, the best practice is to use base modules + profiles + roles.

I have a base module called spuder/gitlab

puppet module install spuder/gitlab

I have a profile module that installes the gitlab module, then addes a few files.

class profiles::gitlab {

  $ssh_host_rsa_key = hiera('gitlab::ssh_host_rsa_key')
  $gitlab_branch = hiera('gitlab::gitlab_branch')
  $external_url = hiera('gitlab::external_url')

class { '::gitlab':
  external_url => $external_url,
  gitlab_branch => $gitlab_branch

file { /foo/bar/logo-black.png":
  ensure  => file,
  source  => "puppet:///modules/${module_name}/gitlab/logo-black.png",
  mode    => '0644',

The problem is that I need the logo-black.png file to only be placed after the base module has been applied.

If I attempt to add a require, it gives me a cyclic dependency error.

file { /foo/bar/logo-black.png":
  ensure  => file,
  source  => "puppet:///modules/${module_name}/gitlab/logo-black.png",
  mode    => '0644',
  require => Class['gitlab'], 

How can I ensure this file is added after the gitlab class?

Using the anchor pattern or using 'contains' don't seem like would be applicable in this situation.


The cyclic dependency problem was resolved by using the global scope.

      require => Class['::gitlab'],

However when I spun up a new node, and applied this profile to it, the file {/foo/bar/logo-black.png} was not placed on the first puppet run. The file was placed on the second puppet run. Why is that?


To clarify, the primary question is "How do you make it so a package is installed after an entire class present"? Is require => Class['::foo'] the correct approach?

I can add more logs for the secondary question of why the file resource wasn't included until the second puppet run.

edit retag flag offensive close merge delete


You've asked questions before. Code, log, and **errors**.

ramindk gravatar imageramindk ( 2014-11-18 12:18:40 -0600 )edit

I've updated the question.

spuder gravatar imagespuder ( 2014-11-18 16:13:43 -0600 )edit