voxpupuli / puppet-python

Puppet module for installing and managing Python, pip, virtualenvs and Gunicorn virtual hosts.
https://forge.puppetlabs.com/puppet/python
Apache License 2.0
199 stars 370 forks source link

Add support for FreeBSD #612

Closed smortex closed 3 years ago

smortex commented 3 years ago

Pull Request (PR) description

Make this module usable on FreeBSD.

While here, sort operating system lists in alphabetical order for consistency.

For now, open as a draft so that I can gather early review while I point other modules to this branch and validate it works as expected. When I am confident with this change, I'll update it.

This Pull Request (PR) fixes the following issues

n/a

bastelfreak commented 3 years ago

looks quite good. Let's see what CI says

bastelfreak commented 3 years ago

@smortex do you want to add more here or is it ready for merge?

smortex commented 3 years ago

It is currently not working, but I suspect this is not FreeBSD-related… I am testing with this simple manifest:

class { 'python':
  version => '38',
}

class { 'puppetboard':
}

This apply without error, noting happen on subsequent runs, but the requirements from requirements.txt are not installed. chowning / chmoding the requirements.txt file allows Puppet to trigger the update. I will have access to a convenient machine for testing tomorrow. If the problem is not tied to FreeBSD, I think it is mergeable, otherwise more work is indeed needed.

smortex commented 3 years ago

I confirm the issue: on Linux the behavior is as expected, but on FreeBSD deployment of the requirements does not work.

I have a working workaround: instead of the trick with managing a resource for the requirements.txt file and auditing changes of it's content, use a python script, executed from the virtualenv which tries to load all dependencies listed in requirements.txt as an unless parameter for the pip install exec (The script for checking dependencies).

@bastelfreak do you prefer that we investigate this is a dedicated PR? If so, this can be merged :wink:

smortex commented 3 years ago
Ignore this, irelevant, `audit` was reintroduced after being deprecated Hum, I missed the warning, but it might also help regarding #375 as a side effect :-) Or maybe it _is_ ignored and hence not working :shrug: [edit] probably not, I am running the same Puppet version on Linux with the AIO package.
bastelfreak commented 3 years ago

where exactly is the issue on FreeBSD? In puppetboard, in python::pyvenv? I'm not sure if we should merge this if some (important) features don't work on the desired platform.

smortex commented 3 years ago

I am currently investigating it: when trying to reproduce the issue with a minimal case, it is actually working as expected. I guess it's the way I test that trigger the issue.

Never used audit before and there are some surprises :-D

smortex commented 3 years ago

@bastelfreak just re-tested from scratch and it works as expected… I must have screwed something on my other test machine :unamused:

romain@agrajag ~/Projects % cat > test.pp << EOT
class { 'python':
  version => '38',
}

class { 'puppetboard':
  apache_confd   => '/usr/local/etc/apache24/extra/',
  apache_service => 'apache24',
  python_version => '3.8',
}
EOT
romain@agrajag ~/Projects % git clone https://github.com/voxpupuli/puppet-puppetboard
romain@agrajag ~/Projects/puppet-puppetboard % cd puppet-puppetboard
romain@agrajag ~/Projects/puppet-puppetboard % bundle
romain@agrajag ~/Projects/puppet-puppetboard % bundle exec rake spec_prep
romain@agrajag ~/Projects/puppet-puppetboard % cd spec/fixtures/modules/python
romain@agrajag ~/Projects/puppet-puppetboard/spec/fixtures/modules/python % git remote add smortex https://github.com/smortex/puppet-python
romain@agrajag ~/Projects/puppet-puppetboard/spec/fixtures/modules/python % git fetch smortex
romain@agrajag ~/Projects/puppet-puppetboard/spec/fixtures/modules/python % git checkout freebsd
romain@agrajag ~/Projects/puppet-puppetboard/spec/fixtures/modules/python % cd ../../../..
romain@agrajag ~/Projects/puppet-puppetboard % puppet apply -t ../test.pp --modulepath spec/fixtures/modules
romain@agrajag ~/Projects/puppet-puppetboard % ls /srv/puppetboard/virtenv-puppetboard/lib/python3.8/site-packages
# What is expected \o/

This can be merged, thanks!

bastelfreak commented 3 years ago

thanks! can you maybe add that as an example to the puppetboard module and add freebsd to the metadata.json in that module?

smortex commented 3 years ago

Yeah, it's one of the next move for me, but even more work needed because we do actually do not need the python module to manage puppetboard on FreeBSD because it's as simple as installing a package :wink:.

That being said, this module was ideal for testing these changes quickly ^_^

Thanks!