使用gitfs_remotes和Salt Stack公式来配置Vagrant VM

时间:2015-10-28 00:54:24

标签: vagrant salt-stack vagrant-provision

我试图使用含有现有盐配方的盐来配置流浪汉。我已按照此演示文稿访问gitfs_remoteshttps://github.com/borgstrom/salt-vagrant-saltconf2014/blob/master/presentation.md

盐/仆从

master: 127.0.0.1
state_verbose: False

盐/主

# 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(部分):

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:

base:
  '*':
    - mysql

但我收到错误:

  

[INFO] SaltReqTimeoutError:60秒后。 (尝试7的7)尝试   用salt master验证失败

2 个答案:

答案 0 :(得分:2)

无主的奴才能够在没有明确配置的主人的情况下使用gitfs。有issue in saltstack/salt

请查看此issue in saltstack/salt-bootstrap,了解有关使用bash配置安装事物的原因的详细信息。

这是使用节点公式的工作配置。

<强> 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 /仆从

state_verbose: True

file_client: local

gitfs_provider: gitpython

fileserver_backend:
  - roots
  - git

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

答案 1 :(得分:-1)

您收到该错误是因为当一个小兵连接到Salt Master时 - 该请求必须得到Salt master的批准。它就像一个安全机制 - 第一次需要批准,第二次使用机器的指纹。在你的盐主人运行:

sudo salt-key

你应该看到类似的东西,你会注意到新机器的钥匙尚未被接受。

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

继续并运行命令:

sudo salt-key -A

在确认时说“是”,密钥将被接受,错误应该消失。还要测试minion是否可以在master上运行命令:

sudo salt '*' test.ping

这应该从小兵身上回归。

最后使用来自Salt团队或this oneone I have written等经过试验的测试项目,您将很快得到Salt。