简体   繁体   English

使用gitfs_remotes和Salt Stack公式设置Vagrant VM

[英]Using gitfs_remotes and Salt Stack formulas to provision Vagrant VM

I'm trying to provision vagrant VM using salt with existing salt formulas. 我正在尝试使用盐和现有的盐配方来配置无用的VM。 I've followed this presentation to get access to gitfs_remotes : https://github.com/borgstrom/salt-vagrant-saltconf2014/blob/master/presentation.md . 我已经按照此演示文稿访问了gitfs_remoteshttps : //github.com/borgstrom/salt-vagrant-saltconf2014/blob/master/presentation.md

salt/minion 盐/小仆

master: 127.0.0.1
state_verbose: False

salt/master: 盐/大师:

# listen on the loopback in open mode
interface: 127.0.0.1
auto_accept: True

# use both the local roots as well as gitfs remotes
fileserver_backend:
  - roots
  - git

# map our project specific files to the local roots
file_roots:
  base:
    - /vagrant/salt/roots
pillar_roots:
  base:
    - /vagrant/salt/pillar

# setup our salt formulas as gitfs remotes
gitfs_remotes:
  - https://github.com/saltstack-formulas/mysql-formula

Vagrantfile (part): Vagrantfile(部分):

config.vm.synced_folder "salt/roots/", "/srv/salt/"
config.vm.synced_folder "salt/pillar", "/srv/pillar/"

config.vm.provision :salt do |salt|
    salt.minion_config = "salt/minion"
    salt.master_config = "salt/master"
    salt.bootstrap_options = "-F -c /tmp/ -P"
    salt.run_highstate = true
end

/salt/roots/top.sls: /salt/roots/top.sls:

base:
  '*':
    - mysql

But I get the error: 但是我得到了错误:

[INFO ] SaltReqTimeoutError: after 60 seconds. [INFO] SaltReqTimeoutError:60秒后。 (Try 7 of 7) Attempt to authenticate with the salt master failed (尝试7之7)尝试与盐管理器进行身份验证失败

A masterless minion is able to use gitfs without an explicitly configured master. 无主控的奴才无需明确配置的主控方即可使用gitfs。 There was an issue in saltstack/salt . saltstack / salt中存在问题

Have a look at this issue in saltstack/salt-bootstrap , for details about why to install things in front using bash provisioning. 请查看saltstack / salt-bootstrap中的此问题 ,以获取有关为何使用bash设置在前端安装东西的详细信息。

Here is a working configuration using the node-formula. 这是使用节点公式的工作配置。

Vagrantfile 流浪文件

Vagrant.configure(2) do |config|
  config.vm.box = "debian/jessie64"

  # mount state tree and pillar
  config.vm.synced_folder ".saltstack/salt/", "/srv/salt/", type: "rsync"
  config.vm.synced_folder ".saltstack/pillar/", "/srv/pillar/", type: "rsync"

  # install those to be able to use gitfs for node formula
  # @see https://github.com/saltstack/salt-bootstrap/issues/245
  config.vm.provision :shell, :inline => "sudo apt-get -y install git-core"
  config.vm.provision :shell, :inline => "sudo apt-get -y install python-setuptools"
  config.vm.provision :shell, :inline => "sudo easy_install GitPython"

  config.vm.provision :salt do |salt|
    # Workaround for:
    # Copying salt minion config to /etc/salt
    # Failed to upload a file to the guest VM via SCP due to a permissions
    # error. [...]; @see:
    # https://github.com/mitchellh/vagrant/issues/5973#issuecomment-137276605
    salt.bootstrap_options = '-F -c /tmp/ -P'
    salt.masterless = true
    salt.minion_config = ".saltstack/minion"
    salt.run_highstate = true
    salt.verbose = true
  end

  # sync working dir
  config.vm.synced_folder ".", "/vagrant", type: "rsync",
    rsync__exclude: [".git/", ".saltstack"]
end

.saltstack/minion .saltstack / minion

state_verbose: True

file_client: local

gitfs_provider: gitpython

fileserver_backend:
  - roots
  - git

gitfs_remotes:
  - https://github.com/saltstack-formulas/node-formula.git

You are getting that error because when a minion connects to Salt Master - the request has to be approved by Salt master. 您收到该错误的原因是,当一个小兵连接到Salt Master时-该请求必须得到Salt Master的批准。 It is like a security mechanism - first time around needs approval, second time onwards the fingerprint of machine is used. 就像安全机制一样-第一次需要审批,第二次使用机器指纹。 On your salt master run: 在您的盐大师运行中:

sudo salt-key

You should see something like and you will notice that the key of new machine is not yet accepted. 您应该看到类似的内容,并且您会注意到新机器的密钥尚未被接受。

Accepted Keys: Denied Keys: Unaccepted Keys: xyz.hostname.com Rejected Keys:

Go ahead and run the command: 继续运行命令:

sudo salt-key -A

Say yes on confirmation and the key will be accepted and the error should go away. 在确认时说“是”,密钥将被接受并且错误应该消失。 Also to test that the minion is reachable run command on master: 还要测试master上的minion是否可以到达运行命令:

sudo salt '*' test.ping

This should return true from minions. 奴才应该返回true。

Finally use a tried and test project like this one from Salt team or one I have written and you will get going with Salt quite fast. 最后,使用一个经过试验和测试的项目,如Salt团队或我编写的 一个项目,您将很快开始使用Salt。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM