puppet resouces 使用示例

  • user 使用示例:
user {"nginx":
ensure => present,
shell => "/sbin/nologin",
mangehome => true,
comment => "nginx user",
}
  • group 使用示例:
group { "nginx":
        ensure => present,
        gid => 1000,
       }
  • package 使用示例:
 packages { "nginx":
           ensure =>present,
        } 
  • service 使用示例:
service { "nginx": 
        ensure => running,
        enable => true, 
     hasstatus => true,
    hasrestart => true,
       pattern => nginx,
       require => Package['nginx'],
    }
  • cron 使用示例:
 cron { "clean-files":
ensure => present,
user => 'root',
command => '/usr/local/bin/clean-files',
minute => '1',
hour => '3',
weekday => [ '2', '6' ],
environment => 'MAILTO=puppetfans@163.com',
} 
  • exec 使用示例:

exec { 'perl -MCPAN -e "install YAML"':
path => '/bin:/usr/bin',
unless => 'cpan -l | grep -qP ^YAML\\b',
}
  • file 使用示例:
 file { "nginx.conf":
 ensure  => present,
 path    => "/etc/nginx/nginx.conf",
 mode    => 644,
 owner   => root,
 group   => root,
 require => Package['nginx'],
 notify  => Service['nginx'],
 source  => "puppet:///modules/hotpu/nginx/nginx.conf",
 }
  • mount 使用示例:
mount { '/media/gluster-data':
ensure => 'mounted',
device => 'gluster01:/data',
fstype => 'glusterfs',
options => 'defaults,_netdev',
dump => 0,
pass => 0,
}
  • 虚拟资源使用示例:
@@user { "nginx":
 ensure => present,
 tag => nginx,
 }
  • 实现虚拟资源使用示例:
 realize User["nginx"]
User <| tag == nginx |>

发表评论

电子邮件地址不会被公开。 必填项已用*标注