diff --git a/lib/kitchen-ansible/version.rb b/lib/kitchen-ansible/version.rb index d69f95a..1c06e47 100644 --- a/lib/kitchen-ansible/version.rb +++ b/lib/kitchen-ansible/version.rb @@ -1,6 +1,6 @@ # -*- encoding: utf-8 -*- module Kitchen module Ansible - VERSION = '0.47.1'.freeze + VERSION = '0.47.2'.freeze end end diff --git a/lib/kitchen/provisioner/ansible_playbook.rb b/lib/kitchen/provisioner/ansible_playbook.rb index f06188f..5425316 100644 --- a/lib/kitchen/provisioner/ansible_playbook.rb +++ b/lib/kitchen/provisioner/ansible_playbook.rb @@ -980,6 +980,15 @@ def prepare_hosts if config[:hosts].nil? fail 'No hosts have been set. Please specify one in .kitchen.yml' + elsif config[:hosts].is_a?(Array) + debug("Using an array of hosts from #{hosts}") + File.open(File.join(sandbox_path, 'hosts'), 'wb') do |file| + hoststring="localhost ansible_connection=local\n" + config[:hosts].each do |h| + hoststring+="[#{h}]\nlocalhost\n\n" + end + file.write(hoststring) + end else debug("Using host from #{hosts}") File.open(File.join(sandbox_path, 'hosts'), 'wb') do |file| diff --git a/provisioner_options.md b/provisioner_options.md index 19c8c44..ee2b2be 100644 --- a/provisioner_options.md +++ b/provisioner_options.md @@ -66,7 +66,7 @@ extra_vars_file | nil | file containing environment variables e.g. `private_vars 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 -hosts | | Create Ansible hosts file for localhost with this server group +hosts | | Create Ansible hosts file for localhost with this server group or list of groups http_proxy | nil | Use HTTP proxy when installing Ansible, packages and running Ansible https_proxy | nil | Use HTTPS proxy when installing Ansible, packages and running Ansible idempotency_test | false | Enable to test Ansible playbook idempotency