(四)使用ansible部署nfs
4.1、设定nfs-server共享目录
[root@ansible-server ~]# vim corosync/roles/nfs/files/exports
/web/htdocs 192.168.80.0/24(rw)
4.2、创建http默认访问文件index.html,为后面做测试使用
[root@ansible-server ~]# vim corosync/roles/nfs/files/index.html
<h1>nfs-storage</h1>
4.3、定义nfs的tasks
[root@ansible-server ~]# vim corosync/roles/nfs/tasks/main.yml
- name: install nfs
yum: name=nfs-utils state=present
- name: copy exports
copy: src=https://www.linuxidc.com/exports dest=/etc/exports
- shell: mkdir /web/htdocs -pv
args:
creates: /web/htdocs
- name: copy index.html
copy: src=https://www.linuxidc.com/index.html dest=/web/htdocs
- service: name=nfs state=started enabled=yes
tags: start
4.4、定义YAML
[root@ansible-server ~]# vim corosync/ha.yml
- name: install and config corosync
remote_user: root
hosts: hbhosts
roles:
- common
- name: install nfs #新增下面这些项,目的是不会影响node1和node2
remote_user: root
hosts: nfs-Server
roles:
- nfs
4.5、执行ansible-play自动部署nfs设置
[root@ansible-server ~]# ansible-playbook corosync/ha.yml
Ansible+Corosync+Pacemaker+NFS实现http高可用(2)
内容版权声明:除非注明,否则皆为本站原创文章。
转载注明出处:https://www.heiqu.com/33b6b3063e210d5220e265e65d907ad5.html