saltstack之module
module是saltstack接触最多的一个组件,用于管理对象的操作,
查看所有的module
sys.list_modules
[root@localhost pillar]# salt 'test' sys.list_modules
test:
- acl
- aliases
- alternatives
- archive
- artifactory
- blockdev
- btrfs
- buildout
- cloud
- cmd
- composer
- config
- container_resource
- cp
- cron
- data
- defaults
- devmap
- disk
- django
- dnsmasq
- dnsutil
- drbd
- elasticsearch
- environ
- etcd
- event
- extfs
- file
- firewalld
- gem
- genesis
- git
- gnome
- grains
- group
- hashutil
- hg
- hipchat
- hosts
- http
- img
- incron
- ini
- introspect
- ip
- ipset
- iptables
- jboss7
- jboss7_cli
- key
- keyboard
- kmod
- locale
- locate
- logrotate
- lowpkg
- lvm
- match
- mine
- modjk
- mount
- network
- openstack_config
- pagerduty
- partition
- pillar
- pip
- pkg
- pkg_resource
- postfix
- ps
- publish
- pyenv
- random
- random_org
- rbenv
- redis
- ret
- rsync
- runit
- rvm
- s3
- saltutil
- schedule
- scsi
- sdb
- seed
- selinux
- serverdensity_device
- service
- shadow
- slack
- smtp
- sqlite3
- ssh
- state
- status
- supervisord
- sys
- sysctl
- syslog_ng
- system
- test
- timezone
- user
- vbox_guest
- virtualenv
- xfs
查看指定module的所有functions
sys.list_functions
[root@localhost pillar]# salt 'test' sys.list_functions user
test:
- user.add
- user.chfullname
- user.chgid
- user.chgroups
- user.chhome
- user.chhomephone
- user.chloginclass
- user.chroomnumber
- user.chshell
- user.chuid
- user.chworkphone
- user.delete
- user.get_loginclass
- user.getent
- user.info
- user.list_groups
- user.list_users
- user.rename
查看指定module的用法
[root@localhost pillar]# salt 'test' sys.doc user
'user.add:'
Add a user to the minion
CLI Example:
salt '*' user.add name <uid> <gid> <groups> <home> <shell>
'user.chfullname:'
Change the user's Full Name
CLI Example:
salt '*' user.chfullname foo "Foo Bar"
'user.chgid:'
Change the default group of the user
CLI Example:
salt '*' user.chgid foo 4376
'user.chgroups:'
Change the groups to which this user belongs
name
User to modify
groups
Groups to set for the user
append : False
If ``True``, append the specified group(s). Otherwise, this function
will replace the user's groups with the specified group(s).
CLI Examples:
salt '*' user.chgroups foo wheel,root
salt '*' user.chgroups foo wheel,root append=True
'user.chhome:'
Change the home directory of the user, pass True for persist to move files
to the new home directory if the old home directory exist.
CLI Example:
salt '*' user.chhome foo /home/users/foo True
'user.chhomephone:'
Change the user's Home Phone
CLI Example:
salt '*' user.chhomephone foo 7735551234
'user.chloginclass:'
Change the default login class of the user
Note:
This function only applies to OpenBSD systems.
CLI Example:
salt '*' user.chloginclass foo staff
'user.chroomnumber:'
Change the user's Room Number
CLI Example:
salt '*' user.chroomnumber foo 123
'user.chshell:'
Change the default shell of the user
CLI Example:
salt '*' user.chshell foo /bin/zsh
'user.chuid:'
Change the uid for a named user
CLI Example:
salt '*' user.chuid foo 4376
'user.chworkphone:'
Change the user's Work Phone
CLI Example:
salt '*' user.chworkphone foo 7735550123
'user.delete:'
Remove a user from the minion
CLI Example:
salt '*' user.delete name remove=True force=True
'user.get_loginclass:'
Get the login class of the user
Note:
This function only applies to OpenBSD systems.
CLI Example:
salt '*' user.get_loginclass foo
'user.getent:'
Return the list of all info for all users
CLI Example:
salt '*' user.getent
'user.info:'
Return user information
CLI Example:
salt '*' user.info root
'user.list_groups:'
Return a list of groups the named user belongs to
CLI Example:
salt '*' user.list_groups foo
'user.list_users:'
Return a list of all users
CLI Example:
salt '*' user.list_users
saltstack之module
http://www.jcwit.com/article/295/