From 131ce4fc9742395ca474156f373e56e36ec156a8 Mon Sep 17 00:00:00 2001 From: Matthew Johnson Date: Fri, 13 Sep 2013 22:48:12 -0400 Subject: [PATCH] add ansible.host_key_checking configuration parameter --- plugins/provisioners/ansible/config.rb | 51 ++++++++++--------- plugins/provisioners/ansible/provisioner.rb | 2 +- .../source/v2/provisioning/ansible.html.md | 1 + 3 files changed, 29 insertions(+), 25 deletions(-) diff --git a/plugins/provisioners/ansible/config.rb b/plugins/provisioners/ansible/config.rb index fb162ef27..fbf932a26 100644 --- a/plugins/provisioners/ansible/config.rb +++ b/plugins/provisioners/ansible/config.rb @@ -12,38 +12,41 @@ module VagrantPlugins attr_accessor :tags attr_accessor :skip_tags attr_accessor :start_at_task + attr_accessor :host_key_checking # Joker attribute, used to pass unsupported arguments to ansible anyway attr_accessor :raw_arguments def initialize - @playbook = UNSET_VALUE - @extra_vars = UNSET_VALUE - @inventory_path = UNSET_VALUE - @ask_sudo_pass = UNSET_VALUE - @limit = UNSET_VALUE - @sudo = UNSET_VALUE - @sudo_user = UNSET_VALUE - @verbose = UNSET_VALUE - @tags = UNSET_VALUE - @skip_tags = UNSET_VALUE - @start_at_task = UNSET_VALUE - @raw_arguments = UNSET_VALUE + @playbook = UNSET_VALUE + @extra_vars = UNSET_VALUE + @inventory_path = UNSET_VALUE + @ask_sudo_pass = UNSET_VALUE + @limit = UNSET_VALUE + @sudo = UNSET_VALUE + @sudo_user = UNSET_VALUE + @verbose = UNSET_VALUE + @tags = UNSET_VALUE + @skip_tags = UNSET_VALUE + @start_at_task = UNSET_VALUE + @raw_arguments = UNSET_VALUE + @host_key_checking = "true" end def finalize! - @playbook = nil if @playbook == UNSET_VALUE - @extra_vars = nil if @extra_vars == UNSET_VALUE - @inventory_path = nil if @inventory_path == UNSET_VALUE - @ask_sudo_pass = nil if @ask_sudo_pass == UNSET_VALUE - @limit = nil if @limit == UNSET_VALUE - @sudo = nil if @sudo == UNSET_VALUE - @sudo_user = nil if @sudo_user == UNSET_VALUE - @verbose = nil if @verbose == UNSET_VALUE - @tags = nil if @tags == UNSET_VALUE - @skip_tags = nil if @skip_tags == UNSET_VALUE - @start_at_task = nil if @start_at_task == UNSET_VALUE - @raw_arguments = nil if @raw_arguments == UNSET_VALUE + @playbook = nil if @playbook == UNSET_VALUE + @extra_vars = nil if @extra_vars == UNSET_VALUE + @inventory_path = nil if @inventory_path == UNSET_VALUE + @ask_sudo_pass = nil if @ask_sudo_pass == UNSET_VALUE + @limit = nil if @limit == UNSET_VALUE + @sudo = nil if @sudo == UNSET_VALUE + @sudo_user = nil if @sudo_user == UNSET_VALUE + @verbose = nil if @verbose == UNSET_VALUE + @tags = nil if @tags == UNSET_VALUE + @skip_tags = nil if @skip_tags == UNSET_VALUE + @start_at_task = nil if @start_at_task == UNSET_VALUE + @raw_arguments = nil if @raw_arguments == UNSET_VALUE + @host_key_checking = nil if @host_key_checking == UNSET_VALUE end def validate(machine) diff --git a/plugins/provisioners/ansible/provisioner.rb b/plugins/provisioners/ansible/provisioner.rb index e353b5fed..bbfda33b3 100644 --- a/plugins/provisioners/ansible/provisioner.rb +++ b/plugins/provisioners/ansible/provisioner.rb @@ -38,7 +38,7 @@ module VagrantPlugins # Write stdout and stderr data, since it's the regular Ansible output command << { - :env => { "ANSIBLE_FORCE_COLOR" => "true" }, + :env => { "ANSIBLE_FORCE_COLOR" => "true" , "ANSIBLE_HOST_KEY_CHECKING" => "#{config.host_key_checking}" }, :notify => [:stdout, :stderr], :workdir => @machine.env.root_path.to_s } diff --git a/website/docs/source/v2/provisioning/ansible.html.md b/website/docs/source/v2/provisioning/ansible.html.md index 9b805a918..e72588e33 100644 --- a/website/docs/source/v2/provisioning/ansible.html.md +++ b/website/docs/source/v2/provisioning/ansible.html.md @@ -141,3 +141,4 @@ by the sudo command. * `ansible.raw_arguments` is an *unsafe wildcard* string that can be used to take advantage of `ansible-playbook` arguments that are not (yet) supported by this Vagrant provisioner plugin. This can be very useful when integrating with bleeding edge Ansible versions. Following precedence rules apply: * Any supported options (described above) will override conflicting `raw_arguments` value (e.g. `--tags` or `--start-at-task`) * Vagrant default user authentication can be overridden via `raw_arguments` (with custom values for `--user` and `--private-key`) +* `ansible.host_key_checking` can be set to `false` which will disable host key checking and prevent `"FAILED: (25, 'Inappropriate ioctl for device')"` errors from being reported during provisioner runs. The default value is `true`, which matches the default behavior of Ansible 1.2.1 and later.