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:
parent
06e772a241
commit
9867281971
|
@ -113,6 +113,10 @@ module VagrantPlugins
|
||||||
inventory_groups = ""
|
inventory_groups = ""
|
||||||
|
|
||||||
config.groups.each_pair do |gname, gmembers|
|
config.groups.each_pair do |gname, gmembers|
|
||||||
|
if gname.is_a?(Symbol)
|
||||||
|
gname = gname.to_s
|
||||||
|
end
|
||||||
|
|
||||||
if gmembers.is_a?(String)
|
if gmembers.is_a?(String)
|
||||||
gmembers = gmembers.split(/\s+/)
|
gmembers = gmembers.split(/\s+/)
|
||||||
elsif gmembers.is_a?(Hash)
|
elsif gmembers.is_a?(Hash)
|
||||||
|
|
|
@ -287,6 +287,7 @@ VF
|
||||||
"group1:children" => 'bar',
|
"group1:children" => 'bar',
|
||||||
"group2" => [iso_env.machine_names[1]],
|
"group2" => [iso_env.machine_names[1]],
|
||||||
"group3" => ["unknown", "#{machine.name}"],
|
"group3" => ["unknown", "#{machine.name}"],
|
||||||
|
group4: [machine.name],
|
||||||
"bar" => ["#{machine.name}", "group3"],
|
"bar" => ["#{machine.name}", "group3"],
|
||||||
"bar:children" => ["group1", "group2", "group3", "group4"],
|
"bar:children" => ["group1", "group2", "group3", "group4"],
|
||||||
}
|
}
|
||||||
|
@ -304,11 +305,13 @@ VF
|
||||||
# Skip "unknown" machines
|
# Skip "unknown" machines
|
||||||
expect(inventory_content).to include("[group3]\n#{machine.name}\n")
|
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
|
# Don't mix group names and host names
|
||||||
expect(inventory_content).to include("[bar]\n#{machine.name}\n")
|
expect(inventory_content).to include("[bar]\n#{machine.name}\n")
|
||||||
|
|
||||||
# A group of groups only includes declared groups
|
# 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")
|
expect(inventory_content).to include("[bar:children]\ngroup1\ngroup2\ngroup3\n")
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue