介绍
有时我们需要安装软件同时同步配置文件,或者我们只需要更新配置文件。主配置文件
# salt '*' state.sls xes.elk.test
include:
- xes.elk.httpd-install
# 同步httpd的配置文件
/etc/httpd/conf/httpd.conf:
file.managed:
- source: salt://xes/elk/files/httpd.conf
- user: root
- group: root
- mode: 644
- require:# 需要include中文件的apache-install生效才执行这个同步文件的步骤
- pkg: apache-install
/var/www/html/index.html:
file.managed:
- source: salt://xes/elk/files/index.html
- user: root
- group: root
- mode: 644
- require:
- pkg: apache-install
# httpd服务状态控制
httpd:
service.running:
- enable: True# 开机启动
- watch:# 同时监听下面两个文件,有变化就重新启动httpd
- file: /etc/httpd/conf/httpd.conf
- file: /var/www/html/index.html
- include文件
- 安装apache
apache-install:
pkg.installed:
- pkgs:
- httpd