provisioners/ansible: allow symbol in `groups` key

After c49a146467, it makes even more sense
to support Symbol datatypes in `groups` option handling.
This commit is contained in:
Gilles Cornu 2015-12-03 09:34:53 +01:00
parent 06e772a241
commit 9867281971
2 changed files with 8 additions and 1 deletions

View File

@ -113,6 +113,10 @@ module VagrantPlugins
inventory_groups = ""
config.groups.each_pair do |gname, gmembers|
if gname.is_a?(Symbol)
gname = gname.to_s
end
if gmembers.is_a?(String)
gmembers = gmembers.split(/\s+/)
elsif gmembers.is_a?(Hash)

View File

@ -287,6 +287,7 @@ VF
"group1:children" => 'bar',
"group2" => [iso_env.machine_names[1]],
"group3" => ["unknown", "#{machine.name}"],
group4: [machine.name],
"bar" => ["#{machine.name}", "group3"],
"bar:children" => ["group1", "group2", "group3", "group4"],
}
@ -304,11 +305,13 @@ VF
# Skip "unknown" machines
expect(inventory_content).to include("[group3]\n#{machine.name}\n")
# Accept Symbol datatype for group names
expect(inventory_content).to include("[group4]\n#{machine.name}\n\n")
# Don't mix group names and host names
expect(inventory_content).to include("[bar]\n#{machine.name}\n")
# A group of groups only includes declared groups
expect(inventory_content).not_to match(/^group4$/)
expect(inventory_content).to include("[bar:children]\ngroup1\ngroup2\ngroup3\n")
}
end