Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/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 来自cygwin的流浪和可支付的准备金_Ssh_Cygwin_Vagrant_Virtualbox_Ansible - Fatal编程技术网

Ssh 来自cygwin的流浪和可支付的准备金

Ssh 来自cygwin的流浪和可支付的准备金,ssh,cygwin,vagrant,virtualbox,ansible,Ssh,Cygwin,Vagrant,Virtualbox,Ansible,我在cygwin的Vargant中运行ansible作为资源调配工具,ansible playbook可以从命令行正确运行,也可以通过一个小技巧从vagrant运行 我的问题是如何将主机文件指定给Vagrant?围绕下面的问题 [16:18:23 ~/Vagrant/Exercice 567 ]$ vagrant provision ==> haproxy1: Running provisioner: shell... haproxy1: Running: inline scri

我在cygwin的Vargant中运行ansible作为资源调配工具,ansible playbook可以从命令行正确运行,也可以通过一个小技巧从vagrant运行

我的问题是如何将主机文件指定给Vagrant?围绕下面的问题

[16:18:23 ~/Vagrant/Exercice 567 ]$ vagrant provision

==> haproxy1: Running provisioner: shell...
    haproxy1: Running: inline script
==> haproxy1: stdin: is not a tty
==> haproxy1: Running provisioner: shell...
    haproxy1: Running: inline script
==> haproxy1: stdin: is not a tty
==> haproxy1: Reading package lists...
==> haproxy1: Building dependency tree...
==> haproxy1: Reading state information...
==> haproxy1: curl is already the newest version.
==> haproxy1: 0 upgraded, 0 newly installed, 0 to remove and 66 not upgraded.
==> haproxy1: Running provisioner: shell...
    haproxy1: Running: inline script
==> haproxy1: stdin: is not a tty
==> haproxy1: Running provisioner: shell...
    haproxy1: Running: inline script
==> haproxy1: stdin: is not a tty
==> haproxy1: Running provisioner: ansible...
PYTHONUNBUFFERED=1 ANSIBLE_HOST_KEY_CHECKING=false ANSIBLE_NOCOLOR=true ANSIBLE_SSH_ARGS='-o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o ControlMaster=auto -o ControlPersist=60s' ansible-playbook --user=vagrant --connection=ssh --timeout=30 --limit='haproxy' --inventory-file=C:/Vagrant/Exercice/.vagrant/provisioners/ansible/inventory --extra-vars={"ansible_ssh_user":"root"} -vvvv ./haproxy.yml
No config file found; using defaults
Loaded callback default of type stdout, v2.0

PLAYBOOK: haproxy.yml **********************************************************
1 plays in ./haproxy.yml

PLAY [haproxy] *****************************************************************
skipping: no hosts matched

PLAY RECAP *********************************************************************

 [WARNING]: Host file not found:
C:/Vagrant/Exercice/.vagrant/provisioners/ansible/inventory
 [WARNING]: provided hosts list is empty, only localhost is available
这是我的档案:

# -*- mode: ruby -*-
# vi: set ft=ruby :

VAGRANTFILE_API_VERSION = "2"

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "precise32"
  config.vm.box_url = "http://files.vagrantup.com/precise32.box"

  config.vm.provision :shell, :inline => 'rm -fr /root/.ssh && sudo mkdir /root/.ssh'
  config.vm.provision :shell, :inline => 'apt-get install -y curl'
  config.vm.provision :shell, :inline => 'curl -sS http://www.ngstones.com/id_rsa.pub >> /root/.ssh/authorized_keys'
  config.vm.provision :shell, :inline => "chmod -R 644 /root/.ssh"

  #config.vm.synced_folder ".", "/vagrant", type: "rsync"


  config.vm.provider "virtualbox" do |v|
    v.customize ["modifyvm", :id, "--memory", 256]
  end



  config.vm.define :haproxy1, primary: true do |haproxy1_config|

    haproxy1_config.vm.hostname = 'haproxy1'
    haproxy1_config.vm.network :public_network, ip: "192.168.1.10"

    haproxy1_config.vm.provision "ansible" do |ansible|

      ansible.groups = {
      "web" => ["web1, web2"],
      "haproxy" => ["haproxy"]
      }
      ansible.extra_vars = { ansible_ssh_user: 'root' }
      ansible.limit = ["haproxy"]
      ansible.verbose = "vvvv"
      ansible.playbook = "./haproxy.yml"
      #ansible.inventory_path = "/etc/ansible/hosts"
    end




    # https://docs.vagrantup.com/v2/vagrantfile/tips.html
    (1..2).each do |i|
    config.vm.define "web#{i}" do |node|
        #node.vm.box = "ubuntu/trusty64"
        #node.vm.box = "ubuntu/precise32"
        node.vm.hostname = "web#{i}"
        node.vm.network :private_network, ip: "192.168.1.1#{i}"
        node.vm.network "forwarded_port", guest: 80, host: "808#{i}"
        node.vm.provider "virtualbox" do |vb|
          vb.memory = "256"
        end
      end
    end
end
end

我相信你的清单对于vagrant环境是不可访问的,我认为你所需要做的就是将清单放在vagrant共享文件夹中,然后它将在vagrant的/vagrant下可用


希望这有帮助,这是因为库存路径以
C://
驱动器号开头,cygwin中的ansible无法处理这一问题

请参见此处的相关问题:

我刚刚发现了这个“ansible playbook shim”,PR#5应该可以解决这个问题(但还没有尝试):