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
if !playbook
@errors << I18n.t("vagrant.provisioners.ansible.no_playbook")
@errors << I18n.t("vagrant.provisioners.ansible.errors.no_playbook")
end
# Validate the existence of the 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
# Validate the existence of the inventory_path, if specified
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
# Validate the existence of the vault_password_file, if specified
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
# Validate that extra_vars is either a hash, or a path to an
# existing file
# Validate that extra_vars is either a hash, or a path to an existing file
if extra_vars
extra_vars_is_valid = extra_vars.kind_of?(Hash) || extra_vars.kind_of?(String)
if extra_vars.kind_of?(String)
@ -92,7 +88,7 @@ module VagrantPlugins
if !extra_vars_is_valid
@errors << I18n.t(
"vagrant.provisioners.ansible.extra_vars_invalid",
"vagrant.provisioners.ansible.errors.extra_vars_invalid",
type: extra_vars.class.to_s,
value: extra_vars.to_s)
end

View File

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

View File

@ -47,15 +47,15 @@ module VagrantPlugins
if config.install &&
(config.version.to_s.to_sym == :latest ||
!@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)
end
# Check for the existence of ansible-playbook binary on the guest,
@machine.communicate.execute(
"ansible-playbook --help",
:error_class => Ansible::Errors::AnsibleError,
:error_key => :ansible_playbook_app_not_found_on_guest)
:error_class => Ansible::Errors::AnsibleNotFoundOnGuest,
:error_key => :ansible_not_found_on_guest)
# Check if requested ansible version is available
if (!config.version.empty? &&

View File

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

View File

@ -2039,12 +2039,16 @@ en:
upload_path_not_set: "`upload_path` must be set for the shell provisioner."
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:
ansible_playbook_app_failed: |-
ansible_command_failed: |-
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.
ansible_playbook_app_not_found_on_guest: |-
The "ansible-playbook" program could not be found! Please verify
ansible_not_found_on_guest: |-
The Ansible software could not be found! Please verify
that Ansible is correctly installed on your guest system.
If you haven't installed Ansible yet, please install Ansible
@ -2052,36 +2056,32 @@ en:
`install` option of this provisioner. Please check
http://docs.vagrantup.com/v2/provisioning/ansible_local.html
for more information.
ansible_version_not_found_on_guest: |-
The requested Ansible version (%{required_version}) was not found on the guest.
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
ansible_not_found_on_host: |-
The Ansible software could not be found! Please verify
that Ansible is correctly installed on your host system.
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
automated way.
Please check http://docs.ansible.com for more information.
extra_vars_invalid: |-
`extra_vars` for the Ansible provisioner must be a hash or a path to an existing file. Received: %{value} (as %{type})
inventory_path_invalid: |-
`inventory_path` for the Ansible provisioner does not exist on the %{system}: %{path}
no_playbook: |-
`playbook` must be set for the Ansible provisioner.
playbook_path_invalid: |-
`playbook` for the Ansible provisioner does not exist on the %{system}: %{path}
vault_password_file_invalid: |-
`vault_password_file` for the Ansible provisioner does not exist on the %{system}: %{path}
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.
installing: |-
Installing Ansible...
ansible_version_not_found_on_guest: |-
The requested Ansible version (%{required_version}) was not found on the guest.
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.
extra_vars_invalid: |-
`extra_vars` must be a hash or a path to an existing file. Received: %{value} (as %{type})
inventory_path_invalid: |-
`inventory_path` does not exist on the %{system}: %{path}
no_playbook: |-
`playbook` file path must be set.
playbook_path_invalid: |-
`playbook` does not exist on the %{system}: %{path}
vault_password_file_invalid: |-
`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 is not officially supported for the Ansible Control Machine.
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)
expect(result["ansible remote provisioner"]).to eql([
I18n.t("vagrant.provisioners.ansible.no_playbook")
I18n.t("vagrant.provisioners.ansible.errors.no_playbook")
])
end
@ -104,7 +104,7 @@ describe VagrantPlugins::Ansible::Config::Host do
result = subject.validate(machine)
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")
])
end
@ -131,7 +131,7 @@ describe VagrantPlugins::Ansible::Config::Host do
result = subject.validate(machine)
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,
value: subject.extra_vars.to_s)
])
@ -143,7 +143,7 @@ describe VagrantPlugins::Ansible::Config::Host do
result = subject.validate(machine)
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,
value: subject.extra_vars.to_s)
])
@ -163,7 +163,7 @@ describe VagrantPlugins::Ansible::Config::Host do
result = subject.validate(machine)
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")
])
end
@ -174,7 +174,8 @@ describe VagrantPlugins::Ansible::Config::Host do
result = subject.validate(machine)
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")
])
end
@ -187,14 +188,14 @@ describe VagrantPlugins::Ansible::Config::Host do
result = subject.validate(machine)
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"))
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,
value: subject.extra_vars.to_s))
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"))
end