2
我有下面的文件夹结构,这似乎使它建立和加载的角色,但组和主机变量没有被加载。怎么来的?host_vars和group_vars没有得到加载
的/ etc/ansible/
- hosts
- requirements.yml
- group_vars/
- app/
- postgres.yml
- host_vars/
- app1/
- postgres.yml
- roles
/文件/ ansible/
- playbook.yml
- vagrant
主机文件
# Application servers
[app]
192.168.60.6
# Group multi
[multi:children]
app
#variables applied to all servers
[multi:vars]
ansible_ssh_user=vagrant
ansible_ssh_private_key_file=~/.vagrant.d/insecure_private_key
**流浪汉**
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# Genral Vagrant VM Configuration.
config.vm.box = "geerlingguy/centos7"
config.ssh.insert_key = false
config.vm.synced_folder ".", "/vagrant", disabled: true
config.vm.provider :virtualbox do |v|
v.memory = 256
v.linked_clone = true
end
config.vm.provision "ansible" do |ansible|
ansible.playbook = "playbook.yml"
end
# Application server 1
config.vm.define "app1" do |app|
app.vm.hostname = "orc-app1.dev"
app.vm.network :private_network, ip: "192.168.60.6"
end
end
所以我需要将'host_vars'和'group_vars'复制到playbook.yml文件夹中?以及我如何指向'/ etc/ansible/hosts' in vagrant文件? –
我不知道你需要什么,因为我不知道你想要什么。乍一看,为Vagrant项目使用全局清单文件是没有意义的,但也许你有自己的理由。我不确定第二个问题,我在答案中给出了设置的名称 - 使用它的问题是什么? – techraf
即使你像现在一样拷贝'group_vars',Vagrant也不会知道'app'是什么。它将从'host_vars'获取'app1',因为你在'Vagrantfile'中定义了'app1',它会反映在自动生成的库存中,而不是'app'。 – techraf