88.第十八章 运维自运化之ANSIBLE -- Ansible Playbook(四)

4.3.4 其它组件说明

某任务的状态在运行后为changed时,可通过"notify"通知给相应的handlers任务

还可以通过"tags"给task 打标签,可在ansible-playbook命令上使用-t指定进行调用

4.3.5 Shell Scripts VS Playbook 案例

#SHELL脚本实现
#!/bin/bash
# 安装Apache
yum install --quiet -y httpd
# 复制配置文件
cp /tmp/httpd.conf /etc/httpd/conf/httpd.conf
cp/tmp/vhosts.conf /etc/httpd/conf.d/
# 启动Apache,并设置开机启动
systemctl enable --now httpd

#Playbook实现
---
- hosts: websrvs
  remote_user: root
  gather_facts: no

  tasks:
    - name: "安装Apache"

猜你喜欢

转载自blog.csdn.net/qq_25599925/article/details/122090173