William Myers
10/05/2022, 5:33 PMnatemccurdy
10/05/2022, 5:34 PMWilliam Myers
10/05/2022, 5:34 PMWilliam Myers
10/05/2022, 5:34 PMWilliam Myers
10/05/2022, 5:35 PMSlackbot
10/05/2022, 5:37 PMWilliam Myers
10/05/2022, 5:38 PMnatemccurdy
10/05/2022, 5:38 PMWilliam Myers
10/05/2022, 5:38 PMvchepkov
10/05/2022, 5:40 PMcase $facts['os']['family'] {
'RedHat': {
case $facts['os']['architecture'] {
'aarch64': {
contain splunk::platform::redhat_aarch64_package
}
default : {
contain splunk::platform::redhat_package
}
}
}
'Solaris' : { contain splunk::platform::solaris_package }
'Windows' : { contain splunk::platform::windows_package }
default : { fail('unsupported OS') }
}
William Myers
10/05/2022, 5:40 PMnatemccurdy
10/05/2022, 5:41 PMdesktopcentral_agent/
└── manifests/
├── init.pp
├── linux.pp
└── windows.pp
And yeah, init.pp
would contain some kind of case statement like what vchepkov said.William Myers
10/05/2022, 5:42 PMWilliam Myers
10/05/2022, 5:42 PMhelindbe
10/05/2022, 5:44 PMhelindbe
10/05/2022, 5:45 PMinit.pp
is named init
for historical reasons, it is the file that is loaded when referencing a class having the same name as the module - in your case desktopcentral_agent
. The init.pp
is also loaded if a reference is made to a name in the module’s namespace and there is no corresponding file.William Myers
10/05/2022, 5:45 PMvchepkov
10/05/2022, 5:47 PMvchepkov
10/05/2022, 5:47 PMramindk
10/05/2022, 5:47 PMhelindbe
10/05/2022, 5:47 PMinit.pp
is named init
for historical reasons, it is the file that is loaded when referencing a class having the same name as the module - in your case desktopcentral_agent
. The init.pp
is also loaded if a reference is made to a name in the module’s namespace and there is no corresponding file.William Myers
10/05/2022, 5:48 PMvchepkov
10/05/2022, 5:49 PMvchepkov
10/05/2022, 5:49 PMvchepkov
10/05/2022, 5:50 PMvchepkov
10/05/2022, 5:50 PMWilliam Myers
10/05/2022, 5:54 PMclass desktopcentral_agent::linux {
$source_file = 'puppet:///modules/desktopcentral_agent/UEMSLinuxAgent.zip'
}
Slackbot
10/05/2022, 5:55 PMramindk
10/05/2022, 5:57 PMpuppetagent $ tree
├── data
│ └── os
│ ├── Linux.yaml
│ └── windows.yaml
├── files
│ ├── puppet.conf
│ └── sysconfig
├── hiera.yaml
├── manifests
│ ├── config.pp
│ ├── init.pp
│ ├── install.pp
│ ├── service
│ │ └── disable.pp
│ └── service.pp
local hiera.yaml looks like
hiera.yaml
---
version: 5
defaults: # Used for any hierarchy level that omits these keys.
datadir: data # This path is relative to hiera.yaml's directory.
data_hash: yaml_data # Use the built-in YAML backend.
hierarchy:
- name: "osfamily/major release"
paths:
- "os/%{facts.os.family}/%{facts.os.release.major}.yaml"
# Used for Solaris
- "os/%{facts.os.family}/%{facts.kernelrelease}.yaml"
# Used to distinguish between Debian and Ubuntu
- "os/%{facts.os.name}/%{facts.os.release.major}.yaml"
- name: "osfamily"
paths:
- "os/%{facts.os.family}.yaml"
- "os/%{facts.os.name}.yaml"
- "os/%{facts.kernel}.yaml"
- name: 'common'
path: 'common.yaml'
And data
## data/os/windows.yaml
---
puppetagent::config:
main:
autoflush: true
manage_internal_file_permissions: false
puppetagent::config_dir: 'C:/ProgramData/PuppetLabs/puppet/etc'
puppetagent::install_dir: 'C:/Program Files/Puppet Labs/Puppet/puppet'
## data/os/Linux.yaml
---
puppetagent::config_owner: 'root'
puppetagent::config_group: 'root'
puppetagent::config_mode: '0644'
and init.pp
manifests/init.pp
# manages puppet agent install and config.
class puppetagent(
Stdlib::Fqdn $server,
Optional[Hash] $config = undef,
Stdlib::Absolutepath $config_dir = '/etc/puppetlabs/puppet',
Optional[String[1]] $config_owner = undef,
Optional[String[1]] $config_group = undef,
Optional[String[1]] $config_mode = undef,
Optional[Hash] $gemrc = undef,
Stdlib::Absolutepath $install_dir = '/opt/puppetlabs/puppet',
String[1] $version = 'installed',
) {
Slackbot
10/05/2022, 5:59 PM