Ansible学习笔记14

实现多台的分离实现:

bash 复制代码
[root@localhost playbook]# cat example3.yaml
---
- hosts: 192.168.17.105
  remote_user: root
  tasks:
  - name: create test1 directory
    file: path=/test1/ state=directory

- hosts: 192.168.17.106
  remote_user: root
  tasks:
  - name: create test2 directory
    file: path=/test2/ state=directory

剧本执行情况:

在105的机器上创建了test1目录。

在106的机器上创建了test2目录。

搭建nfs系统,并在另外一台机器上进行挂载操作。

bash 复制代码
[root@localhost playbook]# cat example4.yaml
---
- hosts: 192.168.17.105
  remote_user: root
  tasks:
  - name: install nfs software
    yum: name=nfs-utils,rpcbind,setup state=latest

  - name: create share folder
    file: path=/share/ state=directory

  - name: sync nfs configure
    copy: src=/etc/exports dest=/etc/exports

    notify: restart nfs

  - name: start rpcbind and enabled in boot
    service: name=rpcbind state=started enabled=yes

  - name: start nfs and enabled in boot
    service: name=nfs state=started enabled=yes

  handlers:
  - name: restart nfs
    service: name=nfs state=restarted

- hosts: 192.168.17.106
  remote_user: root
  tasks:
  - name: install nfs client package
    yum: name=nfs-utils state=latest

  - name: mount
    shell: mount 192.168.17.105:/share /mnt

检查已经挂在成功:

相关推荐
qq_401700413 分钟前
嵌入式Linux网口MAC地址修改
linux·运维·macos
Xの哲學40 分钟前
Linux DRM 架构深度解析
linux·服务器·算法·架构·边缘计算
老王熬夜敲代码1 小时前
Linux的权限
linux
我是谁??1 小时前
Linux上检查U盘可读和修复
linux·运维·服务器
南棱笑笑生1 小时前
20251213给飞凌OK3588-C开发板适配Rockchip原厂的Buildroot【linux-6.1】系统时适配CTP触摸屏FT5X06
linux·c语言·开发语言·rockchip
杰克逊的日记1 小时前
怎么排查pod重启
linux·运维·服务器
hgz07102 小时前
JMeter性能压测执行与Linux环境部署
java·linux·jmeter
KingRumn2 小时前
Linux进程间通信之共享内存与消息队列的竞争问题(同步策略)对比
linux·运维·服务器
qq_401700413 小时前
Linux文件锁解决多进程并发
linux·服务器·算法
南棱笑笑生3 小时前
20251213给飞凌OK3588-C开发板适配Rockchip原厂的Buildroot【linux-6.1】系统时适配type-C0
linux·c语言·开发语言·rockchip