Skip to content

Conversation

@sam-github
Copy link
Contributor

cc: @AshCripps who found this

@rvagg
Copy link
Member

rvagg commented Oct 26, 2019

Can we get an explanation of this? I don't think I've needed this, I don't have it on my system and I can't find reference to it in the repo.

also, this doc has python2, I'm pretty sure the ansible you install from brew these days is linked against python3 only so getting python2 involved might not be doing anything anymore, maybe that's why yamlish is coming up somehow?

$ head -1 $(which ansible-playbook)
#!/usr/local/Cellar/ansible/2.8.5/libexec/bin/python3.7

^ that's new in the last year, since the macos docs were added anyway, the change was a bit traumatic for a while, I couldn't reliably run ansible on my mac and had to do it all on my linux machine but it seems to be all sorted out now (mainly the fault of our python usage here).

@sam-github
Copy link
Contributor Author

@AshCripps see above, can you confirm whether we were using python2, and used pip2 to install yamlish?

@AshCripps
Copy link
Member

Yeah we swapped to python 2 to run the ansible

@cclauss
Copy link
Contributor

cclauss commented Oct 27, 2019

Used here https://github.com/nodejs/tap2junit/blob/master/tap2junit/tap13.py#L23

Installed here https://github.com/nodejs/tap2junit/blob/master/setup.py#L34

When Ansible does pip install tap2junit then setup.py is run and yamlish is installed.

@rvagg
Copy link
Member

rvagg commented Oct 27, 2019

@cclauss but that's on the server, this change is on the client. I don't see why yamlish is getting involved on the Ansible client.

@AshCripps can you explain why Python 3 didn't work? Or didn't you try that?

@AshCripps
Copy link
Member

AshCripps commented Oct 28, 2019

Didn't try 3 as I was just following the instructions in the doc https://github.com/nodejs/build/blob/master/ansible/README.md

@sam-github
Copy link
Contributor Author

I have always used python2, too, as the docs direct. I only ansible from ubuntu 19.04, and python2 is what ansible-playbook uses: head -n1 =ansible-playbook # #! /usr/bin/python2

@rvagg are you saying you are using py3, so that's why you don't run into this?

I'm pretty sure I've run into the yamlish error before and installed it, but my memory is not so great.

I do see this locally, fwiw:

% pip show yamlish 
Name: yamlish
Version: 0.18.1
Summary: Python implementation of YAMLish
Home-page: https://gitlab.com/mcepl/yamlish/
Author: Matěj Cepl
Author-email: mcepl@redhat.com
License: UNKNOWN
Location: /home/sam/.local/lib/python2.7/site-packages
Requires: PyYAML
Required-by: tap2junit

@sam-github
Copy link
Contributor Author

@rvagg

I don't see why yamlish is getting involved on the Ansible client.

Did you check playbook/write-ssh-config.yml? It might have been that playbook not the main ones that needed it.

@rvagg
Copy link
Member

rvagg commented Oct 28, 2019

Did you check playbook/write-ssh-config.yml? It might have been that playbook not the main ones that needed it.

sorry, I'm not sure what this is referring to

$ git grep yamlish
 ... no results in our repo

Perhaps this is a broken Ansible + Python2 thing on macOS? How about you try to uninstall all of those things installed with brew and just run brew install ansible and try again. There's a good chance that when George was setting this up he was hitting the not-compatible-with-python3 period of our Ansible configs. That's been resolved and I can use all of our Ansible scripting on both macOS (plain Ansible which links to Python 3) and Linux (plain Ansible from a PPA that links to Python 2).

If you want to out yamlish in the docs then that's fine, it just seems a big step backward to further bake in Python 2 when brew is likely going to entirely remove it at the end of the year because they're being really militant about the 2 EOL.

@sam-github sam-github closed this Oct 29, 2019
@sam-github sam-github deleted the correct-osx-ansible-install branch October 29, 2019 14:00
@AshCripps
Copy link
Member

