New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ansible Not Found during Post Provision Task #1772

Closed
jonnyeom opened this Issue May 15, 2018 · 3 comments

Comments

3 participants
@jonnyeom

jonnyeom commented May 15, 2018

Issue Type

  • Bug Report / Support Request

Your Environment

Vagrant 2.0.3
VirtualBox 5.2.8r121009

Your OS

  • Linux (Ubuntu 16.04)

Full console output

==> project: Running provisioner: ansible...
Vagrant gathered an unknown Ansible version:


and falls back on the compatibility mode '1.8'.

Alternatively, the compatibility mode can be specified in your Vagrantfile:
https://www.vagrantup.com/docs/provisioning/ansible_common.html#compatibility_mode

    project: Running ansible-galaxy...
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.

Summary

I Created a custom task inside my local.playbook.yml
I included that task with a Vagrantfile.local with the following (per instructions here)

config.vm.provision 'ansible' do |ansible|
  ansible.playbook = "#{host_config_dir}/local.playbook.yml"
  ansible.galaxy_role_file = "#{host_config_dir}/local.requirements.yml"
end

Am I missing something?

@geerlingguy

This comment has been minimized.

Show comment
Hide comment
@geerlingguy

geerlingguy May 16, 2018

Owner

If you use a custom Ansible playbook via Vagrantfile.local, you'll also need to have Ansible installed locally on your computer (e.g. pip install ansible, then check if it's installed with ansible --version).

Alternatively, change that first line to:

config.vm.provision 'ansible_local' do |ansible|

And see if that works, using the Ansible version installed inside Drupal VM.

Owner

geerlingguy commented May 16, 2018

If you use a custom Ansible playbook via Vagrantfile.local, you'll also need to have Ansible installed locally on your computer (e.g. pip install ansible, then check if it's installed with ansible --version).

Alternatively, change that first line to:

config.vm.provision 'ansible_local' do |ansible|

And see if that works, using the Ansible version installed inside Drupal VM.

@guoqiao

This comment has been minimized.

Show comment
Hide comment
@guoqiao

guoqiao Oct 5, 2018

@geerlingguy I got similar problem:

vagrant provision                                                                          [±master ●●]
==> default: Running provisioner: ansible...
Vagrant gathered an unknown Ansible version:


and falls back on the compatibility mode '1.8'.

Alternatively, the compatibility mode can be specified in your Vagrantfile:
https://www.vagrantup.com/docs/provisioning/ansible_common.html#compatibility_mode

    default: Running ansible-playbook...
PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=true ANSIBLE_HOST_KEY_CHECKING=false ANSIBLE_SSH_ARGS='-o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o ControlMaster=auto -o ControlPersist=60s' ansible-playbook --connection=ssh --timeout=30 --limit="default" --inventory-file=/home/joeg/autobuild/roles/samba-common/tests/.vagrant/provisioners/ansible/inventory -vvvv main.yml
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007f68a2b7f700 (most recent call first):
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.
                                                                                                                      
(ansible) > $ ansible --version                                                                          [±master ●●]
.....
  python version = 3.6.6 (default, Aug 29 2018, 10:25:37) [GCC 5.4.0 20160609]

vagrant -v                                                                                           [±master ●●]
Vagrant 2.1.5

guoqiao commented Oct 5, 2018

@geerlingguy I got similar problem:

vagrant provision                                                                          [±master ●●]
==> default: Running provisioner: ansible...
Vagrant gathered an unknown Ansible version:


and falls back on the compatibility mode '1.8'.

Alternatively, the compatibility mode can be specified in your Vagrantfile:
https://www.vagrantup.com/docs/provisioning/ansible_common.html#compatibility_mode

    default: Running ansible-playbook...
PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=true ANSIBLE_HOST_KEY_CHECKING=false ANSIBLE_SSH_ARGS='-o UserKnownHostsFile=/dev/null -o IdentitiesOnly=yes -o ControlMaster=auto -o ControlPersist=60s' ansible-playbook --connection=ssh --timeout=30 --limit="default" --inventory-file=/home/joeg/autobuild/roles/samba-common/tests/.vagrant/provisioners/ansible/inventory -vvvv main.yml
Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007f68a2b7f700 (most recent call first):
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.
                                                                                                                      
(ansible) > $ ansible --version                                                                          [±master ●●]
.....
  python version = 3.6.6 (default, Aug 29 2018, 10:25:37) [GCC 5.4.0 20160609]

vagrant -v                                                                                           [±master ●●]
Vagrant 2.1.5
@geerlingguy

This comment has been minimized.

Show comment
Hide comment
@geerlingguy

geerlingguy Oct 10, 2018

Owner

@guoqiao - It looks like there are two issues in your case:

Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'

According to the following, it looks like this can happen often if you're running Python 3.x in a virtual environment, and there are some fixes:

Closing this issue as the initial issue was a missing Ansible installation and that should be resolved by just installing Ansible.

Owner

geerlingguy commented Oct 10, 2018

@guoqiao - It looks like there are two issues in your case:

Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'

According to the following, it looks like this can happen often if you're running Python 3.x in a virtual environment, and there are some fixes:

Closing this issue as the initial issue was a missing Ansible installation and that should be resolved by just installing Ansible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment