puppet-python icon indicating copy to clipboard operation
puppet-python copied to clipboard

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

Open n1md4 opened this issue 5 years ago • 6 comments

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 6.17.0
  • Ruby: 2.5.5
  • Distribution: centos
  • Module version:4.1.1

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.

n1md4 avatar Sep 25 '20 14:09 n1md4

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

kenyon avatar Sep 25 '20 19:09 kenyon

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 avatar Sep 28 '20 09:09 n1md4

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

n1md4 avatar Sep 28 '20 09:09 n1md4

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

% facter os.distro.codename
buster

That fact should exist.

kenyon avatar Sep 29 '20 06:09 kenyon

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.

n1md4 avatar Sep 29 '20 10:09 n1md4

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?

alexjfisher avatar Sep 29 '20 17:09 alexjfisher