provisioners/ansible(both): reorganize i18n texts

These adaptations will make even more sense with the upcoming
introduction of `ansible-galaxy` support.
This commit is contained in:
Gilles Cornu 2015-11-17 07:55:32 +01:00
parent f24250ae9a
commit a0576349fe
6 changed files with 52 additions and 55 deletions

View File

@ -57,26 +57,22 @@ module VagrantPlugins
# Validate that a playbook path was provided # Validate that a playbook path was provided
if !playbook if !playbook
@errors << I18n.t("vagrant.provisioners.ansible.no_playbook") @errors << I18n.t("vagrant.provisioners.ansible.errors.no_playbook")
end end
# Validate the existence of the playbook
if playbook if playbook
check_path_is_a_file(machine, playbook, "vagrant.provisioners.ansible.playbook_path_invalid") check_path_is_a_file(machine, playbook, "vagrant.provisioners.ansible.errors.playbook_path_invalid")
end end
# Validate the existence of the inventory_path, if specified
if inventory_path if inventory_path
check_path_exists(machine, inventory_path, "vagrant.provisioners.ansible.inventory_path_invalid") check_path_exists(machine, inventory_path, "vagrant.provisioners.ansible.errors.inventory_path_invalid")
end end
# Validate the existence of the vault_password_file, if specified
if vault_password_file if vault_password_file
check_path_is_a_file(machine, vault_password_file, "vagrant.provisioners.ansible.vault_password_file_invalid") check_path_is_a_file(machine, vault_password_file, "vagrant.provisioners.ansible.errors.vault_password_file_invalid")
end end
# Validate that extra_vars is either a hash, or a path to an # Validate that extra_vars is either a hash, or a path to an existing file
# existing file
if extra_vars if extra_vars
extra_vars_is_valid = extra_vars.kind_of?(Hash) || extra_vars.kind_of?(String) extra_vars_is_valid = extra_vars.kind_of?(Hash) || extra_vars.kind_of?(String)
if extra_vars.kind_of?(String) if extra_vars.kind_of?(String)
@ -92,7 +88,7 @@ module VagrantPlugins
if !extra_vars_is_valid if !extra_vars_is_valid
@errors << I18n.t( @errors << I18n.t(
"vagrant.provisioners.ansible.extra_vars_invalid", "vagrant.provisioners.ansible.errors.extra_vars_invalid",
type: extra_vars.class.to_s, type: extra_vars.class.to_s,
value: extra_vars.to_s) value: extra_vars.to_s)
end end

View File

@ -8,15 +8,15 @@ module VagrantPlugins
end end
class AnsiblePlaybookAppFailed < AnsibleError class AnsiblePlaybookAppFailed < AnsibleError
error_key(:ansible_playbook_app_failed) error_key(:ansible_command_failed)
end end
class AnsiblePlaybookAppNotFoundOnHost < AnsibleError class AnsibleNotFoundOnHost < AnsibleError
error_key(:ansible_playbook_app_not_found_on_host) error_key(:ansible_not_found_on_host)
end end
class AnsiblePlaybookAppNotFoundOnGuest < AnsibleError class AnsibleNotFoundOnGuest < AnsibleError
error_key(:ansible_playbook_app_not_found_on_guest) error_key(:ansible_not_found_on_guest)
end end
class AnsibleVersionNotFoundOnGuest < AnsibleError class AnsibleVersionNotFoundOnGuest < AnsibleError

View File

