Linux安全网 - Linux操作系统_Linux 命令_Linux教程_Linux黑客

会员投稿 投稿指南 本期推荐: 强烈推荐:Ylmf OS 3.0 正式版发布附迅雷高 XP系统下硬盘安装Fedora 14图文教程
搜索:
您的位置: Linux安全网 > Linux入门 > » 正文

自动化运维管理工具_puppet实践笔记

来源: qubaoquan 分享至:

以下配置文件为各种应用的举例

#默认

node default {
          file { "/tmp/temp1.txt": content => "hello,first puppet manifest"; }
         }

#分发文件

node 'puppet_client2.qubaoquan.com'{
        file { "/opt/file_test/":
                mode => 755,
                owner => puppet,
                group => puppet,
                recurse => true,
                recurselimit => 100,
                source => "puppet:///test/"

             }
}

#删除目录

node 'puppet_client3.qubaoquan.com'{
        file { "/opt/file_test/":
                ensure => absent,
                force =>true
             }
}

#创建文件

node 'puppet_client4.qubaoquan.com'{
        file { "/opt/file_test":
                ensure => file,
                force =>true
             }
}

#创建目录并且分发脚本文件,请按条件执行该脚本

node 'puppet_client5.qubaoquan.com'{
        file { "/opt/file_test":
                ensure => directory,
                force =>true
             }
        file { "/opt/file_test/test.sh":
                mode => 755,
                owner => puppet,
                group => puppet,
                recurse => true,
                ensure => "file",
                recurselimit => 100,
                source => "puppet:///test/test.sh"

             }
        exec { "scprits":
        cwd => "/opt/file_test",
        logoutput => true,
        onlyif => "test -f /home/1.txt",
        command => "bash test.sh",
        user => "root",
        path =>"/sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/usr/X11R6/bin:/bin:/usr/games:/usr/lib/mit/bin:/usr/lib/mit/sbin:/usr/java/jdk1.6.0_12/bin:/usr/java/jdk1.6.0_12/bin:/usr/local/mysql/bin"
                }
}

#自动化任务执行分发过去的脚本

node 'puppet_client6.qubaoquan.com'{
        file { "/opt/file_test":
                ensure => directory,
                force =>true
             }
        file { "/opt/file_test/test.sh":
                mode => 755,
                owner => puppet,
                group => puppet,
                recurse => true,
                ensure => "file",
                recurselimit => 100,
                source => "puppet:///test/test.sh"
             }
        cron {  test:
                command => "/opt/file_test/test.sh",
                user => root,
                minute => '*/10'
              }
}

#创建用户

node 'puppet_client7.qubaoquan.com'{
        user {"test_test":
                uid =>2000,
                home =>"/home/test_test",
                shell =>"/bin/bash",
                managehome =>"true",
                #ensure => "absent",
                provider => dd.html' target='_blank'>useradd
            }
}

#控制服务

node 'puppet_client1.qubaoquan.com'{
        service {
            "postfix":
             ensure => running;
            "cron":
             ensure => stopped;
           }
}


Tags:
分享至:
最新图文资讯
1 2 3 4 5 6
验证码:点击我更换图片 理智评论文明上网,拒绝恶意谩骂 用户名:
关于我们 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 发展历史