ansible在web集群中批量部署nfs

简介: ansible在web集群中批量部署nfs

NFS–network file system 可以在linux/unix系统之间共享,支持多节点同时挂载以及并发写入。如果大家有那种web集群(httpd/tomcat/nginx),可以用nfs挂载,方便管理网页信息

我写了一个yml文件,供参考

1 安装ansible,配置inventory

yum -y install ansible

01bd9c736a74402998ee380c7633f86c.png

2 建立一个***.yaml 文件,位置我放在了root下

复制该文本请记得修改挂载点的 ip,nfs_info目录位置随意,但它下面的文件index.html 中后缀不可以出错。

vim nfs.yml

---
- name: initial preparations
  hosts: all
  tasks:
    - name: stop firewalld
      service:
        name: firewalld
        state: stopped
    - name: disable selinux
      shell: setenforce 0
- name: for nfs
  hosts: nfs
  tasks:
    - name: install nfs-utils
      yum:
        name: nfs-utils
        state: present
    - name: make directory for storig info
      file:
        path: /opt/nfs_info
        state: directory
    - name: copy random contents to /nfs_info
      copy:
        content: "testing"
        dest: /opt/nfs_info/index.html
    - name: for /etc/exports
      copy:
        content: "/opt/nfs_info  192.168.122.163(rw)"
        dest: /etc/exports
    - name: start nfs-server
      service:
        name: nfs-server
        state: started
        enabled: yes
- name: for webs
  hosts: web
  tasks:
    - name: install apps
      yum: 
        name: nfs-utils,httpd
        state: present
    - name: start nfs-server
      service:
        name: nfs-server
        state: started
        enabled: yes
    - name: start httpd
      service:
        name: httpd
        state: started
        enabled: yes
    - name: mount
      mount:
        path: /var/www/html
        src: 192.168.122.163:/opt/nfs_info
        fstype: nfs
        state: mounted

3 ansible执行剧本

ansible-playbook nfs.yml #执行上面的剧本,具体名字根据剧本名字来
ansible all -m shell -a 'lsblk' 
ansibel all -m shell -a 'df -Th'
# 查询挂载是否成功


目录
相关文章
|
25天前
|
存储 Kubernetes 容器
第十章 集群安装NFS以及NFS卸载客户端和服务端
第十章 集群安装NFS以及NFS卸载客户端和服务端
38 1
|
1月前
|
存储 资源调度 应用服务中间件
浅谈本地开发好的 Web 应用部署到 ABAP 应用服务器上的几种方式
浅谈本地开发好的 Web 应用部署到 ABAP 应用服务器上的几种方式
27 0
|
2月前
|
存储 Kubernetes 容器
百度搜索:蓝易云【Kubernetes使用helm部署NFS Provisioner】
现在,你已经成功使用Helm部署了NFS Provisioner,并且可以在Kubernetes中创建使用NFS存储的PersistentVolumeClaim。
44 10
|
3月前
|
安全 应用服务中间件 nginx
百度搜索:蓝易云【使用Debian、Docker和Nginx部署Web应用教程】
这些是在Debian上使用Docker和Nginx部署Web应用的基本步骤。根据您的需求和具体环境,可能还需要进行其他配置和调整。请确保在进行任何与网络连接和安全相关的操作之前,详细了解您的网络环境和安全需求,并采取适当的安全措施。
45 0
|
3天前
|
测试技术 Linux Docker
【好玩的经典游戏】Docker部署FC-web游戏模拟器
【好玩的经典游戏】Docker部署FC-web游戏模拟器
28 1
|
12天前
|
Web App开发 Java 应用服务中间件
【Java Web】在 IDEA 中部署 Tomcat
【Java Web】在 IDEA 中部署 Tomcat
|
1月前
|
应用服务中间件 Linux nginx
web后端-linux-nginx-1.18操作命令和部署
web后端-linux-nginx-1.18操作命令和部署
|
1月前
|
Java 应用服务中间件
解决tomcat启动报错:无法在web.xml或使用此应用程序部署的jar文件中解析绝对的url [http:java.sun.com/jsp/jstl/core]
解决tomcat启动报错:无法在web.xml或使用此应用程序部署的jar文件中解析绝对的url [http:java.sun.com/jsp/jstl/core]
133 1
|
2月前
|
安全 网络安全 开发者
如何在OpenWRT部署uhttpd搭建服务器实现远程访问本地web站点
如何在OpenWRT部署uhttpd搭建服务器实现远程访问本地web站点
122 0
|
3月前
|
TensorFlow 算法框架/工具 数据安全/隐私保护
如何在云服务器使用docker快速部署jupyter web服务器(Nginx+docker+jupyter+tensorflow)
如何在云服务器使用docker快速部署jupyter web服务器(Nginx+docker+jupyter+tensorflow)
89 0