From 525802e9e6b346f5e273923ed7df1050eac4988f Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 27 Dec 2013 08:28:50 -0700 Subject: [PATCH] provisioner/ansible-local: templates for role, playbook paths [GH-749] --- CHANGELOG.md | 2 ++ provisioner/ansible-local/provisioner.go | 19 ++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c0037526..56730953a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -66,6 +66,8 @@ BUG FIXES: * builder/virtualbox: don't download guest additions if disabled. [GH-731] * post-processor/vsphere: Uploads VM properly. [GH-694] * post-processor/vsphere: Process user variables. +* provisioner/ansible-local: all configurations are processed as templates + [GH-749] * provisioner/ansible-local: playbook paths are properly validated as directories, not files. [GH-710] * provisioner/chef-solo: Environments are recognized. [GH-726] diff --git a/provisioner/ansible-local/provisioner.go b/provisioner/ansible-local/provisioner.go index 860527bbb..1cbbe2626 100644 --- a/provisioner/ansible-local/provisioner.go +++ b/provisioner/ansible-local/provisioner.go @@ -54,7 +54,8 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { // Templates templates := map[string]*string{ - "staging_dir": &p.config.StagingDir, + "playbook_file": &p.config.PlaybookFile, + "staging_dir": &p.config.StagingDir, } for n, ptr := range templates { @@ -66,6 +67,22 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { } } + sliceTemplates := map[string][]string{ + "playbook_paths": p.config.PlaybookPaths, + "role_paths": p.config.RolePaths, + } + + for n, slice := range sliceTemplates { + for i, elem := range slice { + var err error + slice[i], err = p.config.tpl.Process(elem, nil) + if err != nil { + errs = packer.MultiErrorAppend( + errs, fmt.Errorf("Error processing %s[%d]: %s", n, i, err)) + } + } + } + // Validation err = validateFileConfig(p.config.PlaybookFile, "playbook_file", true) if err != nil {