SaltStack常用模块

saltstack模块介绍

saltstack模块介绍

sys.list_modules 查看所有模块的列表

[root@node01 ~]# salt 'node02' sys.list_modules
node02:
    - acl
    - aliases
    - alternatives
    - ansible
    - apache
    - archive
    - artifactory
    - beacons
    - bigip
    - btrfs
    - buildout
    - 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
    - gem
    - genesis
    - glassfish
    - gnome
    - google_chat
    - grafana4
    - grains
    - group
    - hashutil
    - highstate_doc
    - hipchat
    - hosts
    - http
    - incron
    - ini
    - inspector
    - introspect
    - iosconfig
    - ip
    - ipset
    - iptables
    - jboss7
    - jboss7_cli
    - 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
    - pdbedit
    - peeringdb
    - pillar
    - pkg
    - pkg_resource
    - postfix
    - ps
    - publish
    - pushover
    - pyenv
    - random
    - random_org
    - rbenv
    - rest_sample_utils
    - restartcheck
    - ret
    - rvm
    - s3
    - s6
    - salt_proxy
    - 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
    - tls
    - tuned
    - udev
    - uptime
    - user
    - vault
    - vbox_guest
    - virtualenv
    - vsphere
    - webutil
    - x509
    - xfs
    - zabbix
    - zenoss

sys.list_functions.cmd 查看cmd命令可用的函数,模块后面可用的方法有哪些

[root@node01 ~]# salt 'node01' sys.list_functions cmd
node01:
    - 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

sys.doc.cmd 查看模块的用法

[root@node01 ~]# salt 'node01' sys.doc cmd 
'cmd.exec_code:'

    Pass in two strings, the first naming the executable language, aka -
    python2, python3, ruby, perl, lua, etc. the second string containing
    the code you wish to execute. The stdout will be returned.

    CLI Example:

        salt '*' cmd.exec_code ruby 'puts "cheese"'

执行多个模块的功能,之间用逗号隔开

[root@node01 ~]# salt 'node01' test.echo,cmd.run,service.status haha,ls,httpd
node01:
    ----------
    cmd.run:
        anaconda-ks.cfg
    service.status:
        True
    test.echo:
        haha

saltstack常用模块之network

network.active_tcp 查看node2上面的活动的tcp连接

表示nide01的4505端口和192.168.100.132的ip与node02的53868端口和192.168.100.131的4505端口建立saltstack的tcp连接,还有一个是本机的192.168.100.1ip和12295端口来和虚拟机的192.168.100.132ip和22端口建立连接

[root@node01 ~]# salt 'node02' network.active_tcp
node02:
    ----------
    0:
        ----------
        local_addr:
            192.168.100.132
        local_port:
            52868
        remote_addr:
            192.168.100.131
        remote_port:
            4505
    1:
        ----------
        local_addr:
            192.168.100.132
        local_port:
            22
        remote_addr:
            192.168.100.1
        remote_port:
            13395

查看22端口的连接关系

[root@node02 ~]# lsof -i :22
COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
sshd     1110 root    3u  IPv4  20549      0t0  TCP *:ssh (LISTEN)
sshd     1110 root    4u  IPv6  20551      0t0  TCP *:ssh (LISTEN)
sshd    31271 root    3u  IPv4 159719      0t0  TCP node02:ssh->192.168.100.1:14461 (ESTABLISHED)

network.calat_net 通过ip和子网掩码计算出网段

[root@node01 ~]# salt '*' network.calc_net 192.168.100.131 255.255.255.0
node01:
    192.168.100.0/24
node02:
    192.168.100.0/24

network.connect 测试某台服务器的网络是否连通

去测试是否能连接到百度

[root@node01 ~]# salt '*' network.connect baidu.com 80
node01:
    ----------
    comment:
        Successfully connected to baidu.com (220.181.38.148) on tcp port 80
    result:
        True
node02:
    ----------
    comment:
        Successfully connected to baidu.com (39.156.69.79) on tcp port 80
    result:
        True

network.default_route 查看默认路由

[root@node01 ~]# salt '*' network.default_route
node01:
    |_
      ----------
      addr_family:
          inet
      destination:
          0.0.0.0
      flags:
          UG
      gateway:
          192.168.100.2
      interface:
          ens33
      netmask:
          0.0.0.0
    |_
      ----------
      addr_family:
          inet6
      destination:
          ::/0
      flags:
          !n
      gateway:
          ::
      interface:
          lo
      netmask:
    |_
      ----------
      addr_family:
          inet6
      destination:
          ::/0
      flags:
          !n
      gateway:
          ::
      interface:
          lo
      netmask:
node02:
    |_
      ----------
      addr_family:
          inet
      destination:
          0.0.0.0
      flags:
          UG
      gateway:
          192.168.100.2
      interface:
          ens33
      netmask:
          0.0.0.0
    |_
      ----------
      addr_family:
          inet6
      destination:
          ::/0
      flags:
          !n
      gateway:
          ::
      interface:
          lo
      netmask:
    |_
      ----------
      addr_family:
          inet6
      destination:
          ::/0
      flags:
          !n
      gateway:
          ::
      interface:
          lo
      netmask:

network.get_fqdn 查看主机的fqdn

完全限定域名

[root@node01 ~]# salt '*' network.get_fqdn
node01:
    node01
node02:
    node02

network.get_hostname 获取主机名

[root@node01 ~]# salt '*' network.get_hostname
node01:
    node01
node02:
    node02

network.get_route 查询到一个目标网络的路由信息

[root@node01 ~]# salt '*' network.get_route 192.168.100.132
node01:
    ----------
    destination:
        192.168.100.132
    gateway:
        None
    interface:
        ens33
    source:
        192.168.100.131
node02:
    ----------
    destination:
        192.168.100.132
    gateway:
        None
    interface:
        lo
    source:
        192.168.100.132

network.hw_addr 返回指定网卡的mac地址

[root@node01 ~]# salt '*' network.hw_addr ens33
node01:
    00:0c:29:ed:39:d9
node02:
    00:0c:29:31:84:0c

network_subnet 判断的当前主机是否在某一网段内

[root@node01 ~]# salt '*' network.in_subnet 192.168.100.0/24
node02:
    True
node01:
    True

network.interface 查看网卡信息

[root@node01 ~]# salt '*' network.interface ens33
node02:
    |_
      ----------
      address:
          192.168.100.132
      broadcast:
          192.168.100.255
      label:
          ens33
      netmask:
          255.255.255.0
node01:
    |_
      ----------
      address:
          192.168.100.131
      broadcast:
          192.168.100.255
      label:
          ens33
      netmask:
          255.255.255.0

network.interface_ip 网卡ip

[root@node01 ~]# salt '*' network.interface_ip ens33
node02:
    192.168.100.132
node01:
    192.168.100.131

nwtwork.interfaces 返回当前系统中的所有网卡信息

[root@node01 ~]# salt '*' network.interfaces
node01:
    ----------
    ens33:
        ----------
        hwaddr:
            00:0c:29:ed:39:d9
        inet:
            |_
              ----------
              address:
                  192.168.100.131
              broadcast:
                  192.168.100.255
              label:
                  ens33
              netmask:
                  255.255.255.0
        inet6:
            |_
              ----------
              address:
                  fe80::45e:8127:e68e:905
              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
node02:
    ----------
    ens33:
        ----------
        hwaddr:
            00:0c:29:31:84:0c
        inet:
            |_
              ----------
              address:
                  192.168.100.132
              broadcast:
                  192.168.100.255
              label:
                  ens33
              netmask:
                  255.255.255.0
        inet6:
            |_
              ----------
              address:
                  fe80::bd4c:afba:c0f8:1b4b
              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

network.ip_addrs 返回一个ipv4的地址列表

[root@node01 ~]# salt '*' network.ip_addrs
node01:
    - 192.168.100.131
node02:
    - 192.168.100.132

network.netstat 返回所有打开的端口和状态

