vagrant - 如何从 Vagrantfile 写入配置文件
问题描述
您好我正在尝试将目录索引指令添加到 Vagrantfile 中的 Apache 的默认 VirtualHost。我想知道是否有办法从 Vagrantfile 编辑文件(我使用的是内联 SHELL)。我知道我可以将整个 VH 文件复制到客户机,但我想知道如果可能的话如何写入文件。
谢谢!
解决方案
You can do that with ansible like this:
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
or with a shell
Vagrant.configure("2") do |config|
config.vm.provision "shell" do |s|
s.inline = "echo $1"
s.args = "'hello, world!'"
end
end
推荐阅读
- asp.net-core - 在 ASP.Net Core 的 ConfigureServices 中访问数据库(EF Core DbContext)
- javascript - 如何在不使用库的情况下求解 3x3 矩阵的逆矩阵?
- javascript - 如何删除一个类的所有元素期望一个数组
- python - 如何在范围内获取列表输出
- javascript - 在 ExpressJs 路由中检查“req.params.id”时得到“未定义”
- python - Anaconda conda env create -f tfdl_env.yml(解决环境:失败)
- c# - 使用制表符和 asp.net 网络表单进行远程分页
- azure-cosmosdb - 带有 WHERE 子句的 Azure Cosmos SQL 结果没有意义
- python - 为 Python 解析和操作 XML 数据
- python - 如何在 IF 语句中要求输入?