一键安装nfs服务

#install nfs_server
- hosts: 172.16.1.31    服务端
  tasks:
    -name: installnfs-utils rpcbind
      yum: name=nfs-utils,rpcbind
    -name: copyconffile
      copy: src=/etc/ansible/nfs_conf/exports dest=/etc/exports #将nfs配置文件配置好直接发送过去
    -name: createuser_www
      user: name=www createhome=no shell=/sbin/nologinuid=888
    -name: create dirdata
      file: dest=/data state=directory owner=www group=www
    -name: startrpc_server
      shell: /etc/init.d/rpcbind start
    -name: startnfs_server
      shell: /etc/init.d/nfs start
- hosts: 172.16.1.41    客户端
  tasks:
    -name: install nfsrpc rpcbind
      yum: name=nfs-utils,rpcbind
    -name: createuser_www
      user: name=www createhome=no shell=/sbin/nologinuid=888
    -name: mountdata_dir
      mount: name=/mnt src=172.16.1.31:/data fstype=nfs state=mounted