Foreman 3.9 + Katello - Installation failing due to Jinja2

Problem:
I followed step-by-step documentation for installing Foreman+Katello on CentOS Stream 8 and RHEL 8, and in both cases, the installation process failed with the following error:

2024-01-30 11:34:38 [ERROR ] [configure] /Stage[main]/Pulpcore::Static/Pulpcore::Admin[collectstatic --noinput]/Exec[pulpcore-manager collectstatic --noinput]: Failed to call refresh: 'pulpcore-manager collectstatic --noinput' returned 1 instead of one of [0]
2024-01-30 11:34:38 [ERROR ] [configure] /Stage[main]/Pulpcore::Static/Pulpcore::Admin[collectstatic --noinput]/Exec[pulpcore-manager collectstatic --noinput]: 'pulpcore-manager collectstatic --noinput' returned 1 instead of one of [0]
2024-01-30 11:35:20 [NOTICE] [configure] 750 configuration steps out of 1425 steps complete.
2024-01-30 11:35:25 [NOTICE] [configure] 1000 configuration steps out of 1450 steps complete.
2024-01-30 11:37:10 [NOTICE] [configure] 1250 configuration steps out of 1450 steps complete.
2024-01-30 11:37:18 [ERROR ] [configure] 'pulpcore-manager migrate --noinput' returned 1 instead of one of [0]
2024-01-30 11:37:18 [ERROR ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]/returns: change from 'notrun' to ['0'] failed: 'pulpcore-manager migrate --noinput' returned 1 instead of one of [0]
2024-01-30 11:37:18 [ERROR ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]: Failed to call refresh: 'pulpcore-manager migrate --noinput' returned 1 instead of one of [0]
2024-01-30 11:37:18 [ERROR ] [configure] /Stage[main]/Pulpcore::Database/Pulpcore::Admin[migrate --noinput]/Exec[pulpcore-manager migrate --noinput]: 'pulpcore-manager migrate --noinput' returned 1 instead of one of [0]
2024-01-30 11:38:01 [NOTICE] [configure] System configuration has finished.

