puppet 配置实例 用户管理

380阅读 0评论2014-01-07 wfeng
分类:系统运维

 site.pp:

一、添加及组

class test_class {

group { "test":
   gid => 2222,
   ensure =>present;  
}

user { "test":
         uid => 2222,
         gid => 2222,
         password =>'$1$Q4elAs8J$Fdi8GtbxZoHRWAJrmRSa7/',
         shell =>"/bin/bash",
         managehome =>"ture",
         require => Group["test"];
}


file {   "/home/test":
           owner   => 2222,
           group   => 2222,
           mode    => 711,
           ensure => directory,
           require => User["test"];
       }


exec { "userhome":
    command => "cp /etc/skel/.* /home/test/",
    cwd => "/tmp",
    path => ["/usr/bin", "/usr/sbin","/bin"],
    require => File["/home/test"];
    }


#file
#       {"/etc/sudoers":
#       owner => root,
#       group => root,
#       mode => 600,
#//需要把提前修改后的文件拷贝到文件服务器的位置
#       source=> "puppet://puppet/files/sudoers";
#       }

 


}
# tell puppet on which client to run the class
node changzheng{
include test_class
}


二、修改用户密码

class test_class {

user { "test":
         password =>'$1$159tPW3i$oLadwa1iSxkrV8I0S9bSn1'; #这里的密码为000000,linux用户密码加密如果不会算,就直接passwd一个测试用户,然后通过查看/etc/shadow

获取。这里password必须要用单引号,因为还有$字符。
}
}
# tell puppet on which client to run the class
node changzheng{
include test_class
}


更多实例:

另外,可以引入外部的manifests配置文件
在site.pp开始的部分可以通过
import "node1.pp"
import "node2.pp"
...
这样就可以对不同客户端进行相关的配置了。

 
    
上一篇:ORA-09968: unable to lock file lk$ORACLE_SID
下一篇:linux 安装tomcat