playbook(剧本)

lftp可以免密登录ftp

搭建nfs步骤:

1.准备2台主机c,s

2.在服务器端安装rpcbind,nfs-utils

     1.创建共享目录

     2.配置文件  /etc/exports

     3.启动nfs,rpcbind

3.在客户端安装nfs-utils

     1.创建挂载目录

     2.挂载文件

剧本格式


---

- hosts:  组名/别名/ip/域名

  remote_user:  root

  tasks: 

  -  name:  任务说明

     模块:  key0=value0

     service:  name=vsftpd state=started enabled=yes

 -   name:  修改配置文件

     command:  sed........

     notify:

     -  abcdefg

    handlers:

     -  name:  abcdefg

        service:  name=httpd state=restarted

...

playbook(剧本)

playbook(剧本): 是ansible⽤于配置,部署,和管理被控节点的剧本。⽤于ansible操作的编排。
使⽤的格式为yaml格式
yaml格式:
以.yaml或.yml结尾
⽂件的第⼀⾏以 "---"开始,表明YMAL⽂件的开始(可选的)
以#号开头为注释
列表中的所有成员都开始于相同的缩进级别, 并且使⽤⼀个 "- " 作为开头(⼀个横杠和⼀个空格)
⼀个字典是由⼀个简单的 键: 值 的形式组成(这个冒号后⾯必须是⼀个空格)

用剧本安装vsftpd:不允许匿名访问

将httpd的端口号80改为8080:

使用剧本在不同主机上同时创建不同的文件:

使用剧本搭建nfs服务:

---
-       hosts:          mysql1
        remote_user:    root
        tasks:
        -       name:   安装nfs-utils
                yum:    name=nfs-utils  state=present
 
        -       name:   安装rpcbind
                yum:    name=rpcbind    state=present
 
        -       name:   创建共享目录
                file:   path=/static   state=directory
 
        -       name:   配置文件
                shell:  echo '/static    *(ro,sync)' > /etc/exports
                notify:
                -       rstss
 
        -       name:           启动服务nfs
                service:        name=nfs        state=started enabled=yes
        -       name:           启动服务rpcbind
                service:        name=rpcbind    state=started enabled=yes
        handlers:
                -       name:   rstss
                        service:        name=nfs state=restarted
 
 
 
-       hosts:  mysql2
        remote_user:    root
        tasks:
        -       name:   安装nfs-utils
                yum:    name=nfs-utils   state=latest
        -       name:   创建挂载目录
                file:   path=/nfs   state=directory
        -       name:   挂载nfs文件
                command:        mount -t nfs 192.168.118.20:/static /nfs

  • 4
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值