Error 1: Puppet Exec resource 'pulpcore-manager collectstatic --noinput' failed. Logs:
  /Stage[main]/Pulpcore::Static/Pulpcore::Admin[collectstatic --noinput]/Exec[pulpcore-manager collectstatic --noinput]
    Adding autorequire relationship with File[/var/lib/pulp]
    Adding autorequire relationship with User[pulp]
    Starting to evaluate the resource (710 of 1425)
    'pulpcore-manager collectstatic --noinput' won't be executed because of failed check 'refreshonly'
    Failed to call refresh: 'pulpcore-manager collectstatic --noinput' returned 1 instead of one of [0]
    'pulpcore-manager collectstatic --noinput' returned 1 instead of one of [0]
    Evaluated in 0.30 seconds
  Exec[pulpcore-manager collectstatic --noinput](provider=posix)
    Executing 'pulpcore-manager collectstatic --noinput'
  /Stage[main]/Pulpcore::Static/Pulpcore::Admin[collectstatic --noinput]/Exec[pulpcore-manager collectstatic --noinput]/returns
    Traceback (most recent call last):
      File "/usr/lib/python3.11/site-packages/pkg_resources/__init__.py", line 581, in _build_master
        ws.require(__requires__)
      File "/usr/lib/python3.11/site-packages/pkg_resources/__init__.py", line 909, in require
        needed = self.resolve(parse_requirements(requirements))
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.11/site-packages/pkg_resources/__init__.py", line 800, in resolve
        raise VersionConflict(dist, req).with_context(dependent_req)
    pkg_resources.ContextualVersionConflict: (Jinja2 3.1.3 (/usr/lib/python3.11/site-packages), Requirement.parse('jinja2<=3.1.2,>=3.1'), {'pulpcore'})
        During handling of the above exception, another exception occurred:
        Traceback (most recent call last):
      File "/usr/bin/pulpcore-manager", line 33, in <module>
        sys.exit(load_entry_point('pulpcore==3.39.4', 'console_scripts', 'pulpcore-manager')())
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.11/site-packages/pulpcore/app/manage.py", line 11, in manage
        execute_from_command_line(sys.argv)
      File "/usr/lib/python3.11/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
        utility.execute()
      File "/usr/lib/python3.11/site-packages/django/core/management/__init__.py", line 382, in execute
        settings.INSTALLED_APPS
      File "/usr/lib/python3.11/site-packages/django/conf/__init__.py", line 102, in __getattr__
        self._setup(name)
      File "/usr/lib/python3.11/site-packages/django/conf/__init__.py", line 89, in _setup
        self._wrapped = Settings(settings_module)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.11/site-packages/django/conf/__init__.py", line 217, in __init__
        mod = importlib.import_module(self.SETTINGS_MODULE)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib64/python3.11/importlib/__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
      File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
      File "<frozen importlib._bootstrap>", line 1147, in _find_and_load_unlocked
      File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
      File "<frozen importlib._bootstrap_external>", line 940, in exec_module
      File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
      File "/usr/lib/python3.11/site-packages/pulpcore/app/settings.py", line 17, in <module>
        from pkg_resources import iter_entry_points
      File "/usr/lib/python3.11/site-packages/pkg_resources/__init__.py", line 3259, in <module>
        @_call_aside
         ^^^^^^^^^^^
      File "/usr/lib/python3.11/site-packages/pkg_resources/__init__.py", line 3234, in _call_aside
        f(*args, **kwargs)
      File "/usr/lib/python3.11/site-packages/pkg_resources/__init__.py", line 3272, in _initialize_master_working_set
        working_set = WorkingSet._build_master()
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.11/site-packages/pkg_resources/__init__.py", line 583, in _build_master
        return cls._build_from_requirements(__requires__)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.11/site-packages/pkg_resources/__init__.py", line 596, in _build_from_requirements
        dists = ws.resolve(reqs, Environment())
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/usr/lib/python3.11/site-packages/pkg_resources/__init__.py", line 795, in resolve
        raise DistributionNotFound(req, requirers)
    pkg_resources.DistributionNotFound: The 'jinja2<=3.1.2,>=3.1' distribution was not found and is required by pulpcore

How to reproduce:

  • Spin up fresh machine (stream8 or rhel8)
  • Follow instructions in the docs
  • Run foreman-installer --scenario katello

Foreman and Proxy versions:
Foreman 3.9

Distribution and version:

  • CentOS stream 8
  • RHEL 8

Other relevant data:
I used Vagrant with libvirt to spin up the VMS, with these boxes:

  • generic/centos8s
  • generic/rhel8

There is also a topic about upgrading the Foreman with the same error, but in my case I’ve been trying to make it work on the fresh instances, following exactly what docs say.

Do you have EPEL enabled by any chance? I also raised it in pulpcore-3.22-rpm-pipeline 392 failed.

1 Like

Yes, the generic boxes come with EPEL enabled by default. So it would be required to disable the repository first, what of course is not part of the documentation.

2 Likes

Confirming that disabling EPEL repos (or excludepkgs=jinja2) works and fixed the problem.

Thanks @ekohl @Dirk

Ohai,

We fixed this problem yesterday on rpm/develop here is the cherrypick for 3.39 Cherrypick Jinja2 bump to Pulp 3.39 by Odilhao · Pull Request #871 · theforeman/pulpcore-packaging · GitHub

1 Like

Both packages are published
https://yum.theforeman.org/pulpcore/3.39/el8/x86_64/python3.11-jinja2-3.1.3-1.el8.noarch.rpm

and

https://yum.theforeman.org/pulpcore/3.39/el8/x86_64/python3.11-pulpcore-3.39.8-1.el8.noarch.rpm

2 Likes