Foreman 3.4.0 and external phpipam integration

Problem:
Hello,

I’m trying to connect my foreman instance to my phpipam in order to use it as external IPAM, I saw this post about external IPAM being merged into core feature and tried following the official documentation for plugin install but after installing gem file from rubygems.org and adding Gemfile.local.rb and reloading foreman service I have an error (log below).

I’m not sure if I’m doing something wrong or if there is a compatibility issue as I see that the plugin was not much updated since 2 years, may I ask for some help with this setup ?

Expected outcome:

Being able to use phpipam as external IPAM

Foreman and Proxy versions:

Foreman 3.4.0

Foreman and Proxy plugin versions:

phpipam 1.5
smart_proxy_ipam 0.1.4

Distribution and version:

Other relevant data:

systemd[1]: Starting Foreman...
foreman[82903]: /usr/share/gems/gems/bundler-2.2.24/lib/bundler/dsl.rb:266:in `method_missing':  (Bundler::Dsl::DSLError)
foreman[82903]: [!] There was an error parsing `Gemfile.in`: Undefined local variable or method `smart_proxy_ipam' for Gemfile. Bundler c>
foreman[82903]:  #  from /usr/share/foreman/Gemfile.in:62
foreman[82903]:  #  -------------------------------------------
foreman[82903]:  #  Dir["#{File.dirname(FOREMAN_GEMFILE)}/bundler.d/*.rb"].each do |bundle|
foreman[82903]:  >    instance_eval(Bundler.read_file(bundle))
foreman[82903]:  #  end
foreman[82903]:  #  -------------------------------------------
foreman[82903]:         from (eval):1:in `block in eval_gemfile'
foreman[82903]:         from /usr/share/foreman/Gemfile.in:62:in `instance_eval'
foreman[82903]:         from /usr/share/foreman/Gemfile.in:62:in `block in eval_gemfile'
foreman[82903]:         from /usr/share/foreman/Gemfile.in:61:in `each'
foreman[82903]:         from /usr/share/foreman/Gemfile.in:61:in `eval_gemfile'
foreman[82903]:         from /usr/share/gems/gems/bundler-2.2.24/lib/bundler/dsl.rb:47:in `instance_eval'
foreman[82903]:         from /usr/share/gems/gems/bundler-2.2.24/lib/bundler/dsl.rb:47:in `eval_gemfile'
foreman[82903]:         from /usr/share/gems/gems/bundler-2.2.24/lib/bundler/dsl.rb:12:in `evaluate'
foreman[82903]:         from /usr/share/gems/gems/bundler_ext-0.4.1/lib/bundler_ext/gemfile.rb:46:in `parse'
foreman[82903]:         from /usr/share/gems/gems/bundler_ext-0.4.1/lib/bundler_ext.rb:14:in `system_require'
foreman[82903]:         from /usr/share/foreman/config/application.rb:36:in `<top (required)>'
foreman[82903]:         from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:83:in `require'
foreman[82903]:         from /usr/share/gems/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:332:in `block in require'
foreman[82903]:         from /usr/share/gems/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:299:in `load_dependency'
foreman[82903]:         from /usr/share/gems/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:332:in `require'
foreman[82903]:         from /usr/share/gems/gems/railties-6.1.6.1/lib/rails/commands/server/server_command.rb:138:in `block in perform'
foreman[82903]:         from /usr/share/gems/gems/railties-6.1.6.1/lib/rails/commands/server/server_command.rb:135:in `tap'
foreman[82903]:         from /usr/share/gems/gems/railties-6.1.6.1/lib/rails/commands/server/server_command.rb:135:in `perform'
foreman[82903]:         from /usr/share/gems/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
foreman[82903]:         from /usr/share/gems/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
foreman[82903]:         from /usr/share/gems/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
foreman[82903]:         from /usr/share/gems/gems/railties-6.1.6.1/lib/rails/command/base.rb:69:in `perform'
foreman[82903]:         from /usr/share/gems/gems/railties-6.1.6.1/lib/rails/command.rb:48:in `invoke'
foreman[82903]:         from /usr/share/gems/gems/railties-6.1.6.1/lib/rails/commands.rb:18:in `<top (required)>'
foreman[82903]:         from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:158:in `require'
foreman[82903]:         from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:158:in `rescue in require'
foreman[82903]:         from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:147:in `require'
foreman[82903]:         from /usr/share/foreman/bin/rails:9:in `<main>'

It seems the contents of Gemfile.local.rb are wrong.

  1. smart_proxy_ipam is a Proxy plugin, so no need to add it to Foreman (but the readme says so, and I think it’s wrong)
  2. it seems you’ve written gem smart_proxy_ipam and not gem 'smart_proxy_ipam' so Ruby tries to interpret this as code.

I did try without the single quote around so maybe I pick the log with this syntax, but my first try was with the single quotes around and I had this error :

systemd[1]: Failed to start Foreman.
systemd[1]: Starting Foreman...
foreman[87530]: /usr/share/gems/gems/bundler_ext-0.4.1/lib/bundler_ext/output.rb:13:in `strict_err': Gem loading error: cannot load such file -- smart_proxy_ipam (RuntimeError)
foreman[87530]:         from /usr/share/gems/gems/bundler_ext-0.4.1/lib/bundler_ext/runtime.rb:46:in `rescue in block in system_require'
foreman[87530]:         from /usr/share/gems/gems/bundler_ext-0.4.1/lib/bundler_ext/runtime.rb:39:in `block in system_require'
foreman[87530]:         from /usr/share/gems/gems/bundler_ext-0.4.1/lib/bundler_ext/runtime.rb:37:in `each'
foreman[87530]:         from /usr/share/gems/gems/bundler_ext-0.4.1/lib/bundler_ext/runtime.rb:37:in `system_require'
foreman[87530]:         from /usr/share/gems/gems/bundler_ext-0.4.1/lib/bundler_ext.rb:19:in `block in system_require'
foreman[87530]:         from /usr/share/gems/gems/bundler_ext-0.4.1/lib/bundler_ext.rb:14:in `each'
foreman[87530]:         from /usr/share/gems/gems/bundler_ext-0.4.1/lib/bundler_ext.rb:14:in `system_require'
foreman[87530]:         from /usr/share/foreman/config/application.rb:36:in `<top (required)>'
foreman[87530]:         from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:83:in `require'
foreman[87530]:         from /usr/share/gems/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:332:in `block in require'
foreman[87530]:         from /usr/share/gems/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:299:in `load_dependency'
foreman[87530]:         from /usr/share/gems/gems/activesupport-6.1.6.1/lib/active_support/dependencies.rb:332:in `require'
foreman[87530]:         from /usr/share/gems/gems/railties-6.1.6.1/lib/rails/commands/server/server_command.rb:138:in `block in perform'
foreman[87530]:         from /usr/share/gems/gems/railties-6.1.6.1/lib/rails/commands/server/server_command.rb:135:in `tap'
foreman[87530]:         from /usr/share/gems/gems/railties-6.1.6.1/lib/rails/commands/server/server_command.rb:135:in `perform'
foreman[87530]:         from /usr/share/gems/gems/thor-1.2.1/lib/thor/command.rb:27:in `run'
foreman[87530]:         from /usr/share/gems/gems/thor-1.2.1/lib/thor/invocation.rb:127:in `invoke_command'
foreman[87530]:         from /usr/share/gems/gems/thor-1.2.1/lib/thor.rb:392:in `dispatch'
foreman[87530]:         from /usr/share/gems/gems/railties-6.1.6.1/lib/rails/command/base.rb:69:in `perform'
foreman[87530]:         from /usr/share/gems/gems/railties-6.1.6.1/lib/rails/command.rb:48:in `invoke'
foreman[87530]:         from /usr/share/gems/gems/railties-6.1.6.1/lib/rails/commands.rb:18:in `<top (required)>'
foreman[87530]:         from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:158:in `require'
foreman[87530]:         from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:158:in `rescue in require'
foreman[87530]:         from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:147:in `require'
foreman[87530]:         from /usr/share/foreman/bin/rails:9:in `<main>'


Did you install the gem? But in either case, adding it to Foreman is not what you need here.

Yes the gem is installed :

[root@foreman ~]# gem install --ignore-dependencies smart_proxy_ipam
Successfully installed smart_proxy_ipam-0.1.4
Parsing documentation for smart_proxy_ipam-0.1.4
Done installing documentation for smart_proxy_ipam after 0 seconds
1 gem installed

As recommended by the documentation I installed it with ignoring dependencies.

What should be the next steps for a proper install ?

Hello,

I’m still looking for help on this topic, if anyone has clues on how to setup external phpipam integration I would appreciate you sharing it with me.

Best regards,

Hi did you find a solution for getting ipam to work in foreman? If you don’t mind sharing I am interested in step by step details to get this working. Thanks

Hello,

No I did not find a solution, I keep this issue in my backlog but it’s not something critical for me so I did not put too much efforts in getting it working.
I just checked the plugin gitlab and found this issue where people are trying to make it works : Should installation of this plugin work on Foreman 3.3? · Issue #56 · grizzthedj/smart_proxy_ipam · GitHub

Best regards,

Thanks for the info. Yes, I’ve been asking Chris, the guy that owns it but it seem for some reason there are issues trying to get this pulled in. It is not pressing either but would be a nice thing to incorp in Foreman but it is taking forever.
Well, if you do start trying again and get any further along I am interested in the steps. Thanks