ansible(15) |
您所在的位置:网站首页 › 艾米丽瑜伽冥想 › ansible(15) |
环境准备:将 ansible 作为 nfs 服务端, 192.168.20.22、192.168.20.23 作为 nfs客户端挂载; [root@xuzhichao ~]# ansible localhost -m yum -a 'name=nfs-utils state=present' [root@xuzhichao ~]# ansible localhost -m file -a 'path=/data/nfs/ owner=nginx group=nginx state=directory' [root@xuzhichao ~]# ansible localhost -m copy -a 'dest=/etc/exports content="/data/nfs 192.168.20.0/24(rw,all_squash,anonuid=887,anongid=887)\n"' [root@xuzhichao ~]# ansible localhost -m service -a 'name=nfs-server state=started' [root@xuzhichao ~]# exportfs -arv exporting 192.168.20.0/24:/data/nfs示例一:挂载 nfs 至本地的 /opt 目录,并实现开机自动挂载: [root@xuzhichao ~]# ansible NginxWebs -m mount -a 'src=192.168.20.17:/data/nfs path=/opt fstype=nfs opts=defaults state=mounted' [root@nginx03 ~]# df Filesystem 1K-blocks Used Available Use% Mounted on 192.168.20.17:/data/nfs 154057344 33280 154024064 1% /opt [root@nginx03 ~]# cat /etc/fstab 192.168.20.17:/data/nfs /opt nfs defaults 0 0示例二:临时卸载 nfs 的挂载,但不清理 /etc/fstab : [root@xuzhichao ~]# ansible NginxWebs -m mount -a 'src=192.168.20.17:/data/nfs path=/opt fstype=nfs opts=defaults state=unmounted'示例三:永久卸载 nfs 挂载,同时清理 /etc/fstab: [root@xuzhichao ~]# ansible NginxWebs -m mount -a 'src=192.168.20.17:/data/nfs path=/opt fstype=nfs opts=defaults state=absent' |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |