1. 程式人生 > >saltstack模塊之user及group相關模塊

saltstack模塊之user及group相關模塊

saltstack user 模塊 創建 group 刪除

1、group.add模塊

group.add:添加指定用戶組。

[[email protected] ~]# salt ‘salt-minion02.contoso.com‘ group.add user1 1000
salt-minion02.contoso.com:
    True

2、group.info模塊

group.info:返回用戶組信息。

[[email protected] ~]# salt ‘salt-minion02.contoso.com‘ group.info user1
salt-minion02.contoso.com:
    ----------
    gid:
        1000
    members:
    name:
        user1
    passwd:
        x

3、group.getent模塊

group.getent:返回所有用戶組的信息。

[[email protected] ~]# salt ‘salt-minion02.contoso.com‘ group.getent
salt-minion02.contoso.com:
    |_
      ----------
      gid:
          0
      members:
      name:
          root
      passwd:
          x
    |_
      ----------
      gid:
          1
      members:
          - bin
          - daemon
      name:
          bin
      passwd:
          x
    |_
      ----------
      gid:
          2
      members:
          - bin
          - daemon
      name:
          daemon
      passwd:
          x
    |_
      ----------
      gid:
          3
      members:
          - bin
          - adm
      name:
          sys
      passwd:
          x
    |_
      ----------
      gid:
          4
      members:
          - adm
          - daemon
      name:
          adm
      passwd:
          x
    |_
      ----------
      gid:
          5
      members:
      name:
          tty
      passwd:
          x
    |_
      ----------
      gid:
          6
      members:
      name:
          disk
      passwd:
          x
    |_
      ----------
      gid:
          7
      members:
          - daemon
      name:
          lp
      passwd:
          x
    |_
.......

4、group.adduser模塊

group.adduser:添加一個用戶到指定組中。(必須是一個已經存在的組和已存在的用戶)

[[email protected] ~]# salt ‘salt-minion02.contoso.com‘ group.adduser user1 zabbix
salt-minion02.contoso.com:
    True

5、group.deluser模塊

group.deluser:將用戶從用戶組中移除。

[[email protected] ~]# salt ‘salt-minion02.contoso.com‘ group.deluser user1 zabbix
salt-minion02.contoso.com:
    True

6、group.delete模塊

group.delete:移除指定用戶組。

[[email protected] ~]# salt ‘salt-minion02.contoso.com‘ group.delete user1
salt-minion02.contoso.com:
    True

7、user.add模塊

user.add:在minion端上創建一個用戶。用法:salt ‘*‘ user.add name <uid> <gid> <groups> <home> <shell>。

[[email protected] ~]# salt ‘salt-minion02.contoso.com‘ user.add test 610 605 zabbix /home/test /bin/bash
salt-minion02.contoso.com:
    True

8、user.info模塊

user.info:返回用戶信息。

[[email protected] ~]# salt ‘salt-minion02.contoso.com‘ user.info test
salt-minion02.contoso.com:
    ----------
    fullname:
    gid:
        605
    groups:
        - zabbix
    home:
        /home/test
    homephone:
    name:
        test
    passwd:
        x
    roomnumber:
    shell:
        /bin/bash
    uid:
        610
    workphone:

9、user.getent模塊

user.getent:返回所有系統用戶信息的列表。

[[email protected] ~]# salt ‘salt-minion02.contoso.com‘ user.getent 
salt-minion02.contoso.com:
    |_
      ----------
      fullname:
          root
      gid:
          0
      groups:
          - root
      home:
          /root
      homephone:
      name:
          root
      passwd:
          x
      roomnumber:
      shell:
          /bin/bash
      uid:
          0
      workphone:
    |_
      ----------
      fullname:
          bin
      gid:
          1
      groups:
          - bin
          - daemon
          - sys
      home:
          /bin
      homephone:
      name:
          bin
      passwd:
          x
      roomnumber:
      shell:
          /sbin/nologin
      uid:
          1
      workphone:
  .......

10、user.list_groups模塊

user.list_groups:列出指定用戶所屬組的列表。

[[email protected] ~]# salt ‘salt-minion02.contoso.com‘ user.list_groups zabbix
salt-minion02.contoso.com:
    - zabbix

11、user.rename模塊

user.rename:修改指定用戶的用戶名。

[[email protected] ~]# salt ‘salt-minion02.contoso.com‘ user.rename test testuser
salt-minion02.contoso.com:
    False

(雖然返回False但是操作是成功完成了的)

12、user.delete模塊

user.delete:在minion端刪除一個用戶。

[[email protected] ~]# salt ‘salt-minion02.contoso.com‘ user.delete test
salt-minion02.contoso.com:
    True


本文出自 “IT小二郎” 博客,請務必保留此出處http://jerry12356.blog.51cto.com/4308715/1932096

saltstack模塊之user及group相關模塊