Playbook vs shell

shell 脚本

# 安装apache
yum install -quiet -y httpd
# 复制配置文件
cp /tmp/httpd.conf /etc/httpd/conf/httpd.conf
cp /tmp/vhosts.conf /etc/httpd/conf.d/

# 启动 apache 配置开机启动
service httpd start
chkconfig httpd on

playbook 定义

---

- hosts: all  
  tasks:
  - name:“安装 Apache  yum 
    name=httpd 
  - name:“复制配置文件
    copy: src=/tmp/httpd.conf dest=/etc/httpd/conf/  
    copy: src = /tmp/vhosts.conf dest=/etc/httpd/conf.cd/ 
  - name:“启动 Apache,并设置开机启动
    service: name=httpd state = started enabled = yes
posted @ 2021-09-06 11:45  Star-Hitian  阅读(55)  评论(0)    收藏  举报