Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Require Another Custom Class Using Puppet

Tags:

puppet

If I have two class's in my own puppet module and class 'b' has a dependency on class 'a'. How can I express this in my require statement:

# a.pp
class rehan::a {
    package { 'javaruntime':
        ensure   => latest,
        provider => chocolatey
    }
}

# b.pp
class rehan::b {
    file { 'C:\foo':
        ensure  => present,
        require => Package['?????']
    }
}

# site.pp
node default {
    include rehan::a
    include rehan::b
}
like image 924
Muhammad Rehan Saeed Avatar asked Dec 24 '22 08:12

Muhammad Rehan Saeed


1 Answers

If you want to express a dependency of class b on class a (and also ensure that a is in the catalog):

class rehan::b {
    require rehan::a
}

If you just one resource on rehan::b to depend on class A:

class rehan::b {
    include rehan::a  # ensure the class is in the catalog
    file { 'C:\foo':
        ensure  => present,
        require => Class['rehan::a'],
    }
}

You can also express this relationship anywhere with Class['rehan::a'] -> Class['rehan::b'] (assuming both are included in the catalog).

like image 134
Artefacto Avatar answered Feb 23 '23 03:02

Artefacto