Salt minion如何用sudo提升非root用户?

时间:2014-09-17 17:42:40

标签: python salt-stack

尝试以非root身份运行minion时,我获得了权限被拒绝错误。我创建了一个名为'salt-master'的特殊用户并赋予它sudo权限。然而,我仍然看到许可被拒绝错误。我在同一台服务器上使用salt master和minion进行测试,否则用户名将被命名为salt-minion用于客户端。如何让盐用于所有的东西?

的/ etc / sudoers的

# salt-master user allowed root with no password
salt-master ALL=(ALL) NOPASSWD:ALL

的/ etc /盐/仆从

# The user to run salt
#user: root
user: salt-master

/srv/salt/gedit/init.sls

gedit:
  pkg:
    - installed

命令

salt 'SaltStack-01' state.sls gedit

命令结果

SaltStack-01:
----------
          ID: gedit
    Function: pkg.installed
      Result: False
     Comment: The following packages failed to install/update: gedit.
     Changes:   

Summary
------------
Succeeded: 0
Failed:    1
------------
Total:     1

minion logs / var / log / salt / minion

2014-09-17 13:35:05,199 [salt.loaded.int.module.cmdmod][ERROR] Command 'zypper refresh' failed with return code: 5
2014-09-17 13:35:05,200 [salt.loaded.int.module.cmdmod][ERROR] output: Root privileges are required for refreshing system repositories.
2014-09-17 13:35:05,243 [salt.loaded.int.module.cmdmod][ERROR] Command 'zypper --non-interactive install --name --auto-agree-with-licenses "gedit"' failed with return code: 5
2014-09-17 13:35:05,244 [salt.loaded.int.module.cmdmod][ERROR] output: Root privileges are required for installing or uninstalling packages.

1 个答案:

答案 0 :(得分:3)

http://docs.saltstack.com/en/latest/ref/configuration/nonroot.html

引用 minion也拥有它自己的用户参数,但是作为非特权用户运行minion将阻止它对用户,已安装的软件包等进行更改,除非设置了访问控制(sudo等) minion允许非root用户进行必要的更改。

为了允许Salt成功以非root用户身份运行,需要设置所有权和权限,以便所需用户可以读取和写入以下目录(及其子目录,如果适用):