Ansible Provisioning via Vagrant on Windows

I have had a working Windows Vagrant / Ansible environment for a while, and now have decided to document the process (see xxxx). First though I am documenting the gotchas I have found.

Gotcha 1 - Spaces in Directory Path

When using Ansible on a a Cygwin / Babun shell, make sure that the users home directory does not contain any spaces. i.e /home/NIrving Development , as this causes some issues. The first issue is the following

[code lang=”bash”]

{ test } » vagrant provision ~/vm/test ==> default: Running provisioner: ansible… PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=true ANSIBLE_HOST_KEY_CHECKING=false ANSIBLE_SSH_ARGS=’-o UserKnownHostsFile=/dev/null -o ControlMaster=auto -o ControlPersist=60s’ ansible-playbook –private-key=<strong>D:/vm/babun/.babun/cygwin/home/NIrving Development/vm/test/.vagrant/machines/default/virtualbox/private_key</strong> –user=vagrant –connection=ssh –limit=’default’ –inventory-file=<strong>D:/vm/babun/.babun/cygwin/home/NIrving Development/vm/test/.vagrant/provisioners/ansible/inventory</strong> playbook.yml Usage: ansible-playbook playbook.yml

Options:

………

–version show program’s version number and exit Ansible failed to complete successfully. Any error output should be visible above. Please fix these errors and try again.

[/code]

Notice the spaces. To fix this move the Vagrant container to a directory that does not have any spaces e.g /opt/vm/test and run again.

Gotcha 2 - File Permissions

Once the directory path was resolved, the next issue was related to file permissions of the private key.

[code lang=”bash”] GATHERING FACTS *********************** fatal: [default] => private_key_file (D:/vm/babun/.babun/cygwin/opt/vm/test/.vagrant/machines/default/virtualbox/private_key) is group-readable or world-readable and thus insecure - you will probably get an SSH failure

TASK: [update apt cache] ****************** FATAL: no hosts matched or all hosts have already failed – aborting PLAY RECAP ************************ to retry, use: –limit @/home/NIrving Development/playbook.retry

default : ok=0 changed=0 unreachable=1 failed=0

Ansible failed to complete successfully. Any error output should be visible above. Please fix these errors and try again.

[/code]

This is not so easily fixed, as changing the file permissions do not alter the error. To resolve the check has to be removed from /usr/lib/python2.7/site-packages/ansible/runner/connection.py

Gotcha 3 - SSH Connections

The next issue was related to connecting via SSH.

[code lang=”bash”] GATHERING FACTS *********************** fatal: [default] => SSH Error: mux_client_request_session: send fds failed while connecting to 127.0.0.1:2222 It is sometimes useful to re-run the command using -vvvv, which prints SSH debug output to help diagnose the issue.

TASK: [update apt cache] ****************** FATAL: no hosts matched or all hosts have already failed – aborting PLAY RECAP ************************ to retry, use: –limit @/home/NIrving Development/playbook.retry

default : ok=0 changed=0 unreachable=1 failed=0

Ansible failed to complete successfully. Any error output should be visible above. Please fix these errors and try again.

[/code]

This can be resolved by creating the ~/.ansible.cfg with the following details

[code lang=”bash”] [ssh_connection] control_path = /tmp [/code]

Gotcha 4 - DLL issues

Next I was experiencing issues with Babun and DLLs.

[code] GATHERING FACTS *********************** 171 [main] python2.7 4988 child_info_fork::abort: address space needed by ‘_speedups.dll’ (0xA50000) is already occupied fatal: [default] => Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/ansible/runner/init.py", line 582, in _executor exec_rc = self._executor_internal(host, new_stdin) File "/usr/lib/python2.7/site-packages/ansible/runner/init.py", line 785, in _executor_internal return self._executor_internal_inner(host, self.module_name, self.module_args, inject, port, complex_args=complex_args) File "/usr/lib/python2.7/site-packages/ansible/runner/init.py", line 1032, in _executor_internal_inner result = handler.run(conn, tmp, module_name, module_args, inject, complex_args) File "/usr/lib/python2.7/site-packages/ansible/runner/action_plugins/normal.py", line 57, in run return self.runner._execute_module(conn, tmp, module_name, module_args, inject=inject, complex_args=complex_args) File "/usr/lib/python2.7/site-packages/ansible/runner/init.py", line 480, in _execute_module self._transfer_str(conn, tmp, module_name, module_data) File "/usr/lib/python2.7/site-packages/ansible/runner/init.py", line 307, in _transfer_str conn.put_file(afile, remote) File "/usr/lib/python2.7/site-packages/ansible/runner/connection_plugins/ssh.py", line 423, in put_file (p, stdin) = self._run(cmd, indata) File "/usr/lib/python2.7/site-packages/ansible/runner/connection_plugins/ssh.py", line 111, in _run stdout=subprocess.PIPE, stderr=subprocess.PIPE) File "/usr/lib/python2.7/subprocess.py", line 710, in init errread, errwrite) File "/usr/lib/python2.7/subprocess.py", line 1223, in _execute_child self.pid = os.fork() OSError: [Errno 11] Resource temporarily unavailable

TASK: [update apt cache] ****************** FATAL: no hosts matched or all hosts have already failed – aborting

PLAY RECAP ************************ to retry, use: –limit @/home/NIrving Development/playbook.retry

default : ok=0 changed=0 unreachable=1 failed=0

217 [main] python2.7 4204 child_info_fork::abort: address space needed by ‘_speedups.dll’ (0xA50000) is already occupied Ansible failed to complete successfully. Any error output should be visible above. Please fix these errors and try again.

[/code]

Reading http://stackoverflow.com/questions/9300722/cygwin-error-bash-fork-retry-resource-temporarily-unavailable gave the answer.

  1. Open a Command Prompt and change to the  cygwin directory of the Babun install D:\vm\babun\.babun\cygwin\bin
  2. Issue the following command ash.exe
  3. In the prompt enter /usr/bin/rebaseall -v
  4. Retry the provisioning.

So far these are all the gotcha I have encountered, any more and I will update this page.

Loading Google+ Comments ...