Ruby 如何在文件中呈现YAML列表
我有一个Vagrantfile,它引用了一个YAML文件,以简化多主机配置 它大部分工作正常,但我正在使用Ansible provisioner,需要为Ansible.groups项引用列表/数组 YAML如下所示:Ruby 如何在文件中呈现YAML列表,ruby,vagrantfile,Ruby,Vagrantfile,我有一个Vagrantfile,它引用了一个YAML文件,以简化多主机配置 它大部分工作正常,但我正在使用Ansible provisioner,需要为Ansible.groups项引用列表/数组 YAML如下所示: hosts: - host: provision: ansible: enable: yes playbook_path: webserver.yml groups:
hosts:
- host:
provision:
ansible:
enable: yes
playbook_path: webserver.yml
groups:
- web
- vagrant
- live
我试图在Vagrant文件中引用它,使用:
但在构建实际虚拟机时,这给了我一个错误:
undefined method `each_pair' for ["web", "vagrant", "dev"]:Array
虽然我在Vagrant文件中看到了读取列表/数组的各种模式,但我搜索了并没有找到任何专门针对ansible_组的内容。有什么想法吗?Ansible组不应该是一个数组,而是一个散列,将组映射到服务器名称。它应该是这样的:
hosts:
- host:
provision:
ansible:
enable: yes
playbook_path: webserver.yml
groups:
web:
- machine1
- machine2
vagrant:
- machine3
- machine4
live:
- machine5
有关如何使用此功能的更多详细信息,请参阅
hosts:
- host:
provision:
ansible:
enable: yes
playbook_path: webserver.yml
groups:
web:
- machine1
- machine2
vagrant:
- machine3
- machine4
live:
- machine5