provisoners/ansible(both): Accept 'all:vars'

The patterns "all" is a special keyword that target all hosts in the
inventory. Therefore it makes sense to accept "all:vars" as a group
variable name. Note that "*:vars" pattern is not valid in an Ansible
inventory.
See http://docs.ansible.com/ansible/latest/intro_patterns.html#patterns

Fix #7730
This commit is contained in:
Gilles Cornu 2017-09-03 17:09:16 +02:00
parent 2170d40bb2
commit b741ff7999
No known key found for this signature in database
GPG Key ID: F6BC2CF7E1FE8FFF
3 changed files with 15 additions and 1 deletions

View File

@ -12,6 +12,7 @@ IMPROVEMENTS:
BUG FIXES:
- guests/shell_expand_guest_path : Properly expand guest paths that include relative path alias [GH-8918]
- provisioners/ansible(both): Add the "all:vars" section to the inventory when defined in `groups` option [GH-7730]
- util/ssh: Properly quote key path for IdentityFile option to allow for spaces [GH-8924]
## 1.9.8 (August 23, 2017)

View File

@ -228,7 +228,7 @@ module VagrantPlugins
end
group_vars.each_pair do |gname, gmembers|
if defined_groups.include?(gname.sub(/:vars$/, ""))
if defined_groups.include?(gname.sub(/:vars$/, "")) || gname == "all:vars"
inventory_groups += "\n[#{gname}]\n" + gmembers.join("\n") + "\n"
end
end

View File

@ -396,6 +396,19 @@ VF
expect(inventory_content).to include("[group3:vars]\nstringvar1=stringvalue1\nstringvar2=stringvalue2\n")
}.and_return(default_execute_result)
end
it "adds 'all:vars' section to the generated inventory" do
config.groups = {
"all:vars" => { "var1" => "value1", "var2" => "value2" }
}
expect(Vagrant::Util::Subprocess).to receive(:execute).with('ansible-playbook', any_args) { |*args|
inventory_content = File.read(generated_inventory_file)
expect(inventory_content).to include("[all:vars]\nvar1=value1\nvar2=value2\n")
}.and_return(default_execute_result)
end
end
describe "with host_key_checking option enabled" do