zoukankan      html  css  js  c++  java
  • salt-ssh

    1.生产---测试--开发

    salt-runners

    salt-run manage.status#显示当前up或down的minion

    salt-run manage.down

    salt-run manage.up

    salt-run manage.down removekeys=True #显示未存活的minion,并将其删除

    salt-run manage.versions

    2,salt-ssh

    https://docs.saltstack.com/en/latest/topics/ssh/

    服务端安装:

    yum install salt-ssh -y

    定义目标:

    salt roster 花名册[目标+参数]

    定义目标主机----->通过saltssh执行

    [root@linux-node1 .ssh]# cat /etc/salt/roster
    # Sample salt-ssh config file
    #web1:
    #  host: 192.168.42.1 # The IP addr or DNS hostname
    #  user: fred         # Remote executions will be executed as user fred
    #  passwd: foobarbaz  # The password to use for login, if omitted, keys are used
    #  sudo: True         # Whether to sudo to root, not enabled by default
    #web2:
    #  host: 192.168.42.2
    
    linux-node1.example.com:
      host: 192.168.14.129
      user: root
      port: 22
    
    linux-node2.example.com:
      host: 192.168.14.130
      user: root
      port: 22
    linux-node3.example.com:
      host: 192.168.14.134
      user: root
      port: 22

    注意:首次使用salt-ssh连接一台陌生主机时候,需要kownhosts.  必须手动ssh 对端ip ,输yes后获取kownhosts后,然后再通过salt-ssh首次连接部署.

    [root@linux-node1 .ssh]# salt-ssh 'linux-node3.example.com' test.ping
    linux-node3.example.com:
        ----------
        retcode:
            254
        stderr:
        stdout:
            The host key needs to be accepted, to auto accept run salt-ssh with the -i flag:
            The authenticity of host '192.168.14.134 (192.168.14.134)' can't be established.
            RSA key fingerprint is 39:93:59:e6:27:60:13:c2:89:52:61:4e:52:e3:0c:f9.
            Are you sure you want to continue connecting (yes/no)? 

    官网给出的一个脚本:[其实salt-ssh首次连接的时候会自动部署(条件:已有了kownhosts)]

    #!/bin/bash
    if [ -z $1 ]; then
       echo $0 user@host.com
       exit 0
    fi
    ssh-copy-id -i /etc/salt/pki/master/ssh/salt-ssh.rsa.pub $1

    -z 判断字符串是否存在.----也可以通过判断参数个数控制无参即退出.

    如果没参数,它给的提示是: $0是参数名字.

    echo $0 user@host.com
  • 相关阅读:
    秒杀多线程第十篇 生产者消费者问题 (续)
    平面最近点距离问题(分治法)
    阿里神马搜索算法实习生 二面
    37. Sudoku Solver
    52. N-Queens II(数个数)
    51. N-Queens
    89. Gray Code(公式题)
    22. Generate Parentheses(回溯)
    回溯总结
    40. Combination Sum II
  • 原文地址:https://www.cnblogs.com/iiiiher/p/5802450.html
Copyright © 2011-2022 走看看