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
本文来自博客园, 作者:Star-Hitian, 转载请注明原文链接:https://www.cnblogs.com/Star-Haitian/articles/15233089.html

浙公网安备 33010602011771号