saltstack的grains类似于ansible的setup模块,主要作用为手机客户端的主机基本信息(cpu,内核,os,virtual等)
[[email protected]_master ~]# cat /etc/salt/master |grep -v "^#\|^$" cachedir: /var/cache/salt/master auto_accept: True file_recv: True file_roots: base: - /root nodegroups: master1: ‘[email protected]_master‘ agents: ‘[email protected]_node1,k8s_node2‘
查看主机的详细信息
salt -N ‘master1‘ grains.items
查看所有键
[[email protected]_master ~]# salt -N master1 grains.ls k8s_master: - SSDs - biosreleasedate - biosversion - cpu_flags - cpu_model - cpuarch - domain - fqdn - fqdn_ip4 - fqdn_ip6 - gpus - host - hwaddr_interfaces - id - init - ip4_interfaces - ip6_interfaces - ip_interfaces - ipv4 - ipv6 - kernel - kernelrelease - locale_info - localhost - lsb_distrib_id - machine_id - manufacturer - master - mdadm - mem_total - nodename - num_cpus - num_gpus - os - os_family - osarch - oscodename - osfinger - osfullname - osmajorrelease - osrelease - osrelease_info - path - productname - ps - pythonexecutable - pythonpath - pythonversion - saltpath - saltversion - saltversioninfo - selinux - serialnumber - server_id - shell - systemd - virtual - zmqversion
用法示例: salt <匹配主机> grains.item <grains.ls>获取的键
[[email protected]_master ~]# salt -N master1 grains.item ipv4 k8s_master: ---------- ipv4: - 10.1.14.0 - 127.0.0.1 - 172.17.0.1 - 192.168.132.148