[root@node01 ~]# salt '*' network.netstat
node01:
    |_
      ----------
      inode:
          26269
      local-address:
          0.0.0.0:22
      program:
          5339/sshd
      proto:
          tcp
      recv-q:
          0
      remote-address:
          0.0.0.0:*
      send-q:
          0
      state:
          LISTEN
      user:
          0
    |_
      ----------
      inode:
          341855
      local-address:
          0.0.0.0:4505
      program:
          123136/python
      proto:
          tcp
      recv-q:
          0
      remote-address:
          0.0.0.0:*
      send-q:
          0
      state:
          LISTEN
      user:
          0
    |_
      ----------
      inode:
          26480
      local-address:
          127.0.0.1:25
      program:
          5496/master
      proto:
          tcp
      recv-q:
          0
      remote-address:
          0.0.0.0:*
      send-q:
          0
      state:
          LISTEN
      user:
          0
    |_
      ----------
      inode:
          339648
      local-address:
          0.0.0.0:4506
      program:
          123142/python
      proto:
          tcp
      recv-q:
          0
      remote-address:
          0.0.0.0:*
      send-q:
          0
      state:
          LISTEN
      user:
          0
    |_
      ----------
      inode:
          0
      local-address:
          192.168.100.131:49804
      program:
          -
      proto:
          tcp
      recv-q:
          0
      remote-address:
          192.168.100.131:4506
      send-q:
          0
      state:
          TIME_WAIT
      user:
          0
    |_
      ----------
      inode:
          0
      local-address:
          127.0.0.1:43604
      program:
          -
      proto:
          tcp
      recv-q:
          0
      remote-address:
          127.0.0.1:4506
      send-q:
          0
      state:
          TIME_WAIT
      user:
          0
    |_
      ----------
      inode:
          343772
      local-address:
          192.168.100.131:4505
      program:
          123136/python
      proto:
          tcp
      recv-q:
          0
      remote-address:
          192.168.100.132:52868
      send-q:
          0
      state:
          ESTABLISHED
      user:
          0
    |_
      ----------
      inode:
          339824
      local-address:
          192.168.100.131:50726
      program:
          1972/python
      proto:
          tcp
      recv-q:
          0
      remote-address:
          192.168.100.131:4505
      send-q:
          0
      state:
          ESTABLISHED
      user:
          0
    |_
      ----------
      inode:
          344080
      local-address:
          192.168.100.131:4505
      program:
          123136/python
      proto:
          tcp
      recv-q:
          0
      remote-address:
          192.168.100.131:50726
      send-q:
          0
      state:
          ESTABLISHED
      user:
          0
    |_
      ----------
      inode:
          0
      local-address:
          127.0.0.1:43600
      program:
          -
      proto:
          tcp
      recv-q:
          0
      remote-address:
          127.0.0.1:4506
      send-q:
          0
      state:
          TIME_WAIT
      user:
          0
    |_
      ----------
      inode:
          377011
      local-address:
          192.168.100.131:22
      program:
          1763/sshd:
      proto:
          tcp
      recv-q:
          0
      remote-address:
          192.168.100.1:2086
      send-q:
          0
      state:
          ESTABLISHED
      user:
          0
    |_
      ----------
      inode:
          201697
      local-address:
          :::80
      program:
          84311/httpd
      proto:
          tcp6
      recv-q:
          0
      remote-address:
          :::*
      send-q:
          0
      state:
          LISTEN
      user:
          0
    |_
      ----------
      inode:
          26271
      local-address:
          :::22
      program:
          5339/sshd
      proto:
          tcp6
      recv-q:
          0
      remote-address:
          :::*
      send-q:
          0
      state:
          LISTEN
      user:
          0
    |_
      ----------
      inode:
          26481
      local-address:
          ::1:25
      program:
          5496/master
      proto:
          tcp6
      recv-q:
          0
      remote-address:
          :::*
      send-q:
          0
      state:
          LISTEN
      user:
          0
    |_
      ----------
      inode:
          36900
      local-address:
          127.0.0.1:323
      program:
          13839/chronyd
      proto:
          udp
      recv-q:
          0
      remote-address:
          0.0.0.0:*
      send-q:
          0
      user:
          0
    |_
      ----------
      inode:
          36901
      local-address:
          ::1:323
      program:
          13839/chronyd
      proto:
          udp6
      recv-q:
          0
      remote-address:
          :::*
      send-q:
          0
      user:
          0
node02:
    |_
      ----------
      inode:
          122787
      local-address:
          0.0.0.0:139
      program:
          28497/smbd
      proto:
          tcp
      recv-q:
          0
      remote-address:
          0.0.0.0:*
      send-q:
          0
      state:
          LISTEN
      user:
          0
    |_
      ----------
      inode:
          20549
      local-address:
          0.0.0.0:22
      program:
          1110/sshd
      proto:
          tcp
      recv-q:
          0
      remote-address:
          0.0.0.0:*
      send-q:
          0
      state:
          LISTEN
      user:
          0
    |_
      ----------
      inode:
          19831
      local-address:
          127.0.0.1:25
      program:
          1537/master
      proto:
          tcp
      recv-q:
          0
      remote-address:
          0.0.0.0:*
      send-q:
          0
      state:
          LISTEN
      user:
          0
    |_
      ----------
      inode:
          122786
      local-address:
          0.0.0.0:445
      program:
          28497/smbd
      proto:
          tcp
      recv-q:
          0
      remote-address:
          0.0.0.0:*
      send-q:
          0
      state:
          LISTEN
      user:
          0
    |_
      ----------
      inode:
          152124
      local-address:
          192.168.100.132:52868
      program:
          27940/python
      proto:
          tcp
      recv-q:
          0
      remote-address:
          192.168.100.131:4505
      send-q:
          0
      state:
          ESTABLISHED
      user:
          0
    |_
      ----------
      inode:
          0
      local-address:
          192.168.100.132:58010
      program:
          -
      proto:
          tcp
      recv-q:
          0
      remote-address:
          192.168.100.131:4506
      send-q:
          0
      state:
          TIME_WAIT
      user:
          0
    |_
      ----------
      inode:
          167890
      local-address:
          192.168.100.132:22
      program:
          31923/sshd:
      proto:
          tcp
      recv-q:
          0
      remote-address:
          192.168.100.1:2091
      send-q:
          0
      state:
          ESTABLISHED
      user:
          0
    |_
      ----------
      inode:
          122785
      local-address:
          :::139
      program:
          28497/smbd
      proto:
          tcp6
      recv-q:
          0
      remote-address:
          :::*
      send-q:
          0
      state:
          LISTEN
      user:
          0
    |_
      ----------
      inode:
          156830
      local-address:
          :::80
      program:
          30552/httpd
      proto:
          tcp6
      recv-q:
          0
      remote-address:
          :::*
      send-q:
          0
      state:
          LISTEN
      user:
          0
    |_
      ----------
      inode:
          20551
      local-address:
          :::22
      program:
          1110/sshd
      proto:
          tcp6
      recv-q:
          0
      remote-address:
          :::*
      send-q:
          0
      state:
          LISTEN
      user:
          0
    |_
      ----------
      inode:
          19832
      local-address:
          ::1:25
      program:
          1537/master
      proto:
          tcp6
      recv-q:
          0
      remote-address:
          :::*
      send-q:
          0
      state:
          LISTEN
      user:
          0
    |_
      ----------
      inode:
          122784
      local-address:
          :::445
      program:
          28497/smbd
      proto:
          tcp6
      recv-q:
          0
      remote-address:
          :::*
      send-q:
          0
      state:
          LISTEN
      user:
          0
    |_
      ----------
      inode:
          122674
      local-address:
          192.168.100.255:137
      program:
          28470/nmbd
      proto:
          udp
      recv-q:
          0
      remote-address:
          0.0.0.0:*
      send-q:
          0
      user:
          0
    |_
      ----------
      inode:
          122673
      local-address:
          192.168.100.132:137
      program:
          28470/nmbd
      proto:
          udp
      recv-q:
          0
      remote-address:
          0.0.0.0:*
      send-q:
          0
      user:
          0
    |_
      ----------
      inode:
          122663
      local-address:
          0.0.0.0:137
      program:
          28470/nmbd
      proto:
          udp
      recv-q:
          0
      remote-address:
          0.0.0.0:*
      send-q:
          0
      user:
          0
    |_
      ----------
      inode:
          122676
      local-address:
          192.168.100.255:138
      program:
          28470/nmbd
      proto:
          udp
      recv-q:
          0
      remote-address:
          0.0.0.0:*
      send-q:
          0
      user:
          0
    |_
      ----------
      inode:
          122675
      local-address:
          192.168.100.132:138
      program:
          28470/nmbd
      proto:
          udp
      recv-q:
          0
      remote-address:
          0.0.0.0:*
      send-q:
          0
      user:
          0
    |_
      ----------
      inode:
          122664
      local-address:
          0.0.0.0:138
      program:
          28470/nmbd
      proto:
          udp
      recv-q:
          0
      remote-address:
          0.0.0.0:*
      send-q:
          0
      user:
          0
    |_
      ----------
      inode:
          18467
      local-address:
          127.0.0.1:323
      program:
          820/chronyd
      proto:
          udp
      recv-q:
          0
      remote-address:
          0.0.0.0:*
      send-q:
          0
      user:
          0
    |_
      ----------
      inode:
          18468
      local-address:
          ::1:323
      program:
          820/chronyd
      proto:
          udp6
      recv-q:
          0
      remote-address:
          :::*
      send-q:
          0
      user:
          0

network.ping 使用ping命令测试某主机的连通性

[root@node01 ~]# salt '*' network.ping baidu.com
node01:
    PING baidu.com (220.181.38.148) 56(84) bytes of data.
    64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=1 ttl=128 time=48.5 ms
    64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=2 ttl=128 time=18.4 ms
    64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=3 ttl=128 time=18.9 ms
    64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=4 ttl=128 time=9.01 ms
    
    --- baidu.com ping statistics ---
    4 packets transmitted, 4 received, 0% packet loss, time 3004ms
    rtt min/avg/max/mdev = 9.018/23.735/48.524/14.849 ms
node02:
    PING baidu.com (220.181.38.148) 56(84) bytes of data.
    64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=1 ttl=128 time=36.2 ms
    64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=2 ttl=128 time=8.12 ms
    64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=3 ttl=128 time=9.03 ms
    64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=4 ttl=128 time=11.1 ms
    
    --- baidu.com ping statistics ---
    4 packets transmitted, 4 received, 0% packet loss, time 12051ms
    rtt min/avg/max/mdev = 8.129/16.147/36.262/11.665 ms

network.reverse-ip 返回一个指定的ip地址的反向地址

[root@node01 ~]# salt '*' network.reverse_ip 192.168.69.90
node01:
    90.69.168.192.in-addr.arpa
node02:
    90.69.168.192.in-addr.arpa

service.available 判断指定的服务是否可用

[root@node01 ~]# salt '*' service.available sshd
node02:
    True
node01:
    True

service.get_all 获取正在运行的服务

[root@node01 ~]# salt 'node01' service.get_all
node01:
    - NetworkManager
    - NetworkManager-dispatcher
    - NetworkManager-wait-online
    - arp-ethers
    - auditd
    - autovt@
    - basic.target
    - blk-availability
    - bluetooth.target
    - brandbot
    - brandbot.path
    - chrony-dnssrv@
    - chrony-dnssrv@.timer
    - chrony-wait
    - chronyd
    - console-getty
    - console-shell
    - container-getty@
    - cpupower
    - crond
    - cryptsetup-pre.target
    - cryptsetup.target
    - ctrl-alt-del.target
    - dbus
    - 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
    - htcacheclean
    - httpd
    - 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
    - nmb
    - 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
    - rsyncd
    - rsyncd.socket
    - rsyncd@
    - rsyslog
    - runlevel0.target
    - runlevel1.target
    - runlevel2.target
    - runlevel3.target
    - runlevel4.target
    - runlevel5.target
    - runlevel6.target
    - salt-master
    - salt-minion
    - salt-proxy@
    - selinux-policy-migrate-local-changes@
    - serial-getty@
    - shutdown.target
    - sigpwr.target
    - sleep.target
    - slices.target
    - smartcard.target
    - smb
    - 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
    - vmtoolsd-init
    - winbind
    - wpa_supplicant

