Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ssh windows上带有vagrant的多机ansible设置 目的_Ssh_Virtualbox_Vagrant_Virtualization_Ansible - Fatal编程技术网

Ssh windows上带有vagrant的多机ansible设置 目的

Ssh windows上带有vagrant的多机ansible设置 目的,ssh,virtualbox,vagrant,virtualization,ansible,Ssh,Virtualbox,Vagrant,Virtualization,Ansible,我希望ansible[通过Vagrant]在我的windows 8计算机上设置虚拟机。一切都需要在本地运行,因为Ansible不在Windows上运行,所以我用Ansible作为控制机器引导debian vm。作为一个例子。 在与这个系统搏斗之后,我让它在某种程度上正常工作,但并不完全正常(尽管ansible没有告诉我) 问题: 使用ansible[在虚拟机中]、vagrant和virtualbox[在windows主机上]进行多机设置需要什么配置 ssh从主机访问ansible vm以及所有从

我希望ansible[通过Vagrant]在我的windows 8计算机上设置虚拟机。一切都需要在本地运行,因为Ansible不在Windows上运行,所以我用Ansible作为控制机器引导debian vm。作为一个例子。 在与这个系统搏斗之后,我让它在某种程度上正常工作,但并不完全正常(尽管ansible没有告诉我)

问题: 使用ansible[在虚拟机中]、vagrant和virtualbox[在windows主机上]进行多机设置需要什么配置

  • ssh从主机访问ansible vm以及所有从机

  • ssh从ansible vm访问所有从机

  • 如果可能,能够从主机网络屏蔽多机网络

  • 问题 运行到主机的
    ansible-mping-all-i路径会产生ssh错误。ansible似乎试图访问名为web1和db1的计算机,但找不到这样的主机

    为用户建立连接:vagrant 远程模块ping 为用户建立连接:vagrant 远程模块ping 执行官['ssh'、'-C'、'-tt'、'-vvv'、'-o'、'ControlMaster=auto'、'-o'、'ControlPersist=60s'、'-o'、'ControlPath=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r'、'-o'、'KbdInteractiveAuthentication=no'、'-o'、'PreferredAuthentications=gssapi-with-mic、gssapi-keyex、hostbased、publickey'、'-o'、'PasswordAuthentication=no'、'o'、'connect=10'、'web1',“/bin/sh-c'mkdir-p$HOME/.ansible/tmp/ansible-tmp-1398362619.41-142470238612762&&chmod a+rx$HOME/.ansible/tmp/ansible-tmp-1398362619.41-142470238612762&&echo$HOME/.ansible/tmp/ansible-tmp-1398362619.41-142470238612762'” 找不到web1的EXEC以前的已知主机文件 执行官['ssh'、'-C'、'-tt'、'-vvv'、'-o'、'ControlMaster=auto'、'-o'、'ControlPersist=60s'、'-o'、'ControlPath=/home/vagrant/.ansible/cp/ansible-ssh-%h-%p-%r'、'-o'、'KbdInteractiveAuthentication=no'、'-o'、'PreferredAuthentications=gssapi-with-mic、gssapi-keyex、hostbased、publickey'、'o'、'PasswordAuthentication=no'、'o'、'o'、'connect=10'、'db1'”/bin/sh-c'mkdir-p$HOME/.ansible/tmp/ansible-tmp-1398362619.41-4982781019922&&chmod a+rx$HOME/.ansible/tmp/ansible-tmp-1398362619.41-4982781019922&&echo$HOME/.ansible/tmp/ansible-tmp-1398362619.41-4982781019922'] 找不到db1的EXEC以前的已知主机文件 web1 | FAILED=>SSH遇到未知错误。输出为: OpenSSH_6.0p1 Debian-4,OpenSSL 1.0.1e 2013年2月11日 debug1:读取配置数据/etc/ssh/ssh\u config debug1:/etc/ssh/ssh\u配置第19行:应用* debug1:自动多路复用器:尝试现有主机 debug1:控制套接字“/home/vagrant/.ansible/cp/ansible-ssh-web1-22-vagrant”不存在 debug2:ssh\u connect:needpriv 0 ssh:无法解析主机名web1:名称或服务未知

    db1 | FAILED=>SSH遇到未知错误。输出为: OpenSSH_6.0p1 Debian-4,OpenSSL 1.0.1e 2013年2月11日 debug1:读取配置数据/etc/ssh/ssh\u config debug1:/etc/ssh/ssh\u配置第19行:应用* debug1:自动多路复用器:尝试现有主机 debug1:控制套接字“/home/vagrant/.ansible/cp/ansible-ssh-db1-22-vagrant”不存在 debug2:ssh\u connect:needpriv 0 ssh:无法解析主机名db1:名称或服务未知

    代码 以下代码尝试设置 1.ansible主机:运行ansible的控制机器 1.db1:数据库服务器 1.web1:一个web服务器

    流浪汉档案
    Vagrant.configure(“2”)do | config|
    config.vm.box=“喘息64”
    config.vm.box_url=”http://puppet-vagrant-boxes.puppetlabs.com/debian-70rc1-x64-vbox4210.box"
    config.vm.synced_文件夹“,”/vagrant“,:mount_options=>['dmode=777','fmode=666']
    config.vm.network:公共网络
    config.vm.provider“virtualbox”do | v|
    v、 定制[
    “modifyvm”,:id,
    “--groups”、“/Vagrant/Ansible”,
    #--natdnshostresolver1,“打开”
    ]
    结束
    config.vm.define:ansiblemaster do | ansiblemaster|
    #ansiblemaster.vm.network:专用_网络,ip:“192.168.111.101”
    ansiblemaster.vm.hostname=“ansiblemaster”
    #ansiblemaster.vm.network:转发_端口,来宾:80,主机:8080
    ansiblemaster.ssh.forward\u agent=true
    ansiblemaster.vm.provider:virtualbox do | vb|
    vb.customize[“modifyvm”,:id,“--memory”,512]
    vb.customize[“modifyvm”,:id,“--name”,“ansible master”]
    vb.name=“ansiblemaster”
    结束
    ansiblemaster.vm.provision:shell,:inline=>
    “如果[!-f/apt get run]];则sudo apt get update&&sudo touch/apt get run;fi”
    ansiblemaster.vm.provision:shell do|sh|
    sh.path=“provision.sh”
    sh.args=“./ansible provisioning/site.yml provisioning/hosts/dev_hosts”
    结束
    结束
    config.vm.define:web1 do | slave|
    slave.vm.hostname=“web1”
    #slave.vm.network:专用_网络,ip:“192.168.111.201”
    slave.vm.synced_文件夹“/src”,“/var/www/site”,id:“项目根”
    slave.vm.provider:virtualbox do | vb|
    vb.name=“web1”
    vb.customize[“modifyvm”,:id,“--memory”,“512”]
    结束
    结束
    config.vm.define:db1 do | slave|
    slave.vm.hostname=“db1”
    #slave.vm.network:专用_网络,ip:“192.168.111.202”
    slave.vm.provider:virtualbox do | vb|
    vb.name=“db1”
    vb.customize[“modifyvm”,:id,“--memory”,“512”]
    结束
    结束
    结束
    
    Provision.sh
    !/bin/bash
    ANSIBLE_DIR=$1
    ANSIBLE_剧本=$2
    ANSIBLE_主机=$3
    TEMP_HOSTS=“/tmp/ansible_HOSTS”
    如果[!-f/vagrant/$ANSIBLE_剧本];那么
    echo“找不到Ansible剧本”
    出口1
    fi
    如果[!-f/vagrant/$ANSIBLE_HOSTS];那么
    echo“找不到可用主机”
    出口2
    fi
    如果[!-d$ANSIBLE_DIR];那么
    回显“更新apt缓存”
    更新源
    echo“安装Ansible依赖项和Git”
    apt get install-y git python yaml python paramiko python-jinja2
    echo“克隆Ansible”
    git克隆git://github.com/ansible
    
    [webservers]
    web1
    
    [dbservers]
    db1
    
    [webservers]
    web1     ansible_ssh_host=xxx.xxx.xxx.xxx
    
    [dbservers]
    db1     ansible_ssh_host=xxx.xxx.xxx.yyy
    
    ansible -m win_ping -all -i path-to-hosts
    
    # fix permissions on private key file
    chmod 600 /home/vagrant/.ssh/id_rsa
    
    # add web/database hosts to known_hosts (IP is defined in Vagrantfile)
    ssh-keyscan -H 192.168.51.4 >> /home/vagrant/.ssh/known_hosts
    ssh-keyscan -H 192.168.52.4 >> /home/vagrant/.ssh/known_hosts
    chown vagrant:vagrant /home/vagrant/.ssh/known_hosts
    
    # reload ssh in order to load the known hosts
    /etc/init.d/ssh reload