Puppet : 利用方法 [class の設定]2024/09/12 |
[class] 宣言を使って複数のリソースをまとめて管理できます。 |
|
[1] | [sample01] クラスを定義し、そのクラス中で必要なリソースを定義して [include] で [node02.srv.world] へ適用する。 |
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] | [sample01] クラスを定義し、さらに [sample01] を継承した [sample02] を定義して [node02.srv.world] へ適用する。 |
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 |
|