Skip to content
This repository was archived by the owner on Apr 7, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
kitchen-ansiblepush (0.9.1)
kitchen-ansiblepush (0.10.0)
test-kitchen (~> 1.4)

GEM
Expand Down Expand Up @@ -91,4 +91,4 @@ DEPENDENCIES
test-kitchen

BUNDLED WITH
1.16.0
1.17.1
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ provisioner :

## When running on EC2 with Windows and using get-password pass the password as ansible_password variable
pass_transport_password: false
## (optional), if you want to set specific environment variables when running ansible
environment_vars:
PROXMOX_URL: https://example.com:8006
```
## Idempotency test
If you want to check your code is idempotent you can use the idempotency_test. Essentially, this will run Ansible twice and check nothing changed in the second run. If something changed it will list the tasks. Note: If your using Ansible callback in your config this might conflict.
Expand Down
2 changes: 1 addition & 1 deletion lib/kitchen-ansible/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Kitchen
module AnsiblePush
VERSION = '0.9.1'.freeze
VERSION = '0.10.0'.freeze
end
end
12 changes: 12 additions & 0 deletions lib/kitchen/provisioner/ansible_push.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ class AnsiblePush < Base
default_config :ssh_common_args, nil
default_config :module_path, nil
default_config :pass_transport_password, false
default_config :environment_vars, {}

# For tests disable if not needed
default_config :chef_bootstrap_url, 'https://omnitruck.chef.io/install.sh'
Expand Down Expand Up @@ -88,6 +89,12 @@ def conf

raise UserError, "ansible extra_vars is in valid type: #{config[:extra_vars].class} value: #{config[:extra_vars]}" unless extra_vars_is_valid
end

unless config[:environment_vars].is_a?(Hash)
raise UserError,
"ansible environment_vars is not a `Hash` type. Given type: #{config[:environment_vars].class}"
end

info('Ansible push config validated')
@validated_config = config
end
Expand Down Expand Up @@ -176,6 +183,11 @@ def command_env
'ANSIBLE_HOST_KEY_CHECKING' => conf[:host_key_checking].to_s
}
@command_env['ANSIBLE_CONFIG'] = conf[:ansible_config] if conf[:ansible_config]

# NOTE: Manually merge to fix keys possibly being Symbol(s)
conf[:environment_vars].each do |key, value|
@command_env[key.to_s] = value
end
@command_env
end

Expand Down