Saltstack数据系统初探

2023年 7月 15日 50.0k 0

Saltstack数据系统Grains:静态数据当minion启动,收集服务器所有信息保存,在后面进行调用,如果需要设备变动则需要重启进行收集信息Pillar

grains.items可查看服务器的详细信息,也可以分别刷选

[root@master ~]# salt 'minion.23.com' grains.items
minion.23.com:
    ----------
    SSDs:
    biosreleasedate:
        05/20/2014
    biosversion:
        6.00
    cpu_flags:
        - fpu
        - vme
        - de
        - pse
        - tsc
        - msr
        - pae
        - mce
    cpu_model:
        Intel(R) Xeon(R) CPU E3-1230 v3 @ 3.30GHz
    cpuarch:
        x86_64
    domain:
    fqdn:
        minion1
    fqdn_ip4:
        - 180.168.41.175
    fqdn_ip6:
    gpus:
        |_
          ----------
          model:
              SVGA II Adapter
          vendor:
              unknown
    host:
        minion1
    hwaddr_interfaces:
        ----------
        eth1:
            00:0c:29:77:21:16
        lo:
            00:00:00:00:00:00
    id:
        minion.23.com
    init:
        upstart
    ip4_interfaces:
        ----------
        eth1:
            - 10.0.0.23
        lo:
            - 127.0.0.1
    ip6_interfaces:
        ----------
        eth1:
            - fe80::20c:29ff:fe77:2116
        lo:
            - ::1
    ip_interfaces:
        ----------
        eth1:
            - 10.0.0.23
            - fe80::20c:29ff:fe77:2116
        lo:
            - 127.0.0.1
            - ::1
    ipv4:
        - 10.0.0.23
        - 127.0.0.1
    ipv6:
        - ::1
        - fe80::20c:29ff:fe77:2116
    kernel:
        Linux
    kernelrelease:
        2.6.32-504.el6.x86_64
    locale_info:
        ----------
        defaultencoding:
            UTF8
        defaultlanguage:
            en_US
        detectedencoding:
            UTF-8
    localhost:
        minion1
    lsb_distrib_codename:
        Final
    lsb_distrib_id:
        CentOS
    lsb_distrib_release:
        6.6
    machine_id:
        2ed4a92704e1ebf06cf1c9f80000000b
    manufacturer:
        VMware, Inc.
    master:
        10.0.0.22
    mdadm:
    mem_total:
        980
    nodename:
        minion1
    num_cpus:
        1
    num_gpus:
        1
    os:
        CentOS
    os_family:
        RedHat
    osarch:
        x86_64
    oscodename:
        Final
    osfinger:
        CentOS-6
    osfullname:
        CentOS
    osmajorrelease:
        6
    osrelease:
        6.6
    osrelease_info:
        - 6
        - 6
    path:
        /sbin:/usr/sbin:/bin:/usr/bin
    productname:
        VMware Virtual Platform
    ps:
        ps -efH
    pythonexecutable:
        /usr/bin/python2.6
    pythonpath:
        - /usr/bin
        - /usr/lib64/python26.zip
        - /usr/lib64/python2.6
        - /usr/lib64/python2.6/plat-linux2
        - /usr/lib64/python2.6/lib-tk
        - /usr/lib64/python2.6/lib-old
        - /usr/lib64/python2.6/lib-dynload
        - /usr/lib64/python2.6/site-packages
        - /usr/lib64/python2.6/site-packages/gst-0.10
        - /usr/lib64/python2.6/site-packages/gtk-2.0
        - /usr/lib64/python2.6/site-packages/webkit-1.0
        - /usr/lib/python2.6/site-packages
    pythonversion:
        - 2
        - 6
        - 6
        - final
        - 0
    saltpath:
        /usr/lib/python2.6/site-packages/salt
    saltversion:
        2015.5.5
    saltversioninfo:
        - 2015
        - 5
        - 5
        - 0
    selinux:
        ----------
        enabled:
            False
        enforced:
            Disabled
    serialnumber:
        VMware-56 4d 67 7b b3 c5 57 53-89 4d 88 a7 38 77 21 16
    server_id:
        1982461425
    shell:
        /bin/sh
    virtual:
        VMware
    zmqversion:
        3.2.5
[root@master ~]# 

分别刷选

[root@master ~]#  salt 'minion.23.com' grains.item os
minion.23.com:
    ----------
    os:
        CentOS
[root@master ~]# 

键值显示

[root@master ~]#  salt 'minion.23.com' grains.ls
minion.23.com:
    - SSDs
    - biosreleasedate
    - biosversion
    - cpu_flags
    - cpu_model
    - cpuarch
    - domain
    - fqdn
[root@master ~]# 

get取值

[root@master ~]#  salt 'minion.23.com' grains.get os
minion.23.com:
    CentOS
[root@master ~]#  salt 'minion.23.com' grains.item os
minion.23.com:
    ----------
    os:
        CentOS
[root@master ~]# 


-G过滤os为centos的机器

[root@master ~]# salt -G 'os:CentOS' test.ping
master.22.com:
    True
minion.21.com:
    True
minion.23.com:
    True
[root@master ~]# 

minion1是minion.23.com的主机名,一般情况下主机名和id一致

[root@master ~]# salt 'minion.23.com' grains.get fqdn
minion.23.com:
    minion1
[root@master ~]# salt -G 'fqdn:minion1' test.ping
minion.23.com:
    True
[root@master ~]# 

Saltstack数据系统初探-1

相关文章

对接alertmanager创建钉钉卡片(1)
手把手教你搭建OpenFalcon监控系统
无需任何魔法即可使用 Ansible 的神奇变量“hostvars”
openobseve HA本地单集群模式
基于k8s上loggie/vector/openobserve日志收集
openobseve单节点和查询语法

发布评论