Puppet : 利用方法 [class の設定]2023/10/17 |
[class] 宣言を使って複数のリソースをまとめて管理できます。 |
|
[1] | [sample01] クラスを定義し、そのクラス中で必要なリソースを定義して [include] で [node02.srv.world] へ適用する。 |
[root@dlp ~]#
vi /etc/puppetlabs/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 { 'centos': ensure => present, home => '/home/centos', managehome => true, password => '$6$0XTc2rjlxxxxxxxx', } } node 'node02.srv.world' { include 'sample01' } |
[2] | [sample01] クラスを定義し、さらに [sample01] を継承した [sample02] を定義して [node03.srv.world] へ適用する。 |
[root@dlp ~]#
vi /etc/puppetlabs/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 { 'centos': ensure => present, home => '/home/centos', managehome => true, password => '$6$0XTc2rjlxxxxxxxx', } } class sample02 inherits sample01 { file { '/home/testfile8.txt': ensure => file, owner => 'root', group => 'root', content => 'test file #8', } } node 'node03.srv.world' { include 'sample02' } |
Sponsored Link |