@rvagg Ive tried uninstalling everything I can but ansible is giving me weird errors. It cant find the yaml plugin and when I try the export PYTHONPATH=$(pip show pyyaml | grep Location | awk '{print $2}') (using pip3) it says im pointing to a python 3.x directory when im running python 2.x. Weirdly if I change the directory to python2.7 it tells me the exact opposite (accessing python2 directory while running python3). The only time write-ssh-config.yml ran is when I ran brew install python@2

Did you do anything else to get ansible to run with python 3 on your mac?

@cclauss
Copy link
Contributor

cclauss commented Oct 30, 2019

PYTHONPATH=$(python3 -m pip show pyyaml | grep Location | awk '{print $2}')

@rvagg
Copy link
Member

rvagg commented Oct 30, 2019

Ouch, so I'm far from the expert on this, I mainly just rage at Python and hope others will figure stuff out.

$ which ansible
/usr/local/bin/ansible
$ head -1 /usr/local/bin/ansible
#!/usr/local/Cellar/ansible/2.8.5/libexec/bin/python3.7

And all of the playbooks that I've had to use in the past few months have been fine on my mac, except for an ongoing Python 3 problem with the ccache build task that I finally took care of by replacing the Python with Bash in #1945 (pretty much a reversion to how it was before Python got involved!)

It's very possible that I'm just running on cruft that's built up on my mac over the last year or two and I happen to have the necessary pieces. I've just been assuming that brew install ansible and various brew upgrades have been doing their thing. I don't ever recall having to manually install any dependencies for Ansible on my mac, certainly not YAML dependencies which is a core thing for Ansible so I would have thought that would be taken care of properly or the user community would be angry.

i.e. this is just my experience, one instance and with limited Python expertise, if you can't work it out then maybe just go ahead and document what works for you and the next person to do a fresh install with some knowledge about this stuff might clean it up.

@cclauss
Copy link
Contributor

cclauss commented Oct 31, 2019

I mainly just rage at Python and hope others will figure stuff out.

May the force be with you...

$ head -1 /usr/local/bin/ansible
#!/usr/local/Cellar/ansible/2.8.5/libexec/bin/python3.7

This means that Ansible is (wisely) running its own version of Python in a virtualenv.

This means that Ansible has its own python, its own pip and its own site-packages that have separate dependencies from system Python. The following commands become of interest:

  1. /usr/local/Cellar/ansible/2.8.5/libexec/bin/python3.7 -m pip --version
    • Displays the absolute path to this pip's site-packages
  2. /usr/local/Cellar/ansible/2.8.5/libexec/bin/python3.7 -m pip list
    • Probably different from pip list
  3. /usr/local/Cellar/ansible/2.8.5/libexec/bin/python3.7 -m pip list --outdated
    • Possible upgrades

@rvagg
Copy link
Member

rvagg commented Oct 31, 2019

https://gist.github.com/rvagg/74bbfcd1ad730fa0060d6a88b3cc7b3d for me, not sure how helpful that is, this is just what brew gives me and I assume everyone else who installs Ansible via brew.

@AshCripps
Copy link
Member

AshCripps commented Oct 31, 2019

This means that Ansible is (wisely) running its own version of Python in a virtualenv

Interesting when I use this python in export PYTHONPATH=$(/usr/local/Cellar/ansible/2.8.5_1/libexec/bin/python3.7 -m pip show pyyaml | grep Location | awk '{print $2}') I no longer get a module not found error or any error about using the wrong directory but instead I now get:

[WARNING]: * Failed to parse /Users/ashleycripps/nodework/build/ansible/plugins/inventory/nodejs_yaml.py with script plugin: Inventory script (/Users/ashleycripps/nodework/build/ansible/plugins/inventory/nodejs_yaml.py) had an execution error: Traceback (most recent call last):
File "/Users/ashleycripps/nodework/build/ansible/plugins/inventory/nodejs_yaml.py", line 33, in import yaml File "/usr/local/Cellar/ansible/2.8.5_1/libexec/lib/python3.7/site-packages/yaml/init.py", line 374 class YAMLObject(metaclass=YAMLObjectMetaclass):
^ SyntaxError: invalid syntax

Which is progress I guess?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants