• ansible剧本--实现一键部署nfs服务


    [root@m01 ansible-playbook]# 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: copy conf file
    copy: src=/etc/ansible/ansible-playbook/nfs-file/nfs-server/exports dest=/etc
    notify: restart nfs server
    - name: create dir file
    file: path={{ Data_dir }} state=directory owner=nfsnobody group=nfsnobody
    - name: boot server
    #service: name=nfs state=started enabled=yes
    #service: name=rpcbind state=started enabled=yes
    sevice: 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 }}

     

  • 相关阅读:
    PHP Session 变量
    PHP Cookie是什么
    PHP 文件上传
    PHP 文件处理
    PHP include 和 require 语句
    Mac pycharm专业版安装以及破解方法
    bzoj3946: 无聊的游戏
    win10 uwp 九幽图床
    win10 uwp 九幽图床
    git无法pull仓库refusing to merge unrelated histories
  • 原文地址:https://www.cnblogs.com/chenyuxia/p/13345691.html
Copyright © 2020-2023  润新知