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

检查已经挂在成功:

相关推荐
企鹅侠客24 分钟前
Linux性能调优使用strace来分析文件系统的性能问题
linux·运维·服务器
奔跑吧邓邓子2 小时前
CentOS 7性能飞升秘籍:实战系统优化与调优
linux·运维·centos·实战·系统优化·性能调优
qinyia2 小时前
WisdomSSH如何高效检查服务器状态并生成运维报告
linux·运维·服务器·数据库·人工智能·后端·ssh
laocooon5238578863 小时前
实现了一个新闻数据采集与分析系统python
linux·服务器·windows
海棠蚀omo3 小时前
解读Linux进程的“摩尔斯电码”:信号产生的原理与实践,掌控进程的生死时速
linux·操作系统
YouEmbedded9 小时前
解码UDP
linux·udp
w***48829 小时前
Linux安装redis
linux·运维·redis
python百炼成钢11 小时前
28.嵌入式 Linux LED 驱动开发实验
linux·运维·驱动开发
西风未眠13 小时前
高效编辑之vi/vim常用快捷键汇总
linux·编辑器·vim
_Stellar13 小时前
Linux 服务器管理 根目录文件夹权限设置 基于用户组实现安全共享
linux·服务器·安全