Merge pull request #3232 from vespian/ansible_provisioner_empty_groups_support

Add empty_groups param to ansible provisioner
This commit is contained in:
Rickard von Essen 2016-02-20 10:28:38 +01:00
commit da1e9f4976
2 changed files with 8 additions and 0 deletions

View File

@ -43,6 +43,7 @@ type Config struct {
// The main playbook file to execute.
PlaybookFile string `mapstructure:"playbook_file"`
Groups []string `mapstructure:"groups"`
EmptyGroups []string `mapstructure:"empty_groups"`
HostAlias string `mapstructure:"host_alias"`
LocalPort string `mapstructure:"local_port"`
SSHHostKeyFile string `mapstructure:"ssh_host_key_file"`
@ -213,6 +214,10 @@ func (p *Provisioner) Provision(ui packer.Ui, comm packer.Communicator) error {
fmt.Fprintf(w, "[%s]\n%s", group, host)
}
for _, group := range p.config.EmptyGroups {
fmt.Fprintf(w, "[%s]\n", group)
}
if err := w.Flush(); err != nil {
tf.Close()
return fmt.Errorf("Error preparing inventory file: %s", err)

View File

@ -51,6 +51,9 @@ Optional Parameters:
should be placed. When unspecified, the host is not associated with any
groups.
- `empty_groups` (array of strings) - The groups which should be present in
inventory file but remain empty.
- `host_alias` (string) - The alias by which the Ansible host should be known.
Defaults to `default`.