在上篇文章中的返回结果是已经安装过的!通过salt在尝试安装sl,返回结果如下:
[root@master init]# salt 'minios.10.0.0.8.com' state.sls init.pkg
minios.10.0.0.8.com:
----------
ID: pkg.init
Function: pkg.installed
Name: sl
Result: True
Comment: The following packages were installed/updated: sl
Started: 07:05:37.645283
Duration: 145585.54 ms
Changes:
----------
sl:
----------
new:
5.02-1.el6
old:
Summary
------------
Succeeded: 1 (changed=1)
Failed: 0
------------
Total states run: 1
[root@master init]#
saltstack配置文件下发创建配置文件的模块!批量修改/etc/security/limits.conf文件~
[root@master init]# vim /etc/salt/status/init/conf.sls
conf-config:----------------------------------->命名
file.managed:-------------------------------->file状态模块:managed管理
- name: /etc/security/limits.conf---------->name:被管理文件的路径
- source: salt://init/files/limits.conf---->source:salt://limits.conf在master的文件路径
- user: root------------------------------->文件用户
- group: root------------------------------>组
- mode: 644-------------------------------->权限
当创建完config.sls
后需要在top.sls
中写入init.conf
,才能够调用!
[root@master status]# vim /etc/salt/status/top.sls
base:
'minios.10.0.0.8.com':
- init.pkg
- init.conf
创建files目录
[root@master init]# mkdir files
[root@master init]# pwd
/etc/salt/status/init
[root@master init]#
将/etc/security/limits.conf
的limits.conf
复制到/etc/salt/status/init/files
下
[root@master init]# cp /etc/security/limits.conf /etc/salt/status/init/files/
修改/etc/salt/status/init/files/
下的limits.conf
模板,打开两个参数
,如下:
[root@master init]# vim /etc/salt/status/init/files/limits.conf
* soft core 0
* hard rss 10000
没改之前,在minion查看
[root@minion ~]# cat /etc/security/limits.conf |grep 10000
#* hard rss 10000
[root@minion ~]#
我们在master上执行state.highstate,在执行过程中,都会检查pkg和conf
[root@master init]# salt 'minios.10.0.0.8.com' state.highstate
minios.10.0.0.8.com:
----------
ID: pkg.init
Function: pkg.installed
Name: sl
Result: True
Comment: Package sl is already installed.
Started: 07:34:41.304171
Duration: 978.561 ms
Changes:
----------
ID: conf-config
Function: file.managed
Name: /etc/security/limits.conf
Result: True
Comment: File /etc/security/limits.conf updated
Started: 07:34:42.339015
Duration: 27.806 ms
Changes:
----------
diff:
---
+++
@@ -39,8 +39,8 @@
#
#
-#* soft core 0
-#* hard rss 10000
+* soft core 0
+* hard rss 10000
#@student hard nproc 20
#@faculty soft nproc 20
#@faculty hard nproc 50
Summary
------------
Succeeded: 2 (changed=1)
Failed: 0
------------
Total states run: 2
[root@master init]#
在minion上查看结果
[root@minion ~]# cat /etc/security/limits.conf |grep 10000
* hard rss 10000
[root@minion ~]#