Skip to content
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 provisioning doesn't work in vagrant on mac #712

Closed
chrisjohnson00 opened this issue May 3, 2017 · 11 comments
Closed

ansible provisioning doesn't work in vagrant on mac #712

chrisjohnson00 opened this issue May 3, 2017 · 11 comments
Labels

Comments

@chrisjohnson00
Copy link

After cloning the project to fix an issue I reported, I attempted to bring up the virtual machine via vagrant. After executing a vagrant up I get the following error from the ansible provisioning:

==> default: Running provisioner: ansible...
default: Running ansible-playbook...

PLAY [all] *********************************************************************

TASK [Gathering Facts] *********************************************************
fatal: [default]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Shared connection to 127.0.0.1 closed.\r\n", "module_stdout": "/bin/sh: 1: /usr/bin/python: not found\r\n", "msg": "MODULE FAILURE", "rc": 0}

I use ansible provisioning on other projects without any issue, so something's missing here for me.

I'm running on OSX (10.11.6), Python 2.7.10, VirtualBox 5.0.30, and vagrant 1.9.1

@siad007
Copy link
Member

siad007 commented May 13, 2017

Strange I cannot reproduce this problem on my environment.
Maybe this stackoverflow post is related?
It would be very helpful if you could try this code for your playbook.yml and report back the result:

---
- hosts: all
  gather_facts: no
  pre_tasks:
    - name: 'install python2'
      raw: sudo apt-get -y install python-simplejson
  roles:
    - { role: phing.vagrant, tags: [vagrant] }
    - { role: phing.environment, tags: [vagrant] }
    - { role: phing.php, tags: [vagrant] }

@chrisjohnson00
Copy link
Author

@siad007 - Can you try destroying the phing vagrant environment and then execute a vagrant up? Does that succeed for you?
There's a different message now, but looks like same root problem "shared connection to 127.0.0.1 closed

==> default: Running provisioner: ansible...
    default: Running ansible-playbook...

PLAY [all] *********************************************************************

TASK [phing.vagrant : Set up the MOTD] *****************************************
fatal: [default]: FAILED! => {"changed": false, "failed": true, "msg": "Failed to get information on remote file (/etc/motd): Shared connection to 127.0.0.1 closed.\r\n"}
        to retry, use: --limit @/Users/cjohnson/PhpstormProjects/phing/ansible/playbook.retry

PLAY RECAP *********************************************************************
default                    : ok=0    changed=0    unreachable=0    failed=1   

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

@chrisjohnson00
Copy link
Author

also of note... here's my version of ansible

FW-529:phing cjohnson$ ansible --version
ansible 2.3.0.0
  config file = 
  configured module search path = Default w/o overrides
  python version = 2.7.10 (default, Oct 23 2015, 19:19:21) [GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)]

@chrisjohnson00
Copy link
Author

running the playbook manually works, having vagrant do it does not.

FW-529:phing cjohnson$ ansible-playbook ansible/playbook.yml -i ansible/inventory -u vagrant --ask-pass --sudo
SSH password: 

PLAY [all] **************************************************************************************************************************************************************************************

TASK [install python2] **************************************************************************************************************************************************************************
changed: [192.168.255.2]

TASK [phing.vagrant : Set up the MOTD] **********************************************************************************************************************************************************
ok: [192.168.255.2]

TASK [phing.vagrant : Adding existing user 'vagrant' to groups www-data,users] ******************************************************************************************************************
changed: [192.168.255.2]

TASK [phing.vagrant : Update our apt cache] *****************************************************************************************************************************************************
changed: [192.168.255.2]

TASK [phing.vagrant : Install Vim] **************************************************************************************************************************************************************
changed: [192.168.255.2] => (item=[u'vim'])

TASK [phing.vagrant : Have SSH user go to /vagrant by default] **********************************************************************************************************************************
changed: [192.168.255.2]

TASK [phing.environment : Install required packages] ********************************************************************************************************************************************
changed: [192.168.255.2] => (item=[u'curl', u'git', u'subversion', u'mercurial', u'python-pip'])

TASK [phing.environment : install python-docutil] ***********************************************************************************************************************************************
changed: [192.168.255.2]

TASK [phing.php : Install PHP] ******************************************************************************************************************************************************************
changed: [192.168.255.2]

TASK [phing.php : Install PHP Modules] **********************************************************************************************************************************************************
changed: [192.168.255.2] => (item=[u'php-bz2', u'php-xdebug', u'php-xsl', u'php-zip'])

TASK [phing.php : Install sqlite extension] *****************************************************************************************************************************************************
changed: [192.168.255.2] => (item=[u'php7.0-sqlite3', u'php7.0-mbstring', u'sqlite3', u'libsqlite3-dev'])

TASK [phing.php : Configure Phar extension.] ****************************************************************************************************************************************************
changed: [192.168.255.2]

TASK [phing.php : Install composer] *************************************************************************************************************************************************************
 [WARNING]: Consider using get_url or uri module rather than running curl

changed: [192.168.255.2]

PLAY RECAP **************************************************************************************************************************************************************************************
192.168.255.2              : ok=13   changed=12   unreachable=0    failed=0   

So the problem lies in Vagrantfile i think...

@siad007 siad007 added the defect label Jun 18, 2017
@siad007 siad007 changed the title ansible provisioning doesn't work in vagrant ansible provisioning doesn't work in vagrant on mac Nov 28, 2017
@aboullaite
Copy link

I've managed to get this working by adding this to my Vagrantfile:

  ansible.extra_vars = {
    ansible_python_interpreter: "/usr/bin/python3",
   }

@akellehe
Copy link

Thanks for documenting, @aboullaite, @chrisjohnson00, and @siad007 👏

@mrook
Copy link
Member

mrook commented Feb 13, 2018

Is that a Mac-specific thing that needs to be added to the Vagrantfile?

@siad007
Copy link
Member

siad007 commented Feb 13, 2018

On windows i cannot reproduce this behaviour but i think the solution

I've managed to get this working by adding this to my Vagrantfile:

ansible.extra_vars = {
ansible_python_interpreter: "/usr/bin/python3",
}

seems to work for a few people

@mrook
Copy link
Member

mrook commented Feb 13, 2018

@siad007 understood, can you add that?

@akellehe
Copy link

akellehe commented Feb 14, 2018 via email

@bentcoder
Copy link

In my case the solutions was:

all:
  children:
    servers:
      hosts:
        linux1:
          ansible_host: 192.168.99.31
          ansible_python_interpreter: /usr/bin/python3

siad007 added a commit that referenced this issue Mar 11, 2018
@siad007 siad007 mentioned this issue Mar 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

6 participants