Salt common commands

Source: Internet
Author: User

Easy to see for yourself. Just record ...


Saltstack Common Commands

* refers to all the Minion

salt -d //View Help Documentation salt -d|grep service //view service-related module commands salt  ' * '  sys.doc  //viewing the Help document salt-key  -l            # Query all received certificates salt-key  -a < certificate name >    #接收单个证书salt-key  -a              #接受所有证书salt-key  -d < Certificate name >     #删除单个证书salt-key  -d              #删除所有证书salt   ' * '  service.get_all //get host all services salt  ' * '  service.reload  sshd //Reload sshd Service salt  ' * '  pkg.list_pkgs  //Show package version list salt  ' * '  pkg.version  python //Display Package version information salt  ' * '  pkg.install httpd //install package salt  ' node1.com '   service.status mysql //view MySQL service status salt  ' node1.com '  service.start mysql // Start the MySQL service salt  ' node1.com '  cmd.run  ' Service mysql status '  //as above view service salt  ' * '  sys.list_modules // Module List salt-cp  ' * '   /etc/hosts   /etc/hosts //distribute the Hosts file on master to all host salt   ' * '  cp.get_file salt://ceshi/b /tmp/test //bar salt-master the corresponding file, distribute the file to the Minion-side salt  ' * '  cp.get_dir salt://zabbix /tmp //bar salt-master The corresponding directory, distributing files to Minion salt  ' * '   file.copy /tmp/zabbix.sls /tmp/sls //salt-master Copy the corresponding file to the corresponding directory on the Minion side.


The cmd module is commonly used to execute remote command modules with powerful features

Salt ' * ' cmd.run ' uptime '//remote command execution test


Remote Execute script command

' Cmd.script: '         salt  ' * '  cmd.script salt://scripts /runme.sh        salt  ' * '  cmd.script salt://scripts/ runme.sh  ' arg1 arg2  ' arg 3 '         salt  ' * '  cmd.script salt://scripts/windows_task.ps1 args= '  -input c:\tmp\infile.txt '   Shell= ' PowerShell '         salt  ' * '  cmd.script salt:// scripts/runme.sh stdin= ' one\ntwo\nthree\nfour\nfive\n ' Cmd.shell: '          This passes the cmd argument directly to the shell         salt  ' * '  cmd.shell  ' ls -l | awk  ' /foo/{print \$2} '         salt  ' * '  cmd.shell  template=jinja  "ls -l /tmp/{{grains.id}} | awk  '/foo/{print \$2} '          salt  ' * '  cmd.shell  ' get-childitem c:\  '  shell= ' PowerShell '          salt  ' * '  cmd.shell  ' grep f '  stdin= ' one\ntwo \nthree\nfour\nfive\n '         salt  ' * '  cmd.shell cmd= ' Sed -e s/=/:/g ' cmd.shells: '         salt  ' * '   Cmd.shells ' cmd.tty: '         salt  ' * '  cmd.tty tty0  ' This is a test '         salt  ' * '  cmd.tty  pts3  ' this is a test ' Cmd.which: '          salt  ' * '  cmd.which cat

Grains Options

Salt ' * ' grains.ls//view grains category Salt ' * ' grains.items//view grains All information salt ' * ' grains.item osrelease//view grains a message


Salt-run Options

Salt-run Manage.up See the surviving Minionsalt-run Manage.down see the Dead minionsalt-run manage.down removekeys=t Rue view down the Minion and delete it Salt-run manage.status view Minion's related status Salt-run manage.versions view all of the Slat's master and Version information for Minion

Job Management

The active method runs saltutil.running on all minions, outputting all running tasks in a more efficient and dense manner. The active method will also output when comparing the tasks that have been returned and the tasks that are running to make it more intuitive to see which system tasks have been completed , which system's tasks are still being processed

Salt-run jobs.activesalt \* saltutil.running//view run jobs idsalt \* saltutil.kill_job 20151209034239907625//kill off process ID

before querying the history task, you need to get the specified task ID. List_jobs is able to parse the cached execution data and display all completed or partially completed task information .

Salt-run Jobs.list_jobssalt-run jobs.list_job 20151208172130003474


The state module is the management module for the Minion, which can operate the SLS status with a simple

Salt ' node1.com ' state.highstate//update all SLS status Salt ' node1.com ' state.running for specified minons//view current running SLS status


This article is from the "Village Boys" blog, please make sure to keep this source http://noodle.blog.51cto.com/2925423/1744607

Salt common commands

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.