Issues creating smart proxy in local dev environment


#1

Hi There,

I have local Foreman and a Smart Proxy up and running, and have my smart_proxy_phpipam plugin installed on the Smart Proxy. I’m trying to create a Smart Proxy in the Foreman UI, but get the following error:

Features "phpipam" in this proxy are not recognized by Foreman. If these features come from a Smart Proxy plugin, make sure Foreman has the plugin installed too.

So I tried installing the smart_proxy_phpipam plugin in Foreman as well, but now Foreman won’t start up with the following error:

mac-dev:foreman christopher.smith$ bundle exec foreman start
10:19:01 rails.1   | started with pid 93133
10:19:01 webpack.1 | started with pid 93134
10:19:03 webpack.1 | Project is running at http://localhost:3808/
10:19:03 webpack.1 | webpack output is served from /webpack/
10:19:04 rails.1   | /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/active_support.rb:79:in `block in load_missing_constant': uninitialized constant Proxy::Plugin (NameError)
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/active_support.rb:8:in `without_bootsnap_cache'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/active_support.rb:79:in `rescue in load_missing_constant'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/active_support.rb:58:in `load_missing_constant'
10:19:04 rails.1   | 	from /Users/christopher.smith/Documents/development/opensource/smart_proxy_phpipam/lib/smart_proxy_phpipam/phpipam.rb:5:in `<module:Phpipam>'
10:19:04 rails.1   | 	from /Users/christopher.smith/Documents/development/opensource/smart_proxy_phpipam/lib/smart_proxy_phpipam/phpipam.rb:2:in `<main>'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
10:19:04 rails.1   | 	from /Users/christopher.smith/Documents/development/opensource/smart_proxy_phpipam/lib/smart_proxy_phpipam.rb:3:in `<main>'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:81:in `block (2 levels) in require'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:76:in `each'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:76:in `block in require'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:65:in `each'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/bundler-2.0.1/lib/bundler/runtime.rb:65:in `require'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/bundler-2.0.1/lib/bundler.rb:114:in `require'
10:19:04 rails.1   | 	from /Users/christopher.smith/Documents/development/opensource/foreman/config/application.rb:37:in `<main>'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/railties-5.2.1/lib/rails/commands/server/server_command.rb:145:in `block in perform'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/railties-5.2.1/lib/rails/commands/server/server_command.rb:142:in `tap'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/railties-5.2.1/lib/rails/commands/server/server_command.rb:142:in `perform'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/thor-0.19.4/lib/thor/command.rb:27:in `run'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/thor-0.19.4/lib/thor/invocation.rb:126:in `invoke_command'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/thor-0.19.4/lib/thor.rb:369:in `dispatch'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/railties-5.2.1/lib/rails/command/base.rb:65:in `perform'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/railties-5.2.1/lib/rails/command.rb:46:in `invoke'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/railties-5.2.1/lib/rails/commands.rb:18:in `<main>'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/bootsnap-1.4.3/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
10:19:04 rails.1   | 	from /Users/christopher.smith/Documents/development/opensource/foreman/bin/rails:9:in `<top (required)>'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
10:19:04 rails.1   | 	from /Users/christopher.smith/.rvm/gems/ruby-2.5.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
10:19:04 rails.1   | 	from /Users/christopher.smith/Documents/development/opensource/foreman/bin/spring:13:in `require'
10:19:04 rails.1   | 	from /Users/christopher.smith/Documents/development/opensource/foreman/bin/spring:13:in `<top (required)>'
10:19:04 rails.1   | 	from bin/rails:3:in `load'
10:19:04 rails.1   | 	from bin/rails:3:in `<main>'
10:19:04 rails.1   | exited with code 1
10:19:04 system    | sending SIGTERM to all processes
10:19:09 system    | sending SIGKILL to all processes

I didn’t realize that Smart Proxy plugins had to be installed into Foreman as well. Am I missing a step in this process?


#2

Hi,

You are missing the creation of the plugin for the foreman as you are adding new feature to smart proxy, the foreman counterpart is needed, so foreman would understand how to use this new feature.

I would guess, you can use another features of smart-proxy (like dhcp and dns) instead of making your custom one. So you would just implement a feature, what foreman already understands how to use. But for that others will probably advice you better.


#3

Thanks @ezr-ondrej.

I’m am actually building a new plugin for IPAM integration with the opensource tool phpIPAM, and hope to contribute this back upstream. I just started development on this and am just trying to understand how everything in the Foreman ecosystem works.

Based on my understanding, I need 2 plugins to accomplish this. A Foreman plugin which will add a new IPAM type called “phpIPAM”, and a Smart Proxy plugin which will do the talking to the phpIPAM instance(i.e. get next available IP etc.)

The challenge I’m facing now is how all these things talk to each other.

So just to be clear, I have to install both plugins in Foreman(i.e. the foreman plugin AND smart proxy plugin), and only the smart proxy plugin in the smart proxy?


#4

Yeah, it is correct as far as you need to add another smart-proxy feature.

But take a look at dhcp/dns providers in <smart-proxy>/modules/dhcp_<provider> and <smart-proxy>/modules/dns_<provider>. If you need just the capabilities already provided by dhcp and dns feature, you can have just a plugin for the smart-proxy.

I am not sure, what is that you need to achieve, but it is possible, you would not need to add new feature, rather implement existing one and you would safe the necessity for the foreman plugin.

No, foreman plugin to foreman and smart-proxy plugin to smart-proxy, no mixing please :blush:


#5

Great - thanks for clarifying. I will have a look at those existing providers and go from there.

Thanks for responding.