Puppet : 利用方法 [facter 変数]2023/10/12 |
|
[facter] 変数というシステム関連の情報が自動でセットされた変数が用意されており、必要に応じて利用することができます。 |
|
| [1] | facter 変数の一覧を表示する。 |
|
root@dlp:~# /opt/puppetlabs/bin/facter
aio_agent_version => 7.26.0
augeas => {
version => "1.13.0"
}
disks => {
vda => {
size => "30.00 GiB",
size_bytes => 32212254720,
type => "hdd",
vendor => "0x1af4"
}
}
dmi => {
bios => {
release_date => "04/01/2014",
vendor => "SeaBIOS",
version => "1.16.1-1.el9"
},
board => {
manufacturer => "Red Hat",
product => "RHEL"
},
chassis => {
type => "Other"
},
.....
.....
|
| [2] | 例として、OS が [Ubuntu] で 且つ リリース番号が [22.04] の場合は [sample01] クラスを適用、リリース番号がそれ以外の場合は [sample02] クラスを適用、OS が [Ubuntu] 以外の場合は [sample03] クラスを適用する。 |
|
root@dlp:~#
vi /etc/puppetlabs/code/environments/production/manifests/class.pp
class sample01 {
file { '/home/testfile9.txt':
ensure => file,
owner => 'root',
group => 'root',
mode => '0644',
content => 'This is the puppet test file.',
}
}
class sample02 {
user { 'trixie':
ensure => present,
home => '/home/trixie',
managehome => true,
password => '$6$0XTc2rjlxxxxxxxx',
}
}
class sample03 {
file { '/home/testfile10.txt':
ensure => file,
owner => 'root',
group => 'adm',
content => 'test file #10',
}
}
case $operatingsystem {
'Ubuntu': {
if $operatingsystemrelease == '22.04' { include 'sample01' }
else { include 'sample02' }
}
default: { include 'sample03' }
}
|
| Sponsored Link |
|
|