puppet进阶指南——user资源详解

简介:

user资源

     user资源主要用来管理操作系统的帐号,如帐号的增加、删除已经属性的变更。

1、user资源常用属性

user {'资源标题':

    name

    ensure

    allowdupe

    comment

    uid

    gid

    groups

    home

    managehome

    manages_expiry

    passowrd

    manages_password_max_age

    manages_password_min_age

    shell

    provider

}

 name:指定创建系统账户名。

 ensure:设定账户的增加和删除,present表示增加账户,absent表示删除账户。

 allowdupe:是否允许重复的UID,设置false表示不可以设置相同的uid,默认为false。

 comment:对账户的描述。

 uid:如果不设置,系统会自动分配uid。

 gid:可以是数字或者组名。

 groups:主要设定附加组,如['group1','group2']。

 home:系统账户的宿主目录,需要提前创建。

 managehome:管理用户的时候是否管理其home目录。

 manages_expiry:管理用户过期时间。

 passowrd:系统账户密码。

 shell:用户的shell。

 provider:

   aix --- AIX的用户管理。

   directoryservice --- 在OS X上使用目录服务进行用户管理。

   Hpuxuseradd --- HP-UX的用户管理。

   ldap --- 通过ldap进行用户管理。

   pw --- 在freebsd平台上通过pw进行用户管理。

   user_role_add --- solaris的用户和角色管理。

   useradd --- 通过useradd进行用户管理,加入你要进行密码管理的话,需要安装ruby的shadow密码库,一般是ruby-libshadow。

   windows_adsi --- 在windows平台上使用本地用户管理。

2、user资源案例

通过user资源在linux系统上面增加test账户,我们先生成一下密码

# openssl passwd -1

Password: 

Verifying - Password: 

$1$8xSEslm.$2l5IB6ohvWxPIbEYPMR8c.


继续编辑/etc/puppet/manifests/user.pp,添加以下内容

user {'test':

   uid => '501',

   home => '/home/test',

   password => '$1$8xSEslm.$2l5IB6ohvWxPIbEYPMR8c.',

   shell =>'/bin/bash',

}

file {'/home/test':

   ensure => directory,

   group => '501',

   owner => '501',

   mode => '700',

}

然后执行测试

# puppet apply user.pp

notice: /Stage[main]//User[test]/ensure: created

notice: /Stage[main]//File[/home/test]/ensure: created

notice: Finished catalog run in 0.04 seconds



欢迎关注http://www.wzlinux.com:45 和http://www.wzlinux.com 。


     本文转自 wzlinux 51CTO博客,原文链接:http://blog.51cto.com/wzlinux/1685628,如需转载请自行联系原作者


相关文章
|
1月前
|
运维 Linux Apache
【一键变身超人!】Puppet 自动化运维神器 —— 让你的服务器听话如婴儿,轻松管理资源不是梦!
【8月更文挑战第9天】随着云计算与容器化技术的发展,自动化运维已成为现代IT基础设施的核心部分。Puppet是一款强大的自动化工具,用于配置管理,确保系统保持预期状态。通过易于理解的配置文件定义资源及其依赖关系,Puppet实现了“基础设施即代码”的理念。本文简要介绍了Puppet的安装配置方法及示例,包括Puppet Agent与Master的安装、基本配置步骤和一个简单的Apache HTTP Server管理示例,展示了Puppet在实际应用中的强大功能与灵活性。
30 9
|
关系型数据库 MySQL Shell
puppet连载24:虚拟资源
class account::virtual { @user {"mysql": ensure => present, uid => 27, gid => 27, home => "/var/lib/mysql", shell => "/bin/bas...
769 0
puppet连载17:file资源详解
file {'/tmp/filetest': content => "aaa", ensure => file, } ensure => present file {'/tmp/filetest': content => "aaa", } file {...
867 0
|
安全 Linux 网络协议
puppet yum模块、配置仓储、mount模块
转载:http://blog.51cto.com/ywzhou/1577335 作用:自动为客户端配置YUM源,为使用yum安装软件包提供便捷。 1、服务端配置yum模块 (1)模块清单 [root@puppet ~]# tree /etc/puppe...
1098 0
|
网络协议 安全 网络安全