Sunday, November 26, 2017

Puppet:- Samba deployment

Puppet:- Samba deployment

[root@pserver manifests]# cat init.pp
class samba {
        package {'samba':
                ensure => 'present',
        }
        package {'samba-client':
                ensure => 'present',
        }
#       file {'smb.conf':
#               path    => '/etc/samba/smb.conf',
#               source  => 'puppet:///modiles/samba/smb.conf',
#               require => Package['samba'],
#               subscribe => Service['smb'],
#       }

        user {'jay':
                ensure => 'present',
                managehome => 'true',
                require => Package['samba'],
        }

#       exec {'set smb passwd for jay':
#               shell => "/bin/echo -e "redhat\nredhat" | /usr/bin/smbpasswd -s -a jay"
##              require => Package['samba-client'],
#       }
        service {'smb':
                ensure => 'running',
#               enable => 'true',
        }
}
[root@pserver manifests]# pwd
/etc/puppet/modules/samba/manifests
[root@pserver manifests]# cd ../../../manifests/
[root@pserver manifests]# cat site.pp
include httpd
include samba
[root@pserver manifests]#


go to agent and run

[root@node2 puppet]# puppet agent -t
Info: Retrieving pluginfacts
Info: Retrieving plugin
Info: Caching catalog for node2.example.com
Info: Applying configuration version '1511746320'
Notice: /Stage[main]/Samba/User[jay]/ensure: created
Notice: Finished catalog run in 0.36 seconds
[root@node2 puppet]# id jay
uid=2002(jay) gid=2002(jay) groups=2002(jay)
[root@node2 puppet]# ls -ld /home/jay
drwx------. 3 jay jay 4096 Nov 26 20:32 /home/jay
[root@node2 puppet]#


[root@node2 puppet]# systemctl status smb
smb.service - Samba SMB Daemon
   Loaded: loaded (/usr/lib/systemd/system/smb.service; disabled)
   Active: active (running) since Sun 2017-11-26 20:30:07 EST; 14s ago
 Main PID: 18255 (smbd)
   Status: "smbd: ready to serve connections..."
   CGroup: /system.slice/smb.service
           ├─18255 /usr/sbin/smbd
           └─18257 /usr/sbin/smbd

Nov 26 20:30:07 node2.example.com smbd[18255]: [2017/11/26 20:30:07.892874,  0] ../lib/u...y)
Nov 26 20:30:07 node2.example.com systemd[1]: Started Samba SMB Daemon.
Hint: Some lines were ellipsized, use -l to show in full.


if you want to specify specific host, edit the site.pp file under manifest.

[root@pserver manifests]# cat site.pp
node 'node1.example.com' {
include samba
}

node 'node2.example.com' {
include httpd
}
[root@pserver manifests]#

No comments:

Post a Comment