saltstack之masterless配置

masterless

masterless配置

  • 修改配置文件minion
  • 注释master行
  • 取消注释file_client并设其值为local
  • 设置file_roots
  • 设置pillar_roots
[root@minion ~]# vim /etc/salt/minion
......
# Set the location of the salt master server. If the master server cannot be
# resolved, then the minion will fail to start.
#master: salt     //添加注释
#master: 192.168.10.20   //添加注释
......
# Set the file client. The client defaults to looking on the master server for
# files, but can be directed to look at the local file directory setting
# defined below by setting it to "local". Setting a local file_client runs the
# minion in masterless mode.
file_client: local   //这一行取消注释改remote为local
......
file_roots:        //设置file_roots的路径
  base:
    - /srv/salt/base    //取消注释或者自行添加

关闭salt-minion服务

使用 masterless 模式时是不需要启动任何服务的,包括salt-master和salt-minion。
[root@minion ~]# systemctl stop salt-minion
[root@minion ~]# systemctl disable salt-minion
Removed /etc/systemd/system/multi-user.target.wants/salt-minion.service.

salt-call

masterless模式执行模块或状态时需要使用salt-call命令,而不再是salt或者salt-ssh。
[root@minion ~]# salt-call --local cmd.run 'uptime'
local:
     09:47:25 up 36 min,  2 users,  load average: 0.25, 0.22, 0.24
[root@minion ~]# salt-call --local cmd.run 'date'
local:
    Wed Jul 21 09:50:48 EDT 2021
    
[root@minion ~]# mkdir -p /srv/salt/base
[root@minion ~]# cd /srv/salt/base/
[root@minion base]# vim wget.sls
test_wget:
  pkg.installed:
    - name: wget
[root@minion base]# salt-call --local state.sls wget
local:
----------
          ID: test_wget
    Function: pkg.installed
        Name: wget
      Result: True
     Comment: All specified packages are already installed
     Started: 09:53:22.047074
    Duration: 1321.579 ms
     Changes:   

Summary for local
------------
Succeeded: 1
Failed:    0
------------
Total states run:     1
Total run time:   1.323 s

[root@minion base]# which wget
/usr/bin/wget
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值