Manage-Users

[root@server ~]# vim /etc/puppet/manifests/site.pp
hiera_include(‘classes’)
node default {
include users::students
}

———————————————————————
[root@server ~]# mkdir -p /etc/puppet/modules/users/manifests/
[root@server ~]# vim /etc/puppet/modules/users/manifests/students.pp
class users::students {
user { ‘mohammed’:
ensure => present,
groups => [‘sudo’, ‘users’],
managehome => ‘true’,
shell => ‘/bin/bash’,
password => ‘$6$4T7f7FMX$hnSX1.CaAiKI1dSQnKdFX0T782N6QYOTFoU2V0A0tywyHR28jxNgcgSGCabFO5m20Fv4ulxokRLhraELyFfFu.’,
}
group { “sudo”:
ensure => “present”,
}

}
———————————————————————
[root@server ~]# puppet apply /etc/puppet/modules/users/manifests/students.pp –noop
Notice: Compiled catalog for server.puppet.com in environment production in 0.03 seconds
Notice: Finished catalog run in 0.08 seconds
———————————————————————
[root@client ~]# tail /etc/passwd
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
apache:x:48:48:Apache:/var/www:/sbin/nologin
saslauth:x:498:76:Saslauthd user:/var/empty/saslauth:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
pulse:x:497:496:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
puppet:x:52:52:Puppet:/var/lib/puppet:/sbin/nologin
———————————————————————
[root@client ~]# puppet agent -t
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Loading facts
Info: Caching catalog for client.puppet.com
Info: Applying configuration version ‘1465792293’
Notice: /Stage[main]/Users::Students/Group[sudo]/ensure: created
Notice: /Stage[main]/Users::Students/User[mohammed]/ensure: created
Notice: Finished catalog run in 1.42 seconds
———————————————————————
[root@client ~]# tail /etc/passwd
gdm:x:42:42::/var/lib/gdm:/sbin/nologin
ntp:x:38:38::/etc/ntp:/sbin/nologin
apache:x:48:48:Apache:/var/www:/sbin/nologin
saslauth:x:498:76:Saslauthd user:/var/empty/saslauth:/sbin/nologin
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
pulse:x:497:496:PulseAudio System Daemon:/var/run/pulse:/sbin/nologin
sshd:x:74:74:Privilege-separated SSH:/var/empty/sshd:/sbin/nologin
tcpdump:x:72:72::/:/sbin/nologin
puppet:x:52:52:Puppet:/var/lib/puppet:/sbin/nologin
mohammed:x:500:501::/home/mohammed:/bin/bash
———————————————————————

[root@client ~]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 52:54:00:b3:90:e7 brd ff:ff:ff:ff:ff:ff
inet 192.168.122.199/24 brd 192.168.122.255 scope global eth1
inet6 fe80::5054:ff:feb3:90e7/64 scope link
valid_lft forever preferred_lft forever

———————————————————————
mohammedrafi@NOC-RAFI:~$ ssh mohammed@192.168.122.199
mohammed@192.168.122.199’s password:
[mohammed@client ~]$

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s