<?xml version="1.0" encoding="UTF-8" ?>

<bugzilla version="5.2"
          urlbase="https://bugzilla.altlinux.org/"
          
          maintainer="jenya@basealt.ru"
>

    <bug>
          <bug_id>60388</bug_id>
          
          <creation_ts>2026-09-03 19:03:37 +0300</creation_ts>
          <short_desc>Плагины из группы :alt не грузятся</short_desc>
          <delta_ts>2026-09-03 19:03:37 +0300</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>4</classification_id>
          <classification>Development</classification>
          <product>Sisyphus</product>
          <component>foreman</component>
          <version>unstable</version>
          <rep_platform>x86_64</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>NEW</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P5</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Vladislav Glinkin">glinkinvd</reporter>
          <assigned_to name="placeholder@altlinux.org">placeholder</assigned_to>
          <cc>admsasha</cc>
    
    <cc>cas</cc>
    
    <cc>majioa</cc>
    
    <cc>mike</cc>
    
    <cc>nbr</cc>
    
    <cc>pav</cc>
    
    <cc>placeholder</cc>
    
    <cc>rider</cc>
    
    <cc>thatman</cc>
          
          <qa_contact>qa-sisyphus</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>295024</commentid>
    <comment_count>0</comment_count>
    <who name="Vladislav Glinkin">glinkinvd</who>
    <bug_when>2026-09-03 19:03:37 +0300</bug_when>
    <thetext>Версия пакета: `foreman-3.19.1-alt1`

---

https://git.altlinux.org/gitoskop/#/gears/f/foreman.git/-/blob/sisyphus/.gear/alt.patch
У нас имеется патч, который формирует группу плагинов `alt` для Foreman.

Текущая схема упаковки плагинов имеет недостатки:
1. Для группы `alt` не выполняется `Bundler.require`. В текущей конфигурации дополнительно загружаются только группы:
```
/usr/lib/foreman/config/application.rb:
	optional_bundler_groups = %w[assets ec2 fog libvirt openstack vmware redis]
```

При этом Bundler саму группу видит:

```
cd /var/lib/foreman

bundle exec ruby -rbundler -e &apos;
Bundler.definition.dependencies
  .select { |d| d.name == &quot;foreman_puppet&quot; }
  .each { |d| puts &quot;name=#{d.name} groups=#{d.groups.inspect}&quot; }
&apos;
```

Результат:
```
name=foreman_puppet groups=[:alt]
```

Но Foreman плагин не загружает:
```
RAILS_ENV=production bundle exec ruby -e &apos;
require &quot;./config/environment&quot;
puts &quot;ForemanPuppet::Engine=#{defined?(ForemanPuppet::Engine).inspect}&quot;
&apos;
```

Результат:
```
ForemanPuppet::Engine=nil
```

Также:
```
RAILS_ENV=production bundle exec rake plugin:list
```

не показывает `foreman_puppet`.
Из-за этого возникают проблемы в работе функциональности, предоставляемой плагинами.

2. Добавить в `optional_bundler_groups` группу `alt` — идея плохая, поскольку `Bundler.require(:alt)` начнёт загружать все gems этой группы (если не задан `require: false`). Ошибка при загрузке или инициализации одного из плагинов может привести к падению Foreman, как сейчас в Sisyphus:

```
foreman[3558]: =&gt; Booting Puma
foreman[3558]: =&gt; Rails 7.1.5.1 application starting in production
foreman[3558]: =&gt; Run `bin/rails server --help` for more startup options
foreman[3558]: /usr/lib/ruby/gemie/gems/foreman_discovery-24.0.2/lib/foreman_discovery/engine.rb:300: warning: already initialized constant ForemanDiscovery::Engine::MANAGER
foreman[3558]: /usr/lib/ruby/gemie/gems/foreman_discovery-24.0.2/lib/foreman_discovery/engine.rb:269: warning: previous definition of MANAGER was here
foreman[3558]: Exiting
foreman[3558]: /usr/lib/ruby/gemie/gems/foreman_discovery-24.0.2/lib/foreman_discovery/engine.rb:319:in `block (2 levels) in &lt;class:Engine&gt;&apos;: uninitialized constant ForemanDiscovery::Engine::Subnet (NameError)
foreman[3558]:         parameter_filter Subnet, :discovery_id
foreman[3558]:                          ^^^^^^
foreman[3558]:         from /usr/lib/foreman/app/registries/foreman/plugin.rb:93:in `instance_eval&apos;
foreman[3558]:         from /usr/lib/foreman/app/registries/foreman/plugin.rb:93:in `register&apos;
```

3. Ограничивается гибкость пользователя. Вместе с `foreman` устанавливаются плагины, которые могут быть в принципе не нужны пользователю.

---

Как предлагается делать:
https://theforeman.org/plugins/#2.3AdvancedInstallationfromGems

Текущую группу плагинов из `alt.patch` убираем. В пакет каждого плагина кладём `bundler.d/foreman_sample_plugin.rb` с содержимым:

```
gem &apos;foreman_sample_plugin&apos;
```

Файл прописываем в `%files` SRPM пакета плагина.

Таким образом, плагин будет подключаться или отключаться в зависимости от наличия соответствующего RPM-пакета.

Практический пример для `gem-foreman-puppet`:
```
# cat /var/lib/foreman/bundler.d/foreman_puppet.rb
gem &apos;foreman_puppet&apos;
```

Для работы по такому принципу необходимо сохранять в runtime механизм загрузки `bundler.d`.

В upstream `Gemfile` для этого имеется секция:
```
Dir[&quot;#{File.dirname(FOREMAN_GEMFILE)}/bundler.d/*.rb&quot;].each do |bundle|
  instance_eval(Bundler.read_file(bundle))
end
```

Сейчас при сборке ALT через `setup-rb` исходный `Gemfile` обрабатывается и в установленный пакет попадает уже сгенерированный вариант без этой секции.

Можно либо сохранить возможность обработки исходного `bundler.d/*.rb`, либо выделить для runtime-плагинов отдельную директорию `bundler.d/plugins/*.rb` и загружать её, например:
```
# ALT runtime Foreman plugin fragments
Dir[&quot;#{File.dirname(FOREMAN_GEMFILE)}/bundler.d/plugins/*.rb&quot;].sort.each do |bundle|
  instance_eval(Bundler.read_file(bundle))
end
```

Тогда каждый RPM-пакет плагина сможет самостоятельно добавлять и удалять свою декларацию, не требуя общей группы `alt`.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>