博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
NFS服务剧本
阅读量:2337 次
发布时间:2019-05-10

本文共 1574 字,大约阅读时间需要 5 分钟。

第一个历程: 创建几个目录

   [root@m01 ansible-playbook]# tree nfs-file/
   nfs-file/
   ├── nfs-client
   └── nfs-server
   
   第二个历程: 编写剧本信息
   主机清单:

vim /etc/ansible/hosts

   [nfs:children]
   nfs_server
   nfs_client
   [nfs_server]
   172.16.1.31
   [nfs_client]
   172.16.1.7
   172.16.1.8
   172.16.1.9

vim nfs-server.yaml

- hosts: nfs  tasks:    - name: 01-install nfs software      yum:        name: ['nfs-utils','rpcbind']        state: installed- hosts: nfs_server  vars:    Data_dir: /data  tasks:    - name: 01-copy conf file      copy: src=/etc/ansible/ansible-playbook/nfs-file/nfs-server/exports dest=/etc      notify: restart nfs server    - name: 02-create data dir      file: path={
{ Data_dir }} state=directory owner=nfsnobody group=nfsnobody        # path: ['data01','data02','data03']        # state: directory        # owner: nfsnobody        # group: nfsnobody    - name: 03-boot server      #service: name=rpcbind state=started enabled=yes      #service: name=nfs state=started enabled=yes      service: name={
{ item }} state=started enabled=yes      with_items:        - rpcbind        - nfs        handlers:    - name: restart nfs server      service: name=nfs state=restarted       - hosts: nfs_client  vars:    Data_dir: /data  tasks:    - name: 01-mount      mount: src=172.16.1.31:{
{ Data_dir }} path=/mnt fstype=nfs state=mounted    - name: 02-check mount info      shell: df -h|grep /data      register: mount_info    - name: display mount info      debug: msg={
{ mount_info.stdout_lines }}  

   

   

第三个历程: 进行剧本测试

 ansible-playbook --syntax-check  nfs_server.yaml

 ansible-playbook -C  nfs_server.yaml

 

 

 

 

 

 

 

 

 

 

转载地址:http://nhepb.baihongyu.com/

你可能感兴趣的文章
Flask vs Django,Python Web开发用哪个框架更好
查看>>
用Python制作动态二维码,一行代码就做到了
查看>>
Python说:常见的数据分析库有哪些
查看>>
Python教程:Python数据类型之字典
查看>>
Python基础教程:python的数据类型
查看>>
Python学习教程:另辟蹊径,appium抓取app应用数据了解一下
查看>>
周董新歌《说好不哭》上线,20W评论,歌迷都说了些啥
查看>>
Python学习教程:用Python进行金融市场文本数据的情感计算
查看>>
Python爬虫:python获取各种街拍美图
查看>>
爬虫工程师是干什么的?你真的知道吗?
查看>>
写给那些想学Python的人,建议收藏后细看
查看>>
数据全裸时代,你的隐私有多容易获取?
查看>>
分析http代理报错问题
查看>>
Python编程学习笔记 - 列表的各种姿势
查看>>
Python学习教程:Python入门笔记整理
查看>>
天了噜,居然用Python查到了女神的姓名
查看>>
不可不学Numpy,带你快速撸Numpy代码,(Python学习教程)一遍过
查看>>
如何写出极致的代码?替你保管钱的支付宝程序员有话说
查看>>
一个能和产品经理喝酒的程序员朋友
查看>>
上了一节神经网络课,我想说的话!
查看>>