Saltstack-api (12)

Source: Internet
Author: User
Tags openssl rsa saltstack

Saltstack-api

Official Document Https://docs.saltstack.com/en/latest/ref/netapi/all/salt.netapi.rest_cherrypy.html

conditions of Use: 1) HTTPS call, need to generate certificate 2) configuration file 3) using PAM authentication 4) Start Salt-api

installation
Yum Install-y Salt-api

Implementation Method

1) Create user useradd-m-s/sbin/nologin Saltapi

2) Set Password passwd saltapi

3) generate a self-signed certificate

Cd/etc/pki/tls/certs

MV Localhost.crt/tmp

Make TestCert

Cd/etc/pki/tls/private

If you enter a password when you generate the certificate above, you need to cancel the password

OpenSSL rsa-in localhost.key-out Salt_nopass.key

4) Install CherryPy module, version 3.2.6

Pip Install cherrypy==3.2.6

5) Modify master configuration file

Vi/etc/salt/masterdefault_include:master.d/*.conf

6) Creating an API configuration file

Cd/etc/salt/master.d/vi api.confrest_cherrypy:  host:192.168.137.11  port:8000  ssl_crt:/etc/pki/tls/ CERTS/LOCALHOST.CRT  Ssl_key:/etc/pki/tls/private/salt_nopass.key

7) Certification Documents

VI Eauth.confexternal_auth:  pam:    saltapi:      -. *      -' @wheel '      -' @runner '

Remarks: . * # All modules executable, ' @wheel ' # Salt key

8) Restart Master

Systemctl Restart Salt-master.service

Introduction to use

1) login test, use Curl request

Curl-k https://192.168.137.11:8000/login-     h ' accept:application/x-yaml '-     D Username=saltapi-     D Password=saltapi-     D eauth=pam

After successful login, the system returns token for subsequent interactive use.

2) Get Minion Asset data test, node is linux-node1.example.com host

Curl-k https://192.168.137.11:8000/minions/linux-node1.example.com-     h ' accept:application/x-yaml '-     h ' X-auth-token:token content '

3) View all Minion surviving hosts

Curl-k https://192.168.137.11:8000/-     h ' accept:application/x-yaml '-     h ' x-auth-token:token content '-     D Client= ' Runner '-     D fun= ' Manage.status '

Note:client= ' runner ' refers to the execution in the master, client= ' local ' refers to the execution in minion

4) Ping test

Curl-k https://192.168.137.11:8000/-     h ' accept:application/x-yaml '-     h ' x-auth-token:token content '-     D client = ' Local '-     d tgt= ' * '-    d fun= ' test.ping '

The TGT represents the target, and you can specify a single minion

5) View Jobs

Curl-k https://192.168.137.11:8000/jobs-     h ' accept:application/x-yaml '-     h ' x-auth-token:token content '

6) View the execution results of a specific jobs

Curl-k https://192.168.137.11:8000/jobs/jobid-     h ' accept:application/x-yaml '-     h ' x-auth-token:token content '

Saltstack-api (12)

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.