Puppet : How to use [class Section]2024/07/25 |
It's possible to manage some resources by using [class] section like follows. |
|
[1] | It's an example to define and use [sample01] class. |
root@dlp:~#
vi /etc/puppet/code/environments/production/manifests/class.pp class sample01 { file { '/home/testfile7.txt': ensure => file, owner => 'root', group => 'root', mode => '0644', content => 'This is the puppet test file.', } user { 'noble': ensure => present, home => '/home/noble', managehome => true, password => '$6$9GoE2liT6.P.U/a*****', } } node 'node02.srv.world' { include 'sample01' } |
[2] | It's an example to use inheritance of a class. The [sample01] and [sample02] class are both applied to [node02.srv.world] by this manifest. |
root@dlp:~#
vi /etc/puppet/code/environments/production/manifests/class.pp class sample01 { file { '/home/testfile7.txt': ensure => file, owner => 'root', group => 'root', mode => '0644', content => 'This is the puppet test file.', } user { 'noble': ensure => present, home => '/home/noble', managehome => true, password => '$6$9GoE2liT6.P.U/a*****', } } class sample02 inherits sample01 { file { '/home/testfile8.txt': ensure => file, owner => 'root', group => 'adm', content => 'test file #8', } } node 'node02.srv.world' { include 'sample02' } |
Sponsored Link |