Requirements are as follows:
The existing server A,b,c three, the user dev1,dev2,dev3 belong to the dev group, the user sa1,sa2,sa3 belong to wheel group;
User dev1 can log on to server A, and dev2,dev3 can not login, and wheel members can log in;
The same server B only allows users dev2 and wheel members to log in, Server C allows only dev3 and wheel members to log in;
The architecture is as follows:
The relevant documents are as follows:
1,init.pp class User {include User::adduser import ' deluser.pp '} 2,addus
Er.pp class User::adduser {@user {"Dev1": #dev2, dev3 similar to ensure =>, present, Shell => "/bin/bash", tag => [' Dev '], groups => Dev, require => ;
group[' Dev '], managehome => true, password => ' $SAWERADF 123 ',}
@user {"SA1": #sa2, sa3 similar to ensure => present, Shell => "/bin/bash", Tag => [' sa], groups => dev, require => group[' wheel '], managehome => true, password => ' Werae$aer12 ',} group {"Dev": Ensu
Re => present,} 3,deluser.pp define User::d Eluser ($username )
{
User {"$username": Ensure => absent,} file {"/home/$username": Ensure => absent,}}
Note that puppet also supports SSH key authentication, you can go to the official website to see, here or with the password
Use the following methods:
Node ' Server1 ' {
include user
realize user[' Dev1 '] # # Create Dev1
user individually::d eluser{"Userdel sa1": # # Delete SA1
username => SA1,
}
User <| groups = Wheel |> # #创建所有wheel成员
}
premises Remember Or are you going to import "user" inside the modules.pp?
GitHub Address: Https://github.com/vTNT/puppet-user is not updated regularly--
Source: http://tntdba.blog.51cto.com/1199791/1181968