Skip to content
This repository has been archived by the owner on Feb 13, 2023. It is now read-only.

[Arch] SyntaxError during task 'Check if local known_hosts file is present.' #530

Closed
sidneygijzen opened this issue Mar 28, 2016 · 9 comments

Comments

@sidneygijzen
Copy link
Contributor

Hello,

I've been running Drupal VM (also) on a Arch Linux host for the past 8 months without any problems. To be able to make use of all the shiny new features in the latest releases, I'm currently upgrading Drupal VM from a master branch version from September ' 15 to the current master branch version.

Before starting the upgrade, I took all changed variables mentioned in the various release notes (such as updating the Apache Ansible Galaxy role & updating Apache vhost configs) into account.

After that I re-ran the provisioning of my Drupal VM box (default Drupal VM Ubuntu 14.04 box). Everything went well except for one of the last tasks, 'Check if local known_hosts file is present.' , which generates into the following error:

fatal: [drupalvm]: FAILED! => {
    "changed": false, 
    "failed": true, 
    "module_stderr": "  File \"/home/sidneygijzen/.ansible/tmp/ansible-tmp-1459155009.84-185598221565320/stat\", line 314\n    except OSError, e:\n                  ^\nSyntaxError: invalid syntax\n", 
    "module_stdout": "",
    "msg": "MODULE FAILURE",
    "parsed": false}

In order to resolve this I tried the following:

  • if my known_hosts file is present -> it is.
  • start with a new build of the box (vagrant destroy / vagrant up) -> generates the same error
  • Ansible doesn't support Python3 officially, and since Arch has Python 3 by default, I setup an virtualenv with Python 2 and ran it from there -> generates the same error

I have the feeling my Arch host, an interplay between Arch & Ansible is the cause (or maybe the format of the known_hosts file?), since I did the same upgrade of Drupal VM on a Ubuntu 15.10 host yesterday, and that went flawlessly.
I thought to post my question here to see if someone else has stumbled into this error? Are there any issues known with Drupal VM or Ansible on a Arch host?

Thank you in advance!

@geerlingguy
Copy link
Owner

Haven't tried specifically with Arch before... but one quick question: what version of Ansible is installed? (ansible --version)

@sidneygijzen
Copy link
Contributor Author

Thanks for the quick reply.

The installed Ansible version is 2.0.1.0

@oxyc
Copy link
Collaborator

oxyc commented Mar 31, 2016

Hmm does sound like a python2 vs python3 issue.

I also found this comment about virtualenv StreisandEffect/streisand#30 (comment).

@sidneygijzen
Copy link
Contributor Author

Thanks for your reply and the helpful link.

Based on your link I've been trying to get it working by either providing a local ansible.cfg file. The file consists only of:

[defaults]
ansible_python_interpreter=/usr/bin/python2

I tried running vagrant provision (both with and without virtualenv) with the ansible.cfg file the following locations:

  • my home directory (~)
  • same directory as the Vagrantfile
    • also combined with setting a Vagrant variable ANSIBLE_CONFIG parameter in the Vagrantfile on which I ran vagrant reload && vagrant provision, so the new Vagrantfile gets loaded.
  • same directory as playbook.yml
    The first option was based on Ansible configuration docs page, but I'm not sure it gets picked up. So the other options are based on the description in this commit.

I also tried to add a parameter to the inventory file. Vagrant generates this file (.vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory) automatically, so I couldn't make any modifications there. Therefore I added a host_vars directory in /provisioning, in which I added the file all.yml (so path from drupalvm root is /provisioning/host_vars/all.yml) where I specified

---
ansible_python_interpreter=/usr/bin/python2

How can I check btw which Python interpreter Ansible is using?

Unfortunately I can't get it to work with any of the options specified above. The same error keeps occuring. I hope my description above provides enough information. If not, don't hesitate to ask :)

@oxyc
Copy link
Collaborator

oxyc commented Apr 6, 2016

Could you try putting it in the Vagrantfile and see what happens.

diff --git a/Vagrantfile b/Vagrantfile
index 9ef14ab..19defa0 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -109,6 +109,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
   if which('ansible-playbook')
     config.vm.provision 'ansible' do |ansible|
       ansible.playbook = "#{dir}/provisioning/playbook.yml"
+      ansible.extra_vars = { 'ansible_python_interpreter': '/usr/bin/env python2' }
     end
   else
     config.vm.provision 'shell' do |sh|

By setting this to python3 I get your exact error message at least.

@sidneygijzen
Copy link
Contributor Author

Awesome! That works. Thanks a lot @oxyc !!

Can we incorporate this by default into DrupalVM? Or, if it affects other hosts in a bad way, perhaps a mention in the docs somewhere?

@oxyc
Copy link
Collaborator

oxyc commented Apr 7, 2016

@geerlingguy is the ansible expert, what do you think? I don't see a problem with adding it as a a default. Guess there might be a few cases where people do have python referencing python3. The local provisioners would never need it right?

Edit: Unfortunately you can't fix this with Vagrantfile.local as provisioners are appended, not replaced.

@oxyc
Copy link
Collaborator

oxyc commented Apr 9, 2016

@sidneygijzen I think I found a very easy fix. Just add it to your config.yml

ansible_python_interpreter: "/usr/bin/env python2"

Could you verify that this works?

oxyc added a commit to oxyc/drupal-vm that referenced this issue Apr 9, 2016
geerlingguy added a commit that referenced this issue Apr 11, 2016
Fixes #530: Add docs for arch linux where python 3 is the default
@sidneygijzen
Copy link
Contributor Author

@oxyc Neat! That works as well. Thank you!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants