Saltstack sls文件:批量安装服务
2018-07-24 09:59
405 查看
一、使用saltstack 批量安装nginx
1、创建salt目录
mkdir /srv/{salt,pillar}
2、再/srv/salt/下创建sls文件
vim nginx_install.sls
3、输入内容
# 备注安装程序 nginx-install: # 指定安装程序 pkg.installed: # 指定安装程序名 - names: # 指定服务 - nginx # 第一行需要管理的文件名,minion端指定路径 /etc/hosts: # 两个空格,写入方法名。如下方法为管理这个文件 file.managed: # 四个空格,告诉管理文件地址的相对路径 - source: salt://files/hosts # 四个空格,管理用户 - user: root # 四个空格,管理用户组 - group: root # 四个空格,设置权限 - mode: 644 # 四个空格,表明一个依赖关系,上述install执行不成功就不执行pkg - require: # 六个空格,依赖成立后就执行此命令 - pkg: nginx-install # 两个空格,启动程序 service.running: # 四个空格,指定启动程序名 - names: # 六个空格,启动程序名 - nginx
-------------------------------------------- test1: ---------- ID: nginx-install Function: pkg.installed Name: nginx Result: True Comment: The following packages were installed/updated: nginx Started: 15:10:51.676789 Duration: 105600.801 ms Changes: ---------- fontconfig: ---------- new: 2.10.95-11.el7 old: fontpackages-filesystem: ---------- new: 1.44-8.el7 old: gd: ---------- new: 2.0.35-26.el7 old: gperftools-libs: ---------- new: 2.6.1-1.el7 old: libX11: ---------- new: 1.6.5-1.el7 old: libX11-common: ---------- new: 1.6.5-1.el7 old: libXau: ---------- new: 1.0.8-2.1.el7 old: libXpm: ---------- new: 3.5.12-1.el7 old: libjpeg-turbo: ---------- new: 1.2.90-5.el7 old: libpng: ---------- new: 2:1.5.13-7.el7_2 old: libxcb: ---------- new: 1.12-1.el7 old: lyx-fonts: ---------- new: 2.2.3-1.el7 old: nginx: ---------- new: 1:1.12.2-2.el7 old: nginx-all-modules: ---------- new: 1:1.12.2-2.el7 old: nginx-filesystem: ---------- new: 1:1.12.2-2.el7 old: nginx-mod-http-geoip: ---------- new: 1:1.12.2-2.el7 old: nginx-mod-http-image-filter: ---------- new: 1:1.12.2-2.el7 old: nginx-mod-http-perl: ---------- new: 1:1.12.2-2.el7 old: nginx-mod-http-xslt-filter: ---------- new: 1:1.12.2-2.el7 old: nginx-mod-mail: ---------- new: 1:1.12.2-2.el7 old: nginx-mod-stream: ---------- new: 1:1.12.2-2.el7 old: ---------- ID: /etc/hosts Function: file.managed Result: True Comment: File /etc/hosts updated Started: 15:12:37.282207 Duration: 79.977 ms Changes: ---------- diff: --- +++ @@ -3,4 +3,4 @@ 192.168.1.185 master.zjz.cn 192.168.1.138 client1.zjz.cn 192.168.1.142 client2.zjz.cn -1.1.1.1 www.111.com +192.168.1.12 xsk.xsk.com ---------- ID: /etc/hosts Function: service.running Name: nginx Result: True Comment: Started Service nginx Started: 15:12:37.392914 Duration: 1206.268 ms Changes: ---------- nginx: True Summary ------------ Succeeded: 3 (changed=3) Failed: 0 ------------ Total states run: 3 Stest2: ---------- ID: nginx-install Function: pkg.installed Name: nginx Result: True Comment: The following packages were installed/updated: nginx Started: 15:10:51.816280 Duration: 125657.229 ms Changes: ---------- fontconfig: ---------- new: 2.10.95-11.el7 old: fontpackages-filesystem: ---------- new: 1.44-8.el7 old: gd: ---------- new: 2.0.35-26.el7 old: gperftools-libs: ---------- new: 2.6.1-1.el7 old: libX11: ---------- new: 1.6.5-1.el7 old: libX11-common: ---------- new: 1.6.5-1.el7 old: libXau: ---------- new: 1.0.8-2.1.el7 old: libXpm: ---------- new: 3.5.12-1.el7 old: libjpeg-turbo: ---------- new: 1.2.90-5.el7 old: libpng: ---------- new: 2:1.5.13-7.el7_2 old: libxcb: ---------- new: 1.12-1.el7 old: lyx-fonts: ---------- new: 2.2.3-1.el7 old: nginx: ---------- new: 1:1.12.2-2.el7 old: nginx-all-modules: ---------- new: 1:1.12.2-2.el7 old: nginx-filesystem: ---------- new: 1:1.12.2-2.el7 old: nginx-mod-http-geoip: ---------- new: 1:1.12.2-2.el7 old: nginx-mod-http-image-filter: ---------- new: 1:1.12.2-2.el7 old: nginx-mod-http-perl: ---------- new: 1:1.12.2-2.el7 old: nginx-mod-http-xslt-filter: ---------- new: 1:1.12.2-2.el7 old: nginx-mod-mail: ---------- new: 1:1.12.2-2.el7 old: nginx-mod-stream: ---------- new: 1:1.12.2-2.el7 old: ---------- ID: /etc/hosts Function: file.managed Result: True Comment: File /etc/hosts updated Started: 15:12:57.478176 Duration: 21.038 ms Changes: ---------- diff: --- +++ @@ -3,4 +3,4 @@ 192.168.1.185 master.zjz.cn 192.168.1.138 client1.zjz.cn 192.168.1.142 client2.zjz.cn -1.1.1.1 www.111.com +192.168.1.12 xsk.xsk.com ---------- ID: /etc/hosts Function: service.running Name: nginx Result: True Comment: Started Service nginx Started: 15:12:57.567074 Duration: 884.324 ms Changes: ---------- nginx: True Summary ------------ Succeeded: 3 (changed=3) Failed: 0 ------------ Total states run: 3 --------------------------------------------测试结果
相关文章推荐
- saltstack 安装部署及ntp服务批量部署过程实例
- 部署 SaltStack 自动化运维工具,并简易批量安装 httpd 服务
- Saltstack sls文件:批量替换指定文件
- 部署SaltStack及批量安装httpd服务
- Saltstack sls文件:批量添加删除计划任务
- saltstack的探索-演示部署文件和脚本安装zabbix-agent服务
- 【saltstack学习笔记之十】使用sls安装nginx并管理nginx的配置文件
- xp系统安装Office2010出错“windows installer 服务不能更新一个或多个受保护的文件”
- shell脚本实现nfs服务安装配置,共享文件分发
- 安装Office 2010是出现windows installer服务不能更新一个或多个受保护的windows文件 错误
- saltstack的探索-安装vim、nginx服务和配置、自定义脚本
- Windows Server 2008 R2使用WDS服务实现批量安装操作系统演示
- 关于saltstack下 sls文件编写的一点收获
- Linux系统下以RPM方式安装mysql-5.7.9【5.7版本以后,启动mysqld服务首次登录需要密码,为root生成的随机密码在错误日志文件/var/log/mysqld.log】
- Centos下安装配置nfs服务实现服务器间文件共享
- 安装tomcat与JDK,为cloudify提供文件服务
- SQL Server 服务无法启动。有关详细信息,请参阅 SQL Server 联机丛书中的主题“如何查看 SQL Server 2005 安装日志文件”和“手动启动 SQL Server”
- NodeJs 安装静态的文件服务
- [置顶] 编写shell脚本以及利用函数实现批量安装Linux服务配置
- windows下通过配置文件简易安装Mongodb(windows服务安装,权限设置)