zoukankan      html  css  js  c++  java
  • 利用ansible一键部署nfs.yml格式剧本

    条件及部署过程如下:

    1. 现有一台主机创建共享目录其他主机挂载到该服务器
    2. 管理主机一台,已经分发好被管理主机基于ssh的认证请。参考本人另一篇博文:http://www.cnblogs.com/ExzaiTin/p/7687410.html
    3. 管理主机已经编写好共享目录的配置文件
    4. 被管理主机部署好libselinux-python 安装方法:yum install libselinux-python -y
    5. 管理主机部署好ansible安装方法:yum install -y ansible
    6. 管理主机部署好/etc/ansible/hosts配置文件
    7. 编写ansible剧本参考如下
      ##NFS
      ##by ExzaiTin for20171021
      - hosts: Nfs_Sharing
        tasks:
          - name: No1:yum rpcbind nfs-utils  ##安装rpcbind和nfs-utils
            yum: name=rpcbind name=nfs-utils state=installed
          - name: No2:crete nfs conf  ##传输nfs配置文件并备份
            copy: src=/conf/exports dest=/etc/exports backup=yes
          - name: No3:boot rpcbind server  ##启动rpcbind并设置开机自启
            service: name=rpcbind state=started enabled=yes
          - name: No4:boot nfs server  ##启动nfs并设置开机自启
            service: name=nfs state=started enabled=yes
          - name: No5:create nfs dir  ##分配共享目录属主属组为nfsnoboddy
            file: dest=/data state=directory owner=nfsnobody group=nfsnobody
      - hosts: Nfs_Mount
        tasks:
          - name: No1:yum rpcbind nfs-utils  ##rpcbind和nfs-utils
            yum: name=rpcbind name=nfs-utils state=installed
          - name: No2:create nfs dir  ##创建挂载目录
            file: dest=/data state=directory 
          - name: No3:mount  ##挂载到共享目录
            mount: fstype=nfs opts=rw src=172.16.1.31:/data path=/data state=mounted

      ps.在编写完剧本后使用ansible-playbook -C推演确认没有问题在执行ansible-playbook nfs.yml进行部署

  • 相关阅读:
    Truck History(poj 1789)
    Highways poj 2485
    117. Populating Next Right Pointers in Each Node II
    116. Populating Next Right Pointers in Each Node
    115. Distinct Subsequences
    114. Flatten Binary Tree to Linked List
    113. Path Sum II
    109. Convert Sorted List to Binary Search Tree
    106. Construct Binary Tree from Inorder and Postorder Traversal
    105. Construct Binary Tree from Preorder and Inorder Traversal
  • 原文地址:https://www.cnblogs.com/ExzaiTin/p/7701661.html
Copyright © 2011-2022 走看看