@ -47,15 +47,15 @@ module VagrantPlugins
if config.install && if config.install &&
(config.version.to_s.to_sym == :latest || (config.version.to_s.to_sym == :latest ||
!@machine.guest.capability(:ansible_installed, config.version)) !@machine.guest.capability(:ansible_installed, config.version))
@machine.ui.detail(I18n.t("vagrant.provisioners.ansible.installing")) @machine.ui.info(I18n.t("vagrant.provisioners.ansible.installing"))
@machine.guest.capability(:ansible_install) @machine.guest.capability(:ansible_install)
end end
# Check for the existence of ansible-playbook binary on the guest, # Check for the existence of ansible-playbook binary on the guest,
@machine.communicate.execute( @machine.communicate.execute(
"ansible-playbook --help", "ansible-playbook --help",
:error_class => Ansible::Errors::AnsibleError, :error_class => Ansible::Errors::AnsibleNotFoundOnGuest,
:error_key => :ansible_playbook_app_not_found_on_guest) :error_key => :ansible_not_found_on_guest)
# Check if requested ansible version is available # Check if requested ansible version is available
if (!config.version.empty? && if (!config.version.empty? &&

View File

@ -97,7 +97,7 @@ module VagrantPlugins
end end
raise Ansible::Errors::AnsiblePlaybookAppFailed if result.exit_code != 0 raise Ansible::Errors::AnsiblePlaybookAppFailed if result.exit_code != 0
rescue Vagrant::Errors::CommandUnavailable rescue Vagrant::Errors::CommandUnavailable
raise Ansible::Errors::AnsiblePlaybookAppNotFoundOnHost raise Ansible::Errors::AnsibleNotFoundOnHost
end end
end end

View File

@ -2039,12 +2039,16 @@ en:
upload_path_not_set: "`upload_path` must be set for the shell provisioner." upload_path_not_set: "`upload_path` must be set for the shell provisioner."
ansible: ansible:
cannot_detect: |-
Vagrant does not support detecting whether Ansible is installed
for the guest OS running in the machine. Vagrant will assume it is
installed and attempt to continue.
errors: errors:
ansible_playbook_app_failed: |- ansible_command_failed: |-
Ansible failed to complete successfully. Any error output should be Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again. visible above. Please fix these errors and try again.
ansible_playbook_app_not_found_on_guest: |- ansible_not_found_on_guest: |-
The "ansible-playbook" program could not be found! Please verify The Ansible software could not be found! Please verify
that Ansible is correctly installed on your guest system. that Ansible is correctly installed on your guest system.
If you haven't installed Ansible yet, please install Ansible If you haven't installed Ansible yet, please install Ansible
@ -2052,36 +2056,32 @@ en:
`install` option of this provisioner. Please check `install` option of this provisioner. Please check
http://docs.vagrantup.com/v2/provisioning/ansible_local.html http://docs.vagrantup.com/v2/provisioning/ansible_local.html
for more information. for more information.
ansible_version_not_found_on_guest: |- ansible_not_found_on_host: |-
The requested Ansible version (%{required_version}) was not found on the guest. The Ansible software could not be found! Please verify
Please check the ansible installation on your guest system,
or adapt the `version` option of this provisioner in your Vagrantfile.
See http://docs.vagrantup.com/v2/provisioning/ansible_local.html
for more information.
ansible_playbook_app_not_found_on_host: |-
The "ansible-playbook" program could not be found! Please verify
that Ansible is correctly installed on your host system. that Ansible is correctly installed on your host system.
If you haven't installed Ansible yet, please install Ansible If you haven't installed Ansible yet, please install Ansible
on your host system. Vagrant can't do this for you in a safe and on your host system. Vagrant can't do this for you in a safe and
automated way. automated way.
Please check http://docs.ansible.com for more information. Please check http://docs.ansible.com for more information.
extra_vars_invalid: |- ansible_version_not_found_on_guest: |-
`extra_vars` for the Ansible provisioner must be a hash or a path to an existing file. Received: %{value} (as %{type}) The requested Ansible version (%{required_version}) was not found on the guest.
inventory_path_invalid: |- Please check the ansible installation on your guest system,
`inventory_path` for the Ansible provisioner does not exist on the %{system}: %{path} or adapt the `version` option of this provisioner in your Vagrantfile.
no_playbook: |- See http://docs.vagrantup.com/v2/provisioning/ansible_local.html
`playbook` must be set for the Ansible provisioner. for more information.
playbook_path_invalid: |- extra_vars_invalid: |-
`playbook` for the Ansible provisioner does not exist on the %{system}: %{path} `extra_vars` must be a hash or a path to an existing file. Received: %{value} (as %{type})
vault_password_file_invalid: |- inventory_path_invalid: |-
`vault_password_file` for the Ansible provisioner does not exist on the %{system}: %{path} `inventory_path` does not exist on the %{system}: %{path}
cannot_detect: |- no_playbook: |-
Vagrant does not support detecting whether Ansible is installed `playbook` file path must be set.
for the guest OS running in the machine. Vagrant will assume it is playbook_path_invalid: |-
installed and attempt to continue. `playbook` does not exist on the %{system}: %{path}
installing: |- vault_password_file_invalid: |-
Installing Ansible... `vault_password_file` does not exist on the %{system}: %{path}
installing: "Installing Ansible..."
running_playbook: "Running ansible-playbook..."
windows_not_supported_for_control_machine: |- windows_not_supported_for_control_machine: |-
Windows is not officially supported for the Ansible Control Machine. Windows is not officially supported for the Ansible Control Machine.
Please check http://docs.ansible.com/intro_installation.html#control-machine-requirements Please check http://docs.ansible.com/intro_installation.html#control-machine-requirements

View File

@ -94,7 +94,7 @@ describe VagrantPlugins::Ansible::Config::Host do
result = subject.validate(machine) result = subject.validate(machine)
expect(result["ansible remote provisioner"]).to eql([ expect(result["ansible remote provisioner"]).to eql([
I18n.t("vagrant.provisioners.ansible.no_playbook") I18n.t("vagrant.provisioners.ansible.errors.no_playbook")
]) ])
end end
@ -104,7 +104,7 @@ describe VagrantPlugins::Ansible::Config::Host do
result = subject.validate(machine) result = subject.validate(machine)
expect(result["ansible remote provisioner"]).to eql([ expect(result["ansible remote provisioner"]).to eql([
I18n.t("vagrant.provisioners.ansible.playbook_path_invalid", I18n.t("vagrant.provisioners.ansible.errors.playbook_path_invalid",
path: non_existing_file, system: "host") path: non_existing_file, system: "host")
]) ])
end end
@ -131,7 +131,7 @@ describe VagrantPlugins::Ansible::Config::Host do
result = subject.validate(machine) result = subject.validate(machine)
expect(result["ansible remote provisioner"]).to eql([ expect(result["ansible remote provisioner"]).to eql([
I18n.t("vagrant.provisioners.ansible.extra_vars_invalid", I18n.t("vagrant.provisioners.ansible.errors.extra_vars_invalid",
type: subject.extra_vars.class.to_s, type: subject.extra_vars.class.to_s,
value: subject.extra_vars.to_s) value: subject.extra_vars.to_s)
]) ])
@ -143,7 +143,7 @@ describe VagrantPlugins::Ansible::Config::Host do
result = subject.validate(machine) result = subject.validate(machine)
expect(result["ansible remote provisioner"]).to eql([ expect(result["ansible remote provisioner"]).to eql([
I18n.t("vagrant.provisioners.ansible.extra_vars_invalid", I18n.t("vagrant.provisioners.ansible.errors.extra_vars_invalid",
type: subject.extra_vars.class.to_s, type: subject.extra_vars.class.to_s,
value: subject.extra_vars.to_s) value: subject.extra_vars.to_s)
]) ])
@ -163,7 +163,7 @@ describe VagrantPlugins::Ansible::Config::Host do
result = subject.validate(machine) result = subject.validate(machine)
expect(result["ansible remote provisioner"]).to eql([ expect(result["ansible remote provisioner"]).to eql([
I18n.t("vagrant.provisioners.ansible.inventory_path_invalid", I18n.t("vagrant.provisioners.ansible.errors.inventory_path_invalid",
path: non_existing_file, system: "host") path: non_existing_file, system: "host")
]) ])
end end
@ -174,7 +174,8 @@ describe VagrantPlugins::Ansible::Config::Host do
result = subject.validate(machine) result = subject.validate(machine)
expect(result["ansible remote provisioner"]).to eql([ expect(result["ansible remote provisioner"]).to eql([
I18n.t("vagrant.provisioners.ansible.vault_password_file_invalid", I18n.t("vagrant.provisioners.ansible.errors.vault_password_file_invalid",
path: non_existing_file, system: "host")
path: non_existing_file, system: "host") path: non_existing_file, system: "host")
]) ])
end end
@ -187,14 +188,14 @@ describe VagrantPlugins::Ansible::Config::Host do
result = subject.validate(machine) result = subject.validate(machine)
expect(result["ansible remote provisioner"]).to include( expect(result["ansible remote provisioner"]).to include(
I18n.t("vagrant.provisioners.ansible.playbook_path_invalid", I18n.t("vagrant.provisioners.ansible.errors.playbook_path_invalid",
path: non_existing_file, system: "host")) path: non_existing_file, system: "host"))
expect(result["ansible remote provisioner"]).to include( expect(result["ansible remote provisioner"]).to include(
I18n.t("vagrant.provisioners.ansible.extra_vars_invalid", I18n.t("vagrant.provisioners.ansible.errors.extra_vars_invalid",
type: subject.extra_vars.class.to_s, type: subject.extra_vars.class.to_s,
value: subject.extra_vars.to_s)) value: subject.extra_vars.to_s))
expect(result["ansible remote provisioner"]).to include( expect(result["ansible remote provisioner"]).to include(
I18n.t("vagrant.provisioners.ansible.inventory_path_invalid", I18n.t("vagrant.provisioners.ansible.errors.inventory_path_invalid",
path: non_existing_file, system: "host")) path: non_existing_file, system: "host"))
end end