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

检查已经挂在成功:

相关推荐
kaoa0001 小时前
Linux入门攻坚——62、memcached使用入门
linux·运维·memcached
model20052 小时前
alibaba linux3 系统盘清理
linux·运维·服务器
WG_172 小时前
Linux:动态库加载总结_进程间通信+进程池 + 进程IPC(27/28/29/30/31/32)
linux·运维·服务器
小赵还有头发3 小时前
安装 RealSense SDK (驱动层)
linux
Root_Hacker4 小时前
include文件包含个人笔记及c底层调试
android·linux·服务器·c语言·笔记·安全·php
微学AI4 小时前
内网穿透的应用-告别局域网束缚!MonkeyCode+cpolar 解锁 AI 编程新体验
linux·服务器·网络
宴之敖者、7 小时前
Linux——权限
linux·运维·服务器
刘叨叨趣味运维7 小时前
Linux性能排查实战:从“系统慢”到精准定位
linux
欣然~8 小时前
法律案例 PDF 批量转 TXT 工具代码
linux·前端·python
阮松云9 小时前
a start job is running for Builds and install new kernel modules through DKMS
linux·centos