summaryrefslogtreecommitdiff
path: root/3 Resources/Puppet/Declaring classes.md
blob: 793d4b32eff55e8c64b589a0e4116a98092ca001 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
---
tags:
  - puppet
references:
  - https://www.puppet.com/docs/puppet/7/lang_classes#lang_class_declare
---
Prefer include over resource-like; more flexible and idempotent. Resource-like to pass args without needing to use hieradata.

> Mixing declaration types for the same class can lead to compilation errors.

# Include-like <- preferred
Relies on external data, e.g hieradata, and defaults.
Idempotent: it is only added to the catalog once.

### `include`
Accepts: single class, class reference (`Class[..]`), comma-seperated list of those or an array of them.

## `require`
Same as above - but the class becomes a dependency of the container. #clarify dependency.

## `contain`
Adheres to same rules as above. Relationships of the containing class extend to the contained class.
See [[Containment]].

# Resource-like
Can be declared only once. 
Must be unique to avoid conflicting parameter values.