Puppet : How to use [class Section]2024/09/12 |
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 /usr/local/etc/puppet/code/environments/production/manifests/class.pp class sample01 { file { '/home/testfile7.txt': ensure => file, owner => 'root', group => 'wheel', mode => '0644', content => 'This is the puppet test file.', } user { 'serverworld': ensure => present, home => '/home/serverworld', managehome => true, password => '$6$v/Mo7qyDFJU9d*****', } } 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 /usr/local/etc/puppet/code/environments/production/manifests/class.pp class sample01 { file { '/home/testfile7.txt': ensure => file, owner => 'root', group => 'wheel', mode => '0644', content => 'This is the puppet test file.', } user { 'serverworld': ensure => present, home => '/home/serverworld', managehome => true, password => '$6$v/Mo7qyDFJU9d*****', } } class sample02 inherits sample01 { file { '/home/testfile8.txt': ensure => file, owner => 'root', group => 'wheel', content => 'test file #8', } } node 'node02.srv.world' { include 'sample02' } |
Sponsored Link |
|