service.disbaled 检查指定服务是否开机不自动启动

[root@node01 ~]# salt 'node01' service.disabled httpd
node01:
    False

service.reload 重新加载指定服务

[root@node01 ~]# salt 'node01' service.reload httpd
node01:
    True

service.stop 停止指定服务

[root@node01 ~]# salt 'node01' service.stop httpd
node01:
    True

service.start 启动指定服务

[root@node01 ~]# salt 'node01' service.start httpd
node01:
    True

sercvice.restart 重启指定服务

[root@node01 ~]# salt 'node01' service.restart httpd
node01:
    True

service.status 查看指定服务的状态

[root@node01 ~]# salt 'node01' service.status httpd
node01:
    True

pkg.download 只下载软件包但不安装

[root@node01 ~]# salt 'node01' pkg.download wget 
node01:
    ----------
    wget:
        /var/cache/yum/packages/wget-1.14-15.el7_4.1.x86_64.rpm     //下载好的软件放在这里
[root@node01 ~]# ls /var/cache/yum/packages/
wget-1.14-15.el7_4.1.x86_64.rpm

pkg.file_list

[root@node01 ~]# salt ‘node02’' pkg.file_list httpd
node02:
    ----------
    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/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@node01 ~]# salt '*' pkg.group_info 'Development Tools'
node01:
    ----------
    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
        - libstdc++-docs
        - mercurial
        - mod_dav_svn
        - nasm
        - perltidy
        - python-docs
        - rpmdevtools
        - rpmlint
        - systemtap-sdt-devel
        - systemtap-server
    type:
        package group

列出系统中所有的包组

root@node01 ~]# salt '*' pkg.group_list
node02:
    ----------
    available:
        - Additional Development
        - Anaconda Tools
        - Backup Client
        - Backup Server
        - Base
        - Common NetworkManager submodules
        - Compatibility Libraries
        - Conflicts (Server)
        - 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
        - Hyper-v platform specific packages
        - Identity Management Server
        - Infiniband Support
        - Input Methods
        - Internet Browser
        - Java Platform
        - KDE
        - 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
        - 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
        - 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
        - Infrastructure Server
        - File and Print Server
        - Basic Web Server
        - Virtualization Host
        - Server with GUI
    available languages:
        ----------
    installed:
    installed environments:
node01:
    ----------
    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@node01 ~]# salt 'node01' pkg.install vim
node01:
    ----------
    gpm-libs:
        ----------
        new:
            1.20.7-5.el7
        old:
    vim-common:
        ----------
        new:
            2:7.4.160-4.el7
        old:
    vim-enhanced:
        ----------
        new:
            2:7.4.160-4.el7
        old:
    vim-filesystem:
        ----------
        new:
            2:7.4.160-4.el7
        old:

列出已下载到本地的软件包

[root@node01 ~]# salt 'node01' pkg.list_downloaded
node01:
    ----------
    wget:
        ----------
        1.14-15.el7_4.1:
            ----------
            creation_date_time:
                2020-02-20T19:00:03
            creation_date_time_t:
                1582196403
            path:
                /var/cache/yum/packages/wget-1.14-15.el7_4.1.x86_64.rpm
            size:
                559932

以字典的方式列出当前已安装的软件包

