CMDB Asset Management Acquisition

Source: Internet
Author: User
Tags unique id

Paramiko

1 ImportParamiko2  3Private_key = Paramiko. Rsakey.from_private_key_file ('/home/auto/.ssh/id_rsa')4  5 #To create an SSH object6SSH =Paramiko. Sshclient ()7 #allow connections to hosts that are not in the Know_hosts file8 Ssh.set_missing_host_key_policy (Paramiko. Autoaddpolicy ())9 #connecting to a serverTenSsh.connect (hostname='c1.salt.com', Port=22, Username='Wupeiqi', key=Private_key) One   A #Execute Command -stdin, stdout, stderr = Ssh.exec_command ('DF') - #Get command Results theresult =Stdout.read () -   - #Close Connection - ssh.close () +  -Paramiko

Saltstack

1. Installation and Configuration

1 """ 2 1. Install Salt-master  3    yum install salt-master  42. Modify the configuration file:/etc/salt/master  5    interface:0.0.0.0      63. Start up  7    Service Salt-master start  8 "" 9 Master
1 """2 1. Installing Salt-minion3 Yum Install salt-minion4 5 2. Modify the configuration file/etc/salt/minion6 master:10.211.55.4 # Master's address7 or8 Master:9 -10.211.55.4Ten -10.211.55.5 One random_master:true A  - Id:c2.salt.com # The unique ID that the client displays in Salt-master - 3. Start the Service salt-minion Start - """ -  -Slave

2. Authorization

1 """ 2 salt-key-l                    # View authorized and unauthorized slave3salt-key-a  salve_id      # Accept Salve 4 of the specified ID salt-key-r  salve_id      # Deny salve5salt-key-d  salve_id      # of the specified ID Delete Salve6"""78 Master with the specified ID

3. Execution of commands

Remote operation of the salve on the master server

1Salt'c2.salt.com'Cmd.run'ifconfig'
Equivalent to Python:2 Importsalt.client3Local =salt.client.LocalClient ()4result = Local.cmd ('c2.salt.com','Cmd.run', ['ifconfig'])

CMDB Asset Management Acquisition

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.