使用gitfs_remotes和Salt Stack公式来提供Vagrant VM



我正试图用现有的salt公式提供使用salt的流浪VM。我已按照此演示文稿访问gitfs_remotes:https://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

流浪文件(部分):

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

/盐/根/顶部。sls:

base:
  '*':
    - mysql

但我得到了错误:

[信息]SaltReqTimeoutError:60秒后。(尝试7次中的7次)尝试向盐主机进行身份验证失败的

一个无主的仆从可以在没有显式配置的主的情况下使用gitfs。盐垛/盐有问题。

在saltstack/salt引导中查看这个问题,了解为什么使用bash配置在前面安装东西的详细信息。

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

流浪文件

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

state_verbose: True
file_client: local
gitfs_provider: gitpython
fileserver_backend:
  - roots
  - git
gitfs_remotes:
  - https://github.com/saltstack-formulas/node-formula.git

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

sudo salt-key

你应该看到这样的东西,你会注意到新机器的钥匙还没有被接受。

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

继续运行命令:

sudo salt-key -A

确认后说"是",钥匙就会被接受,错误就会消失。同样为了测试爪牙是否可以访问,在master上运行命令:

sudo salt '*' test.ping

这应该从小黄人那里得到回报。

最后使用一个经过测试的项目,比如Salt团队的这个项目,或者我写的一个项目,你会很快使用Salt。

最新更新