[root@node01 ~]# salt 'node01' pkg.list_pkgs
node01:
    ----------
    GeoIP:
        1.5.0-14.el7
    NetworkManager:
        1:1.18.0-5.el7_7.1
    NetworkManager-libnm:
        1:1.18.0-5.el7_7.1
    NetworkManager-team:
        1:1.18.0-5.el7_7.1
    NetworkManager-tui:
        1:1.18.0-5.el7_7.1
    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.8-1.el7
    alsa-tools-firmware:
        1.1.0-1.el7
    apr:
        1.4.8-3.el7_4.1
    apr-util:
        1.5.2-6.el7
    audit:
        2.8.5-4.el7
    audit-libs:
        2.8.5-4.el7
    authconfig:
        6.2.8-30.el7
    avahi-libs:
        0.6.31-19.el7
    basesystem:
        10.0-7.el7.centos
    bash:
        4.2.46-33.el7
    bind-export-libs:
        32:9.11.4-9.P2.el7
    bind-libs-lite:
        32:9.11.4-9.P2.el7
    bind-license:
        32:9.11.4-9.P2.el7
    binutils:
        2.27-41.base.el7_7.1
    biosdevname:
        0.7.3-2.el7
    btrfs-progs:
        4.9.1-1.el7
    bzip2-libs:
        1.0.6-13.el7
    ca-certificates:
        2019.2.32-76.el7_7
    centos-logos:
        70.0.6-3.el7.centos
    centos-release:
        7-7.1908.0.el7.centos
    chkconfig:
        1.7.4-1.el7
    chrony:
        3.4-1.el7
    coreutils:
        8.22-24.el7
    cpio:
        2.11-27.el7
    cpp:
        4.8.5-39.el7
    cracklib:
        2.9.0-11.el7
    cracklib-dicts:
        2.9.0-11.el7
    cronie:
        1.4.11-23.el7
    cronie-anacron:
        1.4.11-23.el7
    crontabs:
        1.11-6.20121102git.el7
    cryptsetup-libs:
        2.0.3-5.el7
    cups-libs:
        1:1.6.3-35.el7
    curl:
        7.29.0-54.el7_7.1
    cyrus-sasl-lib:
        2.1.26-23.el7
    dbus:
        1:1.10.24-13.el7_6
    dbus-glib:
        0.100-7.el7
    dbus-libs:
        1:1.10.24-13.el7_6
    dbus-python:
        1.1.1-9.el7
    device-mapper:
        7:1.02.158-2.el7_7.2
    device-mapper-event:
        7:1.02.158-2.el7_7.2
    device-mapper-event-libs:
        7:1.02.158-2.el7_7.2
    device-mapper-libs:
        7:1.02.158-2.el7_7.2
    device-mapper-persistent-data:
        0.8.5-1.el7
    dhclient:
        12:4.2.5-77.el7.centos
    dhcp-common:
        12:4.2.5-77.el7.centos
    dhcp-libs:
        12:4.2.5-77.el7.centos
    diffutils:
        3.3-5.el7
    dmidecode:
        1:3.2-3.el7
    dracut:
        033-564.el7
    dracut-config-rescue:
        033-564.el7
    dracut-network:
        033-564.el7
    e2fsprogs:
        1.42.9-16.el7
    e2fsprogs-libs:
        1.42.9-16.el7
    ebtables:
        2.0.10-16.el7
    elfutils-default-yama-scope:
        0.176-2.el7
    elfutils-libelf:
        0.176-2.el7
    elfutils-libs:
        0.176-2.el7
    epel-release:
        7-12
    ethtool:
        2:4.8-10.el7
    expat:
        2.1.0-10.el7_3
    file:
        5.11-35.el7
    file-libs:
        5.11-35.el7
    filesystem:
        3.2-25.el7
    findutils:
        1:4.5.11-6.el7
    fipscheck:
        1.4.1-6.el7
    fipscheck-lib:
        1.4.1-6.el7
    firewalld:
        0.6.3-2.el7_7.2
    firewalld-filesystem:
        0.6.3-2.el7_7.2
    freetype:
        2.8-14.el7
    fuse:
        2.9.2-11.el7
    fuse-libs:
        2.9.2-11.el7
    fxload:
        2002_04_11-16.el7
    gawk:
        4.0.2-4.el7_3.1
    gcc:
        4.8.5-39.el7
    gdbm:
        1.10-8.el7
    geoipupdate:
        2.5.0-1.el7
    gettext:
        0.19.8.1-2.el7
    gettext-libs:
        0.19.8.1-2.el7
    git:
        1.8.3.1-20.el7
    glib2:
        2.56.1-5.el7
    glibc:
        2.17-292.el7
    glibc-common:
        2.17-292.el7
    glibc-devel:
        2.17-292.el7
    glibc-headers:
        2.17-292.el7
    gmp:
        1:6.0.0-15.el7
    gnupg2:
        2.0.22-5.el7_5
    gobject-introspection:
        1.56.1-1.el7
    gpg-pubkey.(none):
        352c64e5-52ae6884,621e9f35-58adea78,7bd9bf62-5762b5f8,de57bfbe-53a9be98,f4a80eb5-53a7ff4b
    gpgme:
        1.3.2-5.el7
    gpm-libs:
        1.20.7-5.el7
    grep:
        2.20-3.el7
    groff-base:
        1.22.2-8.el7
    grub2:
        1:2.02-0.80.el7.centos
    grub2-common:
        1:2.02-0.80.el7.centos
    grub2-pc:
        1:2.02-0.80.el7.centos
    grub2-pc-modules:
        1:2.02-0.80.el7.centos
    grub2-tools:
        1:2.02-0.80.el7.centos
    grub2-tools-extra:
        1:2.02-0.80.el7.centos
    grub2-tools-minimal:
        1:2.02-0.80.el7.centos
    grubby:
        8.28-26.el7
    gzip:
        1.5-10.el7
    hardlink:
        1:1.0-19.el7
    hostname:
        3.13-3.el7_7.1
    httpd:
        2.4.6-80.el7.centos
    httpd-tools:
        2.4.6-80.el7.centos
    hwdata:
        0.252-9.3.el7
    info:
        5.1-5.el7
    initscripts:
        9.49.47-1.el7
    iproute:
        4.11.0-25.el7_7.2
    iprutils:
        2.4.17.1-2.el7
    ipset:
        7.1-1.el7
    ipset-libs:
        7.1-1.el7
    iptables:
        1.4.21-33.el7
    iputils:
        20160308-10.el7
    irqbalance:
        3:1.0.7-12.el7
    ivtv-firmware:
        2:20080701-26.el7
    iwl100-firmware:
        39.31.5.1-72.el7
    iwl1000-firmware:
        1:39.31.5.1-72.el7
    iwl105-firmware:
        18.168.6.1-72.el7
    iwl135-firmware:
        18.168.6.1-72.el7
    iwl2000-firmware:
        18.168.6.1-72.el7
    iwl2030-firmware:
        18.168.6.1-72.el7
    iwl3160-firmware:
        22.0.7.0-72.el7
    iwl3945-firmware:
        15.32.2.9-72.el7
    iwl4965-firmware:
        228.61.2.24-72.el7
    iwl5000-firmware:
        8.83.5.1_1-72.el7
    iwl5150-firmware:
        8.24.2.2-72.el7
    iwl6000-firmware:
        9.221.4.1-72.el7
    iwl6000g2a-firmware:
        17.168.5.3-72.el7
    iwl6000g2b-firmware:
        17.168.5.2-72.el7
    iwl6050-firmware:
        41.28.5.1-72.el7
    iwl7260-firmware:
        22.0.7.0-72.el7
    iwl7265-firmware:
        22.0.7.0-72.el7
    jansson:
        2.10-1.el7
    json-c:
        0.11-4.el7_0
    kbd:
        1.15.5-15.el7
    kbd-legacy:
        1.15.5-15.el7
    kbd-misc:
        1.15.5-15.el7
    kde-filesystem:
        4-47.el7
    kde-l10n:
        4.10.5-2.el7
    kde-l10n-Chinese:
        4.10.5-2.el7
    kernel:
        3.10.0-862.el7,3.10.0-1062.9.1.el7
    kernel-headers:
        3.10.0-1062.9.1.el7
    kernel-tools:
        3.10.0-1062.9.1.el7
    kernel-tools-libs:
        3.10.0-1062.9.1.el7
    kexec-tools:
        2.0.15-33.el7
    keyutils-libs:
        1.5.8-3.el7
    kmod:
        20-25.el7
    kmod-libs:
        20-25.el7
    kpartx:
        0.4.9-127.el7
    krb5-libs:
        1.15.1-37.el7_7.2
    less:
        458-9.el7
    libacl:
        2.2.51-14.el7
    libaio:
        0.3.109-13.el7
    libarchive:
        3.1.2-10.el7_2
    libassuan:
        2.1.0-3.el7
    libattr:
        2.4.46-13.el7
    libblkid:
        2.23.2-61.el7_7.1
    libcap:
        2.22-10.el7
    libcap-ng:
        0.7.5-4.el7
    libcom_err:
        1.42.9-16.el7
    libcroco:
        0.6.12-4.el7
    libcurl:
        7.29.0-54.el7_7.1
    libdaemon:
        0.14-7.el7
    libdb:
        5.3.21-25.el7
    libdb-utils:
        5.3.21-25.el7
    libdnet:
        1.12-13.1.el7
    libdrm:
        2.4.97-2.el7
    libedit:
        3.0-12.20121213cvs.el7
    libestr:
        0.1.9-2.el7
    libfastjson:
        0.99.4-3.el7
    libffi:
        3.0.13-18.el7
    libgcc:
        4.8.5-39.el7
    libgcrypt:
        1.5.3-14.el7
    libgomp:
        4.8.5-39.el7
    libgpg-error:
        1.12-3.el7
    libicu:
        50.2-3.el7
    libidn:
        1.28-4.el7
    libldb:
        1.2.2-1.el7
    libmnl:
        1.0.3-7.el7
    libmount:
        2.23.2-61.el7_7.1
    libmpc:
        1.0.1-3.el7
    libmspack:
        0.5-0.7.alpha.el7
    libndp:
        1.2-9.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
    libpng:
        2:1.5.13-7.el7_2
    libpwquality:
        1.2.3-5.el7
    libseccomp:
        2.3.1-3.el7
    libselinux:
        2.5-14.1.el7
    libselinux-python:
        2.5-14.1.el7
    libselinux-utils:
        2.5-14.1.el7
    libsemanage:
        2.5-14.el7
    libsepol:
        2.5-10.el7
    libsmartcols:
        2.23.2-61.el7_7.1
    libsmbclient:
        4.7.1-6.el7
    libsodium:
        1.0.18-1.el7
    libss:
        1.42.9-16.el7
    libssh2:
        1.8.0-3.el7
    libstdc++:
        4.8.5-39.el7
    libsysfs:
        2.1.0-16.el7
    libtalloc:
        2.1.10-1.el7
    libtasn1:
        4.10-1.el7
    libtdb:
        1.3.15-1.el7
    libteam:
        1.27-9.el7
    libtevent:
        0.9.33-2.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-61.el7_7.1
    libverto:
        0.2.5-4.el7
    libwbclient:
        4.7.1-6.el7
    libxml2:
        2.9.1-6.el7_2.3
    libxml2-python:
        2.9.1-6.el7_2.3
    libxslt:
        1.1.28-5.el7
    libyaml:
        0.1.4-11.el7_0
    linux-firmware:
        20190429-72.gitddde598.el7
    logrotate:
        3.8.6-17.el7
    lshw:
        B.02.18-13.el7
    lsscsi:
        0.27-6.el7
    lua:
        5.1.4-15.el7
    lvm2:
        7:2.02.185-2.el7_7.2
    lvm2-libs:
        7:2.02.185-2.el7_7.2
    lz4:
        1.7.5-3.el7
    lzo:
        2.06-8.el7
    mailcap:
        2.1.41-2.el7
    make:
        1:3.82-24.el7
    man-db:
        2.6.3-11.el7
    mariadb-libs:
        1:5.5.64-1.el7
    microcode_ctl:
        2:2.1-53.7.el7_7
    mozjs17:
        17.0.0-20.el7
    mpfr:
        3.1.1-4.el7
    ncurses:
        5.9-14.20130511.el7_4
    ncurses-base:
        5.9-14.20130511.el7_4
    ncurses-libs:
        5.9-14.20130511.el7_4
    net-tools:
        2.0-0.22.20131004git.el7
    newt:
        0.52.15-4.el7
    newt-python:
        0.52.15-4.el7
    nspr:
        4.21.0-1.el7
    nss:
        3.44.0-7.el7_7
    nss-pem:
        1.0.3-7.el7
    nss-softokn:
        3.44.0-8.el7_7
    nss-softokn-freebl:
        3.44.0-8.el7_7
    nss-sysinit:
        3.44.0-7.el7_7
    nss-tools:
        3.44.0-7.el7_7
    nss-util:
        3.44.0-4.el7_7
    numactl-libs:
        2.0.12-3.el7_7.1
    open-vm-tools:
        10.3.0-2.el7_7.1
    openldap:
        2.4.44-21.el7_6
    openpgm:
        5.2.122-2.el7
    openssh:
        7.4p1-21.el7
    openssh-clients:
        7.4p1-21.el7
    openssh-server:
        7.4p1-21.el7
    openssl:
        1:1.0.2k-19.el7
    openssl-libs:
        1:1.0.2k-19.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-31.el7
    passwd:
        0.79-5.el7
    pciutils:
        3.5.1-3.el7
    pciutils-libs:
        3.5.1-3.el7
    pcre:
        8.32-17.el7
    perl:
        4:5.16.3-294.el7_6
    perl-Carp:
        1.26-244.el7
    perl-Encode:
        2.51-7.el7
    perl-Error:
        1:0.17020-2.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-Git:
        1.8.3.1-20.el7
    perl-HTTP-Tiny:
        0.033-3.el7
    perl-PathTools:
        3.40-5.el7
    perl-Pod-Escapes:
        1:1.04-294.el7_6
    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-4.el7
    perl-Storable:
        2.45-3.el7
    perl-TermReadKey:
        2.30-20.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-294.el7_6
    perl-macros:
        4:5.16.3-294.el7_6
    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.32.20140113.el7.centos
    plymouth-core-libs:
        0.8.9-0.32.20140113.el7.centos
    plymouth-scripts:
        0.8.9-0.32.20140113.el7.centos
    policycoreutils:
        2.5-33.el7
    polkit:
        0.112-22.el7_7.1
    polkit-pkla-compat:
        0.1-4.el7
    popt:
        1.13-16.el7
    postfix:
        2:2.10.1-7.el7
    procps-ng:
        3.3.10-26.el7_7.1
    pth:
        2.0.7-23.el7
    pygpgme:
        0.3-9.el7
    pyldb:
        1.2.2-1.el7
    pyliblzma:
        0.5.3-11.el7
    pytalloc:
        2.1.10-1.el7
    python:
        2.7.5-86.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-chardet:
        2.2.1-3.el7
    python-configobj:
        4.7.2-7.el7
    python-decorator:
        3.4.0-3.el7
    python-dns:
        1.12.0-4.20150617git465785f.el7
    python-firewall:
        0.6.3-2.el7_7.2
    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-86.el7
    python-linux-procfs:
        0.4.11-4.el7
    python-markupsafe:
        0.11-10.el7
    python-perf:
        3.10.0-1062.9.1.el7
    python-pycurl:
        7.19.0-19.el7
    python-pyudev:
        0.15-9.el7
    python-requests:
        2.6.0-8.el7_7
    python-schedutils:
        0.4-6.el7
    python-six:
        1.9.0-2.el7
    python-slip:
        0.4.0-4.el7
    python-slip-dbus:
        0.4.0-4.el7
    python-tdb:
        1.3.15-1.el7
    python-tevent:
        0.9.33-2.el7
    python-tornado:
        4.2.1-5.el7
    python-urlgrabber:
        3.10-9.el7
    python-urllib3:
        1.10.2-7.el7
    python-zmq:
        15.3.0-3.el7
    python2-crypto:
        2.6.1-16.el7
    python2-futures:
        3.1.1-5.el7
    python2-msgpack:
        0.5.6-7.el7
    python2-psutil:
        2.2.1-5.el7
    pyxattr:
        0.5.1-5.el7
    qrencode-libs:
        3.4.1-3.el7
    readline:
        6.2-11.el7
    rootfiles:
        8.1-11.el7
    rpm:
        4.11.3-40.el7
    rpm-build-libs:
        4.11.3-40.el7
    rpm-libs:
        4.11.3-40.el7
    rpm-python:
        4.11.3-40.el7
    rsync:
        3.1.2-6.el7_6.1
    rsyslog:
        8.24.0-41.el7_7.2
    salt:
        2019.2.3-1.el7
    salt-master:
        2019.2.3-1.el7
    salt-minion:
        2019.2.3-1.el7
    salt-repo:
        latest-2.el7
    samba:
        4.7.1-6.el7
    samba-client:
        4.7.1-6.el7
    samba-client-libs:
        4.7.1-6.el7
    samba-common:
        4.7.1-6.el7
    samba-common-libs:
        4.7.1-6.el7
    samba-common-tools:
        4.7.1-6.el7
    samba-krb5-printing:
        4.7.1-6.el7
    samba-libs:
        4.7.1-6.el7
    samba-python:
        4.7.1-6.el7
    samba-winbind:
        4.7.1-6.el7
    samba-winbind-modules:
        4.7.1-6.el7
    sed:
        4.2.2-5.el7
    selinux-policy:
        3.13.1-252.el7_7.6
    selinux-policy-targeted:
        3.13.1-252.el7_7.6
    setup:
        2.8.71-10.el7
    sg3_utils:
        1.37-18.el7_7.1
    sg3_utils-libs:
        1.37-18.el7_7.1
    shadow-utils:
        2:4.6-5.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.23-4.el7_7.1
    systemd:
        219-67.el7_7.3
    systemd-libs:
        219-67.el7_7.3
    systemd-python:
        219-67.el7_7.3
    systemd-sysv:
        219-67.el7_7.3
    sysvinit-tools:
        2.88-14.dsf.el7
    tar:
        2:1.26-35.el7
    tcp_wrappers-libs:
        7.6-77.el7
    teamd:
        1.27-9.el7
    tree:
        1.6.0-10.el7
    tuned:
        2.11.0-5.el7_7.1
    tzdata:
        2019c-1.el7
    ustr:
        1.0.4-16.el7
    util-linux:
        2.23.2-61.el7_7.1
    vim-common:
        2:7.4.160-4.el7
    vim-enhanced:
        2:7.4.160-4.el7
    vim-filesystem:
        2:7.4.160-4.el7
    vim-minimal:
        2:7.4.629-6.el7
    virt-what:
        1.18-4.el7
    wget:
        1.14-18.el7_6.1
    which:
        2.20-7.el7
    wpa_supplicant:
        1:2.6-12.el7
    xfsprogs:
        4.5.0-20.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-163.el7.centos
    yum-metadata-parser:
        1.1.4-10.el7
    yum-plugin-fastestmirror:
        1.1.31-52.el7
    yum-utils:
        1.1.31-52.el7
    zeromq:
        4.1.4-7.el7
    zlib:
        1.2.7-18.el7

