Skip to content

Commit

Permalink
extra_vars_file
Browse files Browse the repository at this point in the history
  • Loading branch information
neillturner committed Mar 5, 2017
1 parent 4367bc3 commit df4e83b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/kitchen-ansible/version.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- encoding: utf-8 -*-
module Kitchen
module Ansible
VERSION = '0.45.10'
VERSION = '0.46.0'
end
end
1 change: 1 addition & 0 deletions lib/kitchen/provisioner/ansible/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class Config
default_config :require_ansible_repo, true
default_config :enable_yum_epel, false
default_config :extra_vars, {}
default_config :extra_vars_file, nil
default_config :env_vars, {}
default_config :tags, []
default_config :ansible_apt_repo, 'ppa:ansible/ansible'
Expand Down
14 changes: 9 additions & 5 deletions lib/kitchen/provisioner/ansible_playbook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -747,11 +747,15 @@ def extra_vars
bash_vars = config[:attributes][:extra_vars]
end

return nil if bash_vars.none?
bash_vars = JSON.dump(bash_vars)
bash_vars = "-e '#{bash_vars}'"
debug(bash_vars)
bash_vars
return nil if bash_vars.none? && config[:extra_vars_file].nil?
if !bash_vars.none?
bash_extra_vars = JSON.dump(bash_vars)
else
bash_extra_vars = "\@#{config[:extra_vars_file]}"
end
bash_extra_vars = "-e '#{bash_extra_vars}'"
debug(bash_extra_vars)
bash_extra_vars
end

def tags
Expand Down
1 change: 1 addition & 0 deletions provisioner_options.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ chef_bootstrap_url | `https://www.getchef.com/chef/install.sh` | The Chef instal
enable_yum_epel | false | Enable the `yum` EPEL repo
env_vars | Hash.new | Hash to set environment variable to use with `ansible-playbook` command
extra_vars | Hash.new | Hash to set the `extra_vars` passed to `ansible-playbook` command
extra_vars_file | nil | file containing environment variables e.g. `private_vars/production.yml site.yml` Only if extra_vars not specified. Don't prefix with a @ sign.
filter_plugins_path | filter_plugins | Ansible repo `filter_plugins` directory
group_vars_path | group_vars | Ansible repo group_vars directory
host_vars_path | host_vars | Ansible repo hosts directory
Expand Down

0 comments on commit df4e83b

Please sign in to comment.