From 1b35c586ce557103af35dbf887662ed886ac7830 Mon Sep 17 00:00:00 2001 From: Ruben Tsirunyan Date: Sat, 27 Jul 2019 15:56:14 +0400 Subject: [PATCH] Changes to roles_path option --- provisioner/ansible/provisioner.go | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/provisioner/ansible/provisioner.go b/provisioner/ansible/provisioner.go index 9640e1b05..d61d4d44e 100644 --- a/provisioner/ansible/provisioner.go +++ b/provisioner/ansible/provisioner.go @@ -64,7 +64,7 @@ type Config struct { GalaxyFile string `mapstructure:"galaxy_file"` GalaxyCommand string `mapstructure:"galaxy_command"` GalaxyForceInstall bool `mapstructure:"galaxy_force_install"` - RolesDir string `mapstructure:"roles_dir"` + RolesPath string `mapstructure:"roles_path"` } type Provisioner struct { @@ -108,10 +108,6 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { p.config.GalaxyCommand = "ansible-galaxy" } - if p.config.RolesDir == "" { - p.config.RolesDir = "~/.ansible/roles" - } - if p.config.HostAlias == "" { p.config.HostAlias = "default" } @@ -364,15 +360,18 @@ func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.C } func (p *Provisioner) executeGalaxy(ui packer.Ui, comm packer.Communicator) error { - rolesDir := filepath.ToSlash(p.config.RolesDir) galaxyFile := filepath.ToSlash(p.config.GalaxyFile) - // ansible-galaxy install -r requirements.yml -p roles/ - args := []string{"install", "-r", galaxyFile, "-p", rolesDir} + // ansible-galaxy install -r requirements.yml + args := []string{"install", "-r", galaxyFile} // Add force to arguments if p.config.GalaxyForceInstall { args = append(args, "-f") } + // Add roles_path argument if specified + if p.config.RolesPath != "" { + args = append(args, "-p", filepath.ToSlash(p.config.RolesPath)) + } ui.Message(fmt.Sprintf("Executing Ansible Galaxy")) cmd := exec.Command(p.config.GalaxyCommand, args...)