Foreman in docker with salt plugins

Hello Everyone! I’m a newbie in Foreman and trying to use Foreman for managing salt minions.
I run salt master in docker container and I’d like running Foreman in K8s too (from this repo

So, I tried multiple approaches to build this Foreman image:

  1. Rebuild image adfter adding foreman_salt and foreman_smart_proxy_salt to Gemfile
    I’ve error like constant Proxy is not associated. Found related issue on the forum which recommended to install plugins only with rpm or even with foreman-installer.
  2. I’m not sure if it is correct, I tried to build test image based on centos:7.8.2003 and installed all necessary rpms. AS CMD in this Dockerfile I added:
    CMD foreman-installer --enable-foreman-plugin-salt --enable-foreman-proxy-plugin-salt
    Note: I didn’t manage to add RUN foreman-installer --enable-foreman-plugin-salt --enable-foreman-proxy-plugin-salt as separate layer due to hostname conflicts.
    But running foreman-installer is too long operation amd it is inconvenient to use it as entrypoint in docker container.

Expected outcome:
Could you please advice what is recommended way to build foreman with salt plugins in docker?

And If I understand correctly I need install foreman_salt and foreman_smart_proxy_salt in container with Foreman and foreman_smart_proxy_salt in container with Salt master?

Thank you in advance!
And have a good day!

Foreman and Proxy versions:
Tested with 1.24 too

did you see you would need to rebuild the image with the gemfile for the plugin.

regarding the proxy, sadly i didn’t build the smart proxy image yet, but probably your approach with the installer would work (as a second container image vs bundling it into one larger image).

there is multiple prior art doing that exactly, my first hit on google seems close

Thank you Ohad for advice!

Yes, adding ruby packages sounds amazing!
and I’d like to follow this way

But building docker image with gem smart_proxy_salt I got this error on step 25
( rake aborted!NameError: uninitialized constant Proxy::Log ) :

Step 25/47 : RUN   make -C locale all-mo &&   mv -v db/schema.rb.nulldb db/schema.rb &&   bundle exec rake assets:clean assets:precompile apipie:cache:index
 ---> Running in 3bcec9220684
make: Entering directory '/home/foreman/locale'
mkdir -p sv_SE/LC_MESSAGES
msgfmt -o sv_SE/LC_MESSAGES/ sv_SE/foreman.po
mkdir -p cs_CZ/LC_MESSAGES
msgfmt -o cs_CZ/LC_MESSAGES/ cs_CZ/foreman.po
mkdir -p pt_BR/LC_MESSAGES
msgfmt -o pt_BR/LC_MESSAGES/ pt_BR/foreman.po
mkdir -p zh_TW/LC_MESSAGES
msgfmt -o zh_TW/LC_MESSAGES/ zh_TW/foreman.po
mkdir -p de/LC_MESSAGES
msgfmt -o de/LC_MESSAGES/ de/foreman.po
mkdir -p es/LC_MESSAGES
msgfmt -o es/LC_MESSAGES/ es/foreman.po
mkdir -p nl_NL/LC_MESSAGES
msgfmt -o nl_NL/LC_MESSAGES/ nl_NL/foreman.po
mkdir -p pl/LC_MESSAGES
msgfmt -o pl/LC_MESSAGES/ pl/foreman.po
mkdir -p ca/LC_MESSAGES
msgfmt -o ca/LC_MESSAGES/ ca/foreman.po
mkdir -p ru/LC_MESSAGES
msgfmt -o ru/LC_MESSAGES/ ru/foreman.po
mkdir -p ja/LC_MESSAGES
msgfmt -o ja/LC_MESSAGES/ ja/foreman.po
mkdir -p en_GB/LC_MESSAGES
msgfmt -o en_GB/LC_MESSAGES/ en_GB/foreman.po
mkdir -p fr/LC_MESSAGES
msgfmt -o fr/LC_MESSAGES/ fr/foreman.po
mkdir -p gl/LC_MESSAGES
msgfmt -o gl/LC_MESSAGES/ gl/foreman.po
mkdir -p zh_CN/LC_MESSAGES
msgfmt -o zh_CN/LC_MESSAGES/ zh_CN/foreman.po
mkdir -p ko/LC_MESSAGES
msgfmt -o ko/LC_MESSAGES/ ko/foreman.po
mkdir -p it/LC_MESSAGES
msgfmt -o it/LC_MESSAGES/ it/foreman.po
mkdir -p en/LC_MESSAGES
msgfmt -o en/LC_MESSAGES/ en/foreman.po
make: Leaving directory '/home/foreman/locale'
renamed 'db/schema.rb.nulldb' -> 'db/schema.rb'
rake aborted!
NameError: uninitialized constant Proxy::Log
/home/foreman/vendor/ruby/2.6.0/gems/smart_proxy_salt-3.1.1/lib/smart_proxy_salt/cli.rb:9:in `<module:CLI>'
/home/foreman/vendor/ruby/2.6.0/gems/smart_proxy_salt-3.1.1/lib/smart_proxy_salt/cli.rb:8:in `<module:Salt>'
/home/foreman/vendor/ruby/2.6.0/gems/smart_proxy_salt-3.1.1/lib/smart_proxy_salt/cli.rb:6:in `<module:Proxy>'
/home/foreman/vendor/ruby/2.6.0/gems/smart_proxy_salt-3.1.1/lib/smart_proxy_salt/cli.rb:5:in `<top (required)>'
/home/foreman/vendor/ruby/2.6.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
/home/foreman/vendor/ruby/2.6.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
/home/foreman/vendor/ruby/2.6.0/gems/smart_proxy_salt-3.1.1/lib/smart_proxy_salt/salt.rb:3:in `<top (required)>'
/home/foreman/vendor/ruby/2.6.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
/home/foreman/vendor/ruby/2.6.0/gems/polyglot-0.3.5/lib/polyglot.rb:65:in `require'
/home/foreman/vendor/ruby/2.6.0/gems/smart_proxy_salt-3.1.1/lib/smart_proxy_salt.rb:4:in `<top (required)>'
/usr/share/gems/gems/bundler-1.17.2/lib/bundler/runtime.rb:81:in `require'
/usr/share/gems/gems/bundler-1.17.2/lib/bundler/runtime.rb:81:in `block (2 levels) in require'
/usr/share/gems/gems/bundler-1.17.2/lib/bundler/runtime.rb:76:in `each'
/usr/share/gems/gems/bundler-1.17.2/lib/bundler/runtime.rb:76:in `block in require'
/usr/share/gems/gems/bundler-1.17.2/lib/bundler/runtime.rb:65:in `each'
/usr/share/gems/gems/bundler-1.17.2/lib/bundler/runtime.rb:65:in `require'
/usr/share/gems/gems/bundler-1.17.2/lib/bundler.rb:114:in `require'
/home/foreman/config/application.rb:37:in `<top (required)>'
/home/foreman/Rakefile:1:in `require'
/home/foreman/Rakefile:1:in `<top (required)>'
/home/foreman/vendor/ruby/2.6.0/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
/usr/share/gems/gems/bundler-1.17.2/lib/bundler/cli/exec.rb:74:in `load'
/usr/share/gems/gems/bundler-1.17.2/lib/bundler/cli/exec.rb:74:in `kernel_load'
/usr/share/gems/gems/bundler-1.17.2/lib/bundler/cli/exec.rb:28:in `run'
/usr/share/gems/gems/bundler-1.17.2/lib/bundler/cli.rb:463:in `exec'
/usr/share/gems/gems/bundler-1.17.2/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
/usr/share/gems/gems/bundler-1.17.2/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
/usr/share/gems/gems/bundler-1.17.2/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
/usr/share/gems/gems/bundler-1.17.2/lib/bundler/cli.rb:27:in `dispatch'
/usr/share/gems/gems/bundler-1.17.2/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
/usr/share/gems/gems/bundler-1.17.2/lib/bundler/cli.rb:18:in `start'
/usr/share/gems/gems/bundler-1.17.2/exe/bundle:30:in `block in <top (required)>'
/usr/share/gems/gems/bundler-1.17.2/lib/bundler/friendly_errors.rb:124:in `with_friendly_errors'
/usr/share/gems/gems/bundler-1.17.2/exe/bundle:22:in `<top (required)>'
/usr/bin/bundle:23:in `load'
/usr/bin/bundle:23:in `<main>'
(See full trace by running task with --trace)
The command '/bin/sh -c make -C locale all-mo &&   mv -v db/schema.rb.nulldb db/schema.rb &&   bundle exec rake assets:clean assets:precompile apipie:cache:index' returned a non-zero code: 1

Will try to troubleshoot it

hmm… this might be a bug in the salt plugin? normally foreman code does
not depend on the proxy code at all and just make api calls to it… why
do we need the proxy gem file? or perhaps you are mixing things up? I would
expect that:

  1. you have a checkout copy of foreman repo, and you add a gemfile with the
    foreman salt plugin and build that container.
  2. you have a smart proxy checkout with the smart proxy salt plugin and you
    build another container based on that…

I might misunderstood (as you didnt paste your changes) but you might tried
to take the smart proxy plugin and add it as a foreman plugin?

I really mixed things up

For now, I successfully built foreman with foreman_salt plugin. I see that some Salt options became available from Foreman UI

and I’m adding to salt-master alpine image: ruby dependencies, smart-proxy and smart_proxy_salt and its configuration

Thank you for your help!

awesome! have fun:-)

Thank you very much.
If you have some improvements for the documentation it would be great that you open a PR on

Thank you very much.

yes, it makes sense
so, for now I’m figuring out with integration processes and I can share when I succeed :slight_smile:

1 Like

How did you resolve your issue?