Module是日常使用SaltStack接触最多的一个组件,其用于管理对象操作,这也是SaltStack通过Push的方式进行管理的入口,比如我们日常简单的执行命令、查看包安装情况、查看服务运行情况等工作都是通过SaltStack Module来实现的。
当安装好Master和Minion包后,系统上会安装很多Module,大家可以通过以下命令查看支持的所有Module列表:
//查看所有module列表
[root@vm1 ~]# salt 'vm1' sys.list_modules
vm1:
- acl
- aliases
- alternatives
- ansible
- archive
- artifactory
- beacons
- bigip
- btrfs
- buildout
- chroot
- cloud
- cmd
- composer
- config
- consul
- container_resource
- cp
- cron
- cryptdev
- data
- defaults
- devmap
- disk
- django
- dnsmasq
- dnsutil
- drbd
- environ
- etcd
- ethtool
- event
- extfs
- file
- firewalld
- freezer
- gem
- genesis
- glassfish
- gnome
- google_chat
- grafana4
- grains
- group
- hashutil
- highstate_doc
- hosts
- http
- incron
- ini
- inspector
- introspect
- iosconfig
- ip
- ipset
- iptables
- jboss7
- jboss7_cli
- jinja
- k8s
- kernelpkg
- key
- keyboard
- kmod
- locale
- locate
- log
- logrotate
- lowpkg
- lvm
- mandrill
- match
- mattermost
- mine
- minion
- modjk
- mount
- msteams
- nagios_rpc
- namecheap_domains
- namecheap_domains_dns
- namecheap_domains_ns
- namecheap_ssl
- namecheap_users
- network
- nexus
- nova
- nspawn
- nxos_api
- openscap
- openstack_config
- opsgenie
- out
- pagerduty
- pagerduty_util
- pam
- parallels
- partition
- peeringdb
- pillar
- pip
- pkg
- pkg_resource
- postfix
- ps
- publish
- pushover
- pyenv
- random
- random_org
- rbenv
- rest_sample_utils
- restartcheck
- ret
- rvm
- s3
- s6
- salt_proxy
- salt_version
- saltcheck
- saltutil
- schedule
- scsi
- sdb
- seed
- serverdensity_device
- service
- shadow
- slack
- slsutil
- smbios
- smtp
- solrcloud
- sqlite3
- ssh
- state
- status
- statuspage
- supervisord
- sys
- sysctl
- sysfs
- syslog_ng
- system
- telegram
- telemetry
- temp
- test
- timezone
- tuned
- udev
- uptime
- user
- vault
- vbox_guest
- virtualenv
- vsphere
- xfs
- xml
- zabbix
- zenoss
//查看指定module的所有function
[root@vm1 ~]# salt 'vm1' sys.list_functions cmd
vm1:
- cmd.exec_code
- cmd.exec_code_all
- cmd.has_exec
- cmd.powershell
- cmd.powershell_all
- cmd.retcode
- cmd.run
- cmd.run_all
- cmd.run_bg
- cmd.run_chroot
- cmd.run_stderr
- cmd.run_stdout
- cmd.script
- cmd.script_retcode
- cmd.shell
- cmd.shell_info
- cmd.shells
- cmd.tty
- cmd.which
- cmd.which_bin
//查看指定module的用法
[root@vm1 ~]# salt 'vm1' sys.doc cmd
----
Lists the valid shells on this system via the /etc/shells file
New in version 2015.5.0
CLI Example::
salt '*' cmd.shells
cmd.tty:
Echo a string to a specific tty
CLI Example:
salt '*' cmd.tty tty0 'This is a test'
salt '*' cmd.tty pts3 'This is a test'
cmd.which:
Returns the path of an executable available on the minion, None otherwise
CLI Example:
salt '*' cmd.which cat
---此处省略N行
//SaltStack默认也支持一次执行多个Module,Module之间通过逗号隔开,默认传参之间也是用逗号分隔,也支持指定传参分隔符号--args-separator=@即可
[root@vm1 ~]# salt 'vm1' test.echo,cmd.run,service.status hello,hostname,salt-minion
vm1:
----------
cmd.run:
vm1
service.status:
True
test.echo:
hello
返回所有活动的tcp连接
[root@vm1 ~]# salt '*' network.active_tcp
vm2:
----------
0:
----------
local_addr:
192.168.30.128
local_port:
60790
remote_addr:
192.168.30.100
remote_port:
4505
1:
----------
local_addr:
192.168.30.130
local_port:
22
remote_addr:
192.168.30.1
remote_port:
63915
vm1:
----------
0:
----------
local_addr:
192.168.30.100
local_port:
4505
remote_addr:
192.168.30.100
remote_port:
40642
1:
----------
local_addr:
192.168.30.100
local_port:
22
remote_addr:
192.168.30.1
remote_port:
63869
2:
----------
local_addr:
192.168.30.100
local_port:
4506
remote_addr:
192.168.30.128
remote_port:
50738
3:
----------
local_addr:
192.168.30.100
local_port:
40642
remote_addr:
192.168.30.100
remote_port:
4505
4:
----------
local_addr:
192.168.30.100
local_port:
4505
remote_addr:
192.168.30.128
remote_port:
60790
通过IP和子网掩码计算出网段
[root@vm1 ~]# salt 'vm1' network.calc_net 192.168.30.110 255.255.255.0
vm1:
192.168.30.0/24
测试minion至某一台服务器的网络是否连通
[root@vm1 ~]# salt '*' network.connect baidu.com 80
vm1:
----------
comment:
Successfully connected to baidu.com (39.156.69.79) on tcp port 80
result:
True
vm2:
----------
comment:
Successfully connected to baidu.com (39.156.69.79) on tcp port 80
result:
True
查看默认路由
[root@vm1 ~]# salt 'vm1' network.default_route
vm1:
|_
----------
addr_family:
inet
destination:
0.0.0.0
flags:
UG
gateway:
192.168.30.2
interface:
ens33
netmask:
0.0.0.0
查看主机的fqdn(完全限定域名)
[root@vm1 ~]# salt '*' network.get_fqdn
vm1:
vm1
vm2:
vm2
获取主机名
[root@vm1 ~]# salt 'vm1' network.get_hostname
vm1:
vm1
查询到一个目标网络的路由信息
[root@vm1 ~]# salt 'vm1' network.get_route 172.25.0.10
vm1:
----------
destination:
172.25.0.10
gateway:
192.168.30.2
interface:
ens33
source:
192.168.30.100
返回指定网卡的MAC地址
[root@vm1 ~]# salt 'vm1' network.hw_addr ens33
vm1:
00:0c:29:e9:2e:d1
从特定CIDR检索接口名称
[root@vm1 ~]# salt '*' network.ifacestartswith 192.168
vm2:
- ens33
vm1:
- ens33
判断当前主机是否在某一个网段内
[root@vm1 ~]# salt 'vm1' network.in_subnet 192.168.30.0/24
vm1:
True
返回指定网卡的信息
[root@vm1 ~]# salt 'vm1' network.interface ens33
vm1:
|_
----------
address:
192.168.30.100
broadcast:
192.168.30.255
label:
ens33
netmask:
255.255.255.0
返回指定网卡的IP地址
[root@vm1 ~]# salt 'vm1' network.interface_ip ens33
vm1:
192.168.30.100
返回当前系统中所有的网卡信息
[root@vm1 ~]# salt 'vm1' network.interfaces
vm1:
----------
ens33:
----------
hwaddr:
00:0c:29:e9:2e:d1
inet:
|_
----------
address:
192.168.30.100
broadcast:
192.168.30.255
label:
ens33
netmask:
255.255.255.0
inet6:
|_
----------
address:
fe80::20c:29ff:fee9:2ed1
prefixlen:
64
scope:
link
up:
True
lo:
----------
hwaddr:
00:00:00:00:00:00
inet:
|_
----------
address:
127.0.0.1
broadcast:
None
label:
lo
netmask:
255.0.0.0
inet6:
|_
----------
address:
::1
prefixlen:
128
scope:
host
up:
True
返回一个IPv4的地址列表
该函数将会忽略掉127.0.0.1的地址
[root@vm1 ~]# salt 'vm1' network.ip_addrs
vm1:
- 192.168.30.100
[root@vm1 ~]# salt 'vm1' network.netstat
vm1:
|_
----------
inode:
17166
local-address:
127.0.0.1:323
program:
chronyd
proto:
udp
recv-q:
0
remote-address:
*:*
send-q:
0
user:
0
|_
----------
inode:
17167
local-address:
::1:323
program:
chronyd
proto:
udp
recv-q:
0
remote-address:
:::*
send-q:
0
user:
0
|_
----------
inode:
19983
local-address:
*:22
program:
sshd
proto:
tcp
recv-q:
0
remote-address:
*:*
send-q:
128
state:
LISTEN
user:
0
|_
----------
inode:
83462
local-address:
*:4505
program:
salt-master
proto:
tcp
recv-q:
0
remote-address:
*:*
send-q:
128
state:
LISTEN
user:
0
|_
----------
inode:
20680
local-address:
127.0.0.1:25
program:
master
proto:
tcp
recv-q:
0
remote-address:
*:*
send-q:
100
state:
LISTEN
user:
0
|_
----------
inode:
83491
local-address:
*:4506
program:
salt-master
proto:
tcp
recv-q:
0
remote-address:
*:*
send-q:
128
state:
LISTEN
user:
0
|_
----------
inode:
84389
local-address:
192.168.30.100:4505
program:
salt-master
proto:
tcp
recv-q:
0
remote-address:
192.168.30.100:40642
send-q:
0
state:
ESTABLISHED
user:
0
|_
----------
inode:
80584
local-address:
192.168.30.100:22
program:
sshd
proto:
tcp
recv-q:
0
remote-address:
192.168.30.1:63869
send-q:
0
state:
ESTABLISHED
user:
0
|_
----------
inode:
0
local-address:
127.0.0.1:57652
program:
proto:
tcp
recv-q:
0
remote-address:
127.0.0.1:4506
send-q:
0
state:
TIME-WAIT
user:
0
|_
----------
inode:
84388
local-address:
192.168.30.100:40642
program:
salt-minion
proto:
tcp
recv-q:
0
remote-address:
192.168.30.100:4505
send-q:
0
state:
ESTABLISHED
user:
0
|_
----------
inode:
84465
local-address:
192.168.30.100:4505
program:
salt-master
proto:
tcp
recv-q:
0
remote-address:
192.168.30.128:60790
send-q:
0
state:
ESTABLISHED
user:
0
|_
----------
inode:
0
local-address:
127.0.0.1:57656
program:
proto:
tcp
recv-q:
0
remote-address:
127.0.0.1:4506
send-q:
0
state:
TIME-WAIT
user:
0
|_
----------
inode:
0
local-address:
192.168.30.100:40598
program:
proto:
tcp
recv-q:
0
remote-address:
192.168.30.100:4506
send-q:
0
state:
TIME-WAIT
user:
0
|_
----------
inode:
19992
local-address:
:::22
program:
sshd
proto:
tcp
recv-q:
0
remote-address:
:::*
send-q:
128
state:
LISTEN
user:
0
|_
----------
inode:
20681
local-address:
::1:25
program:
master
proto:
tcp
recv-q:
0
remote-address:
:::*
send-q:
100
state:
LISTEN
user:
0
使用ping命令测试到某主机的连通性
[root@vm1 ~]# salt 'vm1' network.ping baidu.com
vm1:
PING baidu.com (39.156.69.79) 56(84) bytes of data.
64 bytes from 39.156.69.79 (39.156.69.79): icmp_seq=1 ttl=128 time=23.9 ms
64 bytes from 39.156.69.79 (39.156.69.79): icmp_seq=2 ttl=128 time=23.2 ms
64 bytes from 39.156.69.79 (39.156.69.79): icmp_seq=3 ttl=128 time=23.7 ms
64 bytes from 39.156.69.79 (39.156.69.79): icmp_seq=4 ttl=128 time=24.2 ms
--- baidu.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3006ms
rtt min/avg/max/mdev = 23.240/23.793/24.265/0.385 ms
返回一个指定的IP地址的反向地址
[root@vm1 ~]# salt 'vm1' network.reverse_ip 192.168.101.110
vm1:
110.101.168.192.in-addr.arpa
判断指定的服务是否可用
[root@vm1 ~]# salt '*' service.available sshd
vm1:
True
vm2:
True
[root@vm1 ~]# salt 'vm1' service.get_all
vm1:
- NetworkManager
- NetworkManager-dispatcher
- NetworkManager-wait-online
- auditd
- autovt@
- basic.target
- blk-availability
- bluetooth.target
- brandbot
- brandbot.path
- chrony-dnssrv@
- [email protected]
- chrony-wait
- chronyd
- console-getty
- console-shell
- container-getty@
- cpupower
- crond
- cryptsetup-pre.target
- cryptsetup.target
- ctrl-alt-del.target
- dbus
- dbus-org.fedoraproject.FirewallD1
- dbus-org.freedesktop.NetworkManager
- dbus-org.freedesktop.hostname1
- dbus-org.freedesktop.import1
- dbus-org.freedesktop.locale1
- dbus-org.freedesktop.login1
- dbus-org.freedesktop.machine1
- dbus-org.freedesktop.nm-dispatcher
- dbus-org.freedesktop.timedate1
- dbus.socket
- debug-shell
- default.target
- dev-hugepages.mount
- dev-mqueue.mount
- dm-event
- dm-event.socket
- dracut-cmdline
- dracut-initqueue
- dracut-mount
- dracut-pre-mount
- dracut-pre-pivot
- dracut-pre-trigger
- dracut-pre-udev
- dracut-shutdown
- ebtables
- emergency
- emergency.target
- final.target
- firewalld
- fstrim
- fstrim.timer
- getty-pre.target
- getty.target
- getty@
- graphical.target
- halt-local
- halt.target
- hibernate.target
- hybrid-sleep.target
- initrd-cleanup
- initrd-fs.target
- initrd-parse-etc
- initrd-root-fs.target
- initrd-switch-root
- initrd-switch-root.target
- initrd-udevadm-cleanup-db
- initrd.target
- iprdump
- iprinit
- iprupdate
- iprutils.target
- irqbalance
- kdump
- kexec.target
- kmod-static-nodes
- local-fs-pre.target
- local-fs.target
- lvm2-lvmetad
- lvm2-lvmetad.socket
- lvm2-lvmpolld
- lvm2-lvmpolld.socket
- lvm2-monitor
- lvm2-pvscan@
- machines.target
- messagebus
- microcode
- multi-user.target
- netconsole
- network
- network-online.target
- network-pre.target
- network.target
- nss-lookup.target
- nss-user-lookup.target
- paths.target
- plymouth-halt
- plymouth-kexec
- plymouth-poweroff
- plymouth-quit
- plymouth-quit-wait
- plymouth-read-write
- plymouth-reboot
- plymouth-start
- plymouth-switch-root
- polkit
- postfix
- poweroff.target
- printer.target
- proc-sys-fs-binfmt_misc.automount
- proc-sys-fs-binfmt_misc.mount
- quotaon
- rc-local
- rdisc
- reboot.target
- remote-cryptsetup.target
- remote-fs-pre.target
- remote-fs.target
- rescue
- rescue.target
- rhel-autorelabel
- rhel-autorelabel-mark
- rhel-configure
- rhel-dmesg
- rhel-domainname
- rhel-import-state
- rhel-loadmodules
- rhel-readonly
- rpcbind.target
- rsyslog
- runlevel0.target
- runlevel1.target
- runlevel2.target
- runlevel3.target
- runlevel4.target
- runlevel5.target
- runlevel6.target
- salt-master
- salt-minion
- salt-proxy@
- salt-syndic
- selinux-policy-migrate-local-changes@
- serial-getty@
- shutdown.target
- sigpwr.target
- sleep.target
- slices.target
- smartcard.target
- sockets.target
- sound.target
- sshd
- sshd-keygen
- sshd.socket
- sshd@
- suspend.target
- swap.target
- sys-fs-fuse-connections.mount
- sys-kernel-config.mount
- sys-kernel-debug.mount
- sysinit.target
- syslog.socket
- system-update.target
- systemd-ask-password-console
- systemd-ask-password-console.path
- systemd-ask-password-plymouth
- systemd-ask-password-plymouth.path
- systemd-ask-password-wall
- systemd-ask-password-wall.path
- systemd-backlight@
- systemd-binfmt
- systemd-bootchart
- systemd-firstboot
- systemd-fsck-root
- systemd-fsck@
- systemd-halt
- systemd-hibernate
- systemd-hibernate-resume@
- systemd-hostnamed
- systemd-hwdb-update
- systemd-hybrid-sleep
- systemd-importd
- systemd-initctl
- systemd-initctl.socket
- systemd-journal-catalog-update
- systemd-journal-flush
- systemd-journald
- systemd-journald.socket
- systemd-kexec
- systemd-localed
- systemd-logind
- systemd-machine-id-commit
- systemd-machined
- systemd-modules-load
- systemd-nspawn@
- systemd-poweroff
- systemd-quotacheck
- systemd-random-seed
- systemd-readahead-collect
- systemd-readahead-done
- systemd-readahead-done.timer
- systemd-readahead-drop
- systemd-readahead-replay
- systemd-reboot
- systemd-remount-fs
- systemd-rfkill@
- systemd-shutdownd
- systemd-shutdownd.socket
- systemd-suspend
- systemd-sysctl
- systemd-timedated
- systemd-tmpfiles-clean
- systemd-tmpfiles-clean.timer
- systemd-tmpfiles-setup
- systemd-tmpfiles-setup-dev
- systemd-udev-settle
- systemd-udev-trigger
- systemd-udevd
- systemd-udevd-control.socket
- systemd-udevd-kernel.socket
- systemd-update-done
- systemd-update-utmp
- systemd-update-utmp-runlevel
- systemd-user-sessions
- systemd-vconsole-setup
- teamd@
- time-sync.target
- timers.target
- tmp.mount
- tuned
- umount.target
- vgauthd
- vmtoolsd
- wpa_supplicant
检查指定服务是否开机不自动启动
[root@vm1 ~]# salt 'vm1' service.disabled httpd
vm1:
True
[root@vm1 ~]# salt 'vm2' service.disabled httpd
vm2:
False
检查指定服务是否开机自动启动
[root@vm1 ~]# salt '*' service.enabled httpd
vm2:
True
vm1:
False
设置指定服务开机不自动启动
[root@vm1 ~]# salt 'vm2' service.disable httpd
vm2:
True
[root@vm1 ~]# salt 'vm2' service.enabled httpd
vm2:
False
设置指定服务开机自动启动
[root@vm1 ~]# salt 'vm2' service.enable httpd
vm2:
True
[root@vm1 ~]# salt 'vm2' service.enabled httpd
vm2:
True
重新加载指定服务
[root@vm1 ~]# salt 'vm2' service.reload httpd
vm2:
True
停止指定服务
[root@vm1 ~]# salt 'vm2' service.stop httpd
vm2:
True
启动指定服务
[root@vm1 ~]# salt 'vm2' service.start httpd
vm2:
True
重启指定服务
[root@vm1 ~]# salt 'vm2' service.restart httpd
vm2:
True
查看指定服务的状态
[root@vm1 ~]# salt 'vm2' service.status httpd
vm2:
True
只下载软件包但不安装
此功能将会下载指定的软件包,但是需要在minion端安装yum-utils,可以使用 cmd.run 进行远程安装
[root@vm1 ~]# salt 'vm1' pkg.download wget
vm1:
----------
wget:
/var/cache/yum/packages/wget-1.14-18.el7_6.1.x86_64.rpm //下载好的软件放在这里
列出指定包或系统中已安装的所有包的文件
[root@vm1 ~]# salt 'vm2' pkg.file_list httpd
vm2:
----------
errors:
files:
- /etc/httpd
- /etc/httpd/conf
- /etc/httpd/conf.d
- /etc/httpd/conf.d/README
- /etc/httpd/conf.d/autoindex.conf
- /etc/httpd/conf.d/userdir.conf
- /etc/httpd/conf.d/welcome.conf
- /etc/httpd/conf.modules.d
- /etc/httpd/conf.modules.d/00-base.conf
- /etc/httpd/conf.modules.d/00-dav.conf
- /etc/httpd/conf.modules.d/00-lua.conf
- /etc/httpd/conf.modules.d/00-mpm.conf
- /etc/httpd/conf.modules.d/00-proxy.conf
- /etc/httpd/conf.modules.d/00-systemd.conf
- /etc/httpd/conf.modules.d/01-cgi.conf
- /etc/httpd/conf/httpd.conf
- /etc/httpd/conf/magic
- /etc/httpd/logs
- /etc/httpd/modules
- /etc/httpd/run
- /etc/logrotate.d/httpd
- /etc/sysconfig/htcacheclean
- /etc/sysconfig/httpd
- /run/httpd
- /run/httpd/htcacheclean
- /usr/lib/systemd/system/htcacheclean.service
- /usr/lib/systemd/system/httpd.service
- /usr/lib/tmpfiles.d/httpd.conf
- /usr/lib64/httpd
- /usr/lib64/httpd/modules
- /usr/lib64/httpd/modules/mod_access_compat.so
- /usr/lib64/httpd/modules/mod_actions.so
- /usr/lib64/httpd/modules/mod_alias.so
- /usr/lib64/httpd/modules/mod_allowmethods.so
- /usr/lib64/httpd/modules/mod_asis.so
- /usr/lib64/httpd/modules/mod_auth_basic.so
- /usr/lib64/httpd/modules/mod_auth_digest.so
- /usr/lib64/httpd/modules/mod_authn_anon.so
- /usr/lib64/httpd/modules/mod_authn_core.so
- /usr/lib64/httpd/modules/mod_authn_dbd.so
- /usr/lib64/httpd/modules/mod_authn_dbm.so
- /usr/lib64/httpd/modules/mod_authn_file.so
- /usr/lib64/httpd/modules/mod_authn_socache.so
- /usr/lib64/httpd/modules/mod_authz_core.so
- /usr/lib64/httpd/modules/mod_authz_dbd.so
- /usr/lib64/httpd/modules/mod_authz_dbm.so
- /usr/lib64/httpd/modules/mod_authz_groupfile.so
- /usr/lib64/httpd/modules/mod_authz_host.so
- /usr/lib64/httpd/modules/mod_authz_owner.so
- /usr/lib64/httpd/modules/mod_authz_user.so
- /usr/lib64/httpd/modules/mod_autoindex.so
- /usr/lib64/httpd/modules/mod_buffer.so
- /usr/lib64/httpd/modules/mod_cache.so
- /usr/lib64/httpd/modules/mod_cache_disk.so
- /usr/lib64/httpd/modules/mod_cache_socache.so
- /usr/lib64/httpd/modules/mod_cgi.so
- /usr/lib64/httpd/modules/mod_cgid.so
- /usr/lib64/httpd/modules/mod_charset_lite.so
- /usr/lib64/httpd/modules/mod_data.so
- /usr/lib64/httpd/modules/mod_dav.so
- /usr/lib64/httpd/modules/mod_dav_fs.so
- /usr/lib64/httpd/modules/mod_dav_lock.so
- /usr/lib64/httpd/modules/mod_dbd.so
- /usr/lib64/httpd/modules/mod_deflate.so
- /usr/lib64/httpd/modules/mod_dialup.so
- /usr/lib64/httpd/modules/mod_dir.so
- /usr/lib64/httpd/modules/mod_dumpio.so
- /usr/lib64/httpd/modules/mod_echo.so
- /usr/lib64/httpd/modules/mod_env.so
- /usr/lib64/httpd/modules/mod_expires.so
- /usr/lib64/httpd/modules/mod_ext_filter.so
- /usr/lib64/httpd/modules/mod_file_cache.so
- /usr/lib64/httpd/modules/mod_filter.so
- /usr/lib64/httpd/modules/mod_headers.so
- /usr/lib64/httpd/modules/mod_heartbeat.so
- /usr/lib64/httpd/modules/mod_heartmonitor.so
- /usr/lib64/httpd/modules/mod_include.so
- /usr/lib64/httpd/modules/mod_info.so
- /usr/lib64/httpd/modules/mod_lbmethod_bybusyness.so
- /usr/lib64/httpd/modules/mod_lbmethod_byrequests.so
- /usr/lib64/httpd/modules/mod_lbmethod_bytraffic.so
- /usr/lib64/httpd/modules/mod_lbmethod_heartbeat.so
- /usr/lib64/httpd/modules/mod_log_config.so
- /usr/lib64/httpd/modules/mod_log_debug.so
- /usr/lib64/httpd/modules/mod_log_forensic.so
- /usr/lib64/httpd/modules/mod_logio.so
- /usr/lib64/httpd/modules/mod_lua.so
- /usr/lib64/httpd/modules/mod_macro.so
- /usr/lib64/httpd/modules/mod_mime.so
- /usr/lib64/httpd/modules/mod_mime_magic.so
- /usr/lib64/httpd/modules/mod_mpm_event.so
- /usr/lib64/httpd/modules/mod_mpm_prefork.so
- /usr/lib64/httpd/modules/mod_mpm_worker.so
- /usr/lib64/httpd/modules/mod_negotiation.so
- /usr/lib64/httpd/modules/mod_proxy.so
- /usr/lib64/httpd/modules/mod_proxy_ajp.so
- /usr/lib64/httpd/modules/mod_proxy_balancer.so
- /usr/lib64/httpd/modules/mod_proxy_connect.so
- /usr/lib64/httpd/modules/mod_proxy_express.so
- /usr/lib64/httpd/modules/mod_proxy_fcgi.so
- /usr/lib64/httpd/modules/mod_proxy_fdpass.so
- /usr/lib64/httpd/modules/mod_proxy_ftp.so
- /usr/lib64/httpd/modules/mod_proxy_http.so
- /usr/lib64/httpd/modules/mod_proxy_scgi.so
- /usr/lib64/httpd/modules/mod_proxy_wstunnel.so
- /usr/lib64/httpd/modules/mod_ratelimit.so
- /usr/lib64/httpd/modules/mod_reflector.so
- /usr/lib64/httpd/modules/mod_remoteip.so
- /usr/lib64/httpd/modules/mod_reqtimeout.so
- /usr/lib64/httpd/modules/mod_request.so
- /usr/lib64/httpd/modules/mod_rewrite.so
- /usr/lib64/httpd/modules/mod_sed.so
- /usr/lib64/httpd/modules/mod_setenvif.so
- /usr/lib64/httpd/modules/mod_slotmem_plain.so
- /usr/lib64/httpd/modules/mod_slotmem_shm.so
- /usr/lib64/httpd/modules/mod_socache_dbm.so
- /usr/lib64/httpd/modules/mod_socache_memcache.so
- /usr/lib64/httpd/modules/mod_socache_shmcb.so
- /usr/lib64/httpd/modules/mod_speling.so
- /usr/lib64/httpd/modules/mod_status.so
- /usr/lib64/httpd/modules/mod_substitute.so
- /usr/lib64/httpd/modules/mod_suexec.so
- /usr/lib64/httpd/modules/mod_systemd.so
- /usr/lib64/httpd/modules/mod_unique_id.so
- /usr/lib64/httpd/modules/mod_unixd.so
- /usr/lib64/httpd/modules/mod_userdir.so
- /usr/lib64/httpd/modules/mod_usertrack.so
- /usr/lib64/httpd/modules/mod_version.so
- /usr/lib64/httpd/modules/mod_vhost_alias.so
- /usr/lib64/httpd/modules/mod_watchdog.so
- /usr/libexec/initscripts/legacy-actions/httpd
- /usr/libexec/initscripts/legacy-actions/httpd/configtest
- /usr/libexec/initscripts/legacy-actions/httpd/graceful
- /usr/sbin/apachectl
- /usr/sbin/fcgistarter
- /usr/sbin/htcacheclean
- /usr/sbin/httpd
- /usr/sbin/rotatelogs
- /usr/sbin/suexec
- /usr/share/doc/httpd-2.4.6
- /usr/share/doc/httpd-2.4.6/ABOUT_APACHE
- /usr/share/doc/httpd-2.4.6/CHANGES
- /usr/share/doc/httpd-2.4.6/LICENSE
- /usr/share/doc/httpd-2.4.6/NOTICE
- /usr/share/doc/httpd-2.4.6/README
- /usr/share/doc/httpd-2.4.6/VERSIONING
- /usr/share/doc/httpd-2.4.6/httpd-dav.conf
- /usr/share/doc/httpd-2.4.6/httpd-default.conf
- /usr/share/doc/httpd-2.4.6/httpd-info.conf
- /usr/share/doc/httpd-2.4.6/httpd-languages.conf
- /usr/share/doc/httpd-2.4.6/httpd-manual.conf
- /usr/share/doc/httpd-2.4.6/httpd-mpm.conf
- /usr/share/doc/httpd-2.4.6/httpd-multilang-errordoc.conf
- /usr/share/doc/httpd-2.4.6/httpd-vhosts.conf
- /usr/share/doc/httpd-2.4.6/proxy-html.conf
- /usr/share/httpd
- /usr/share/httpd/error
- /usr/share/httpd/error/HTTP_BAD_GATEWAY.html.var
- /usr/share/httpd/error/HTTP_BAD_REQUEST.html.var
- /usr/share/httpd/error/HTTP_FORBIDDEN.html.var
- /usr/share/httpd/error/HTTP_GONE.html.var
- /usr/share/httpd/error/HTTP_INTERNAL_SERVER_ERROR.html.var
- /usr/share/httpd/error/HTTP_LENGTH_REQUIRED.html.var
- /usr/share/httpd/error/HTTP_METHOD_NOT_ALLOWED.html.var
- /usr/share/httpd/error/HTTP_NOT_FOUND.html.var
- /usr/share/httpd/error/HTTP_NOT_IMPLEMENTED.html.var
- /usr/share/httpd/error/HTTP_PRECONDITION_FAILED.html.var
- /usr/share/httpd/error/HTTP_REQUEST_ENTITY_TOO_LARGE.html.var
- /usr/share/httpd/error/HTTP_REQUEST_TIME_OUT.html.var
- /usr/share/httpd/error/HTTP_REQUEST_URI_TOO_LARGE.html.var
- /usr/share/httpd/error/HTTP_SERVICE_UNAVAILABLE.html.var
- /usr/share/httpd/error/HTTP_UNAUTHORIZED.html.var
- /usr/share/httpd/error/HTTP_UNSUPPORTED_MEDIA_TYPE.html.var
- /usr/share/httpd/error/HTTP_VARIANT_ALSO_VARIES.html.var
- /usr/share/httpd/error/README
- /usr/share/httpd/error/contact.html.var
- /usr/share/httpd/error/include
- /usr/share/httpd/error/include/bottom.html
- /usr/share/httpd/error/include/spacer.html
- /usr/share/httpd/error/include/top.html
- /usr/share/httpd/icons
- /usr/share/httpd/icons/README
- /usr/share/httpd/icons/README.html
- /usr/share/httpd/icons/a.gif
- /usr/share/httpd/icons/a.png
- /usr/share/httpd/icons/alert.black.gif
- /usr/share/httpd/icons/alert.black.png
- /usr/share/httpd/icons/alert.red.gif
- /usr/share/httpd/icons/alert.red.png
- /usr/share/httpd/icons/apache_pb.gif
- /usr/share/httpd/icons/apache_pb.png
- /usr/share/httpd/icons/apache_pb.svg
- /usr/share/httpd/icons/apache_pb2.gif
- /usr/share/httpd/icons/apache_pb2.png
- /usr/share/httpd/icons/back.gif
- /usr/share/httpd/icons/back.png
- /usr/share/httpd/icons/ball.gray.gif
- /usr/share/httpd/icons/ball.gray.png
- /usr/share/httpd/icons/ball.red.gif
- /usr/share/httpd/icons/ball.red.png
- /usr/share/httpd/icons/binary.gif
- /usr/share/httpd/icons/binary.png
- /usr/share/httpd/icons/binhex.gif
- /usr/share/httpd/icons/binhex.png
- /usr/share/httpd/icons/blank.gif
- /usr/share/httpd/icons/blank.png
- /usr/share/httpd/icons/bomb.gif
- /usr/share/httpd/icons/bomb.png
- /usr/share/httpd/icons/box1.gif
- /usr/share/httpd/icons/box1.png
- /usr/share/httpd/icons/box2.gif
- /usr/share/httpd/icons/box2.png
- /usr/share/httpd/icons/broken.gif
- /usr/share/httpd/icons/broken.png
- /usr/share/httpd/icons/burst.gif
- /usr/share/httpd/icons/burst.png
- /usr/share/httpd/icons/c.gif
- /usr/share/httpd/icons/c.png
- /usr/share/httpd/icons/comp.blue.gif
- /usr/share/httpd/icons/comp.blue.png
- /usr/share/httpd/icons/comp.gray.gif
- /usr/share/httpd/icons/comp.gray.png
- /usr/share/httpd/icons/compressed.gif
- /usr/share/httpd/icons/compressed.png
- /usr/share/httpd/icons/continued.gif
- /usr/share/httpd/icons/continued.png
- /usr/share/httpd/icons/dir.gif
- /usr/share/httpd/icons/dir.png
- /usr/share/httpd/icons/diskimg.gif
- /usr/share/httpd/icons/diskimg.png
- /usr/share/httpd/icons/down.gif
- /usr/share/httpd/icons/down.png
- /usr/share/httpd/icons/dvi.gif
- /usr/share/httpd/icons/dvi.png
- /usr/share/httpd/icons/f.gif
- /usr/share/httpd/icons/f.png
- /usr/share/httpd/icons/folder.gif
- /usr/share/httpd/icons/folder.open.gif
- /usr/share/httpd/icons/folder.open.png
- /usr/share/httpd/icons/folder.png
- /usr/share/httpd/icons/folder.sec.gif
- /usr/share/httpd/icons/folder.sec.png
- /usr/share/httpd/icons/forward.gif
- /usr/share/httpd/icons/forward.png
- /usr/share/httpd/icons/generic.gif
- /usr/share/httpd/icons/generic.png
- /usr/share/httpd/icons/generic.red.gif
- /usr/share/httpd/icons/generic.red.png
- /usr/share/httpd/icons/generic.sec.gif
- /usr/share/httpd/icons/generic.sec.png
- /usr/share/httpd/icons/hand.right.gif
- /usr/share/httpd/icons/hand.right.png
- /usr/share/httpd/icons/hand.up.gif
- /usr/share/httpd/icons/hand.up.png
- /usr/share/httpd/icons/icon.sheet.gif
- /usr/share/httpd/icons/icon.sheet.png
- /usr/share/httpd/icons/image1.gif
- /usr/share/httpd/icons/image1.png
- /usr/share/httpd/icons/image2.gif
- /usr/share/httpd/icons/image2.png
- /usr/share/httpd/icons/image3.gif
- /usr/share/httpd/icons/image3.png
- /usr/share/httpd/icons/index.gif
- /usr/share/httpd/icons/index.png
- /usr/share/httpd/icons/layout.gif
- /usr/share/httpd/icons/layout.png
- /usr/share/httpd/icons/left.gif
- /usr/share/httpd/icons/left.png
- /usr/share/httpd/icons/link.gif
- /usr/share/httpd/icons/link.png
- /usr/share/httpd/icons/movie.gif
- /usr/share/httpd/icons/movie.png
- /usr/share/httpd/icons/odf6odb.png
- /usr/share/httpd/icons/odf6odc.png
- /usr/share/httpd/icons/odf6odf.png
- /usr/share/httpd/icons/odf6odg.png
- /usr/share/httpd/icons/odf6odi.png
- /usr/share/httpd/icons/odf6odm.png
- /usr/share/httpd/icons/odf6odp.png
- /usr/share/httpd/icons/odf6ods.png
- /usr/share/httpd/icons/odf6odt.png
- /usr/share/httpd/icons/odf6otc.png
- /usr/share/httpd/icons/odf6otf.png
- /usr/share/httpd/icons/odf6otg.png
- /usr/share/httpd/icons/odf6oth.png
- /usr/share/httpd/icons/odf6oti.png
- /usr/share/httpd/icons/odf6otp.png
- /usr/share/httpd/icons/odf6ots.png
- /usr/share/httpd/icons/odf6ott.png
- /usr/share/httpd/icons/p.gif
- /usr/share/httpd/icons/p.png
- /usr/share/httpd/icons/patch.gif
- /usr/share/httpd/icons/patch.png
- /usr/share/httpd/icons/pdf.gif
- /usr/share/httpd/icons/pdf.png
- /usr/share/httpd/icons/pie0.gif
- /usr/share/httpd/icons/pie0.png
- /usr/share/httpd/icons/pie1.gif
- /usr/share/httpd/icons/pie1.png
- /usr/share/httpd/icons/pie2.gif
- /usr/share/httpd/icons/pie2.png
- /usr/share/httpd/icons/pie3.gif
- /usr/share/httpd/icons/pie3.png
- /usr/share/httpd/icons/pie4.gif
- /usr/share/httpd/icons/pie4.png
- /usr/share/httpd/icons/pie5.gif
- /usr/share/httpd/icons/pie5.png
- /usr/share/httpd/icons/pie6.gif
- /usr/share/httpd/icons/pie6.png
- /usr/share/httpd/icons/pie7.gif
- /usr/share/httpd/icons/pie7.png
- /usr/share/httpd/icons/pie8.gif
- /usr/share/httpd/icons/pie8.png
- /usr/share/httpd/icons/portal.gif
- /usr/share/httpd/icons/portal.png
- /usr/share/httpd/icons/poweredby.png
- /usr/share/httpd/icons/ps.gif
- /usr/share/httpd/icons/ps.png
- /usr/share/httpd/icons/quill.gif
- /usr/share/httpd/icons/quill.png
- /usr/share/httpd/icons/right.gif
- /usr/share/httpd/icons/right.png
- /usr/share/httpd/icons/screw1.gif
- /usr/share/httpd/icons/screw1.png
- /usr/share/httpd/icons/screw2.gif
- /usr/share/httpd/icons/screw2.png
- /usr/share/httpd/icons/script.gif
- /usr/share/httpd/icons/script.png
- /usr/share/httpd/icons/small
- /usr/share/httpd/icons/small/back.gif
- /usr/share/httpd/icons/small/back.png
- /usr/share/httpd/icons/small/binary.gif
- /usr/share/httpd/icons/small/binary.png
- /usr/share/httpd/icons/small/binhex.gif
- /usr/share/httpd/icons/small/binhex.png
- /usr/share/httpd/icons/small/blank.gif
- /usr/share/httpd/icons/small/blank.png
- /usr/share/httpd/icons/small/broken.gif
- /usr/share/httpd/icons/small/broken.png
- /usr/share/httpd/icons/small/burst.gif
- /usr/share/httpd/icons/small/burst.png
- /usr/share/httpd/icons/small/comp1.gif
- /usr/share/httpd/icons/small/comp1.png
- /usr/share/httpd/icons/small/comp2.gif
- /usr/share/httpd/icons/small/comp2.png
- /usr/share/httpd/icons/small/compressed.gif
- /usr/share/httpd/icons/small/compressed.png
- /usr/share/httpd/icons/small/continued.gif
- /usr/share/httpd/icons/small/continued.png
- /usr/share/httpd/icons/small/doc.gif
- /usr/share/httpd/icons/small/doc.png
- /usr/share/httpd/icons/small/folder.gif
- /usr/share/httpd/icons/small/folder.png
- /usr/share/httpd/icons/small/folder2.gif
- /usr/share/httpd/icons/small/folder2.png
- /usr/share/httpd/icons/small/forward.gif
- /usr/share/httpd/icons/small/forward.png
- /usr/share/httpd/icons/small/generic.gif
- /usr/share/httpd/icons/small/generic.png
- /usr/share/httpd/icons/small/generic2.gif
- /usr/share/httpd/icons/small/generic2.png
- /usr/share/httpd/icons/small/generic3.gif
- /usr/share/httpd/icons/small/generic3.png
- /usr/share/httpd/icons/small/image.gif
- /usr/share/httpd/icons/small/image.png
- /usr/share/httpd/icons/small/image2.gif
- /usr/share/httpd/icons/small/image2.png
- /usr/share/httpd/icons/small/index.gif
- /usr/share/httpd/icons/small/index.png
- /usr/share/httpd/icons/small/key.gif
- /usr/share/httpd/icons/small/key.png
- /usr/share/httpd/icons/small/movie.gif
- /usr/share/httpd/icons/small/movie.png
- /usr/share/httpd/icons/small/patch.gif
- /usr/share/httpd/icons/small/patch.png
- /usr/share/httpd/icons/small/ps.gif
- /usr/share/httpd/icons/small/ps.png
- /usr/share/httpd/icons/small/rainbow.gif
- /usr/share/httpd/icons/small/rainbow.png
- /usr/share/httpd/icons/small/sound.gif
- /usr/share/httpd/icons/small/sound.png
- /usr/share/httpd/icons/small/sound2.gif
- /usr/share/httpd/icons/small/sound2.png
- /usr/share/httpd/icons/small/tar.gif
- /usr/share/httpd/icons/small/tar.png
- /usr/share/httpd/icons/small/text.gif
- /usr/share/httpd/icons/small/text.png
- /usr/share/httpd/icons/small/transfer.gif
- /usr/share/httpd/icons/small/transfer.png
- /usr/share/httpd/icons/small/unknown.gif
- /usr/share/httpd/icons/small/unknown.png
- /usr/share/httpd/icons/small/uu.gif
- /usr/share/httpd/icons/small/uu.png
- /usr/share/httpd/icons/sound1.gif
- /usr/share/httpd/icons/sound1.png
- /usr/share/httpd/icons/sound2.gif
- /usr/share/httpd/icons/sound2.png
- /usr/share/httpd/icons/sphere1.gif
- /usr/share/httpd/icons/sphere1.png
- /usr/share/httpd/icons/sphere2.gif
- /usr/share/httpd/icons/sphere2.png
- /usr/share/httpd/icons/svg.png
- /usr/share/httpd/icons/tar.gif
- /usr/share/httpd/icons/tar.png
- /usr/share/httpd/icons/tex.gif
- /usr/share/httpd/icons/tex.png
- /usr/share/httpd/icons/text.gif
- /usr/share/httpd/icons/text.png
- /usr/share/httpd/icons/transfer.gif
- /usr/share/httpd/icons/transfer.png
- /usr/share/httpd/icons/unknown.gif
- /usr/share/httpd/icons/unknown.png
- /usr/share/httpd/icons/up.gif
- /usr/share/httpd/icons/up.png
- /usr/share/httpd/icons/uu.gif
- /usr/share/httpd/icons/uu.png
- /usr/share/httpd/icons/uuencoded.gif
- /usr/share/httpd/icons/uuencoded.png
- /usr/share/httpd/icons/world1.gif
- /usr/share/httpd/icons/world1.png
- /usr/share/httpd/icons/world2.gif
- /usr/share/httpd/icons/world2.png
- /usr/share/httpd/icons/xml.png
- /usr/share/httpd/noindex
- /usr/share/httpd/noindex/css
- /usr/share/httpd/noindex/css/bootstrap-theme.min.css
- /usr/share/httpd/noindex/css/bootstrap.min.css
- /usr/share/httpd/noindex/css/fonts
- /usr/share/httpd/noindex/css/fonts/Bold
- /usr/share/httpd/noindex/css/fonts/Bold/OpenSans-Bold.eot
- /usr/share/httpd/noindex/css/fonts/Bold/OpenSans-Bold.svg
- /usr/share/httpd/noindex/css/fonts/Bold/OpenSans-Bold.ttf
- /usr/share/httpd/noindex/css/fonts/Bold/OpenSans-Bold.woff
- /usr/share/httpd/noindex/css/fonts/BoldItalic
- /usr/share/httpd/noindex/css/fonts/BoldItalic/OpenSans-BoldItalic.eot
- /usr/share/httpd/noindex/css/fonts/BoldItalic/OpenSans-BoldItalic.svg
- /usr/share/httpd/noindex/css/fonts/BoldItalic/OpenSans-BoldItalic.ttf
- /usr/share/httpd/noindex/css/fonts/BoldItalic/OpenSans-BoldItalic.woff
- /usr/share/httpd/noindex/css/fonts/ExtraBold
- /usr/share/httpd/noindex/css/fonts/ExtraBold/OpenSans-ExtraBold.eot
- /usr/share/httpd/noindex/css/fonts/ExtraBold/OpenSans-ExtraBold.svg
- /usr/share/httpd/noindex/css/fonts/ExtraBold/OpenSans-ExtraBold.ttf
- /usr/share/httpd/noindex/css/fonts/ExtraBold/OpenSans-ExtraBold.woff
- /usr/share/httpd/noindex/css/fonts/ExtraBoldItalic
- /usr/share/httpd/noindex/css/fonts/ExtraBoldItalic/OpenSans-ExtraBoldItalic.eot
- /usr/share/httpd/noindex/css/fonts/ExtraBoldItalic/OpenSans-ExtraBoldItalic.svg
- /usr/share/httpd/noindex/css/fonts/ExtraBoldItalic/OpenSans-ExtraBoldItalic.ttf
- /usr/share/httpd/noindex/css/fonts/ExtraBoldItalic/OpenSans-ExtraBoldItalic.woff
- /usr/share/httpd/noindex/css/fonts/Italic
- /usr/share/httpd/noindex/css/fonts/Italic/OpenSans-Italic.eot
- /usr/share/httpd/noindex/css/fonts/Italic/OpenSans-Italic.svg
- /usr/share/httpd/noindex/css/fonts/Italic/OpenSans-Italic.ttf
- /usr/share/httpd/noindex/css/fonts/Italic/OpenSans-Italic.woff
- /usr/share/httpd/noindex/css/fonts/Light
- /usr/share/httpd/noindex/css/fonts/Light/OpenSans-Light.eot
- /usr/share/httpd/noindex/css/fonts/Light/OpenSans-Light.svg
- /usr/share/httpd/noindex/css/fonts/Light/OpenSans-Light.ttf
- /usr/share/httpd/noindex/css/fonts/Light/OpenSans-Light.woff
- /usr/share/httpd/noindex/css/fonts/LightItalic
- /usr/share/httpd/noindex/css/fonts/LightItalic/OpenSans-LightItalic.eot
- /usr/share/httpd/noindex/css/fonts/LightItalic/OpenSans-LightItalic.svg
- /usr/share/httpd/noindex/css/fonts/LightItalic/OpenSans-LightItalic.ttf
- /usr/share/httpd/noindex/css/fonts/LightItalic/OpenSans-LightItalic.woff
- /usr/share/httpd/noindex/css/fonts/Regular
- /usr/share/httpd/noindex/css/fonts/Regular/OpenSans-Regular.eot
- /usr/share/httpd/noindex/css/fonts/Regular/OpenSans-Regular.svg
- /usr/share/httpd/noindex/css/fonts/Regular/OpenSans-Regular.ttf
- /usr/share/httpd/noindex/css/fonts/Regular/OpenSans-Regular.woff
- /usr/share/httpd/noindex/css/fonts/Semibold
- /usr/share/httpd/noindex/css/fonts/Semibold/OpenSans-Semibold.eot
- /usr/share/httpd/noindex/css/fonts/Semibold/OpenSans-Semibold.svg
- /usr/share/httpd/noindex/css/fonts/Semibold/OpenSans-Semibold.ttf
- /usr/share/httpd/noindex/css/fonts/Semibold/OpenSans-Semibold.woff
- /usr/share/httpd/noindex/css/fonts/SemiboldItalic
- /usr/share/httpd/noindex/css/fonts/SemiboldItalic/OpenSans-SemiboldItalic.eot
- /usr/share/httpd/noindex/css/fonts/SemiboldItalic/OpenSans-SemiboldItalic.svg
- /usr/share/httpd/noindex/css/fonts/SemiboldItalic/OpenSans-SemiboldItalic.ttf
- /usr/share/httpd/noindex/css/fonts/SemiboldItalic/OpenSans-SemiboldItalic.woff
- /usr/share/httpd/noindex/css/open-sans.css
- /usr/share/httpd/noindex/images
- /usr/share/httpd/noindex/images/apache_pb.gif
- /usr/share/httpd/noindex/images/poweredby.png
- /usr/share/httpd/noindex/index.html
- /usr/share/man/man8/apachectl.8.gz
- /usr/share/man/man8/fcgistarter.8.gz
- /usr/share/man/man8/htcacheclean.8.gz
- /usr/share/man/man8/httpd.8.gz
- /usr/share/man/man8/rotatelogs.8.gz
- /usr/share/man/man8/suexec.8.gz
- /var/cache/httpd
- /var/cache/httpd/proxy
- /var/lib/dav
- /var/log/httpd
- /var/www
- /var/www/cgi-bin
- /var/www/html
/当不提供参数时,将会列出当前系统中所有已安装软件的文件列表
[root@vm1 ~]# salt ‘vm2’ pkg.file_list
vm2:
----------
errors:
files:
VALUE_TRIMMED
查看包组的信息
[root@vm1 ~]# salt '*' pkg.group_info 'Development Tools'
vm2:
----------
conditional:
default:
- byacc
- cscope
- ctags
- diffstat
- doxygen
- elfutils
- gcc-gfortran
- git
- indent
- intltool
- patchutils
- rcs
- subversion
- swig
- systemtap
description:
A basic development environment.
group:
Development Tools
id:
development
mandatory:
- autoconf
- automake
- binutils
- bison
- flex
- gcc
- gcc-c++
- gettext
- libtool
- make
- patch
- pkgconfig
- redhat-rpm-config
- rpm-build
- rpm-sign
optional:
- ElectricFence
- ant
- babel
- bzr
- chrpath
- cmake
- compat-gcc-44
- compat-gcc-44-c++
- cvs
- dejagnu
- expect
- gcc-gnat
- gcc-objc
- gcc-objc++
- imake
- javapackages-tools
- ksc
- mercurial
- mod_dav_svn
- nasm
- perltidy
- rpmdevtools
- rpmlint
- systemtap-sdt-devel
- systemtap-server
type:
package group
vm1:
----------
conditional:
default:
- byacc
- cscope
- ctags
- diffstat
- doxygen
- elfutils
- gcc-gfortran
- git
- indent
- intltool
- patchutils
- rcs
- subversion
- swig
- systemtap
description:
A basic development environment.
group:
Development Tools
id:
development
mandatory:
- autoconf
- automake
- binutils
- bison
- flex
- gcc
- gcc-c++
- gettext
- libtool
- make
- patch
- pkgconfig
- redhat-rpm-config
- rpm-build
- rpm-sign
optional:
- ElectricFence
- ant
- babel
- bzr
- chrpath
- cmake
- compat-gcc-44
- compat-gcc-44-c++
- cvs
- dejagnu
- expect
- gcc-gnat
- gcc-objc
- gcc-objc++
- imake
- javapackages-tools
- ksc
- mercurial
- mod_dav_svn
- nasm
- perltidy
- rpmdevtools
- rpmlint
- systemtap-sdt-devel
- systemtap-server
type:
package group
列出系统中所有的包组
[root@vm1 ~]# salt 'vm2' pkg.group_list
vm2:
----------
available:
- Additional Development
- Anaconda Tools
- Backup Client
- Backup Server
- Base
- CentOS Linux Client product core
- CentOS Linux ComputeNode product core
- CentOS Linux Server product core
- CentOS Linux Workstation product core
- Common NetworkManager submodules
- Compatibility Libraries
- Conflicts (Client)
- Conflicts (ComputeNode)
- Conflicts (Server)
- Conflicts (Workstation)
- Console Internet Tools
- Core
- DNS Name Server
- Debugging Tools
- Desktop Debugging and Performance Tools
- Development Tools
- Dial-up Networking Support
- Directory Client
- Directory Server
- E-mail Server
- Emacs
- FTP Server
- File and Storage Server
- Fonts
- GNOME
- GNOME Applications
- Graphical Administration Tools
- Graphics Creation Tools
- Guest Agents
- Guest Desktop Agents
- Hardware Monitoring Utilities
- High Availability
- Hyper-v platform specific packages
- Identity Management Server
- Infiniband Support
- Input Methods
- Internet Applications
- Internet Browser
- Java Platform
- KDE
- KDE Applications
- KDE Multimedia Support
- KVM platform specific packages
- Large Systems Performance
- Legacy UNIX Compatibility
- Legacy X Window System Compatibility
- Load Balancer
- Mainframe Access
- MariaDB Database Client
- MariaDB Database Server
- Multimedia
- Network File System Client
- Network Infrastructure Server
- Networking Tools
- Office Suite and Productivity
- PHP Support
- Performance Tools
- Perl Support
- Perl for Web
- Platform Development
- PostgreSQL Database Client
- PostgreSQL Database Server
- Print Server
- Printing Client
- Python
- Remote Desktop Clients
- Remote Management for Linux
- Resilient Storage
- Ruby Support
- Scientific Support
- Security Tools
- Smart Card Support
- System Administration Tools
- System Management
- Technical Writing
- VMware platform specific packages
- Virtualization Client
- Virtualization Hypervisor
- Virtualization Platform
- Virtualization Tools
- Web Server
- Web Servlet Engine
- X Window System
available environments:
- Minimal Install
- Compute Node
- Infrastructure Server
- File and Print Server
- Basic Web Server
- Virtualization Host
- Server with GUI
- GNOME Desktop
- KDE Plasma Workspaces
- Development and Creative Workstation
available languages:
----------
installed:
installed environments:
安装软件
[root@vm1 ~]# salt 'vm1' pkg.install wget
vm1:
----------
列出已下载到本地的软件包
[root@vm1 ~]# salt 'vm1' pkg.list_downloaded
vm1:
----------
wget:
----------
1.14-18.el7_6.1:
----------
creation_date_time:
2020-08-18T22:19:00
creation_date_time_t:
1597803540
path:
/var/cache/yum/packages/wget-1.14-18.el7_6.1.x86_64.rpm
size:
560272
以字典的方式列出当前已安装的软件包
[root@vm1 ~]# salt 'vm1' pkg.list_pkgs
vm1:
----------
GeoIP:
1.5.0-11.el7
NetworkManager:
1:1.10.2-13.el7
NetworkManager-libnm:
1:1.10.2-13.el7
NetworkManager-team:
1:1.10.2-13.el7
NetworkManager-tui:
1:1.10.2-13.el7
PyYAML:
3.11-1.el7
acl:
2.2.51-14.el7
aic94xx-firmware:
30-6.el7
alsa-firmware:
1.0.28-2.el7
alsa-lib:
1.1.4.1-2.el7
alsa-tools-firmware:
1.1.0-1.el7
audit:
2.8.1-3.el7
audit-libs:
2.8.1-3.el7
authconfig:
6.2.8-30.el7
basesystem:
10.0-7.el7.centos
bash:
4.2.46-30.el7
bind-libs-lite:
32:9.9.4-61.el7
bind-license:
32:9.9.4-61.el7
binutils:
2.27-27.base.el7
biosdevname:
0.7.3-1.el7
btrfs-progs:
4.9.1-1.el7
bzip2-libs:
1.0.6-13.el7
ca-certificates:
2017.2.20-71.el7
centos-logos:
70.0.6-3.el7.centos
centos-release:
7-5.1804.el7.centos
chkconfig:
1.7.4-1.el7
chrony:
3.2-2.el7
coreutils:
8.22-21.el7
cpio:
2.11-27.el7
cracklib:
2.9.0-11.el7
cracklib-dicts:
2.9.0-11.el7
cronie:
1.4.11-19.el7
cronie-anacron:
1.4.11-19.el7
crontabs:
1.11-6.20121102git.el7
cryptsetup-libs:
2.0.3-6.el7
curl:
7.29.0-46.el7
cyrus-sasl-lib:
2.1.26-23.el7
dbus:
1:1.10.24-7.el7
dbus-glib:
0.100-7.el7
dbus-libs:
1:1.10.24-7.el7
dbus-python:
1.1.1-9.el7
device-mapper:
7:1.02.146-4.el7
device-mapper-event:
7:1.02.146-4.el7
device-mapper-event-libs:
7:1.02.146-4.el7
device-mapper-libs:
7:1.02.146-4.el7
device-mapper-persistent-data:
0.7.3-3.el7
dhclient:
12:4.2.5-68.el7.centos
dhcp-common:
12:4.2.5-68.el7.centos
dhcp-libs:
12:4.2.5-68.el7.centos
diffutils:
3.3-4.el7
dmidecode:
1:3.0-5.el7
dracut:
033-535.el7
dracut-config-rescue:
033-535.el7
dracut-network:
033-535.el7
e2fsprogs:
1.42.9-11.el7
e2fsprogs-libs:
1.42.9-11.el7
ebtables:
2.0.10-16.el7
elfutils-default-yama-scope:
0.170-4.el7
elfutils-libelf:
0.170-4.el7
elfutils-libs:
0.170-4.el7
ethtool:
2:4.8-7.el7
expat:
2.1.0-10.el7_3
file:
5.11-33.el7
file-libs:
5.11-33.el7
filesystem:
3.2-25.el7
findutils:
1:4.5.11-5.el7
fipscheck:
1.4.1-6.el7
fipscheck-lib:
1.4.1-6.el7
firewalld:
0.4.4.4-14.el7
firewalld-filesystem:
0.4.4.4-14.el7
freetype:
2.4.11-15.el7
fuse:
2.9.2-10.el7
fuse-libs:
2.9.2-10.el7
fxload:
2002_04_11-16.el7
gawk:
4.0.2-4.el7_3.1
gdbm:
1.10-8.el7
gettext:
0.19.8.1-2.el7
gettext-libs:
0.19.8.1-2.el7
glib2:
2.54.2-2.el7
glibc:
2.17-222.el7
glibc-common:
2.17-222.el7
gmp:
1:6.0.0-15.el7
gnupg2:
2.0.22-4.el7
gobject-introspection:
1.50.0-1.el7
gpg-pubkey.(none):
de57bfbe-53a9be98,f4a80eb5-53a7ff4b
gpgme:
1.3.2-5.el7
gpm-libs:
1.20.7-6.el7
grep:
2.20-3.el7
groff-base:
1.22.2-8.el7
grub2:
1:2.02-0.65.el7.centos.2
grub2-common:
1:2.02-0.65.el7.centos.2
grub2-pc:
1:2.02-0.65.el7.centos.2
grub2-pc-modules:
1:2.02-0.65.el7.centos.2
grub2-tools:
1:2.02-0.65.el7.centos.2
grub2-tools-extra:
1:2.02-0.65.el7.centos.2
grub2-tools-minimal:
1:2.02-0.65.el7.centos.2
grubby:
8.28-23.el7
gzip:
1.5-10.el7
hardlink:
1:1.0-19.el7
hostname:
3.13-3.el7
hwdata:
0.252-8.8.el7
info:
5.1-5.el7
initscripts:
9.49.41-1.el7
iproute:
4.11.0-14.el7
iprutils:
2.4.15.1-1.el7
ipset:
6.29-1.el7
ipset-libs:
6.29-1.el7
iptables:
1.4.21-24.el7
iputils:
20160308-10.el7
irqbalance:
3:1.0.7-11.el7
ivtv-firmware:
2:20080701-26.el7
iwl100-firmware:
39.31.5.1-62.el7
iwl1000-firmware:
1:39.31.5.1-62.el7
iwl105-firmware:
18.168.6.1-62.el7
iwl135-firmware:
18.168.6.1-62.el7
iwl2000-firmware:
18.168.6.1-62.el7
iwl2030-firmware:
18.168.6.1-62.el7
iwl3160-firmware:
22.0.7.0-62.el7
iwl3945-firmware:
15.32.2.9-62.el7
iwl4965-firmware:
228.61.2.24-62.el7
iwl5000-firmware:
8.83.5.1_1-62.el7
iwl5150-firmware:
8.24.2.2-62.el7
iwl6000-firmware:
9.221.4.1-62.el7
iwl6000g2a-firmware:
17.168.5.3-62.el7
iwl6000g2b-firmware:
17.168.5.2-62.el7
iwl6050-firmware:
41.28.5.1-62.el7
iwl7260-firmware:
22.0.7.0-62.el7
iwl7265-firmware:
22.0.7.0-62.el7
jansson:
2.10-1.el7
json-c:
0.11-4.el7_0
kbd:
1.15.5-13.el7
kbd-legacy:
1.15.5-13.el7
kbd-misc:
1.15.5-13.el7
kernel:
3.10.0-862.el7
kernel-tools:
3.10.0-862.el7
kernel-tools-libs:
3.10.0-862.el7
kexec-tools:
2.0.15-13.el7
keyutils-libs:
1.5.8-3.el7
kmod:
20-21.el7
kmod-libs:
20-21.el7
kpartx:
0.4.9-119.el7
krb5-libs:
1.15.1-18.el7
less:
458-9.el7
libacl:
2.2.51-14.el7
libaio:
0.3.109-13.el7
libassuan:
2.1.0-3.el7
libattr:
2.4.46-13.el7
libblkid:
2.23.2-52.el7
libcap:
2.22-9.el7
libcap-ng:
0.7.5-4.el7
libcom_err:
1.42.9-11.el7
libcroco:
0.6.11-1.el7
libcurl:
7.29.0-46.el7
libdaemon:
0.14-7.el7
libdb:
5.3.21-24.el7
libdb-utils:
5.3.21-24.el7
libdnet:
1.12-13.1.el7
libdrm:
2.4.83-2.el7
libedit:
3.0-12.20121213cvs.el7
libestr:
0.1.9-2.el7
libfastjson:
0.99.4-2.el7
libffi:
3.0.13-18.el7
libgcc:
4.8.5-28.el7
libgcrypt:
1.5.3-14.el7
libgomp:
4.8.5-28.el7
libgpg-error:
1.12-3.el7
libicu:
50.1.2-15.el7
libidn:
1.28-4.el7
libmnl:
1.0.3-7.el7
libmount:
2.23.2-52.el7
libmspack:
0.5-0.5.alpha.el7
libndp:
1.2-7.el7
libnetfilter_conntrack:
1.0.6-1.el7_3
libnfnetlink:
1.0.1-4.el7
libnl3:
3.2.28-4.el7
libnl3-cli:
3.2.28-4.el7
libpciaccess:
0.14-1.el7
libpipeline:
1.2.3-3.el7
libpwquality:
1.2.3-5.el7
libseccomp:
2.3.1-3.el7
libselinux:
2.5-12.el7
libselinux-python:
2.5-12.el7
libselinux-utils:
2.5-12.el7
libsemanage:
2.5-11.el7
libsepol:
2.5-8.1.el7
libsodium:
1.0.16-1.el7
libss:
1.42.9-11.el7
libssh2:
1.4.3-10.el7_2.1
libstdc++:
4.8.5-28.el7
libsysfs:
2.1.0-16.el7
libtasn1:
4.10-1.el7
libteam:
1.27-4.el7
libtomcrypt:
1.17-26.el7
libtommath:
0.42.0-6.el7
libtool-ltdl:
2.4.2-22.el7_3
libunistring:
0.9.3-9.el7
libuser:
0.60-9.el7
libutempter:
1.1.6-4.el7
libuuid:
2.23.2-52.el7
libverto:
0.2.5-4.el7
libxml2:
2.9.1-6.el7.4
libxml2-python:
2.9.1-6.el7.4
libxslt:
1.1.28-5.el7
libyaml:
0.1.4-11.el7_0
linux-firmware:
20180220-62.git6d51311.el7
logrotate:
3.8.6-15.el7
lshw:
B.02.18-12.el7
lsscsi:
0.27-6.el7
lua:
5.1.4-15.el7
lvm2:
7:2.02.177-4.el7
lvm2-libs:
7:2.02.177-4.el7
lz4:
1.7.5-2.el7
lzo:
2.06-8.el7
make:
1:3.82-23.el7
man-db:
2.6.3-9.el7
mariadb-libs:
1:5.5.56-2.el7
microcode_ctl:
2:2.1-29.el7
mozjs17:
17.0.0-20.el7
ncurses:
5.9-14.20130511.el7_4
ncurses-base:
5.9-14.20130511.el7_4
ncurses-libs:
5.9-14.20130511.el7_4
newt:
0.52.15-4.el7
newt-python:
0.52.15-4.el7
nspr:
4.17.0-1.el7
nss:
3.34.0-4.el7
nss-pem:
1.0.3-4.el7
nss-softokn:
3.34.0-2.el7
nss-softokn-freebl:
3.34.0-2.el7
nss-sysinit:
3.34.0-4.el7
nss-tools:
3.34.0-4.el7
nss-util:
3.34.0-2.el7
numactl-libs:
2.0.9-7.el7
open-vm-tools:
10.1.10-3.el7
openldap:
2.4.44-13.el7
openpgm:
5.2.122-2.el7
openssh:
7.4p1-16.el7
openssh-clients:
7.4p1-16.el7
openssh-server:
7.4p1-16.el7
openssl:
1:1.0.2k-12.el7
openssl-libs:
1:1.0.2k-12.el7
os-prober:
1.58-9.el7
p11-kit:
0.23.5-3.el7
p11-kit-trust:
0.23.5-3.el7
pam:
1.1.8-22.el7
parted:
3.1-29.el7
passwd:
0.79-4.el7
pciutils:
3.5.1-3.el7
pciutils-libs:
3.5.1-3.el7
pcre:
8.32-17.el7
perl:
4:5.16.3-295.el7
perl-Carp:
1.26-244.el7
perl-Encode:
2.51-7.el7
perl-Exporter:
5.68-3.el7
perl-File-Path:
2.09-2.el7
perl-File-Temp:
0.23.01-3.el7
perl-Filter:
1.49-3.el7
perl-Getopt-Long:
2.40-3.el7
perl-HTTP-Tiny:
0.033-3.el7
perl-PathTools:
3.40-5.el7
perl-Pod-Escapes:
1:1.04-295.el7
perl-Pod-Perldoc:
3.20-4.el7
perl-Pod-Simple:
1:3.28-4.el7
perl-Pod-Usage:
1.63-3.el7
perl-Scalar-List-Utils:
1.27-248.el7
perl-Socket:
2.010-5.el7
perl-Storable:
2.45-3.el7
perl-Text-ParseWords:
3.29-4.el7
perl-Time-HiRes:
4:1.9725-3.el7
perl-Time-Local:
1.2300-2.el7
perl-constant:
1.27-2.el7
perl-libs:
4:5.16.3-295.el7
perl-macros:
4:5.16.3-295.el7
perl-parent:
1:0.225-244.el7
perl-podlators:
2.5.1-3.el7
perl-threads:
1.87-4.el7
perl-threads-shared:
1.43-6.el7
pinentry:
0.8.1-17.el7
pkgconfig:
1:0.27.1-4.el7
plymouth:
0.8.9-0.31.20140113.el7.centos
plymouth-core-libs:
0.8.9-0.31.20140113.el7.centos
plymouth-scripts:
0.8.9-0.31.20140113.el7.centos
policycoreutils:
2.5-22.el7
polkit:
0.112-14.el7
polkit-pkla-compat:
0.1-4.el7
popt:
1.13-16.el7
postfix:
2:2.10.1-6.el7
procps-ng:
3.3.10-17.el7
pth:
2.0.7-23.el7
pygpgme:
0.3-9.el7
pyliblzma:
0.5.3-11.el7
python:
2.7.5-68.el7
python-babel:
0.9.6-8.el7
python-backports:
1.0-8.el7
python-backports-ssl_match_hostname:
3.5.0.1-1.el7
python-backports_abc:
0.5-11.el7
python-chardet:
2.2.1-3.el7
python-configobj:
4.7.2-7.el7
python-decorator:
3.4.0-3.el7
python-firewall:
0.4.4.4-14.el7
python-gobject-base:
3.22.0-1.el7_4.1
python-iniparse:
0.4-9.el7
python-ipaddress:
1.0.16-2.el7
python-jinja2:
2.7.2-4.el7
python-kitchen:
1.1.1-5.el7
python-libs:
2.7.5-68.el7
python-linux-procfs:
0.4.9-3.el7
python-markupsafe:
0.11-10.el7
python-perf:
3.10.0-862.el7
python-psutil:
2.2.1-1.el7
python-pycurl:
7.19.0-19.el7
python-pyudev:
0.15-9.el7
python-requests:
2.6.0-9.el7_8
python-schedutils:
0.4-6.el7
python-setuptools:
36.6.0-3.ius.el7
python-singledispatch:
3.4.0.3-16.el7
python-six:
1.9.0-2.el7
python-slip:
0.4.0-4.el7
python-slip-dbus:
0.4.0-4.el7
python-urlgrabber:
3.10-8.el7
python-urllib3:
1.10.2-7.el7
python-zmq:
15.3.0-3.el7
python2-crypto:
2.6.1-15.el7
python2-futures:
3.1.1-5.el7
python2-msgpack:
0.6.2-2.el7
pyxattr:
0.5.1-5.el7
qrencode-libs:
3.4.1-3.el7
readline:
6.2-10.el7
rootfiles:
8.1-11.el7
rpm:
4.11.3-32.el7
rpm-build-libs:
4.11.3-32.el7
rpm-libs:
4.11.3-32.el7
rpm-python:
4.11.3-32.el7
rsyslog:
8.24.0-16.el7
salt:
3000.3-1.el7
salt-master:
3000.3-1.el7
salt-minion:
3000.3-1.el7
salt-repo:
latest-2.el7
salt-ssh:
3000.3-1.el7
salt-syndic:
3000.3-1.el7
sed:
4.2.2-5.el7
selinux-policy:
3.13.1-192.el7
selinux-policy-targeted:
3.13.1-192.el7
setup:
2.8.71-9.el7
sg3_utils:
1.37-12.el7
sg3_utils-libs:
1.37-12.el7
shadow-utils:
2:4.1.5.1-24.el7
shared-mime-info:
1.8-4.el7
slang:
2.2.4-11.el7
snappy:
1.1.0-3.el7
sqlite:
3.7.17-8.el7
sudo:
1.8.19p2-13.el7
systemd:
219-73.el7_8.9
systemd-libs:
219-73.el7_8.9
systemd-python:
219-73.el7_8.9
systemd-sysv:
219-73.el7_8.9
sysvinit-tools:
2.88-14.dsf.el7
tar:
2:1.26-34.el7
tcp_wrappers-libs:
7.6-77.el7
teamd:
1.27-4.el7
tree:
1.6.0-10.el7
tuned:
2.9.0-1.el7
tzdata:
2018c-1.el7
ustr:
1.0.4-16.el7
util-linux:
2.23.2-52.el7
vim-common:
2:7.4.629-6.el7
vim-enhanced:
2:7.4.629-6.el7
vim-filesystem:
2:7.4.629-6.el7
vim-minimal:
2:7.4.160-4.el7
virt-what:
1.18-4.el7
wget:
1.14-18.el7_6.1
which:
2.20-7.el7
wpa_supplicant:
1:2.6-9.el7
xfsprogs:
4.5.0-15.el7
xmlsec1:
1.2.20-7.el7_4
xmlsec1-openssl:
1.2.20-7.el7_4
xz:
5.2.2-1.el7
xz-libs:
5.2.2-1.el7
yum:
3.4.3-158.el7.centos
yum-metadata-parser:
1.1.4-10.el7
yum-plugin-fastestmirror:
1.1.31-45.el7
yum-utils:
1.1.31-54.el7_8
zeromq:
4.1.4-7.el7
zlib:
1.2.7-17.el7
列出指定文件是由哪个包提供的
[root@vm1 ~]# salt 'vm2' pkg.owner /usr/sbin/apachectl
vm2:
httpd
卸载指定软件
[root@vm1 ~]# salt 'vm1' cmd.run 'rpm -qa|grep wget'
vm1:
wget-1.14-18.el7_6.1.x86_64
[root@vm1 ~]# salt 'vm1' pkg.remove wget
vm1:
----------
wget:
----------
new:
old:
1.14-18.el7_6.1
//若要卸载多个文件,中间需要用逗号隔开
升级系统中所有的软件包或升级指定的软件包
[root@vm1 ~]# salt 'vm1' pkg.upgrade name=openssl
vm1:
----------
openssl:
----------
new:
1:1.0.2k-19.el7
old:
1:1.0.2k-12.el7
openssl-libs:
----------
new:
1:1.0.2k-19.el7
old:
1:1.0.2k-12.el7
//若想升级系统中所有的软件包则把 name 参数去掉即可
显示当前系统中有哪些高级状态
[root@vm1 ~]# salt 'vm2' state.show_highstate
vm2:
----------
apache-install:
----------
__env__:
base
__sls__:
web.apache.apache
pkg:
|_
----------
name:
httpd
- installed
|_
----------
order:
10000
apache-service:
----------
__env__:
base
__sls__:
web.apache.apache
service:
|_
----------
name:
httpd
|_
----------
enable:
True
- running
|_
----------
order:
执行高级状态
[root@vm1 ~]# salt 'vm2' state.highstate web.apache.apache
vm2:
----------
ID: apache-install
Function: pkg.installed
Name: httpd
Result: True
Comment: All specified packages are already installed
Started: 22:41:16.474496
Duration: 604.652 ms
Changes:
----------
ID: apache-service
Function: service.running
Name: httpd
Result: True
Comment: The service httpd is already running
Started: 22:41:17.080059
Duration: 55.044 ms
Changes:
Summary for vm2
------------
Succeeded: 2
Failed: 0
------------
Total states run: 2
Total run time: 659.696 ms
显示当前系统中的高级状态执行情况
[root@vm1 ~]# salt 'vm2' state.show_state_usage
vm2:
----------
base:
----------
count_all:
3
count_unused:
2
count_used:
1
unused:
- top
- web.nginx.nginx
used:
- web.apache.apache
返回minion将用于highstate的顶级数据
[root@vm1 ~]# salt 'vm2' state.show_top
vm2:
----------
base:
- web.apache.apache
执行指定的top file,而不是默认的
[root@vm1 ~]# salt 'vm2' state.top top.sls
vm2:
----------
ID: apache-install
Function: pkg.installed
Name: httpd
Result: True
Comment: All specified packages are already installed
Started: 22:46:16.997458
Duration: 583.157 ms
Changes:
----------
ID: apache-service
Function: service.running
Name: httpd
Result: True
Comment: The service httpd is already running
Started: 22:46:17.582087
Duration: 54.532 ms
Changes:
Summary for vm2
------------
Succeeded: 2
Failed: 0
------------
Total states run: 2
Total run time: 637.689 ms
显示 master 上特定sls或sls文件列表中的状态数据
[root@vm1 ~]# salt 'vm2' state.show_sls web.apache.apache
vm2:
----------
apache-install:
----------
__env__:
base
__sls__:
web.apache.apache
pkg:
|_
----------
name:
httpd
- installed
|_
----------
order:
10000
apache-service:
----------
__env__:
base
__sls__:
web.apache.apache
service:
|_
----------
name:
httpd
|_
----------
enable:
True
- running
|_
----------
order:
10001
salt-cp能够很方便的把 vm1 上的文件批量传到 vm2上
//拷贝单个文件到目标主机的/usr/src目录下
[root@vm1 ~]# salt 'vm2' cmd.run 'ls /usr/src/'
vm2:
debug
kernels
[root@vm1 ~]# salt-cp 'vm2' /etc/passwd /usr/src
vm2:
----------
/usr/src/passwd:
True
[root@vm1 ~]# salt 'vm2' cmd.run 'ls /usr/src/'
vm2:
debug
kernels
passwd
//拷贝多个文件到目标主机的/usr/src目录下
[root@vm1 ~]# salt-cp 'vm2' /etc/shadow /etc/group /usr/src
vm2:
----------
/usr/src/group:
True
/usr/src/shadow:
True
[root@vm1 ~]# salt 'vm2' cmd.run 'ls /usr/src/'
vm2:
debug
group
kernels
passwd
shadow
检查指定路径是否存在
[root@vm1 ~]# salt 'vm1' cmd.run 'ls /usr/src'
vm1:
debug
kernels
[root@vm1 ~]# salt 'vm1' file.access /usr/src/debug f
vm1:
True
[root@vm1 ~]# salt 'vm1' file.access /usr/src/yy f
vm1:
False
检查指定文件的权限信息
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /usr/src/'
vm1:
total 0
drwxr-xr-x. 2 root root 6 Apr 11 2018 debug
drwxr-xr-x. 2 root root 6 Apr 11 2018 kernels
-rw-r--r-- 1 root root 0 Aug 19 20:44 yan
drwxr-xr-x 2 root root 6 Aug 19 20:44 yy
[root@vm1 ~]# salt 'vm1' file.access /usr/src/yan r
vm1:
True
[root@vm1 ~]# salt 'vm1' file.access /usr/src/yan w
vm1:
True
[root@vm1 ~]# salt 'vm1' file.access /usr/src/yan x
vm1:
False
往一个文件里追加内容,若此文件不存在则会报异常
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /root/ww'
vm1:
-rw-r--r-- 1 root root 0 Aug 19 20:47 /root/ww
[root@vm1 ~]# salt 'vm1' file.append /root/ww "a" "b" "c"
vm1:
Wrote 3 lines to "/root/ww"
[root@vm1 ~]# salt 'vm1' cmd.run 'cat /root/ww'
vm1:
a
b
c
获取指定路径的基名
[root@vm1 ~]# salt 'vm1' file.basename '/root/ww'
vm1:
ww
获取指定路径的目录名
[root@vm1 ~]# salt 'vm1' file.dirname '/root/ww'
vm1:
/root
检查指定的文件与hash字符串是否匹配,匹配则返回 True 否则返回 False
[root@vm1 ~]# salt 'vm1' cmd.run 'md5sum /root/ww'
vm1:
40c53c58fdafacc83cfff6ee3d2f6d69 /root/ww
[root@vm1 ~]# salt 'vm1' file.check_hash /root/ww 40c53c58fdafacc83cfff6ee3d2f6d69
vm1:
True
修改指定文件的属性
属性 | 对文件的意义 | 对目录的意义 |
---|---|---|
a | 只允许在这个文件之后追加数据, 不允许任何进程覆盖或截断这个文件 |
只允许在这个目录下建立和修改文件, 而不允许删除任何文件 |
i | 不允许对这个文件进行任何的修改, 不能删除、更改、移动 |
任何的进程只能修改目录之下的文件, 不允许建立和删除文件 |
给指定文件添加属性
//查看当前属性
[root@vm1 ~]# salt 'vm1' cmd.run 'lsattr /root'
vm1:
---------------- /root/anaconda-ks.cfg
---------------- /root/salt-repo-latest-2.el7.noarch.rpm
---------------- /root/ww
//添加属性
[root@vm1 ~]# salt 'vm1' file.chattr /root/ww operator=add attributes=ai
vm1:
True
[root@vm1 ~]# salt 'vm1' cmd.run 'lsattr /root'
vm1:
---------------- /root/anaconda-ks.cfg
---------------- /root/salt-repo-latest-2.el7.noarch.rpm
----ia---------- /root/ww
给指定文件去除属性
[root@vm1 ~]# salt 'vm1' file.chattr /root/ww operator=remove attributes=i
vm1:
True
[root@vm1 ~]# salt 'vm1' cmd.run 'lsattr /root'
vm1:
---------------- /root/anaconda-ks.cfg
---------------- /root/salt-repo-latest-2.el7.noarch.rpm
-----a---------- /root/ww
设置指定文件的属主、属组信息
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /root/'
vm1:
total 16
-rw-r--r-- 1 root root 0 Aug 19 21:18 abc
-rw-------. 1 root root 1260 Jul 3 14:50 anaconda-ks.cfg
-rw-r--r-- 1 root root 5748 Apr 29 15:39 salt-repo-latest-2.el7.noarch.rpm
-rw-r--r-- 1 root root 6 Aug 19 20:49 ww
[root@vm1 ~]# salt 'vm1' file.chown /root/abc tom tom
vm1:
None
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /root/'
vm1:
total 16
-rw-r--r-- 1 tom tom 0 Aug 19 21:18 abc
-rw-------. 1 root root 1260 Jul 3 14:50 anaconda-ks.cfg
-rw-r--r-- 1 root root 5748 Apr 29 15:39 salt-repo-latest-2.el7.noarch.rpm
-rw-r--r-- 1 root root 6 Aug 19 20:49 ww
在远程主机上复制文件或目录
拷贝文件
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /root/'
vm1:
total 16
-rw-r--r-- 1 tom tom 0 Aug 19 21:18 abc
-rw-------. 1 root root 1260 Jul 3 14:50 anaconda-ks.cfg
-rw-r--r-- 1 root root 5748 Apr 29 15:39 salt-repo-latest-2.el7.noarch.rpm
-rw-r--r-- 1 root root 6 Aug 19 20:49 ww
[root@vm1 ~]# salt 'vm1' file.copy /root/abc /root/yy
vm1:
True
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /root/'
vm1:
total 16
-rw-r--r-- 1 tom tom 0 Aug 19 21:18 abc
-rw-------. 1 root root 1260 Jul 3 14:50 anaconda-ks.cfg
-rw-r--r-- 1 root root 5748 Apr 29 15:39 salt-repo-latest-2.el7.noarch.rpm
-rw-r--r-- 1 root root 6 Aug 19 20:49 ww
-rw-r--r-- 1 tom tom 0 Aug 19 21:21 yy
覆盖并拷贝目录,将会覆盖同名文件或目录
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /root/'
vm1:
total 16
-rw-r--r-- 1 tom tom 0 Aug 19 21:18 abc
-rw-------. 1 root root 1260 Jul 3 14:50 anaconda-ks.cfg
-rw-r--r-- 1 root root 5748 Apr 29 15:39 salt-repo-latest-2.el7.noarch.rpm
-rw-r--r-- 1 root root 6 Aug 19 20:49 ww
-rw-r--r-- 1 tom tom 0 Aug 19 21:21 yy
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /tmp/'
vm1:
total 0
-rw-r--r-- 1 root root 0 Aug 19 21:24 cc
drwxr-xr-x 2 root root 6 Aug 19 21:24 ll
drwx------ 3 root root 17 Aug 19 20:26 systemd-private-f98e86bf2975456ab89ff96f7445d434-chronyd.service-IQPGmc
-rw-r--r-- 1 root root 0 Aug 19 21:24 yy
[root@vm1 ~]# salt 'vm1' file.copy /tmp/ /root/ll recurse=True
vm1:
True
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /root/'
vm1:
total 16
-rw-r--r-- 1 tom tom 0 Aug 19 21:18 abc
-rw-------. 1 root root 1260 Jul 3 14:50 anaconda-ks.cfg
drwxrwxrwt 9 root root 202 Aug 19 21:26 ll
-rw-r--r-- 1 root root 5748 Apr 29 15:39 salt-repo-latest-2.el7.noarch.rpm
-rw-r--r-- 1 root root 6 Aug 19 20:49 ww
-rw-r--r-- 1 tom tom 0 Aug 19 21:21 yy
删除目标目录中同名的文件或目录并拷贝新内容至其中
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /root/ll'
vm1:
total 0
-rw-r--r-- 1 root root 0 Aug 19 21:32 aa
-rw-r--r-- 1 root root 0 Aug 19 21:26 cc
drwxr-xr-x 2 root root 6 Aug 19 21:26 ll
drwxr-xr-x 3 root root 17 Aug 19 21:26 systemd-private-f98e86bf2975456ab89ff96f7445d434-chronyd.service-IQPGmc
-rw-r--r-- 1 root root 0 Aug 19 21:26 yy
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /tmp/ll'
vm1:
total 0
-rw-r--r-- 1 root root 0 Aug 19 21:31 aa
-rw-r--r-- 1 root root 0 Aug 19 21:31 bb
drwxr-xr-x 2 root root 6 Aug 19 21:31 cc
//拷贝目录
[root@vm1 ~]# salt 'vm1' file.copy /tmp/ll /root/ll recurse=True remove_existing=True
vm1:
True
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /root/ll'
vm1:
total 0
-rw-r--r-- 1 root root 0 Aug 19 21:31 aa
-rw-r--r-- 1 root root 0 Aug 19 21:31 bb
drwxr-xr-x 2 root root 6 Aug 19 21:31 cc
判断指定目录是否存在,存在则返回 True ,否则返回 False
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /root/ll'
vm1:
total 0
-rw-r--r-- 1 root root 0 Aug 19 21:31 aa
-rw-r--r-- 1 root root 0 Aug 19 21:31 bb
drwxr-xr-x 2 root root 6 Aug 19 21:31 cc
[root@vm1 ~]# salt 'vm1' file.directory_exists /root/ll/cc
vm1:
True
递归计算指定路径的磁盘使用情况并以字节为单位返回
[root@vm1 ~]# salt 'vm1' cmd.run 'du -sb /root'
vm1:
9116 /root
[root@vm1 ~]# salt 'vm1' file.diskusage /root
vm1:
8804
判断指定文件是否存在
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /root'
vm1:
total 16
-rw-r--r-- 1 tom tom 0 Aug 19 21:18 abc
-rw-------. 1 root root 1260 Jul 3 14:50 anaconda-ks.cfg
drwxr-xr-x 3 root root 36 Aug 19 21:31 ll
-rw-r--r-- 1 root root 5748 Apr 29 15:39 salt-repo-latest-2.el7.noarch.rpm
-rw-r--r-- 1 root root 6 Aug 19 20:49 ww
-rw-r--r-- 1 tom tom 0 Aug 19 21:21 yy
[root@vm1 ~]# salt 'vm1' file.file_exists /root/yy
vm1:
True
[root@vm1 ~]# salt 'vm1' file.file_exists /root/ll
vm1:
False
类似 find 命令并返回符合指定条件的路径列表
The options include match criteria:
name = path-glob # case sensitive
iname = path-glob # case insensitive
regex = path-regex # case sensitive
iregex = path-regex # case insensitive
type = file-types # match any listed type
user = users # match any listed user
group = groups # match any listed group
size = [+-]number[size-unit] # default unit = byte
mtime = interval # modified since date
grep = regex # search file contents
and/or actions:
delete [= file-types] # default type = 'f'
exec = command [arg ...] # where {} is replaced by pathname
print [= print-opts]
and/or depth criteria:
maxdepth = maximum depth to transverse in path
mindepth = minimum depth to transverse before checking files or directories
The default action is print=path
path-glob:
* = match zero or more chars
? = match any char
[abc] = match a, b, or c
[!abc] or [^abc] = match anything except a, b, and c
[x-y] = match chars x through y
[!x-y] or [^x-y] = match anything except chars x through y
{a,b,c} = match a or b or c
path-regex: a Python Regex (regular expression) pattern to match pathnames
file-types: a string of one or more of the following:
a: all file types
b: block device
c: character device
d: directory
p: FIFO (named pipe)
f: plain file
l: symlink
s: socket
users: a space and/or comma separated list of user names and/or uids
groups: a space and/or comma separated list of group names and/or gids
size-unit:
b: bytes
k: kilobytes
m: megabytes
g: gigabytes
t: terabytes
interval:
[w] [d] [h] [m] [s]
where:
w: week
d: day
h: hour
m: minute
s: second
print-opts: a comma and/or space separated list of one or more of the following:
group: group name
md5: MD5 digest of file contents
mode: file permissions (as integer)
mtime: last modification time (as time_t)
name: file basename
path: file absolute path
size: file size in bytes
type: file type
user: user name
示例:
salt 'vm1' file.find / type=f name=\*.bak size=+10m
salt 'vm1' file.find /var mtime=+30d size=+10m print=path,size,mtime
salt 'vm1' file.find /var/log name=\*.[0-9] mtime=+30d size=+10m delete
获取指定文件的gid
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /root/abc'
vm1:
-rw-r--r-- 1 tom tom 0 Aug 19 21:18 /root/abc
[root@vm1 ~]# salt 'vm1' file.get_gid /root/abc
vm1:
1000
获取指定文件的组名
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /root/abc'
vm1:
-rw-r--r-- 1 tom tom 0 Aug 19 21:18 /root/abc
[root@vm1 ~]# salt 'vm1' file.get_group /root/abc
vm1:
tom
获取指定文件的hash值,该值通过 sha256 算法得来
[root@vm1 ~]# salt 'vm1' cmd.run 'sha256sum /root/abc'
vm1:
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 /root/abc
[root@vm1 ~]# salt 'vm1' file.get_hash /root/abc
vm1:
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
获取指定文件的权限,以数字方式显示
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /root/abc'
vm1:
-rw-r--r-- 1 tom tom 0 Aug 19 21:18 /root/abc
[root@vm1 ~]# salt 'vm1' file.get_mode /root/abc
vm1:
0644
获取指定文件的 SELINUX 上下文信息
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -Z /root/anaconda-ks.cfg'
vm1:
-rw-------. root root system_u:object_r:admin_home_t:s0 /root/anaconda-ks.cfg
[root@vm1 ~]# salt 'vm1' file.get_selinux_context /root/anaconda-ks.cfg
vm1:
system_u:object_r:admin_home_t:s0
按照指定的算法计算指定文件的特征码并显示,默认使用的sha256算法。
该函数可使用的算法参数有:
[root@vm1 ~]# salt 'vm1' cmd.run 'sha256sum /root/abc'
vm1:
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855 /root/abc
[root@vm1 ~]# salt 'vm1' file.get_sum /root/abc
vm1:
e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
[root@vm1 ~]# salt 'vm1' cmd.run 'md5sum /root/abc'
vm1:
d41d8cd98f00b204e9800998ecf8427e /root/abc
[root@vm1 ~]# salt 'vm1' file.get_sum /root/abc md5
vm1:
d41d8cd98f00b204e9800998ecf8427e
获取指定文件的 uid 或 用户名
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /root/abc'
vm1:
-rw-r--r-- 1 tom tom 0 Aug 19 21:18 /root/abc
[root@vm1 ~]# salt 'vm1' file.get_uid /root/abc
vm1:
1000
[root@vm1 ~]# salt 'vm1' file.get_user /root/abc
vm1:
tom
将指定的 gid 转换为组名并显示
[root@vm1 ~]# salt 'vm1' file.gid_to_group 1000
vm1:
tom
[root@vm1 ~]# salt 'vm1' file.gid_to_group 0
vm1:
root
将指定的组名转换为 gid 并显示
[root@vm1 ~]# salt 'vm1' file.group_to_gid root
vm1:
0
在指定文件中检索指定内容
该函数支持通配符,若在指定的路径中用通配符则必须用双引号引起来
salt '*' file.grep /etc/passwd nobody
salt '*' file.grep /etc/sysconfig/network-scripts/ifcfg-eth0 ipaddr -- -i
salt '*' file.grep /etc/sysconfig/network-scripts/ifcfg-eth0 ipaddr -- -i -B2
salt '*' file.grep "/etc/sysconfig/network-scripts/*" ipaddr -- -i -l
判断指定的文件是否是块设备文件
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /dev/sr0'
vm1:
brw-rw---- 1 root cdrom 11, 0 Aug 19 20:26 /dev/sr0
[root@vm1 ~]# salt 'vm1' file.is_blkdev /dev/sr0
vm1:
True
检查并显示出指定文件的属性信息
[root@vm1 ~]# salt 'vm1' cmd.run 'lsattr /root/abc'
vm1:
---------------- /root/abc
[root@vm1 ~]# salt 'vm1' cmd.run 'chattr +i /root/abc'
vm1:
[root@vm1 ~]# salt 'vm1' cmd.run 'lsattr /root/abc'
vm1:
----i----------- /root/abc
[root@vm1 ~]# salt 'vm1' file.lsattr /root/abc
vm1:
----------
/root/abc:
- i
创建目录并设置属主、属组及权限
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /root'
vm1:
total 16
-rw-r--r-- 1 tom tom 0 Aug 19 21:18 abc
-rw-------. 1 root root 1260 Jul 3 14:50 anaconda-ks.cfg
drwxr-xr-x 3 root root 36 Aug 19 21:31 ll
-rw-r--r-- 1 root root 5748 Apr 29 15:39 salt-repo-latest-2.el7.noarch.rpm
-rw-r--r-- 1 root root 6 Aug 19 20:49 ww
-rw-r--r-- 1 tom tom 0 Aug 19 21:21 yy
[root@vm1 ~]# salt 'vm1' file.mkdir /root/yan
vm1:
True
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /root'
vm1:
total 16
-rw-r--r-- 1 tom tom 0 Aug 19 21:18 abc
-rw-------. 1 root root 1260 Jul 3 14:50 anaconda-ks.cfg
drwxr-xr-x 3 root root 36 Aug 19 21:31 ll
-rw-r--r-- 1 root root 5748 Apr 29 15:39 salt-repo-latest-2.el7.noarch.rpm
-rw-r--r-- 1 root root 6 Aug 19 20:49 ww
drwxr-xr-x 2 root root 6 Aug 19 22:12 yan
-rw-r--r-- 1 tom tom 0 Aug 19 21:21 yy
[root@vm1 ~]# salt 'vm1' file.mkdir /root/yan tom tom 666
vm1:
True
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /root'
vm1:
total 16
-rw-r--r-- 1 tom tom 0 Aug 19 21:18 abc
-rw-------. 1 root root 1260 Jul 3 14:50 anaconda-ks.cfg
drwxr-xr-x 3 root root 36 Aug 19 21:31 ll
-rw-r--r-- 1 root root 5748 Apr 29 15:39 salt-repo-latest-2.el7.noarch.rpm
-rw-r--r-- 1 root root 6 Aug 19 20:49 ww
drwxr-xr-x 2 root root 6 Aug 19 22:12 yan
-rw-r--r-- 1 tom tom 0 Aug 19 21:21 yy
移动或重命名
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /tmp'
vm1:
total 0
-rw-r--r-- 1 root root 0 Aug 19 21:24 cc
drwxr-xr-x 3 root root 36 Aug 19 21:31 ll
drwx------ 3 root root 17 Aug 19 20:26 systemd-private-f98e86bf2975456ab89ff96f7445d434-chronyd.service-IQPGmc
-rw-r--r-- 1 root root 0 Aug 19 21:24 yy
[root@vm1 ~]# salt 'vm1' file.move /tmp/cc /tmp/aa
vm1:
----------
comment:
'/tmp/cc' moved to '/tmp/aa'
result:
True
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /tmp'
vm1:
total 0
-rw-r--r-- 1 root root 0 Aug 19 21:24 aa
drwxr-xr-x 3 root root 36 Aug 19 21:31 ll
drwx------ 3 root root 17 Aug 19 20:26 systemd-private-f98e86bf2975456ab89ff96f7445d434-chronyd.service-IQPGmc
-rw-r--r-- 1 root root 0 Aug 19 21:24 yy
//移动
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /tmp'
vm1:
total 0
-rw-r--r-- 1 root root 0 Aug 19 21:24 aa
-rw-r--r-- 1 root root 0 Aug 19 21:18 abc
drwxr-xr-x 3 root root 36 Aug 19 21:31 ll
drwx------ 3 root root 17 Aug 19 20:26 systemd-private-f98e86bf2975456ab89ff96f7445d434-chronyd.service-IQPGmc
-rw-r--r-- 1 root root 0 Aug 19 21:24 yy
[root@vm1 ~]# salt 'vm1' file.move /tmp/aa /opt
vm1:
----------
comment:
'/tmp/aa' moved to '/opt'
result:
True
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /opt'
vm1:
total 0
-rw-r--r-- 1 root root 0 Aug 19 21:24 aa
-rw-r--r-- 1 root root 0 Aug 19 22:23 aaa
把文本插入指定文件的开头
[root@vm1 ~]# salt 'vm1' cmd.run 'cat /opt/aa'
vm1:
hello
hello world
[root@vm1 ~]# salt 'vm1' file.prepend /opt/aa "a" "b" "c"
vm1:
Prepended 3 lines to "/opt/aa"
[root@vm1 ~]# salt 'vm1' cmd.run 'cat /opt/aa'
vm1:
a
b
c
hello
hello world
修改文本文件的内容
[root@vm1 ~]# salt 'vm1' cmd.run 'cat /opt/aa'
vm1:
a
b
c
hello
hello world
[root@vm1 ~]# salt 'vm1' file.sed /opt/aa 'hello' 'abc'
vm1:
----------
pid:
21071
retcode:
0
stderr:
stdout:
[root@vm1 ~]# salt 'vm1' cmd.run 'cat /opt/aa'
vm1:
a
b
c
abc
abc world
[root@vm1 ~]# salt 'vm1' cmd.run 'cat /opt/aa'
vm1:
a
b
c
abc
abc world
[root@vm1 ~]# salt 'vm1' file.sed /opt/aa 'abc' 'cd' flags=1
vm1:
----------
pid:
21213
retcode:
0
stderr:
stdout:
[root@vm1 ~]# salt 'vm1' cmd.run 'cat /opt/aa'
vm1:
a
b
c
cd
cd world
读取文件内容
[root@vm1 ~]# salt 'vm1' cmd.run 'cat /opt/aa'
vm1:
a
b
c
cd
cd world
[root@vm1 ~]# salt 'vm1' file.read /opt/aa
vm1:
a
b
c
cd
cd world
列出指定目录下的所有文件或目录,包括隐藏文件
[root@vm1 ~]# salt 'vm1' file.readdir /opt
vm1:
- .
- ..
- aaa
- aa.bak
- aa
删除指定的文件或目录,若给出的是目录,将递归删除
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /opt'
vm1:
total 8
-rw-r--r-- 1 root root 18 Aug 19 22:31 aa
-rw-r--r-- 1 root root 20 Aug 19 22:29 aa.bak
-rw-r--r-- 1 root root 0 Aug 19 22:23 aaa
[root@vm1 ~]# salt 'vm1' file.remove /opt/aaa
vm1:
True
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /opt'
vm1:
total 8
-rw-r--r-- 1 root root 18 Aug 19 22:31 aa
-rw-r--r-- 1 root root 20 Aug 19 22:29 aa.bak
重命名文件或目录
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /opt'
vm1:
total 8
-rw-r--r-- 1 root root 18 Aug 19 22:31 aa
-rw-r--r-- 1 root root 20 Aug 19 22:29 aa.bak
[root@vm1 ~]# salt 'vm1' file.rename /opt/aa /opt/bb
vm1:
True
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /opt'
vm1:
total 8
-rw-r--r-- 1 root root 20 Aug 19 22:29 aa.bak
-rw-r--r-- 1 root root 18 Aug 19 22:31 bb
给指定文件设置权限
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /opt'
vm1:
total 8
-rw-r--r-- 1 root root 20 Aug 19 22:29 aa.bak
-rw-r--r-- 1 root root 18 Aug 19 22:31 bb
[root@vm1 ~]# salt 'vm1' file.set_mode /opt/bb 0666
vm1:
0666
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /opt'
vm1:
total 8
-rw-r--r-- 1 root root 20 Aug 19 22:29 aa.bak
-rw-rw-rw- 1 root root 18 Aug 19 22:31 bb
给指定的文件创建软链接
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /opt'
vm1:
total 8
-rw-r--r-- 1 root root 20 Aug 19 22:29 aa.bak
-rw-rw-rw- 1 root root 18 Aug 19 22:31 bb
[root@vm1 ~]# salt 'vm1' file.symlink /opt/bb /mnt/a
vm1:
True
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /mnt'
vm1:
total 0
lrwxrwxrwx 1 root root 7 Aug 19 22:40 a -> /opt/bb
创建文件或更新时间戳
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /opt'
vm1:
total 8
-rw-r--r-- 1 root root 20 Aug 19 22:29 aa.bak
-rw-rw-rw- 1 root root 18 Aug 19 22:31 bb
[root@vm1 ~]# salt 'vm1' file.touch /opt/aa
vm1:
True
[root@vm1 ~]# salt 'vm1' cmd.run 'ls -l /opt'
vm1:
total 8
-rw-r--r-- 1 root root 0 Aug 19 22:41 aa
-rw-r--r-- 1 root root 20 Aug 19 22:29 aa.bak
-rw-rw-rw- 1 root root 18 Aug 19 22:31 bb
将指定的 uid 转换成用户名显示出来
[root@vm1 ~]# salt 'vm1' file.uid_to_user 1000
vm1:
tom
将指定的用户转换成 uid 并显示出来
[root@vm1 ~]# salt 'vm1' file.user_to_uid root
vm1:
0
往一个指定的文件里覆盖写入指定内容
[root@vm1 ~]# salt 'vm1' cmd.run 'cat /opt/bb'
vm1:
a
b
c
cd
cd world
[root@vm1 ~]# salt 'vm1' file.write /opt/bb "xixi" "yy" "zz"
vm1:
Wrote 3 lines to "/opt/bb"
[root@vm1 ~]# salt 'vm1' cmd.run 'cat /opt/bb'
vm1:
xixi
yy
zz