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

检查已经挂在成功:

相关推荐
松涛和鸣3 分钟前
23、链式栈(LinkStack)的实现与多场景应用
linux·c语言·c++·嵌入式硬件·ubuntu
虾..3 分钟前
Linux 进程替换
linux·运维·服务器
赖small强5 分钟前
【Linux驱动开发】Linux Debugfs 虚拟文件系统深度解析与实战指南
linux·驱动开发·debugfs
Crazy________6 分钟前
43ansible常用模块及变量定义方式
linux·运维·服务器
小白电脑技术18 分钟前
飞牛NAS最近好奇怪啊?一段时间不重启,内存几乎快用完了?
linux·电脑
幸运小猿19 分钟前
启动项目报错,zookeeper影响的
linux·运维·服务器
liu****21 分钟前
11.字符函数和字符串函数(一)
linux·运维·c语言·开发语言·数据结构·算法
minji...1 小时前
linux 进程控制(一) (fork进程创建,exit进程终止)
linux·运维·服务器·c++·git·算法
I · T · LUCKYBOOM1 小时前
21.Linux网络设置
linux·运维·网络
Likeyou71 小时前
关于Linux下的Oracle的rman备份操作指南
linux·运维·oracle