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

Evaluation Error: Operator '[]' is not applicable to an Undef Value. #571

Open n1md4 opened 3 years ago

n1md4 commented 3 years ago

Affected Puppet, Ruby, OS and module versions/distributions

How to reproduce (e.g Puppet code you use)

Use example code to test virtualenv pip install

What are you seeing

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Operator '[]' is not applicable to an Undef Value. (file: ... python/manifests/pyvenv.pp, line: 49, column: 12) (file: ... python/manifests/init.pp, line: 95) on node host.domain

What behaviour did you expect instead

For the example to work.

Output log

Any additional information you'd like to impart

python/manifests/pyvenv.pp, line: 49
      case $facts['os']['distro']['codename'] {
python/manifests/init.pp, line: 95
  create_resources('python::pyvenv', $python_pyvenvs)

From the host facter os returns results whereas distro and codename do not.

kenyon commented 3 years ago

Hmm, I seem to remember that if you install the package redhat-lsb-core then those facts are available.

n1md4 commented 3 years ago

Hi Kenyon. It is a CentOS server but the agent is running on Debian.

I checked APT and lsb-base, lsb-compat, and lsb-release are installed.

I did get codename and distro from lsb_release with the following options:

# lsb_release -cs
stretch
# lsb_release -is
Debian

Albeit, that doesn't help the facter results.

n1md4 commented 3 years ago

I exported facter values to test, and still puppet runs fail with the same error:

export FACTER_distro="Debian"
export FACTER_codename="stretch"
# facter codename
stretch
# facter distro
Debian
Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Operator '[]' is not applicable to an Undef Value. (file: .../python/manifests/pyvenv.pp, line: 49, column: 12) (file: .../python/manifests/init.pp, line: 95) on node host.domain
kenyon commented 3 years ago

Well, the os fact is structured, so to test that properly you would do this:

% facter os.distro.codename
buster

That fact should exist.

n1md4 commented 3 years ago

Hmm still that command returns nothing on my setup.

All I want is for the python module to install a module with pip in a target directory within a virtualenv.

I am using the example hiera code:

python::python_pyvenvs:
  "/opt/env1":
    version: "system"
  "/opt/env2":
    version: "system"
python::python_pips:
  "nose":
    virtualenv: "/opt/env1"
  "coverage":
    virtualenv: "/opt/env2"

and I get the error I posted.

alexjfisher commented 3 years ago

Unfortunately, the version of facter shipped as part of Debian 9 is really old (and puppet itself is only version 4.8). Puppet Inc was shipping facter 3 from puppet 4.2 onwards, but in Debian 9 it's only version 2.4.6.

When we dropped support for Puppet 4 in January 2019, we also decided to stop supporting facter 2.

Are you able to install puppet from the puppetlabs apt repositories instead?