CentOS 7
Sponsored Link

Puppet : How to use [facter Variable]2015/07/22

 
Facter variables which are the system settings are set automatically, It's possible to use them if need.
[1] Display facter variables.
[root@dlp ~]#
facter

architecture => x86_64
augeasversion => 1.1.0
bios_release_date => 01/01/2007
bios_vendor => Seabios
bios_version => 0.5.1
blockdevice_vda_size => 53687091200
blockdevice_vda_vendor => 0x1af4
...
...
...
uptime_hours => 1
uptime_seconds => 6836
uuid => 8DBDD6BD-B474-765D-D743-1160BE341044
virtual => kvm
[2] For example, if OS is "RedHat" or "CentOS" and version is "7.1.1503", apply "sample01" class, if version is not "7.1.1503", apply "sample02" class, if OS is not "RedHat" or "CentOS", apply "sample03" class.
[root@dlp ~]#
vi /etc/puppet/manifests/site.pp
class sample01 {
    file { '/home/testfile.txt':
        ensure  => file,
        owner   => 'root',
        group   => 'root',
        mode    => 644,
        content => 'This is the puppet test file.',
    }
}
class sample02 {
    user { 'cent':
        ensure     => present,
        home       => '/home/cent',
        managehome => true,
        password   => '$6$0XTc2rjlxxxxxxxx',
    }
}
class sample03 {
    file { '/home/testfile2.txt':
        ensure  => file,
        owner   => 'root',
        group   => 'wheel',
        content => 'test file2',
    }
}
case $operatingsystem {
    'RedHat', 'CentOS': {
        if $operatingsystemrelease == '7.1.1503' { include 'sample01' }
        else                                { include 'sample02' }
    }
    default:            { include 'sample03' }
}
Matched Content