Closed Neurozone closed 4 years ago
I don't have a Gemfile.local.rb file
Installing just the plugins themselves will not be enough to get this integration to work. There are also code changes required on the Foreman side that are required. Until this patch is merged into a Foreman release, the only way to use this plugin(at least right now) will be to do the following. I have not yet started on the necessary PR's for adding these plugins to foreman-installer and puppet plugins etc.
NOTE: I would highly recommend doing this in a non-production system first to ensure that there are no issues! I have not tested these steps myself on a live environment.
feature/ipam_integration
branch from my fork of Foreman core(Your Foreman server will need to be running this branch). foreman_ipam
plugin: Run gem install foreman_ipam
from the /usr/share/foreman
directory on your Foreman server.rails db:migrate
from the /usr/share/foreman
directory on your Foreman server. rails db:seed
from the /usr/share/foreman
directory on your Foreman server.Gemfile.local.rb
in the /usr/share/foreman/bundler.d
directory with the following contents:
gem 'foreman_ipam'
/etc/foreman-proxy/settings.d/external_ipam.yml
. An example config is heresmart_proxy_ipam
plugin: Run gem install smart_proxy_ipam
from /usr/share/foreman-proxy
directory on your Foreman Proxy server).Gemfile.local.rb
in the /usr/share/foreman-proxy/bundler.d
directory with the following contents:
gem 'smart_proxy_ipam'
Navigate to Infrastructure -> IPAM Dashboard in your Foreman UI. If you see phpIPAM sections being loaded on the page, then the whole integration should be working.
Ive got the connection working but getting "A Smart Proxy with an External IPAM feature enabled must be selected in the Proxies tab." when I try and assign it to a subnet It appears in Proxies drop down and in proxy config not sure where to look from here
@stephenbcollier: Are you certain that your proxy has the externalipam
feature enabled? You can test this by hitting http://<PROXY_URL>/features
. externalipam
should be returned in the response.
Yes that returns as part of the features string if I just do the call with features. I'll try the url you suggested when I get into work.
On Fri, 7 Feb. 2020, 1:24 am Chris Smith, notifications@github.com wrote:
@stephenbcollier https://github.com/stephenbcollier: Are you certain that your proxy has the externalipam feature enabled? You can test this by hitting http://
/features. externalipam should be returned in the response. — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/grizzthedj/smart_proxy_ipam/issues/20?email_source=notifications&email_token=AC4B4374KIHAYLHKUODTDRLRBQMTJA5CNFSM4JDOVYVKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEK7MTAY#issuecomment-582928771, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC4B434RLA7TFW5XKFTW5Z3RBQMTJANCNFSM4JDOVYVA .
It returned ["dhcp","dns","externalipam","httpboot","logs","pulp","puppet","puppetca","templates","tftp"] which has the expected string
We also get a spinning top on External IPAM which may be related
I suspect what is happening is that Foreman doesn't know about the External IPAM feature. You can verify this by running bundle exec rails console
from the root of the Foreman directory on the server where Foreman is installed(not the proxy).
RAILS_ENV=<YOUR_RAILS_ENV> bundle exec rails console
Once in the console, then run Feature.where(name: "External IPAM")
. You should see one record returned. If you do not, then you need to seed the database with RAILS_ENV=<YOUR_RAILS_ENV> bundle exec rails db:seed
.
If you think seeding the database is too risky, you can add the feature manually with:
Feature.create(name: "External IPAM", created_at: Time.now, updated_at: Time.now).save!
I'm getting -bash-4.2$ RAILS_ENV=/usr/share/foreman bundle exec rails Could not locate Gemfile
looks like an issue with bundle
My apologies - try this.
From the /usr/share/foreman
directory, run foreman-rake console
And prefix with RAILS_ENV=production
or whatever your rails environment is
I reseeded it originally but with foreman-rake as seems to be required
Having trouble reproducing this. Perhaps try restarting the foreman
service and the web server?
foreman-maintain service restart has been run several times which restarts everything as far as I'm aware
I'll have a close look at the code and make sure no differences to your source, THanks so much for your help it must be early evening in Canada
No worries - Glad to help. Have a few things to take care of, but I will continue to try to reproduce on my end.
Another possibility is that the feature is not associated with the smart proxy in the database. In the rails console, find the ID of your IPAM smart proxy with SmartProxy.all
, and the ID of the externalipam
feature with Feature.all
, then see if the association exists in SmartProxyFeatures with SmartProxyFeature.all
.
If the association doesn't exist, then it needs to be added .. Assuming your IPAM Smart Proxy ID is: 6, and your externalipam Feature is: 2, then you would ...
SmartProxyFeature.create(smart_proxy_id: 6, feature_id: 2, capabilities: [], settings: {}).save!
I remember adding this manually way back when, but this should actually be done in the seeds. I will update the docs and seeds file when I get a chance.
That would explain a lot. thanks. I'll give it a try later this morning and let you know.
On Sat, 8 Feb. 2020, 6:23 am Chris Smith, notifications@github.com wrote:
Another possibility is that the feature is not associated with the smart proxy in the database. In the rails console, find the ID of your IPAM smart proxy with SmartProxy.all, and the ID of the externalipam feature with Feature.all, then see if the association exists in SmartProxyFeatures with SmartProxyFeature.all.
If the association doesn't exist, then it needs to be added .. Assuming your IPAM Smart Proxy ID is: 6, and your externalipam Feature is: 2, then you would ...
SmartProxyFeature.create(smart_proxy_id: 6, feature_id: 2, capabilities: [], settings: {}).save!
I remember adding this manually way back when, but this should actually be done in the seeds. I will update the docs and seeds file when I get a chance.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/grizzthedj/smart_proxy_ipam/issues/20?email_source=notifications&email_token=AC4B4357LHN2BPIBFHZRIOLRBWYKRA5CNFSM4JDOVYVKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELEH2FQ#issuecomment-583564566, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC4B437HGUW7RI75ALMZJMDRBWYKRANCNFSM4JDOVYVA .
On 8/02/2020 6:23 am, Chris Smith wrote:
Another possibility is that the feature is not associated with the smart proxy in the database. In the rails console, find the ID of your IPAM smart proxy with |SmartProxy.all|, and the ID of the |externalipam| feature with |Feature.all|, then see if the association exists in SmartProxyFeatures with |SmartProxyFeature.all|.
If the association doesn't exist, then it needs to be added .. Assuming your IPAM Smart Proxy ID is: 6, and your externalipam Feature is: 2, then you would ...
|SmartProxyFeature.create(smart_proxy_id: 6, feature_id: 2, capabilities: [], settings: {}).save! |
I remember adding this manually way back when, but this should actually be done in the seeds. I will update the docs and seeds file when I get a chance.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/grizzthedj/smart_proxy_ipam/issues/20?email_source=notifications&email_token=AC4B4357LHN2BPIBFHZRIOLRBWYKRA5CNFSM4JDOVYVKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELEH2FQ#issuecomment-583564566, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC4B437HGUW7RI75ALMZJMDRBWYKRANCNFSM4JDOVYVA.
The IPAM proxy is not in Feature not sure about the ... at the end though irb(main):002:0> Feature.all => #<ActiveRecord::Relation [#<Feature id: 1, name: "Templates", created_at: "2020-01-22 23:11:08", updated_at: "2020-01-22 23:11:08">,
<Feature id: 2, name: "Pulp", created_at: "2020-01-22 23:13:48",
updated_at: "2020-01-22 23:13:48">, #<Feature id: 3, name: "Pulp Node", created_at: "2020-01-22 23:13:48", updated_at: "2020-01-22 23:13:48">,
<Feature id: 4, name: "Pulp3", created_at: "2020-01-22 23:13:48",
updated_at: "2020-01-22 23:13:48">, #<Feature id: 5, name: "TFTP", created_at: "2020-01-22 23:13:48", updated_at: "2020-01-22 23:13:48">,
<Feature id: 6, name: "DNS", created_at: "2020-01-22 23:13:48",
updated_at: "2020-01-22 23:13:48">, #<Feature id: 7, name: "DHCP", created_at: "2020-01-22 23:13:48", updated_at: "2020-01-22 23:13:48">,
<Feature id: 8, name: "Puppet", created_at: "2020-01-22 23:13:48",
updated_at: "2020-01-22 23:13:48">, #<Feature id: 9, name: "Puppet CA", created_at: "2020-01-22 23:13:48", updated_at: "2020-01-22 23:13:48">,
<Feature id: 10, name: "BMC", created_at: "2020-01-22 23:13:48",
updated_at: "2020-01-22 23:13:48">, ...]>
On 8/02/2020 6:23 am, Chris Smith wrote:
Another possibility is that the feature is not associated with the smart proxy in the database. In the rails console, find the ID of your IPAM smart proxy with |SmartProxy.all|, and the ID of the |externalipam| feature with |Feature.all|, then see if the association exists in SmartProxyFeatures with |SmartProxyFeature.all|.
If the association doesn't exist, then it needs to be added .. Assuming your IPAM Smart Proxy ID is: 6, and your externalipam Feature is: 2, then you would ...
|SmartProxyFeature.create(smart_proxy_id: 6, feature_id: 2, capabilities: [], settings: {}).save! |
I remember adding this manually way back when, but this should actually be done in the seeds. I will update the docs and seeds file when I get a chance.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/grizzthedj/smart_proxy_ipam/issues/20?email_source=notifications&email_token=AC4B4357LHN2BPIBFHZRIOLRBWYKRA5CNFSM4JDOVYVKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELEH2FQ#issuecomment-583564566, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC4B437HGUW7RI75ALMZJMDRBWYKRANCNFSM4JDOVYVA.
OK got this so it looks like the association is OK. It seems like the smart variables have an issue from the ruby call that fails
irb(main):025:0> feature = Feature.find(17) => #<Feature id: 17, name: "External IPAM", created_at: "2020-02-05 06:03:53", updated_at: "2020-02-05 06:03:53">
irb(main):027:0> SmartProxyFeature.all => #<ActiveRecord::Relation [#<SmartProxyFeature smart_proxy_id: 1, feature_id: 2, id: 1, capabilities: [], settings: {"pulp_url"=>"https://lab03torch01.devops.vocus.local/pulp"}>,
capabilities: [], settings: {"use_provider"=>"dns_nsupdate"}>,
capabilities: [], settings: {}>, #<SmartProxyFeature smart_proxy_id: 1, feature_id: 5, id: 4, capabilities: [], settings: {"tftp_servername"=>nil}>, #<SmartProxyFeature smart_proxy_id: 1, feature_id: 7, id: 5, capabilities: ["dhcp_filename_hostname", "dhcp_filename_ipv4"], settings: {"use_provider"=>"dhcp_isc"}>,
capabilities: [], settings: {"puppet_url"=>"https://lab03torch01.devops.vocus.local:8140", "use_provider"=>["puppetca_hostname_whitelisting", "puppetca_http_api"]}>, #<SmartProxyFeature smart_proxy_id: 1, feature_id: 8, id: 7, capabilities: [], settings: {"puppet_url"=>"https://lab03torch01.devops.vocus.local:8140", "use_provider"=>["puppet_proxy_puppet_api"]}>, #<SmartProxyFeature smart_proxy_id: 1, feature_id: 13, id: 8, capabilities: [], settings: {}>, #<SmartProxyFeature smart_proxy_id: 1, feature_id: 14, id: 9, capabilities: [], settings: {"http_port"=>8000, "https_port"=>9090}>,
capabilities: [], settings: {}>]>
irb(main):032:0> SmartProxy.with_features('External IPAM').first => #<SmartProxy id: 1, name: "lab03torch01.devops.vocus.local", url: "https://lab03torch01.devops.vocus.local:9090", created_at: "2020-01-22 23:55:25", updated_at: "2020-01-23 23:46:28", expired_logs: "0", puppet_path: "/tmp/kafo_installation20200123-10920-fkcdmg/enviro...", download_policy: "on_demand">
so thats working
so why doesn't this
from subnet.rb - the failing bit
if self.ipam == IPAM::MODES[:external_ipam] external_ipam_proxy = SmartProxy.with_features('External IPAM').first
if external_ipamproxy.nil? self.errors.add :ipam, ('There must be at least one Smart Proxy present with an External IPAM plugin installed and configured') elsif self.external_ipamproxy.nil? self.errors.add :ipam, ('A Smart Proxy with an External IPAM feature enabled must be selected in the Proxies tab.') elsif !subnet_exists_in_externalipam self.errors.add :network, ('Subnet not found in the configured External IPAM instance') end end end
Finally found the problem - it was a typo in line 208 on my patch of subnet.rb externalipam instead of external_ipam. Your code is correct - ALL working now - thanks - now finish setting up and demo to appropriate stakeholders Foreman -> phpIPAM -> powerDNS for full stack automation.
Glad to hear you get everything sorted out! Going to close this issue given the instructions are working
The installation instruction here are not clear: https://theforeman.org/plugins/#2.Installation
Can you make a detailed procedure please ?