Last active
September 16, 2021 16:30
-
-
Save Andor/d9feeca3cfeb18b3cc35a6bb89f5ced7 to your computer and use it in GitHub Desktop.
puppet include vs require vs contain
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ntp { | |
file { '/etc/ntp.conf': | |
... | |
require => Package['ntp'], | |
notify => Class['ntp::service'], | |
} | |
contain ntp::service | |
} | |
class main { | |
include ntp | |
# this exec will run strictly after Class['ntp'] but not neccesarily after Class['ntp::service'] | |
# just like if all resources from Class['ntp::service'] are declared in Class['ntp'] | |
# AKA (something like) | |
# Class['ntp'] -> Exec['/bin/runme.sh'] | |
# Class['ntp::service'] -> Exec['/bin/runme.sh'] | |
exec { '/bin/runme.sh': | |
require => Class['ntp'], | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ntp { | |
file { '/etc/ntp.conf': | |
... | |
require => Package['ntp'], | |
notify => Class['ntp::service'], | |
} | |
include ntp::service | |
package { 'ntp': | |
... | |
} | |
} | |
class main { | |
include ntp | |
# this exec will run strictly after Class['ntp'] and all resources in it, but not necessarily after Class['ntp::service'] | |
# AKA | |
# Class['ntp'] -> Exec['/bin/runme.sh'] | |
# but there will be no dependency like this one: | |
# Class['ntp::service'] -> Exec['/bin/runme.sh'] | |
exec { '/bin/runme.sh': | |
require => Class['ntp'], | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ntp { | |
file { '/etc/ntp.conf': | |
... | |
require => Package['ntp'], | |
notify => Class['ntp::service'], | |
} | |
include ntp::service | |
} | |
class main { | |
include ntp | |
# this exec will run randomly, without any dependencies with any class from above | |
exec { '/bin/runme.sh': | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment