加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Windows > 正文

当我尝试在Windows / Cygwin上使用Ansible配置Vagrant VM时,SSH

发布时间:2020-12-14 01:57:18 所属栏目:Windows 来源:网络整理
导读:我在 Windows 8下使用Cygwin(CYGWIN_NT-6.3-WOW64).我还运行Vagrant(1.7.2)和Ansible(1.8.4).要完成,我的Virtualbox是4.3.22. 已经从各自的Windows安装包安装了Cygwin和Vagrant.我在Cygwin下运行Python 2.7.8并使用’pip install ansible’来安装Ansible. 所
我在 Windows 8下使用Cygwin(CYGWIN_NT-6.3-WOW64).我还运行Vagrant(1.7.2)和Ansible(1.8.4).要完成,我的Virtualbox是4.3.22.

已经从各自的Windows安装包安装了Cygwin和Vagrant.我在Cygwin下运行Python 2.7.8并使用’pip install ansible’来安装Ansible.

所有这些应用程序本身都可以正常工作. Cygwin工作得很好;我整天用它作为我的贝壳,每天都没有问题.

当我在Cygwin下运行Vagrant时,Vagrant和Virtualbox也没有问题.当我在网络上的服务器上运行播放或模块时,Ansible在Cygwin下运行正常.

我遇到的问题是当我尝试使用Ansible配置本地运行的Vagrant VM时.

例如,我流浪了一个VM然后起草一个简单的剧本来配置它.以下是Vagrantfile:

VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.define :drupal1 do |config|
  config.vm.box = "centos65-x86_64-updated"
  config.vm.hostname = "drupal1"
  config.vm.network "forwarded_port",guest: 80,host: 10080
  config.vm.network :private_network,ip: "192.168.56.101"
  config.vm.provider "virtualbox" do |v|
    v.name   = "Drupal Server 1"
    v.memory = 1024
  end
  config.vm.provision :ansible do |ansible|
    ansible.playbook = "provisioning/gather_facts.yml"
  end
end

和剧本:

---
- hosts: all
  gather_facts: yes

但是,当我运行’vagrant provision drupal1’时,我收到以下错误:

vagrant provision drupal1
==> drupal1: Running provisioner: ansible… PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=true ANSIBLE_HOST_KEY_CHECKING=false
ANSIBLE_SSH_ARGS=’-o UserKnownHostsFile=/dev/null -o
ControlMaster=auto -o ControlPersist=60s’ ansible-playbook
–private-key=C:/Users/mjenkins/workspace/Vagrant_VMs/Drupal1/.vagrant/machines/drupal1/virtualbox/private_key
–user=vagrant –connection=ssh –limit=’drupal1′ –inventory-file=C:/Users/mjenkins/workspace/Vagrant_VMs/Drupal1/.vagrant/provisioners/ansible/inventory
provisioning/gather_facts.yml PLAY [all]
GATHERING FACTS
fatal: [drupal1] => private_key_file
(C:/Users/mjenkins/workspace/Vagrant_VMs/Drupal1/.vagrant/machines/drupal1/virtualbox/private_key)
is group-readable or world-readable and thus insecure – you will
probably get an SSH failure PLAY RECAP

to retry,use: –limit @/home/mjenkins/gather_facts.retry

drupal1 : ok=0 changed=0 unreachable=1
failed=0 Ansible failed to complete successfully. Any error output
should be visible above. Please fix these errors and try again.
Looking at the error,its plainly obvious that it has something to do
with Ansible’s interpretation of my key and the file permissions on
either it or the folder its in.

以下是我尝试过的一些观察和步骤:

>我尝试设置文件的权限以及导致Cygwin中文件的所有目录.那是项目目录中的chmod -R 700 .vagrant.仍然有同样的错误.
>使用Windows路径引用密钥文件,而不是Cygwin路径(但奇怪的是,限制输出中的文件具有Cygwin路径).所以我检查了Windows端的权限并进行了更改,以便“Everyone”无法访问.vagrant及其下的所有文件/文件夹.仍然有同样的错误.
>然后我想我的基于Cygwin的Ansible之间的文件权限/路径可能仍然存在一些问题,所以我安装了Python for Windows;使用该pip安装Ansible,设置我的路径到该位置,创建一个ansible-playbook.bat文件,并从Windows cmd shell运行Vagrant.很高兴说工具链有效……但我仍然遇到同样的问题.

在这一点上,我只是出于想法所以我转向你,Stackoverflow的朋友,你的意见.

有关解决这个问题的任何想法?

解决方法

您的私钥非常开放,任何人都可以访问.检查SSH客户端会阻止使用此类密钥.

尝试使用您的私钥和公钥上的cygwin或git bash中的chmod更改权限.在C:/Users/mjenkins/workspace/Vagrant_VMs/Drupal1/.vagrant/machines/drupal1/virtualbox/private_key使用chmod 700 private_key并确保你有-rwx ——和ls -la

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读