Feature #1361
closedAllow subnet information to be accessed from provisioning templates & add gateway, dns to subnets
Description
I've attached a patch that does two things.
- Add 2 new fields to the Subnets form. Gateway and DNS
- Allow subnet items (gateway, dns, mask) to be used in provisioning templates.
This has been tested using Foreman-0.4.
I'm still very new to Ruby so these code changes may not adhere to coding best practices for Ruby.
The primary use case this was created for is to allow for a static IP to be assigned to a new host on install while booting it using DHCP.
An example of how to use
network --bootproto static --hostname <%= @host.name %> --ip=<%= @host.ip %> \ --netmask=<%= subnet[:mask] %> --gateway=<%= subnet[:gateway] %> --nameserver=<%= subnet[:dns] %>
Files
Updated by Ohad Levy about 13 years ago
- Assignee changed from Ohad Levy to Trey Dockendorf
- Target version set to 1.0
this patch would only work with one dns server, is that sufficient?
thanks
Updated by Markus Nussdorfer about 13 years ago
Ohad Levy wrote:
this patch would only work with one dns server, is that sufficient?
thanks
Up until RHEL 6.1 you can only define 1 primary nameserver
But according to the Installation Guide for 6 Beta there can be now two
--nameserver= — Primary nameserver, as an IP address. Multiple nameservers must each be separated by a comma.
Updated by Trey Dockendorf about 13 years ago
- File foreman-4.0-subnet-values-in-provisioning-templates.patch foreman-4.0-subnet-values-in-provisioning-templates.patch added
Updated the patch to add secondary DNS and fix a bug with the migrate file. Tested migration successfully
Example usage:
network --bootproto static --hostname <%= @host.name %> --ip=<%= @host.ip %> \ --netmask=<%= subnet[:mask] %> --gateway=<%= subnet[:gateway] %> \ --nameserver=<%= subnet[:dns_primary] %>,<%= subnet[:dns_secondary] %>
Attached is an updated patch file. Could someone remove the previous patch file as it won't work when using db:migrate.
Updated by Trey Dockendorf about 13 years ago
This looks related to Issue #1354.
Updated by Ohad Levy about 13 years ago
- Status changed from New to Assigned
thanks for the patch, I'm willing to merge it, just one question, what is the usage of the subnet help?
you could simply do
@host.subnet.gateway in your templates?
Updated by Trey Dockendorf about 13 years ago
Ohad Levy wrote:
thanks for the patch, I'm willing to merge it, just one question, what is the usage of the subnet help?
you could simply do
@host.subnet.gateway in your templates?
Sorry for the delay. The campus I support had a fiber outage so we've been busy moving servers all over the place.
Accessing subnet values with @host.subnet.gateway is much cleaner, and works. I think the use of the helper method was a lack of understanding on my part of how to use methods in Ruby Rails. You can ignore the changes to app/helpers/unattended_helper.rb. Though make sure to use the patch from my update, not the patches in the original post. It fixes mistakes I made with the DB migration.
Updated by Trey Dockendorf about 13 years ago
Correction, I can't use this is the PXELinux templates...
default linux label linux kernel <%= @kernel %> append initrd=<%= @initrd %> ks=<%= foreman_url("provision")%> ksdevice=eth0 network kssendmac ip=<%= ip %> netmask=<%= subnet[:mask] %> gateway=<%= subnet[:gateway] %> dns=<%= subnet[:dns_primary] %>
I can however use the following
default linux label linux kernel <%= @kernel %> append initrd=<%= @initrd %> ks=<%= foreman_url("provision")%> ksdevice=eth0 network kssendmac ip=<%= ip %> netmask=<%= @host.subnet.mask %> gateway=<%= @host.subnet.gateway %> dns=<%= @host.subnet.dns_primary %>
The error I get when using the first attempt is this (hostnames/ip changed)
Processing HostsController#update (for ...... at 2012-01-05 10:19:27) [PUT] Parameters: {"commit"=>"Submit", "action"=>"update", "_method"=>"put", "authenticity_token"=>"FV/8/chFOEddPnsMHlK7O3jxmASVvSfHXlp1BlGAPiY=", "id"=>"client.tamu.edu", "controller"=>"hosts", "host"=>{"architecture_id"=>"1", "subnet_id"=>"2", "puppetproxy_id"=>"1", "name"=>"client", "sp_mac"=>"", "sp_name"=>"", "managed"=>"1", "puppetmaster_name"=>"puppetca.tamu.edu", "root_pass"=>"[FILTERED]", "hostgroup_id"=>"1", "mac"=>"52:.....", "domain_id"=>"1", "enabled"=>"1", "medium_id"=>"6", "ptable_id"=>"9", "disk"=>"", "ip"=>"........", "puppetclass_ids"=>["", "6", "7", "29", "125", "180", "172", "89", "96"], "environment_id"=>"1", "comment"=>"", "sp_subnet_id"=>"", "sp_ip"=>"", "model_id"=>"5", "operatingsystem_id"=>"7"}} Add the TFTP configuration for client.tamu.edu Failed to generate PXELinux template: undefined method `subnet' for nil:NilClass Fetching required TFTP boot files for client.tamu.edu Rolling back due to a problem: Delete the TFTP configuration for client.tamu.edu Failed to save: Failed to generate PXELinux template: undefined method `subnet' for nil:NilClass Rendering template within layouts/application Rendering hosts/edit Completed in 1098ms (View: 969, DB: 189) | 200 OK [https://foreman.tamu.edu/hosts/client.tamu.edu]
I will get back in a day or two if I found out how to fix...I don't see how it works in Kickstart but not PXELinux as they are all "config_templates".
Updated by Ohad Levy about 13 years ago
tftp templates are kind of special, just drop the "@host." and it should work..
Updated by Trey Dockendorf about 13 years ago
- Status changed from Assigned to Closed
- % Done changed from 0 to 100
Applied in changeset 50751ff43fc703c443721de7fdb8ae178b304838.
Updated by jaffa wify over 12 years ago
The terminals were connected to the terminal hosts through serial interfaces and perhaps circuit switched networks, but not connected to any IP based network, and were not assigned IP addresses. Today's IP hosts may, however, lack ability to serve as terminal hosts. Thanks a lot.
Regards,
make my thesis
Updated by jaffa wify over 12 years ago
The academic field and the engineering practice of computer programming are both largely concerned with discovering and implementing the most efficient algorithms for a given class of problem. Thanks for sharing.
Regards,
architectural conservation
Updated by nitin khare about 12 years ago
From now on I will meet anyone like this unless I commend him to this blog! It is fantastic and I had never found so much useful information on one website. Congratulations. "Austin Home Builder
":http://www.joshwillishomes.com
Updated by nitin khare about 12 years ago
The site is favourable and precisely what he or she stated.Along with Marc Jacobs Bags the actual improvement involving e-business, buying Marc Jacobs Purses on the internet. "technical writing services
":http://www.technicalwritingservices.biz/
Updated by nitin khare about 12 years ago
mba application resume Excellent weblog, many thanks a lot for your awesome posts!