如何将ansible变量传递给无业游民

时间:2018-08-16 10:57:20

标签: ansible vagrant vagrantfile

假设我有一本通常正常运行的剧本:

ansible-playbook -i hosts -e "var1=val1" \
    -e "hosts=all" \
    -e "devops_dir=$DEVOPS_PATH" \
    -e "cname=something.gooten.com" \
    -v playbook.yml

而且我想在启动Vagrantfile时运行它-

  #
  # Run Ansible from the Vagrant Host
  #
  config.ssh.insert_key = false
  config.vm.provision "ansible" do |ansible|
    ansible.playbook = "playbook.yml"
    ansible.verbose = "v"
  end

如何将-e变量添加到Vagrantfile中,以便它们也被调用?

1 个答案:

答案 0 :(得分:0)

您必须使用extra_vars

ansible.extra_vars = {
  var1: val1,
  hosts: all,
  devops_dir: $DEVOPS_PATH,
  cname: something.gooten.com
}