【问题标题】:How to write to a file provisioning from Vagrantfile如何从 Vagrantfile 写入配置文件
【发布时间】:2019-02-07 18:06:08
【问题描述】:

您好,我正在尝试将目录索引指令从 Vagrantfile 添加到 Apache 的默认 VirtualHost。我想知道是否有办法从 Vagrantfile 编辑文件(我使用的是内联 SHELL)。我知道我可以将整个 VH 文件复制到客户机,但我想知道如果可能的话如何写入文件。

谢谢!

【问题讨论】:

    标签: vagrant provisioning vagrantfile


    【解决方案1】:

    你可以像这样使用 ansible 来做到这一点:

    config.vm.provision "ansible_local" do |ansible|
        ansible.verbose   = "vv"
        ansible.become    = true # execute as root
        ansible.playbook  = "relative_path_to_ansible_file/playbook.yml"
      end 
    

    或带壳

    Vagrant.configure("2") do |config|
      config.vm.provision "shell" do |s|
        s.inline = "echo $1"
        s.args   = "'hello, world!'"
      end
    end
    

    https://www.vagrantup.com/docs/provisioning/shell.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-10-27
      • 1970-01-01
      • 1970-01-01
      • 2015-07-06
      • 2012-06-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多