SaltStack 服务-文件-包管理

Salt-stack配置管理

 

包管理

修改配置文件

vim /etc/salt/master

 12default_include: master.d/*.conf

 13

 14 # The addressof the interface to bind to:

 15 interface:0.0.0.0

406 file_roots:

407   base:

408     -/etc/salt/states

409 #  dev:

410 #    -/srv/salt/dev/services

411 #    -/srv/salt/dev/states

412   prod:

413     -/etc/salt/states/prod

329 state_top: top.sls

 

重启服务:service salt-masterrestart

 

在目录下写配置文件

[root@node110 states]# tree

.

|-- init

|   `-- pkg.sls

|-- prod

`-- top.sls

 

[root@node110 states]# ls

init/  prod/  top.sls

[root@node110 states]# cat top.sls

base:

 'minion.saltstack.com':

    - init.pkg         #init目录下所有的文件名要在这里注册要不然salt不会执行里面的语句

[root@node110 states]# cd init

[root@node110 init]# cat pkg.sls

pkg.init:

  pkg.installed:

    - names:

      - lrzsz

      - mtr

      - nmap

执行命令

[root@node110 states]# salt '*' state.sls init.pkg

minion.saltstack.com:

----------

          ID: pkg.init

    Function:pkg.installed

        Name: mtr

      Result: True

     Comment:Package mtr is already installed.

     Started:17:34:03.204376

    Duration:2536.937 ms

     Changes:  

----------

          ID:pkg.init

    Function:pkg.installed

        Name: nmap

      Result: True

     Comment:Package nmap is already installed.

     Started:17:34:05.741786

    Duration: 1.696ms

     Changes:  

----------

          ID:pkg.init

    Function:pkg.installed

        Name: lrzsz

      Result: True

     Comment:Package lrzsz is already installed.

     Started:17:34:05.743800

    Duration: 0.853ms

     Changes:  

 

Summary

------------

Succeeded: 3

Failed:    0

------------

Total states run:    3

 

 

配置文件管理

[root@node110 init]# pwd

/etc/salt/states/init

[root@node110 init]# cat limit.sls

limit-conf-config:

  file.managed:

    - name:/etc/security/limits.conf

    - source:salt://init/files/limits.conf

    - user: root

    - group: root

    - mode: 644

 

[root@node110 files]# pwd

/etc/salt/states/init/files

[root@node110 files]# cp /etc/security/limits.conf ./

[root@node110 files]# ls

limits.conf

 

[root@node110 states]# pwd

/etc/salt/states

[root@node110 states]# cat top.sls

base:

  'minion.saltstack.com':

    - init.pkg

    - init.limit

[root@node110 files]# salt '*' state.highstate       #将所有的资源都管理起来

              diff:

                  --- 

                  +++ 

                  @@ -46,10 +46,11@@

                   #@faculty        hard   nproc           50

                   #ftp             hard    nproc           0

                   #@student        -      maxlogins       4

                  -

                  +#

                  +#rscpass

                  +#gmy

                   # End of file

                   *   soft   nproc   65535

                   *   hard    nproc   65535

                   *   soft    nofile65535

                   *   hard    nofile  65535

                  -

 

Summary

------------

Succeeded: 4 (changed=1)

Failed:    0

------------

Total states run:     4

 

 

 

服务的管理

 

 

 

分割线
感谢打赏
江西数库信息技术有限公司
YWSOS.COM 平台代运维解决方案
 评论
 发表评论
姓   名:

Powered by AKCMS