码迷,mamicode.com
首页 > 其他好文 > 详细

saltstack配置管理

时间:2018-12-01 00:08:52      阅读:253      评论:0      收藏:0      [点我收藏+]

标签:state.sls   res   sea   https   art   只读   pre   状态   master   

状态模块: https://docs.saltstack.com/en/latest/ref/states/all/salt.states.file.html#module-salt.states.file [root@master ~]# grep -v ‘^$‘ /etc/salt/master |grep -v ‘#‘ client_acl: luo: - test.ping - network.* file_roots: #top.sls路径,可以写多个 base: #但是只读取base路径 - /srv/salt/base test: - /srv/salt/test prod: - /srv/salt/prod pillar_roots: base: - /srv/pillar mysql.host: ‘192.168.43.118‘ mysql.user: ‘salt‘ mysql.pass: ‘Myq1231!‘ mysql.db: ‘salt‘ mysql.port: 3306 [root@master ~]# systemctl restart salt-master [root@master ~]# mkdir /srv/salt/{base,test,prod} [root@master salt]# ls apache.sls base prod test top.sls [root@master salt]# mv apache.sls top.sls base/ 编写基本文件管理: [root@master ~]# mkdir /srv/salt/base/files [root@master base]# pwd /srv/salt/base [root@master base]# vim dns.sls [root@master base]# cat dns.sls /etc/resolv.conf: file.managed: #file模块的managed方法 - source: salt://files/resolv.conf #路径,salt://=/srv/salt/base ,files新建的文件。 - user: root #用户 - group: root #用户组 - mode: 777 #权限 [root@master base]# cp /etc/resolv.conf ./files/ [root@master base]# vim files/resolv.conf [root@master base]# cat files/resolv.conf nameserver 192.168.43.1 [root@master base]# salt ‘*‘ state.sls dns state状态模块的sls方法,dns为状态名,可以任意写。 192.168.43.118: ---------- ID: /etc/resolv.conf Function: file.managed Result: True Comment: File /etc/resolv.conf updated Started: 00:18:45.928344 Duration: 18.082 ms Changes: ---------- diff: --- +++ @@ -1,3 +1 @@ -# Generated by NetworkManager -search com nameserver 192.168.43.1 mode: 0777 Summary ------------ Succeeded: 1 (changed=1) [root@master base]# pwd /srv/salt/base [root@master base]# vim top.sls [root@master base]# cat top.sls base: ‘*‘: - dns [root@master files]# pwd /srv/salt/base/files [root@master files]# vim resolv.conf [root@master files]# cat resolv.conf #jjjjjjjjjjjjjjjjjj nameserver 192.168.43.1 [root@master base]# salt ‘*‘ state.sls dns state状态模块的sls方法,dns为状态名,可以任意写。 192.168.43.118: ---------- ID: /etc/resolv.conf Function: file.managed Result: True Comment: File /etc/resolv.conf updated Started: 00:26:07.017848 Duration: 24.144 ms Changes: ---------- diff: --- +++ @@ -1 +1,2 @@ +#jjjjjjjjjjjjjjjjjj nameserver 192.168.43.1 Summary ------------ Succeeded: 1 (changed=1) Failed: 0 [root@master base]# cat /etc/resolv.conf #jjjjjjjjjjjjjjjjjj nameserver 192.168.43.1

saltstack配置管理

标签:state.sls   res   sea   https   art   只读   pre   状态   master   

原文地址:http://blog.51cto.com/13399294/2324550

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!