SaltStack 鎵归噺鎿嶄綔Windows

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SaltStack 鎵归噺鎿嶄綔Windows相关的知识,希望对你有一定的参考价值。

鏍囩锛?a href='http://www.mamicode.com/so/1/ada' title='ada'>ada   tun   nodegroup   linux   otf   tunnel   榛樿   tco   win   

涓€銆佸熀纭€鐜

[root@BJ-SaltStack-Node1 ~]#  cat /etc/redhat-release 
CentOS Linux release 7.7.1908 (Core)
[root@BJ-SaltStack-Node1 ~]# python --version
Python 2.7.5

浜屻€丼altSatck 瀹夎
瀹屽叏鎸夌収瀹樻柟鏂囨。鏉ュ嵆鍙€?br/>https://repo.saltstack.com/2018.3.html#rhel

涓夈€丮aster 閰嶇疆鏂囦欢

榛樿閰嶇疆鍗冲彲姝e父宸ヤ綔銆?/p>

[root@BJ-SaltStack-Node1 ~]# cat /etc/salt/master  | grep -v ^# |grep -v ^$
  default_include: master.d/*.conf
  file_roots:
    base:
      - /srv/salt
    dev:
      - /srv/salt/dev/services
      - /srv/salt/dev/states
    prod:
      - /srv/salt/prod/services
      - /srv/salt/prod/states

salt-minion 瀹夎鐣ャ€?/p>

鍥涖€侀€氳繃cmd妯″潡鎿嶄綔windows

1.鍏堢湅涓媍md妯″潡鍖呭惈鍝簺鏂规硶

[root@BJ-SaltStack-Node1 ~]# salt 鈥楤J-WJ-T-DCS-01鈥?sys.list_functions cmd 
BJ-WJ-T-DCS-01:
    - 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
    - cmd.win_runas

2.鐪嬬湅鐩稿叧鏂规硶鐨勭敤娉?/p>

#濡?salt 鈥楤J-WJ-T-DCS-01鈥?sys.doc cmd.run 

salt 鈥楤J-WJ-T-DCS-01鈥?sys.doc cmd.powershell

3.娴嬭瘯涓€涓媍md.run鍜宑md.script

cmd.run

root@BJ-SaltStack-Node1 ~]# salt 鈥楤J-WJ-T-DCS-01鈥?cmd.run 鈥榟ostname鈥? shell=鈥榩owershell鈥?BJ-WJ-T-DCS-01:
    BJ-WJ-T-DCS-01

[root@BJ-SaltStack-Node1 scripts]# salt 鈥楤J-WJ-T-DCS-01鈥?cmd.run 鈥榞et-hotfix -hfid KB4532931鈥? shell=鈥榩owershell鈥?BJ-WJ-T-DCS-01:

    Source        Description      HotFixID      InstalledBy          InstalledOn  
    ------        -----------      --------      -----------          -----------  
    BJ-WJ-T-DC... Update           KB4532931     NT AUTHORITYSYSTEM  2020/4/10 ...

cmd.script

#鑴氭湰鍐呭锛岃幏鍙栨寚瀹歬b鐨勫畨瑁呮椂闂?[root@BJ-SaltStack-Node1 scripts]# cat get_hotfix.ps1 
 $a = Get-HotFix  | Where-Object {$_.HotFixid -eq "KB4532931"}

 $a.InstalledOn

 #鐢╯alt 鎵ц
 [root@BJ-SaltStack-Node1 scripts]# salt 鈥楤J-WJ-T-DCS-01鈥?cmd.script salt://scripts/get_hotfix.ps1 shell=鈥榩owershell鈥?BJ-WJ-T-DCS-01:
    ----------
    pid:
        3916
    retcode:
        0
    stderr:
    stdout:

        2020?4?10? 0:00:00

浜斻€佹壒閲忔搷浣?/p>

鏈€绠€鍗曠殑鍙互瀹氫箟缁勶細

[root@BJ-SaltStack-Node1 scripts]# cat /etc/salt/master.d/nodegroups.conf 
nodegroups:
  jump_win: 鈥楲@BJ-WJ-Jump-01,BJ-WJ-Jump-02,BJ-DX-JumpLS-01鈥?  demo: 鈥楲@BJ-WJ-T-DCS-01,BJ-WJ-T-DCS-02鈥?

鐒跺悗瀵圭粍杩涜鎵归噺鎿嶄綔锛?/p>

[root@BJ-SaltStack-Node1 scripts]#  salt -N demo cmd.run 鈥榠pconfig 鈥?shell=鈥榩owershell鈥?BJ-WJ-T-DCS-01:

    Windows IP Configuration

    Ethernet adapter 浠ュお缃?

       Connection-specific DNS Suffix  . : 
       IPv4 Address. . . . . . . . . . . : 172.16.7.54
       Subnet Mask . . . . . . . . . . . : 255.255.255.0
       Default Gateway . . . . . . . . . : 172.16.7.1

    Tunnel adapter isatap.{77A1A005-DE37-488B-A1E7-98CDB838E01E}:

       Media State . . . . . . . . . . . : Media disconnected
       Connection-specific DNS Suffix  . :
BJ-WJ-T-DCS-02:

    Windows IP Configuration

    Ethernet adapter 浠ュお缃?

       Connection-specific DNS Suffix  . : 
       IPv4 Address. . . . . . . . . . . : 172.16.7.55
       Subnet Mask . . . . . . . . . . . : 255.255.255.0
       Default Gateway . . . . . . . . . : 172.16.7.1

    Tunnel adapter isatap.{2526DE3F-E74C-4175-B209-B15F924284BB}:

       Media State . . . . . . . . . . . : Media disconnected
       Connection-specific DNS Suffix  . :

以上是关于SaltStack 鎵归噺鎿嶄綔Windows的主要内容,如果未能解决你的问题,请参考以下文章

鎵归噺鎶撳寘

redis鎵归噺鍒犻櫎鎸囧畾鍓嶇紑key鍥涚鏂规硶

CRM admin浣跨敤actions鎵归噺鐢熸垚涓婅璁板綍

Java鎿嶄綔JSON鏁版嵁--Gson鎿嶄綔JSON鏁版嵁

鎿嶄綔绯荤粺-鎿嶄綔绯荤粺-鍐呮牳涓殑灞忓箷鎵撳嵃(涓?

鏁版嵁搴撶瑪璁?馃搾 MySQL鍩虹鎿嶄綔鍛戒护 鍒嗙被娓呮櫚