列出指定文件是由那个包提供的

[root@node01 ~]# salt 'node01' pkg.owner /usr/sbin/apachectl
node01:
    httpd

卸载指定软件

[root@node01 ~]# rpm -qa|grep wget
wget-1.14-18.el7_6.1.x86_64
[root@node01 ~]# salt 'node01' pkg.remove wget
node01:
    ----------
    wget:
        ----------
        new:
        old:
            1.14-18.el7_6.1

SaltStack常用模块之state

显示当前系统中有哪些高级状态

[root@node01 salt]# salt 'node02' state.show_highstate
node02:
    ----------
    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
    samba-install:
        ----------
        __env__:
            prod
        __sls__:
            gongxiang.samba
        pkg:
            |_
              ----------
              name:
                  samba
            - installed
            |_
              ----------
              order:
                  10002
    samba-service:
        ----------
        __env__:
            prod
        __sls__:
            gongxiang.samba
        service:
            |_
              ----------
              names:
                  - nmb
                  - smb
            |_
              ----------
              enable:
                  True
            - running
            |_
              ----------
              order:
                  10003

state.highstate 执行高级状态

[root@node01 salt]# salt 'node02' state.highstate
node02:
----------
          ID: apache-install
    Function: pkg.installed
        Name: httpd
      Result: True
     Comment: All specified packages are already installed
     Started: 19:34:51.291986
    Duration: 560.575 ms
     Changes:   
----------
          ID: apache.service
    Function: service.running
        Name: httpd
      Result: True
     Comment: The service httpd is already running
     Started: 19:34:51.853504
    Duration: 43.573 ms
     Changes:   
----------
          ID: samba-install
    Function: pkg.installed
        Name: samba
      Result: True
     Comment: All specified packages are already installed
     Started: 19:34:51.897309
    Duration: 19.384 ms
     Changes:   
----------
          ID: samba-service
    Function: service.running
        Name: nmb
      Result: True
     Comment: The service nmb is already running
     Started: 19:34:51.917565
    Duration: 32.517 ms
     Changes:   
----------
          ID: samba-service
    Function: service.running
        Name: smb
      Result: True
     Comment: The service smb is already running
     Started: 19:34:51.950304
    Duration: 34.274 ms
     Changes:   

Summary for node02
------------
Succeeded: 5
Failed:    0
------------
Total states run:     5
Total run time: 690.323 ms

state.show_state_usage 显示当前系统中的高级状态执行情况

count_all表示总共有多少状态文件,count_usused表示有一个状态没有被用,count_used表示有一个状态已经被用。

node02:
    ----------
    base:
        ----------
        count_all:
            2
        count_unused:
            1
        count_used:
            1
        unused:
            - top
        used:
            - web.apache.apache
    prod:
        ----------
        count_all:
            2
        count_unused:
            1
        count_used:
            1
        unused:
            - top
        used:
            - gongxiang.samba
[root@node01 salt]# tree 
.
├── base
│   ├── top.sls
│   └── web
│       └── apache
│           └── apache.sls
└── prod
    ├── gongxiang
    │   └── samba.sls
    └── top.sls

5 directories, 4 files

state.show_top 返回minion将用于highstate的顶级数据

[root@node01 salt]# salt 'node02' state.show_top
node02:
    ----------
    base:
        - web.apache.apache
    prod:
        - gongxiang.samba

state.top 执行指定的top.file文件,而不是默认的

[root@node01 salt]# tree
.
├── base
│   ├── top.sls
│   └── web
│       └── apache
│           └── apache.sls
└── prod
    ├── gongxiang
    │   └── samba.sls
    └── top.sls

5 directories, 4 files
[root@node01 salt]# cd base/
[root@node01 base]# ls
top.sls  web
[root@node01 base]# mv top.sls haha.sls
[root@node01 base]# salt 'node02' state.top haha.sls
node02:
----------
          ID: apache-install
    Function: pkg.installed
        Name: httpd
      Result: True
     Comment: All specified packages are already installed
     Started: 19:50:39.290186
    Duration: 598.67 ms
     Changes:   
----------
          ID: apache.service
    Function: service.running
        Name: httpd
      Result: True
     Comment: The service httpd is already running
     Started: 19:50:39.890476
    Duration: 59.535 ms
     Changes:   

Summary for node02
------------
Succeeded: 2
Failed:    0
------------
Total states run:     2
Total run time: 658.205 ms

state.show_sls 显示master上特定sls或sls文件列表中的状态数据

[root@node01 base]# salt 'node01' state.show_sls web.apache.apache
node01:
    ----------
    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

saltstack常用模块之salt-cp

salt-cp 把master上的文件批量传到minion上

拷贝单个文件到目标主机的/usr/src目录下

[root@node01 ~]# salt '*' cmd.run  'ls /usr/src'
node02:
    debug
    kernels
node01:
    debug
    kernels
[root@node01 ~]# salt 'node02' cmd.run  'ls /usr/src'
node02:
    debug
    kernels
[root@node01 ~]# salt-cp 'node02' /etc/passwd /usr/src/ 
node02:
    ----------
    /usr/src/passwd:
        True
[root@node01 ~]# salt 'node02' cmd.run 'ls /usr/src'
node02:
    debug
    kernels
    passwd

拷贝多个文件到目标主机的/usr/src目录下

[root@node01 ~]# salt-cp 'node02' /etc/shadow /etc/group /usr/src
node02:
    ----------
    /usr/src/group:
        True
    /usr/src/shadow:
        True
[root@node01 ~]# salt 'node02' cmd.run 'ls /usr/src'
node02:
    debug
    group
    kernels
    passwd
    shadow

拷贝目录到/opt目录下面

[root@node01 ~]# salt-cp  --chunked 'node02' /tmp /opt/
node02:
    ----------
    /opt/tmp/.ICE-unix:
        True
    /opt/tmp/.Test-unix:
        True
    /opt/tmp/.X11-unix:
        True
    /opt/tmp/.XIM-unix:
        True
    /opt/tmp/.font-unix:
        True
    /opt/tmp/systemd-private-85217f4e60c94a57a6e1f290b3d43cc3-chronyd.service-Vc0MzR/tmp:
        True
    /opt/tmp/systemd-private-85217f4e60c94a57a6e1f290b3d43cc3-httpd.service-XbEpjE/tmp:
        True
[root@node01 ~]# salt 'node02' cmd.run 'ls /opt/'
node02:
    tmp

salt-cp将文件复制到文件下会覆盖

将node01的文件salt复制到node02的/opt/anaconda-ks.cfg下面发现名字没变,内容已经被覆盖

[root@node01 ~]# salt  'node02' cmd.run 'ls /opt/'
node02:
    anaconda-ks.cfg
[root@node01 ~]# salt  'node02' cmd.run 'tail -1  /opt/anaconda-ks.cfg'
node02:
    %end
[root@node01 ~]# ls
anaconda-ks.cfg  salt
[root@node01 ~]# salt-cp 'node02' salt /opt/anaconda-ks.cfg
node02:
    ----------
    /opt/anaconda-ks.cfg:
        True
[root@node01 ~]# salt  'node02' cmd.run 'tail -1  /opt/anaconda-ks.cfg'
node02:
    haha

