puppet mount可以管理Linux文件系统常用的挂载和卸载(nfs、samba等),包括开机自动挂载,默认会写入/etc/fstab。
实际上,就是使用mount的命令。
格式:
mount { "title": #要挂载的目录 ensure =>mounted|unmounted, #挂载和卸载 device => "设备", fstype => "ext3|ext4|nfs|cifs|iso9660|ntfs", #文件系统类型,smbfs已换为cifs options => '参数', #挂载参数,以逗号分隔,常用:defaults、rw、ro path => "要挂载的目录"; #同title,可省略 }
|
例:
#mount and unmount vi /etc/puppet/manifest/test.pp mount {"/mnt": ensure => mounted, device => "/dev/cdrom", fstype => iso9660, options => "defaults"; }
[root@client ~]# ls /mnt/ [root@client ~]# puppet agent -vv --test --server master.perofu.com info: Caching catalog for client.perofu.com info: Applying configuration version '1395098018' notice: /Stage[main]//Mount[/mnt]/ensure: ensure changed 'unmounted' to 'mounted' info: /Stage[main]//Mount[/mnt]: Scheduling refresh of Mount[/mnt] info: Mount[/mnt](provider=parsed): Remounting notice: /Stage[main]//Mount[/mnt]: Triggered 'refresh' from 1 events info: /Stage[main]//Mount[/mnt]: Scheduling refresh of Mount[/mnt] notice: Finished catalog run in 0.56 seconds [root@client ~]# ls /mnt/ CentOS_BuildTag EULA images Packages repodata RPM-GPG-KEY-CentOS-Debug-6 RPM-GPG-KEY-CentOS-Testing-6 EFI GPL isolinux RELEASE-NOTES-en-US.html RPM-GPG-KEY-CentOS-6 RPM-GPG-KEY-CentOS-Security-6 TRANS.TBL [root@client ~]#
# mount {"/mnt": ensure => unmounted, device => "/dev/cdrom", fstype => iso9660, options => "defaults"; }
[root@client ~]# puppet agent -vv --test --server master.perofu.com info: Caching catalog for client.perofu.com info: Applying configuration version '1395098061' notice: /Stage[main]//Mount[/mnt]/ensure: ensure changed 'mounted' to 'unmounted' info: /Stage[main]//Mount[/mnt]: Scheduling refresh of Mount[/mnt] notice: /Stage[main]//Mount[/mnt]: Triggered 'refresh' from 1 events info: /Stage[main]//Mount[/mnt]: Scheduling refresh of Mount[/mnt] notice: Finished catalog run in 0.38 seconds [root@client ~]# ls /mnt/
#参数 [root@client ~]# mount /dev/sda3 on / type ext4 (rw) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,gid=5,mode=620) tmpfs on /dev/shm type tmpfs (rw) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) /dev/sda1 on /boot type ext4 (rw) [root@client ~]# [root@client ~]# puppet agent -vv --test --server master.perofu.com info: Caching catalog for client.perofu.com info: Applying configuration version '1395099209' notice: /Stage[main]//Mount[/boot]/device: device changed 'UUID=7359d0d7-7c3e-403e-9483-35915f83bfbb' to '/dev/sda1' notice: /Stage[main]//Mount[/boot]/options: options changed 'defaults' to 'remount,ro' notice: /Stage[main]//Mount[/boot]/pass: pass changed '2' to '0' notice: /Stage[main]//Mount[/boot]/dump: dump changed '1' to '0' info: FileBucket adding /etc/fstab as {md5}642569bbd3a67d8cdb8379986e81a4cf info: /Stage[main]//Mount[/boot]: Scheduling refresh of Mount[/boot] info: /Stage[main]//Mount[/boot]: Scheduling refresh of Mount[/boot] info: /Stage[main]//Mount[/boot]: Scheduling refresh of Mount[/boot] info: /Stage[main]//Mount[/boot]: Scheduling refresh of Mount[/boot] info: Mount[/boot](provider=parsed): Remounting notice: /Stage[main]//Mount[/boot]: Triggered 'refresh' from 4 events info: /Stage[main]//Mount[/boot]: Scheduling refresh of Mount[/boot] notice: Finished catalog run in 0.30 seconds [root@client ~]# [root@client ~]# mount /dev/sda3 on / type ext4 (rw) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,gid=5,mode=620) tmpfs on /dev/shm type tmpfs (rw) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) /dev/sda1 on /boot type ext4 (ro)
#挂载samba mount {"/media": ensure => mounted, device => "//172.22.2.89/public", fstype => cifs, options => "username=perofu,password=123456"; }
[root@client ~]# ls /media/ [root@client ~]# puppet agent -vv --test --server master.perofu.com info: Caching catalog for client.perofu.com info: Applying configuration version '1395101506' info: FileBucket adding /etc/fstab as {md5}d29e46094aa22aa0013452a6ef3da312 notice: /Stage[main]//Mount[/media]/ensure: defined 'ensure' as 'mounted' info: /Stage[main]//Mount[/media]: Scheduling refresh of Mount[/media] info: Mount[/media](provider=parsed): Remounting notice: /Stage[main]//Mount[/media]: Triggered 'refresh' from 1 events info: /Stage[main]//Mount[/media]: Scheduling refresh of Mount[/media] notice: Finished catalog run in 5.14 seconds [root@client ~]# [root@client ~]# ls /media/ 1.pp nodes.pp site.pp [root@client ~]# mount /dev/sda3 on / type ext4 (rw) proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) devpts on /dev/pts type devpts (rw,gid=5,mode=620) tmpfs on /dev/shm type tmpfs (rw) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) /dev/sda1 on /boot type ext4 (ro) //172.22.2.89/public on /media type cifs (rw,username=perofu,password=123456)
[root@client ~]# cat /etc/fstab //172.22.2.89/public /media cifs username=perofu,password=123456 0 0 |
至此,puppet的mount资源就结束了,接下来的是tidy资源的学习,请听下回分解!!!