Roots Discourse

Ansible on OS X requires python passlib module to create user password hashes

Ansible on OS X requires python passlib module to create user password hashes

sudo easy_install pip
pip install passlib

Have done as it’s suggested and still can’t provision…

###EDIT###
If you install Ansible through Homebrew, you may find yourself needing these commands…

mkdir -p ~/Library/Python/2.7/lib/python/site-packages
echo '/usr/local/lib/python2.7/site-packages' > ~/Library/Python/2.7/lib/python/site-packages/homebrew.pth
1 Like

You’re just missing the ‘–user’ switch.

sudo easy_install pip
pip install --user passlib
1 Like

Hi

I am having this same issue when attempting to provision my staging env.

TASK [common : Check whether passlib is needed] *********************************************
System info:
  Ansible 2.9.8; Darwin
  Trellis version (per changelog): "Fix #1284 - Update logrotate postrotate Nginx command"
---------------------------------------------------
Ansible on OS X requires python passlib module to create user password hashes

sudo easy_install pip
pip install passlib
fatal: [staging.project.com]: FAILED! => {"changed": false}

NO MORE HOSTS LEFT **************************************************************************

PLAY RECAP **********************************************************************************
localhost                  : ok=0    changed=0    unreachable=0    failed=0    skipped=1    rescued=0    ignored=0   
staging.project.com   : ok=7    changed=0    unreachable=0    failed=1    skipped=11   rescued=0    ignored=0   

exit status 2

When I run pip install passlib
I get this:

➜  trellis git:(staging) pip install passlib
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: passlib in /Users/joshb/Library/Python/2.7/lib/python/site-packages (1.7.4)
➜  trellis git:(staging)

I’m not exactly sure what to do here, can anyone point me in the right direction?

Still looking for some help with this… can someone please help me?

I went ahead and started a new trellis instance locally for multi-site with subdomains and was able to get that up and running successfully.

The issue when attempting to provision my new staging environment remains the same and I can’t determine the reason behind this.

Really hope someone can assist.

Here’s the error I receive one last time:

TASK [common : Check whether passlib is needed] ****************************************************
System info:
  Ansible 2.9.8; Darwin
  Trellis 1.9.0: October 27th, 2021
---------------------------------------------------
Ansible on OS X requires python passlib module to create user password hashes

sudo easy_install pip
pip install passlib
fatal: [staged.project.com]: FAILED! => {"changed": false}

When I run:

sudo easy_install pip
pip install passlib

I receive:

DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Requirement already satisfied: passlib in /Users/joshb/Library/Python/2.7/lib/python/site-packages (1.7.4)

DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020.

Seems like it wants you to update Python. Have you tried that?

Yeah, I ran:

brew install python@3.7

Output:

==> Caveats
Python has been installed as
  /usr/local/opt/python@3.7/bin/python3

Unversioned symlinks `python`, `python-config`, `pip` etc. pointing to
`python3`, `python3-config`, `pip3` etc., respectively, have been installed into
  /usr/local/opt/python@3.7/libexec/bin

You can install Python packages with
  /usr/local/opt/python@3.7/bin/pip3 install <package>
They will install into the site-package directory
  /usr/local/lib/python3.7/site-packages

See: https://docs.brew.sh/Homebrew-and-Python

python@3.7 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

If you need to have python@3.7 first in your PATH, run:
  echo 'export PATH="/usr/local/opt/python@3.7/bin:$PATH"' >> ~/.zshrc

For compilers to find python@3.7 you may need to set:
  export LDFLAGS="-L/usr/local/opt/python@3.7/lib"

==> Summary
🍺  /usr/local/Cellar/python@3.7/3.7.12_1: 4,526 files, 70.9MB

python --version in my terminal then returns:

Python 2.7.16

MacOS :put_litter_in_its_place:

The “system version” of Python isn’t replaced by Brew’s version (as it mentions in the install output). You’ll need to convince MacOS to use Python 3 instead of the version it ships with (or potentially use pipenv).

1 Like

Thanks! I will give it a try later.
I don’t understand why this is an issue so suddenly.

Alright, so I have that installed and I am in the pipenv shell.

Checking the Python version I get this:

((trellis) ) ➜  trellis git:(staging) ✗ python --version                          
Python 3.9.7

Then I attempt to provision and I still get this:

TASK [common : Check whether passlib is needed] ******
System info:
  Ansible 2.9.8; Darwin
  Trellis version (per changelog): "Fix #1284 - Update logrotate postrotate Nginx command"
---------------------------------------------------
Ansible on OS X requires python passlib module to create user password hashes

sudo easy_install pip
pip install passlib
fatal: [staging.project.com]: FAILED! => {"changed": false}

From here I attempt to install pip and passlib from the pipenv, provision again and still get the same error.

If I remove the following lines from /roles/common/tasks/main.yml, then of course it continues on:

- name: Check whether passlib is needed
  fail:
    msg: |
      Ansible on OS X requires python passlib module to create user password hashes

      sudo easy_install pip
      pip install passlib
  when: env != 'development' and darwin_without_passlib | default(false)
  run_once: true

Then it fails here:

TASK [common : Retrieve SSH client IP] 
***
System info:
  Ansible 2.9.8; Darwin
  Trellis version (per changelog): "Fix #1284 - Update logrotate postrotate Nginx command"
---------------------------------------------------
No valid or no response from url https://api.ipify.org/ within 10 seconds
(timeout)
fatal: [staging.project.com -> localhost]: FAILED! => {"changed": false}

TASK [common : Fail when unable to retrieve SSH client IP] 
***
System info:
  Ansible 2.9.8; Darwin
  Trellis version (per changelog): "Fix #1284 - Update logrotate postrotate Nginx command"
---------------------------------------------------
External IP resolution failed. Check that your DNS servers are working. Try
to disable DNSCrypt if you are using it.
fatal: [staging.project.com]: FAILED! => {"changed": false}

I’m locking this topic since you’re now posting about unrelated issues, but please open another topic if you are still having trouble. Make sure to make separate topics for separate issues.

The response from @benspants is still valid, and since some folks reading this don’t have access to Roots Slack, here’s what I said over there regarding this:

it looks like even though your system python’s version is on 3, your pip setup is using python 2. you could try setting up pyenv properly to get around it