SaltStack常用模块之file

file.access

检查指定路径是否存在

[root@node01 ~]# salt '*' cmd.run 'ls /usr/src'
node02:
    debug
    group
    kernels
    passwd
    shadow
node01:
    debug
    kernels
[root@node01 ~]# salt '*' file.access /usr/src/debug f
node02:
    True
node01:
    True

检查指定文件的权限信息

[root@node01 ~]# salt '*' cmd.run 'ls -l  /usr/src'
node02:
    total 12
    drwxr-xr-x. 2 root root   6 Mar 10  2016 debug
    -rw-r--r--. 1 root root 493 Feb 21 20:13 group
    drwxr-xr-x. 2 root root   6 Mar 10  2016 kernels
    -rw-r--r--. 1 root root 899 Feb 21 20:03 passwd
    -rw-r--r--. 1 root root 607 Feb 21 20:13 shadow
node01:
    total 0
    drwxr-xr-x. 2 root root 6 Apr 11  2018 debug
    drwxr-xr-x. 2 root root 6 Apr 11  2018 kernels
[root@node01 ~]# salt '*' file.access '/usr/src/debug' x
node02:
    True
node01:
    True
[root@node01 ~]# salt '*' file.access '/usr/src/debug' r
node02:
    True
node01:
    True
[root@node01 ~]# salt '*' file.access '/usr/src/debug' w
node02:
    True
node01:
    True

file.append在一个文件里面追加内容,若此文件不存在则会报异常

[root@node01 ~]# salt 'node01' file.append /root/salt 'huiganh' 'osjgjam' 'lllll'
node01:
    Wrote 3 lines to "/root/salt"
[root@node01 ~]# salt 'node01' cmd.run 'cat salt'
node01:
    haha
    huiganh
    osjgjam
    lllll

获取文件的名字

[root@node01 ~]# salt '*' file.basename '/root/zassd/sjdj'
node02:
    sjdj
node01:
    sjdj

获取目录的名字

[root@node01 ~]# salt '*' file.dirname '/root/zassd/sjdj'
node02:
    /root/zassd
node01:
    /root/zassd

检查文件与hash字符串是否匹配,匹配则返回 True 否则返回 False

[root@node01 ~]# salt '*' cmd.run 'md5sum /etc/passwd'
node02:
    9a5d5e9016836a6e6c795e0869e5d72d  /etc/passwd
node01:
    62508ff337e1551d5d36c67ad6a28d27  /etc/passwd
[root@node01 ~]# salt '*' file.check_hash /etc/passwd 9a5d5e9016836a6e6c795e0869e5d72d
node02:
    True
node01:
    False

chattr修改文件属性

属性对文件的意义对目录的意义
a只允许在这个文件之后追加数据,不允许任何进程覆盖或截断这个文件只允许在这个目录下建立和修改文件,而不允许删除任何文件
i不允许对这个文件进行任何的修改,不能删除、更改、移动任何的进程只能修改目录之下的文件,不允许建立和删除文件

用chattr给目录加a属性

root@node01 ~]# chattr -R +a /opt/
[root@node01 ~]# ls /opt/
anaconda-ks.cfg  salt
[root@node01 ~]# rm -rf /opt/salt 
rm: 无法删除"/opt/salt": 不允许的操作
[root@node01 ~]# touch /opt/kk
[root@node01 ~]# rm -rf /opt/kk
rm: 无法删除"/opt/kk": 不允许的操作

用chattr给文件加a属性,然后此文件可以追加内容但是不能删除,也不能做修改

[root@node01 ~]# chattr -R +a anaconda-ks.cfg 
[root@node01 ~]# echo 'haha' >> anaconda-ks.cfg
[root@node01 ~]# tail -1 anaconda-ks.cfg
haha
[root@node01 ~]# rm -rf anaconda-ks.cfg
rm: 无法删除"anaconda-ks.cfg": 不允许的操作
[root@node01 ~]# sed  -i s/haha/ouou/g anaconda-ks.cfg
sed: 无法重命名 ./sedpMn3D2:不允许的操作
[root@node01 ~]# lsattr anaconda-ks.cfg 
-----a---------- anaconda-ks.cfg

用chattr给目录加i属性

[root@node01 ~]# chattr -R +i /opt/
[root@node01 ~]# touch /opt/haha
touch: 无法创建"/opt/haha": 权限不够
[root@node01 ~]# rm -rf /opt/salt 
rm: 无法删除"/opt/salt": 权限不够

用chattr给文件加i属性

[root@node01 ~]# chattr -R +i anaconda-ks.cfg 
[root@node01 ~]# rm -rf anaconda-ks.cfg 
rm: 无法删除"anaconda-ks.cfg": 不允许的操作
[root@node01 ~]# mv  anaconda-ks.cfg  /opt/
mv:是否覆盖"/opt/anaconda-ks.cfg"? y
mv: 无法将"anaconda-ks.cfg" 移动至"/opt/anaconda-ks.cfg": 不允许的操作
[root@node01 ~]# echo 'ajho' >> anaconda-ks.cfg 
-bash: anaconda-ks.cfg: 权限不够

file.chattr

给指定文件添加属性

[root@node01 ~]# salt 'node01' cmd.run 'lsattr  /root'
node01:
    ----ia---------- /root/anaconda-ks.cfg
    ---------------- /root/skl
[root@node01 ~]# salt 'node01' file.chattr /root/skl operator=add attributes=ai
node01:
    True
[root@node01 ~]# salt 'node01' cmd.run 'lsattr  /root'
node01:
    ----ia---------- /root/anaconda-ks.cfg
    ----ia---------- /root/skl

给指定文件删除属性

[root@node01 ~]# salt 'node01' cmd.run 'lsattr  /root'
node01:
    ----ia---------- /root/anaconda-ks.cfg
    ----ia---------- /root/skl
[root@node01 ~]# salt 'node01' file.chattr /root/skl operator=remove attributes=i
node01:
    True
[root@node01 ~]# salt 'node01' cmd.run 'lsattr  /root'
node01:
    ----ia---------- /root/anaconda-ks.cfg
    -----a---------- /root/skl

file.chown

设置指定文件的属主,属组信息

[root@node01 ~]# salt 'node01' cmd.run 'ls -l'
node01:
    total 8
    -rw------- 1 root root 1465 Feb 22 20:16 anaconda-ks.cfg
    -rw-r--r-- 1 root root    5 Feb 22 20:17 skl
[root@node01 ~]# salt 'node01' file.chown /root/skl tom tom
node01:
    None
[root@node01 ~]# salt 'node01' cmd.run 'ls -l'
node01:
    total 8
    -rw------- 1 root root 1465 Feb 22 20:16 anaconda-ks.cfg
    -rw-r--r-- 1 tom  tom     5 Feb 22 20:17 skl

file.cpy 在远程主机上复制文件或目录

[root@node01 ~]# salt '*' cmd.run 'ls '
node01:
    anaconda-ks.cfg
    dede
    skl
node02:
    anaconda-ks.cfg
    hah
    lala
    yoyo
[root@node01 ~]# salt '*' file.copy /root/anaconda-ks.cfg /root/kk
node01:
    True
node02:
    True
[root@node01 ~]# salt '*' cmd.run 'ls '
node01:
    anaconda-ks.cfg
    dede
    kk
    skl
node02:
    anaconda-ks.cfg
    hah
    kk
    lala
    yoyo

覆盖并拷贝目录,将会覆盖同名文件或目录

[root@node01 ~]# ls
anaconda-ks.cfg  kk  skl
[root@node01 ~]# ls /opt/
anaconda-ks.cfg  salt
[root@node01 ~]# salt '*' file.copy /opt/ /root/haha recurse=True
node01:
    True
node02:
    True
[root@node01 ~]# ls haha/
anaconda-ks.cfg  salt

删除目标目录中同名的文件或目录并拷贝新内容至其中

[root@node01 ~]# ls /opt/
anaconda-ks.cfg  salt
[root@node01 ~]# cat /opt/salt 
haha
huiganh
osjgjam
lllll
[root@node01 ~]# ls
anaconda-ks.cfg  haha  kk  skl
[root@node01 ~]# salt 'node01' file.copy /opt/salt /root/kk recurse=True remove_existing=True
node01:
    True
   [root@node01 ~]# cat kk 
haha
huiganh
osjgjam
lllll

file.ditectory_exists 判断指定目录是否存在

[root@node01 ~]# salt '*' cmd.run 'ls /opt -l'
node01:
    total 8
    -rw------- 1 root root 1451 Feb 22 19:52 anaconda-ks.cfg
    -rw-r--r-- 1 root root   27 Feb 22 19:31 salt
node02:
    total 4
    -rw-r--r--. 1 root root 5 Feb 22 18:59 anaconda-ks.cfg

[root@node01 ~]# salt '*' file.directory_exists '/opt/haha'
node01:
    True
node02:
    False

file.diskusage 查看路径的磁盘使用情况并以字节单位返回

[root@node01 ~]# salt '*' cmd.run 'du -sb /opt'
node01:
    1537	/opt
node02:
    34	/opt
[root@node01 ~]# salt '*' file.diskusage '/opt'
node01:
    1478
node02:
    5

file.file_exists判断指定文件是否存在

[root@node01 ~]# salt '*' cmd.run 'ls'
node01:
    anaconda-ks.cfg
    haha
    kk
    skl
node02:
    anaconda-ks.cfg
    hah
    haha
    kk
    lala
    yoyo
[root@node01 ~]# salt '*' file.file_exists /root/anaconda-ks.cfg 
node01:
    True
node02:
    True

file.find 和find命令类似

在root下面查找类型是目录,大小小于10兆

[root@node01 ~]# salt '*' file.find /root type=d  size=-10M
node01:
    - /root
    - /root/.pki
    - /root/.pki/nssdb
    - /root/.ssh
    - /root/haha
node02:
    - /root
    - /root/.pki
    - /root/.pki/nssdb
    - /root/haha

查看root下面30天之前的文件并且按照路径,大小和时间来显示

[root@node01 ~]# salt 'node01' file.find /root mtime=+30d print=path,size,mtime
node01:
    |_
      - /root/.bash_logout
      - 18
      - 1388283991
    |_
      - /root/.bash_profile
      - 176
      - 1388283991
    |_
      - /root/.bashrc
      - 176
      - 1388283991
    |_
      - /root/.cshrc
      - 100
      - 1388283991
    |_
      - /root/.pki
      - 19
      - 1579137198
    |_
      - /root/.pki/nssdb
      - 6
      - 1579137198
    |_
      - /root/.tcshrc
      - 129
      - 1388283991

删除root下面名字后面有数字的文件

[root@node01 ~]# touch u1
[root@node01 ~]# salt 'node01'  file.find /root name=\*[0-9] 
node01:
    - /root/u1
[root@node01 ~]# salt 'node01'  file.find /root name=\*[0-9] delete
node01:
    - /root/u1
[root@node01 ~]# ls
anaconda-ks.cfg  haha

file.get_gid

获取文件的gid

[root@node01 ~]# ll 
总用量 4
-rw------- 1 root root 1465 2月  22 20:16 anaconda-ks.cfg
drwxr-xr-x 2 root root    6 2月  23 19:43 haha
[root@node01 ~]# salt '*' file.get_gid /root/haha
node01:
    0
node02:
    0

file.get_group获取文件的组名

[root@node01 ~]# salt '*' file.get_group /root/haha
node01:
    root
node02:
    root

file.get_hash 获取文件的hash值,该值通过sha256算法得来

[root@node01 ~]# salt 'node01' cmd.run 'sha256sum /root/a'
node01:
    e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855  /root/a
[root@node01 ~]# salt 'node01' file.get_hash /root/a
node01:
    e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

file.get_mode 获取指定文件的权限,以数字方式显示

[root@node01 ~]# salt 'node01' cmd.run 'ls -l /root/a'
node01:
    -rw-r--r-- 1 root root 0 Feb 23 20:01 /root/a
[root@node01 ~]# salt 'node01' file.get_mode '/root/a'
node01:
    0644

file.get_selinux_context 获取指定文件的selinux上下文信息

[root@node01 ~]# salt 'node02' cmd.run 'ls -Z'
node02:
    -rw-------. root root system_u:object_r:admin_home_t:s0 anaconda-ks.cfg
    -rw-r--r--. root root unconfined_u:object_r:admin_home_t:s0 hah
    drwxr-xr-x. root root system_u:object_r:admin_home_t:s0 haha
    -rw-------. root root system_u:object_r:admin_home_t:s0 kk
    -rw-r--r--. root root system_u:object_r:admin_home_t:s0 lala
    -rw-r--r--. root root system_u:object_r:admin_home_t:s0 yoyo
[root@node01 ~]# salt 'node02' file.get_selinux_context /root/anaconda-ks.cfg 
node02:
    system_u:object_r:admin_home_t:s0

file.get_sum 按照指定的算法计算指定文件的特征码并显示,默认使用的sha256算法。

该函数可使用的算法参数有:

md5
sha1
sha224
sha256 (default)
sha384
sha512

使用sha256算法计算

[root@node01 ~]# salt 'node01' cmd.run 'sha256sum /root/a'
node01:
    e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855  /root/a
[root@node01 ~]#  salt 'node01' file.get_sum /root/a
node01:
    e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855

使用MD5算法计算

[root@node01 ~]# salt 'node01' cmd.run 'md5sum /root/a'
node01:
    d41d8cd98f00b204e9800998ecf8427e  /root/a
[root@node01 ~]#  salt 'node01' file.get_sum /root/a md5
node01:
    d41d8cd98f00b204e9800998ecf8427e

file.get_uid 获取指定文件的uid

[root@node01 ~]# salt 'node01' cmd.run 'ls -l /root/a'
node01:
    -rw-r--r-- 1 root root 0 Feb 23 20:01 /root/a

file.get_user 获取指定文件的用户名

[root@node01 ~]# salt 'node01' file.get_user /root/a
node01:
    root

file.gid_to_group 将指定的gid转换为组名

[root@node01 ~]# salt 'node01' file.gid_to_group 1000
node01:
    tom

file.group_to_gid 将指定的组名转换为gid

[root@node01 ~]# salt 'node01' file.group_to_gid tom
node01:
    1000

file.grep 在指定文件中检索指定内容,该函数支持通配符,若在指定的路径中用通配符则必须用双引号引起来

[root@node01 ~]# salt 'node01' file.grep /etc/passwd tom
node01:
    ----------
    pid:
        4702
    retcode:
        0
    stderr:
    stdout:
        tom:x:1000:1000::/home/tom:/bin/bash

file.grep加上-i可以不区分大小写

[root@node01 ~]# salt 'node01' file.grep /etc/sysconfig/network-scripts/ifcfg-ens33 ipaddr -- -i
node01:
    ----------
    pid:
        4806
    retcode:
        0
    stderr:
    stdout:
        IPADDR=192.168.100.131

file.grep加上A1,B1,C1是看搜索内容和下面一行,上面一行,上下两行

[root@node01 ~]# salt 'node01' file.grep /etc/sysconfig/network-scripts/ifcfg-ens33 ipaddr -- -i -A1
node01:
    ----------
    pid:
        4929
    retcode:
        0
    stderr:
    stdout:
        IPADDR=192.168.100.131
        NETMASK=255.255.255.0
[root@node01 ~]# salt 'node01' file.grep /etc/sysconfig/network-scripts/ifcfg-ens33 ipaddr -- -i -B1
node01:
    ----------
    pid:
        4944
    retcode:
        0
    stderr:
    stdout:
        ONBOOT=yes
        IPADDR=192.168.100.131
[root@node01 ~]# salt 'node01' file.grep /etc/sysconfig/network-scripts/ifcfg-ens33 ipaddr -- -i -C1
node01:
    ----------
    pid:
        4959
    retcode:
        0
    stderr:
    stdout:
        ONBOOT=yes
        IPADDR=192.168.100.131
        NETMASK=255.255.255.0

file.is_blkdev 判断文件是否是块设备文件

[root@node01 ~]# salt 'node01' cmd.run 'ls -l /dev/sr0'
node01:
    brw-rw---- 1 root cdrom 11, 0 Feb 27 19:36 /dev/sr0
[root@node01 ~]# salt 'node01' file.is_blkdev /dev/sr0 
node01:
    True

file.lsattr 检查指定文件的属性信息

[root@node01 ~]# salt 'node01' cmd.run 'lsattr /root/a'
node01:
    ---------------- /root/a
[root@node01 ~]# salt 'node01' cmd.run 'chattr +i /root/a'
node01:
[root@node01 ~]# salt 'node01' cmd.run 'lsattr /root/a'
node01:
    ----i----------- /root/a
    [root@node01 ~]# salt 'node01' file.lsattr /root/a
node01:
    ----------
    /root/a:
        - i

file.mkdir 创建目录并设置属主,属组权限

[root@node01 ~]# salt 'node01' cmd.run 'ls -l /root'
node01:
    total 796
    -rw-r--r-- 1 root root   2047 Feb 25 19:49 123.sql
    -rw-r--r-- 1 root root 802135 Feb 25 20:01 2019.sql
    -rw-r--r-- 1 root root      0 Feb 23 20:01 a
    -rw------- 1 root root   1465 Feb 22 20:16 anaconda-ks.cfg
    drwxr-xr-x 2 root root      6 Feb 23 19:43 haha
    dr-------- 2 tom  tom       6 Feb 27 18:58 jj
    -rw-r--r-- 1 root root     34 Feb 27 19:12 pass
[root@node01 ~]# salt 'node01' file.mkdir /root/lala tom tom 400
node01:
    True
[root@node01 ~]# salt 'node01' cmd.run 'ls -ld /root/lala '
node01:
    dr-------- 2 tom tom 6 Feb 27 20:02 /root/lala

file.move 移动或者重命名

重命名

[root@node01 ~]# salt 'node02' cmd.run 'ls /root'
node02:
    anaconda-ks.cfg
    jjjj
    kk
    lala
    yoyo
[root@node01 ~]# salt 'node02' cmd.run 'ls /root'
node02:
    anaconda-ks.cfg
    lala
[root@node01 ~]# salt 'node02' file.move /root/lala /root/haha
node02:
    ----------
    comment:
        '/root/lala' moved to '/root/haha'
    result:
        True
[root@node01 ~]# salt 'node02' cmd.run 'ls /root'
node02:
    anaconda-ks.cfg
    haha

移动

[root@node01 ~]# salt 'node02' cmd.run 'ls /opt'
node02:
[root@node01 ~]# salt 'node02' file.move /root/haha /opt/
node02:
    ----------
    comment:
        '/root/haha' moved to '/opt/'
    result:
        True
[root@node01 ~]# salt 'node02' cmd.run 'ls /opt'
node02:
    haha

file.prepend 把文本插入指定文件的开头

[root@node01 ~]# salt 'node01' cmd.run 'cat /root/pass'
node01:
    k2Y=U=hekwOI
[root@node01 ~]# salt 'node01' file.prepend /root/pass 'haha' 'lala'
node01:
    Prepended 2 lines to "/root/pass"
[root@node01 ~]# salt 'node01' cmd.run 'cat /root/pass'
node01:
    haha
    lala
    k2Y=U=hekwOI

修改文件的文本内容

[root@node01 ~]# salt 'node01' cmd.run 'cat /root/pass'
node01:
    haha
    lala
    k2Y=U=hekwOI
[root@node01 ~]# salt 'node01' file.sed /root/pass 'haha' 'runtime'
node01:
    ----------
    pid:
        6442
    retcode:
        0
    stderr:
    stdout:
[root@node01 ~]# salt 'node01' cmd.run 'cat /root/pass'
node01:
    runtime
    lala
    k2Y=U=hekwOI

用sed模块将每一行的第二个lala改为haha

[root@node01 ~]# salt 'node01' cmd.run 'cat /root/pass'
node01:
    runtime
    lala lala lala
    k2Y=U=hekwOI
[root@node01 ~]# salt 'node01' file.sed /root/pass 'lala' 'haha' flags=2
node01:
    ----------
    pid:
        6672
    retcode:
        0
    stderr:
    stdout:
[root@node01 ~]# salt 'node01' cmd.run 'cat /root/pass'
node01:
    runtime
    lala haha lala
    k2Y=U=hekwOI

file.read 读取文件内容

[root@node01 ~]# salt 'node01' cmd.run 'cat /root/pass'
node01:
    runtime
    lala haha lala
    k2Y=U=hekwOI
    [root@node01 ~]# salt 'node01' file.read /root/pass
node01:
    runtime
    lala haha lala
    k2Y=U=hekwOI

file.readdir 列出指定目录下的所有文件或目录,包括隐藏文件

[root@node01 ~]# salt 'node01' file.readdir /root
node01:
    - .
    - ..
    - .pki
    - .ssh
    - anaconda-ks.cfg
    - haha
    - a
    - .bash_history
    - .bash_logout
    - .bash_profile
    - .bashrc
    - .mysql_history
    - .my.cnf
    - 123.sql
    - 2019.sql
    - jj
    - lala
    - pass.bak
    - pass

file.remove 删除指定的文件或目录,若给出的是目录,将递归删除

[root@node01 ~]# salt 'node01' cmd.run 'ls -l /root'
node01:
    total 800
    -rw-r--r-- 1 root root   2047 Feb 25 19:49 123.sql
    -rw-r--r-- 1 root root 802135 Feb 25 20:01 2019.sql
    -rw-r--r-- 1 root root      0 Feb 23 20:01 a
    -rw------- 1 root root   1465 Feb 22 20:16 anaconda-ks.cfg
    drwxr-xr-x 2 root root      6 Feb 23 19:43 haha
    dr-------- 2 tom  tom       6 Feb 27 18:58 jj
    dr-------- 2 tom  tom       6 Feb 27 20:02 lala
    -rw-r--r-- 1 root root     36 Feb 27 20:15 pass
    -rw-r--r-- 1 root root     36 Feb 27 20:14 pass.bak
[root@node01 ~]# salt 'node01' file.remove /root/jj
node01:
    True
[root@node01 ~]# salt 'node01' cmd.run 'ls -l /root'
node01:
    total 800
    -rw-r--r-- 1 root root   2047 Feb 25 19:49 123.sql
    -rw-r--r-- 1 root root 802135 Feb 25 20:01 2019.sql
    -rw-r--r-- 1 root root      0 Feb 23 20:01 a
    -rw------- 1 root root   1465 Feb 22 20:16 anaconda-ks.cfg
    drwxr-xr-x 2 root root      6 Feb 23 19:43 haha
    dr-------- 2 tom  tom       6 Feb 27 20:02 lala
    -rw-r--r-- 1 root root     36 Feb 27 20:15 pass
    -rw-r--r-- 1 root root     36 Feb 27 20:14 pass.bak

file.rename 重命名文件或目录

[root@node01 ~]# salt 'node01' cmd.run 'ls -l /root'
node01:
    total 800
    -rw-r--r-- 1 root root   2047 Feb 25 19:49 123.sql
    -rw-r--r-- 1 root root 802135 Feb 25 20:01 2019.sql
    -rw-r--r-- 1 root root      0 Feb 23 20:01 a
    -rw------- 1 root root   1465 Feb 22 20:16 anaconda-ks.cfg
    drwxr-xr-x 2 root root      6 Feb 23 19:43 haha
    dr-------- 2 tom  tom       6 Feb 27 20:02 lala
    -rw-r--r-- 1 root root     36 Feb 27 20:15 pass
    -rw-r--r-- 1 root root     36 Feb 27 20:14 pass.bak
[root@node01 ~]# salt 'node01' file.rename /root/pass.bak /root/kkkk
node01:
    True
[root@node01 ~]# salt 'node01' cmd.run 'ls -l /root'
node01:
    total 800
    -rw-r--r-- 1 root root   2047 Feb 25 19:49 123.sql
    -rw-r--r-- 1 root root 802135 Feb 25 20:01 2019.sql
    -rw-r--r-- 1 root root      0 Feb 23 20:01 a
    -rw------- 1 root root   1465 Feb 22 20:16 anaconda-ks.cfg
    drwxr-xr-x 2 root root      6 Feb 23 19:43 haha
    -rw-r--r-- 1 root root     36 Feb 27 20:14 kkkk
    dr-------- 2 tom  tom       6 Feb 27 20:02 lala
    -rw-r--r-- 1 root root     36 Feb 27 20:15 pass

file.set_mode 给指定文件设置权限

[root@node01 ~]# salt 'node01' cmd.run 'ls -l /root'
node01:
    total 800
    -rw-r--r-- 1 root root   2047 Feb 25 19:49 123.sql
    -rw-r--r-- 1 root root 802135 Feb 25 20:01 2019.sql
    -rw-r--r-- 1 root root      0 Feb 23 20:01 a
    -rw------- 1 root root   1465 Feb 22 20:16 anaconda-ks.cfg
    drwxr-xr-x 2 root root      6 Feb 23 19:43 haha
    -rw-r--r-- 1 root root     36 Feb 27 20:14 kkkk
    dr-------- 2 tom  tom       6 Feb 27 20:02 lala
    -rw-r--r-- 1 root root     36 Feb 27 20:15 pass
[root@node01 ~]# salt 'node01' file.set_mode /root/lala 0700
node01:
    0700
[root@node01 ~]# salt 'node01' cmd.run 'ls -ld  /root/lala'
node01:
    drwx------ 2 tom tom 6 Feb 27 20:02 /root/lala

file.symlink 给指定文件创建软连接

[root@node01 ~]# salt 'node01' cmd.run 'ls /root'
node01:
    123.sql
    2019.sql
    a
    anaconda-ks.cfg
    haha
    kkkk
    lala
    pass
[root@node01 ~]# salt 'node01' file.symlink /root/a /root/ll
node01:
    True
[root@node01 ~]# salt 'node01' cmd.run 'ls -l /root'
node01:
    total 800
    -rw-r--r-- 1 root root   2047 Feb 25 19:49 123.sql
    -rw-r--r-- 1 root root 802135 Feb 25 20:01 2019.sql
    -rw-r--r-- 1 root root      0 Feb 23 20:01 a
    -rw------- 1 root root   1465 Feb 22 20:16 anaconda-ks.cfg
    drwxr-xr-x 2 root root      6 Feb 23 19:43 haha
    -rw-r--r-- 1 root root     36 Feb 27 20:14 kkkk
    drwx------ 2 tom  tom       6 Feb 27 20:02 lala
    lrwxrwxrwx 1 root root      7 Feb 27 20:31 ll -> /root/a
    -rw-r--r-- 1 root root     36 Feb 27 20:15 pass

file.touch 创建空文件或者更新时间戳

[root@node01 ~]# salt 'node01' cmd.run 'ls -l /opt'
node01:
    total 8
    -rw------- 1 root  root  1451 Feb 22 19:52 anaconda-ks.cfg
    drwxr-xr-x 6 mysql mysql  200 Feb 25 20:34 data
    drwxr-xr-x 2 root  root     6 Feb 23 18:45 haha
    -rw-r--r-- 1 root  root    27 Feb 22 19:31 salt
[root@node01 ~]# salt 'node01' file.touch /opt/cc
node01:
    True
[root@node01 ~]# salt 'node01' cmd.run 'ls -l /opt'
node01:
    total 8
    -rw------- 1 root  root  1451 Feb 22 19:52 anaconda-ks.cfg
    -rw-r--r-- 1 root  root     0 Feb 27 20:34 cc
    drwxr-xr-x 6 mysql mysql  200 Feb 25 20:34 data
    drwxr-xr-x 2 root  root     6 Feb 23 18:45 haha
    -rw-r--r-- 1 root  root    27 Feb 22 19:31 salt
[root@node01 ~]# salt 'node01' cmd.run 'ls -l /opt'
node01:
    total 8
    -rw-r--r-- 1 root  root     0 Feb 27 20:34 aa
    -rw------- 1 root  root  1451 Feb 22 19:52 anaconda-ks.cfg
    -rw-r--r-- 1 root  root     0 Feb 27 20:34 cc
    drwxr-xr-x 6 mysql mysql  200 Feb 27 20:35 data
    drwxr-xr-x 2 root  root     6 Feb 23 18:45 haha
    -rw-r--r-- 1 root  root    27 Feb 22 19:31 salt
[root@node01 ~]# salt 'node01' file.touch /opt/haha
node01:
    True
[root@node01 ~]# salt 'node01' cmd.run 'ls -l /opt'
node01:
    total 8
    -rw-r--r-- 1 root  root     0 Feb 27 20:34 aa
    -rw------- 1 root  root  1451 Feb 22 19:52 anaconda-ks.cfg
    -rw-r--r-- 1 root  root     0 Feb 27 20:34 cc
    drwxr-xr-x 6 mysql mysql  200 Feb 27 20:35 data
    drwxr-xr-x 2 root  root     6 Feb 27 20:36 haha
    -rw-r--r-- 1 root  root    27 Feb 22 19:31 salt

file.uid_to_user 将指定的uid转移成用户名显示出来

[root@node01 ~]# salt 'node01' file.uid_to_user 0
node01:
    root

file.user_to_uid 将指定的用户装换成uid显示

[root@node01 ~]# salt 'node01' file.user_to_uid tom
node01:
    1000

file.write 往一个指定文件里覆盖指定内容

[root@node01 ~]# salt 'node01' cmd.run 'cat /root/pass'
node01:
    runtime
    lala haha lala
    k2Y=U=hekwOI
[root@node01 ~]# salt 'node01' file.write /root/pass 'youushg'
node01:
    Wrote 1 lines to "/root/pass"
[root@node01 ~]# salt 'node01' cmd.run 'cat /root/pass'
node01:
    youushg

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值