安装httpd的方式一
修改master配置文件
使用他的功能肯定要打开他的默认目录,但是这个目录得自己建
[root@server1 salt]# cd /etc/salt
[root@server1 salt]# vim master
658 file_roots:
659 base:
660 - /srv/salt
[root@server1 salt]# systemctl restart salt-master
建立目录
root@server1 ~]# mkdir /srv/salt
[root@server1 ~]# cd /srv/salt/
[root@server1 salt]# mkdir apache
[root@server1 salt]# ls
apache
[root@server1 salt]# cd apache/
[root@server1 apache]# vim install.sls
httpd:
pkg.installed ##注意缩进,两个空格
测试: 给minion端server2安装httpd
[root@server1 apache]# salt server2 state.sls apache.install
在server2上查看,安装成功
[root@server2 ~]# rpm -q httpd
httpd-2.4.6-45.el7.x86_64
安装httpd的方式二
[root@server1 apache]# ls
install.sls
[root@server1 apache]# vim install.sls
install-apache:
pkg.installed:
- pkgs:
- httpd
开启httpd服务
查看server2的httpd处于inactived状态
[root@server1 apache]# vim install.sls
install-apache:
pkg.installed:
- pkgs:
- httpd
service-apache:
service.running:
- name: httpd
再次查看server2的httpd状态
验证是否能远端修改minion端的配置文件
vim /install.sls
install-apache:
pkg.installed:
- pkgs:
- httpd
file.managed:
- name: /etc/httpd/conf/httpd.conf
- source: salt://apache/files/httpd.conf
service.running:
- name: httpd
- reload: True
- watch:
- file: install-apache
建立所需要的目录,得到需要的文件,进行验证
默认httpd的主配置文件里端口为80
执行:
现在开始验证,master端的配置文件被修改,那么在minion端是否也会被修改
验证方式:更改端口
目前server2httpd端口为80
修改server1 master端的配置文件,将端口改为8080
[root@server1 apache]# ls
files install.sls
[root@server1 apache]# vim files/httpd.con
42 Listen 8080
查看server2的httpd端口,修改成功