Skip to content

Instantly share code, notes, and snippets.

@charleseff
Last active January 2, 2016 16:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save charleseff/8327709 to your computer and use it in GitHub Desktop.
Save charleseff/8327709 to your computer and use it in GitHub Desktop.
class foo(before => Exec['blah']) {
....
}
@adrienthebo
Copy link

This can be expressed like so:

class foo {
  Class['foo'] -> Exec['bla']
}

However this is relying on a very specific behavior. In general, resources should only depend on other resources inside of a class, and resources should only depend on other classes instead of resources contained in other classes. Helps maintain encapsulation and all that.

EG

class apache {
  service { 'httpd':
    ensure => running
  }
}

class myvhost {
  # bad
  file { '/etc/apache2/sites-enabled/something':
    require => Service['apache'],
  }
}

class anothervhost {
  # good
  file { '/etc/apache2/sites-enabled/another':
    require => Class['apache']
  }
}

@charleseff
Copy link
Author

@adrienthebo would this be legit then?

class foo {
  Class['foo'] -> Class['bla']
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment