Add empty_groups param to ansible provisioner

This commit is contained in:
Vespian 2016-02-19 23:43:29 +01:00
parent 344ed08f49
commit 4750da3457
2 changed files with 8 additions and 0 deletions

View File

@ -43,6 +43,7 @@ type Config struct {
// The main playbook file to execute. // The main playbook file to execute.
PlaybookFile string `mapstructure:"playbook_file"` PlaybookFile string `mapstructure:"playbook_file"`
Groups []string `mapstructure:"groups"` Groups []string `mapstructure:"groups"`
EmptyGroups []string `mapstructure:"empty_groups"`
HostAlias string `mapstructure:"host_alias"` HostAlias string `mapstructure:"host_alias"`
LocalPort string `mapstructure:"local_port"` LocalPort string `mapstructure:"local_port"`
SSHHostKeyFile string `mapstructure:"ssh_host_key_file"` 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) 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 { if err := w.Flush(); err != nil {
tf.Close() tf.Close()
return fmt.Errorf("Error preparing inventory file: %s", err) 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 should be placed. When unspecified, the host is not associated with any
groups. 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. - `host_alias` (string) - The alias by which the Ansible host should be known.
Defaults to `default`. Defaults to `default`.