Recreating DHCP and DNS entries or rerunning orchestration

I posted some time ago about the inability to see the posted code on a blog
article [1] that mentioned how to use a rails runner script to re-apply
DHCP leases to a foreman-proxy. I am now in the process of moving our
infrastructure into a more 'final' state and that includes putting the DNS
and DHCP services on their own VM (they are currently on the Puppetmaster).
I also still have an issue where a misconfigured domain in Foreman
resulted in many of my host's not having complete DNS records created. Is
there any way in Foreman 1.4 to write a script to run in Rails (or in Rails
console) to re-apply all host's DNS and DHCP records to a foreman-proxy.
I've tinkered some in the console and have found most of the obvious
methods in the various models are private and I don't know the "trick" to
trick Foreman via console into rerunning an orchestration.

Thanks

  • Trey

[1]

> I posted some time ago about the inability to see the posted code on a
> blog article [1] that mentioned how to use a rails runner script to
> re-apply DHCP leases to a foreman-proxy. I am now in the process of moving
> our infrastructure into a more 'final' state and that includes putting the
> DNS and DHCP services on their own VM (they are currently on the
> Puppetmaster). I also still have an issue where a misconfigured domain in
> Foreman resulted in many of my host's not having complete DNS records
> created. Is there any way in Foreman 1.4 to write a script to run in Rails
> (or in Rails console) to re-apply all host's DNS and DHCP records to a
> foreman-proxy. I've tinkered some in the console and have found most of
> the obvious methods in the various models are private and I don't know the
> "trick" to trick Foreman via console into rerunning an orchestration.
>
> Thanks
> - Trey
>
>
> [1] -
> http://blog.theforeman.org/2012/01/recovering-lost-dhcp-reservations.html
>

the original gist can be found at https://gist.github.com/ohadlevy/1620981.

I'll try to look at the blog issue again and see if we can fix it.

thanks,
ohad

··· On Fri, Feb 21, 2014 at 2:21 AM, treydock wrote:


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/groups/opt_out.

Thanks!

How would this be adapted for DNS? If it can be adapted, can it do each
interface for a host?

Does the DHCP code from the gist create a new record for each interface?

I'd like to have Foreman act as master record (and creator) of all DNS
records for an HPC cluster where every host has 3 interfaces (BMC
included). Since the hosts already exist, I'd need to update their records
without actually provisioning the hosts, and using a script to add all 325
hosts.

Thanks!

  • Trey
··· On Feb 21, 2014 12:59 AM, "Ohad Levy" wrote:

On Fri, Feb 21, 2014 at 2:21 AM, treydock treydock@gmail.com wrote:

I posted some time ago about the inability to see the posted code on a
blog article [1] that mentioned how to use a rails runner script to
re-apply DHCP leases to a foreman-proxy. I am now in the process of moving
our infrastructure into a more ‘final’ state and that includes putting the
DNS and DHCP services on their own VM (they are currently on the
Puppetmaster). I also still have an issue where a misconfigured domain in
Foreman resulted in many of my host’s not having complete DNS records
created. Is there any way in Foreman 1.4 to write a script to run in Rails
(or in Rails console) to re-apply all host’s DNS and DHCP records to a
foreman-proxy. I’ve tinkered some in the console and have found most of
the obvious methods in the various models are private and I don’t know the
"trick" to trick Foreman via console into rerunning an orchestration.

Thanks

  • Trey

[1] -
http://blog.theforeman.org/2012/01/recovering-lost-dhcp-reservations.html

the original gist can be found at https://gist.github.com/ohadlevy/1620981
.

I’ll try to look at the blog issue again and see if we can fix it.

thanks,
ohad


You received this message because you are subscribed to the Google Groups
"Foreman users" group.
To unsubscribe from this group and stop receiving emails from it, send an
email to foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/groups/opt_out.


You received this message because you are subscribed to a topic in the
Google Groups “Foreman users” group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/foreman-users/86fEMd7sico/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/groups/opt_out.

I have uploaded a script [1] that does DNS re-creation for the host
and all interfaces as well as one for DHCP [2]. Unfortunately the DNS
A records never get created for interfaces because they lack a domain
when sent to the proxy.

When I run the script and create host records I see output like this…

vmstore1.domain.edu…vmstore1.domain.edu/192.168.202.245…VALID
vmstore1.domain.edu…192.168.202.245/vmstore1.domain.edu…VALID

When I remove line #41 and to create the interface DNS records, I see
output like this…

vmstore1-bmc…vmstore1-bmc/192.168.205.245…missing…recreating…DONE
vmstore1-bmc…192.168.205.245/vmstore1-bmc…VALID

Notice the domain does not exist in the output. I see the same in the
foreman-proxy.log files:

D, [2014-02-25T18:10:13.132870 #26653] DEBUG – : running
/usr/bin/nsupdate -k /etc/rndc.key
D, [2014-02-25T18:10:13.175770 #26653] DEBUG – : nsupdate: executed -
server 127.0.0.1
D, [2014-02-25T18:10:13.210169 #26653] DEBUG – : nsupdate: executed -
update add vmstore1-bmc. 86400 A 192.168.205.245

DNS A records that actually get created have the FQDN in the logs.
Using the rails console I find that the "vmstore1-bmc" interface does
have the correct domain associated to it in Rails.

interface = Nic::BMC.find_by_name('vmstore1-bmc')
Nic::BMC Load (0.3ms) SELECT nics.* FROM nics WHERE
nics.type IN ('Nic::BMC') AND nics.name = 'vmstore1-bmc' LIMIT
1
=> #<Nic::BMC id: 30, mac: "00:25:90:ce:4d:6c", ip: "192.168.205.245",
type: "Nic::BMC", name: "vmstore1-bmc", host_id: 47, subnet_id: 2,
domain_id: 1, attrs: {:username=>"<OMIT>", :password=>"<OMIT>",
:provider=>"IPMI"}, created_at: "2014-01-03 19:13:29", updated_at:
"2014-01-03 19:13:29">

interface.domain
Domain Load (0.3ms) SELECT domains.* FROM domains WHERE
domains.id = 1 ORDER BY domains.name LIMIT 1
=> #<Domain id: 1, name: "domain.edu", fullname: "domain.edu",
created_at: "2013-01-10 16:37:08", updated_at: "2014-01-15 20:32:32",
dns_id: 1>

I'm still on Foreman 1.3.2. Has this bug been resolved in 1.4.x, or
is this something that needs to be put into Redmine?

Thanks

  • Trey

[1] - https://gist.github.com/treydock/9220796
[2] - https://gist.github.com/treydock/9220870

··· On Fri, Feb 21, 2014 at 12:59 AM, Ohad Levy wrote: > > > On Fri, Feb 21, 2014 at 2:21 AM, treydock wrote: >> >> I posted some time ago about the inability to see the posted code on a >> blog article [1] that mentioned how to use a rails runner script to re-apply >> DHCP leases to a foreman-proxy. I am now in the process of moving our >> infrastructure into a more 'final' state and that includes putting the DNS >> and DHCP services on their own VM (they are currently on the Puppetmaster). >> I also still have an issue where a misconfigured domain in Foreman resulted >> in many of my host's not having complete DNS records created. Is there any >> way in Foreman 1.4 to write a script to run in Rails (or in Rails console) >> to re-apply all host's DNS and DHCP records to a foreman-proxy. I've >> tinkered some in the console and have found most of the obvious methods in >> the various models are private and I don't know the "trick" to trick Foreman >> via console into rerunning an orchestration. >> >> Thanks >> - Trey >> >> >> [1] - >> http://blog.theforeman.org/2012/01/recovering-lost-dhcp-reservations.html > > > the original gist can be found at https://gist.github.com/ohadlevy/1620981. > > I'll try to look at the blog issue again and see if we can fix it. > > thanks, > ohad >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Foreman users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to foreman-users+unsubscribe@googlegroups.com. >> >> To post to this group, send email to foreman-users@googlegroups.com. >> Visit this group at http://groups.google.com/group/foreman-users. >> For more options, visit https://groups.google.com/groups/opt_out. > > > -- > You received this message because you are subscribed to a topic in the > Google Groups "Foreman users" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/foreman-users/86fEMd7sico/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > foreman-users+unsubscribe@googlegroups.com. > To post to this group, send email to foreman-users@googlegroups.com. > Visit this group at http://groups.google.com/group/foreman-users. > For more options, visit https://groups.google.com/groups/opt_out.

Looks like I answered my own question by looking at code and that the
interface models include the DNS and DHCP orchestration models which have
similar functionality. Will report back Foreman 1.3 (or 1.4) compatible
versions of the scripts that iterate over each host's interfaces.

  • Trey
··· On Feb 23, 2014 9:08 PM, "Trey Dockendorf" wrote:

Thanks!

How would this be adapted for DNS? If it can be adapted, can it do each
interface for a host?

Does the DHCP code from the gist create a new record for each interface?

I’d like to have Foreman act as master record (and creator) of all DNS
records for an HPC cluster where every host has 3 interfaces (BMC
included). Since the hosts already exist, I’d need to update their records
without actually provisioning the hosts, and using a script to add all 325
hosts.

Thanks!

On Fri, Feb 21, 2014 at 2:21 AM, treydock treydock@gmail.com wrote:

I posted some time ago about the inability to see the posted code on a
blog article [1] that mentioned how to use a rails runner script to
re-apply DHCP leases to a foreman-proxy. I am now in the process of moving
our infrastructure into a more ‘final’ state and that includes putting the
DNS and DHCP services on their own VM (they are currently on the
Puppetmaster). I also still have an issue where a misconfigured domain in
Foreman resulted in many of my host’s not having complete DNS records
created. Is there any way in Foreman 1.4 to write a script to run in Rails
(or in Rails console) to re-apply all host’s DNS and DHCP records to a
foreman-proxy. I’ve tinkered some in the console and have found most of
the obvious methods in the various models are private and I don’t know the
"trick" to trick Foreman via console into rerunning an orchestration.

Thanks

  • Trey

[1] -
http://blog.theforeman.org/2012/01/recovering-lost-dhcp-reservations.html

the original gist can be found at
https://gist.github.com/ohadlevy/1620981.

I’ll try to look at the blog issue again and see if we can fix it.

thanks,
ohad


You received this message because you are subscribed to the Google
Groups “Foreman users” group.
To unsubscribe from this group and stop receiving emails from it, send
an email to foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/groups/opt_out.


You received this message because you are subscribed to a topic in the
Google Groups “Foreman users” group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/foreman-users/86fEMd7sico/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
foreman-users+unsubscribe@googlegroups.com.
To post to this group, send email to foreman-users@googlegroups.com.
Visit this group at http://groups.google.com/group/foreman-users.
For more options, visit https://groups.google.com/groups/opt_out.

Hmm, it's quite possible this is related to
Bug #2750: DNS record for BMC interface don't append domain name - Foreman, which is unresolved.

··· On 26/02/14 00:27, Trey Dockendorf wrote: > I have uploaded a script [1] that does DNS re-creation for the host > and all interfaces as well as one for DHCP [2]. Unfortunately the DNS > A records never get created for interfaces because they lack a domain > when sent to the proxy. > > When I run the script and create host records I see output like this... > > vmstore1.domain.edu...vmstore1.domain.edu/192.168.202.245...VALID > vmstore1.domain.edu...192.168.202.245/vmstore1.domain.edu...VALID > > When I remove line #41 and to create the interface DNS records, I see > output like this... > > vmstore1-bmc...vmstore1-bmc/192.168.205.245...missing..recreating..DONE > vmstore1-bmc...192.168.205.245/vmstore1-bmc...VALID > > Notice the domain does not exist in the output. I see the same in the > foreman-proxy.log files: > > D, [2014-02-25T18:10:13.132870 #26653] DEBUG -- : running > /usr/bin/nsupdate -k /etc/rndc.key > D, [2014-02-25T18:10:13.175770 #26653] DEBUG -- : nsupdate: executed - > server 127.0.0.1 > D, [2014-02-25T18:10:13.210169 #26653] DEBUG -- : nsupdate: executed - > update add vmstore1-bmc. 86400 A 192.168.205.245 > > DNS A records that actually get created have the FQDN in the logs. > Using the rails console I find that the "vmstore1-bmc" interface does > have the correct domain associated to it in Rails. > > interface = Nic::BMC.find_by_name('vmstore1-bmc') > Nic::BMC Load (0.3ms) SELECT `nics`.* FROM `nics` WHERE > `nics`.`type` IN ('Nic::BMC') AND `nics`.`name` = 'vmstore1-bmc' LIMIT > 1 > => # type: "Nic::BMC", name: "vmstore1-bmc", host_id: 47, subnet_id: 2, > domain_id: 1, attrs: {:username=>"", :password=>"", > :provider=>"IPMI"}, created_at: "2014-01-03 19:13:29", updated_at: > "2014-01-03 19:13:29"> > > interface.domain > Domain Load (0.3ms) SELECT `domains`.* FROM `domains` WHERE > `domains`.`id` = 1 ORDER BY domains.name LIMIT 1 > => # created_at: "2013-01-10 16:37:08", updated_at: "2014-01-15 20:32:32", > dns_id: 1> > > I'm still on Foreman 1.3.2. Has this bug been resolved in 1.4.x, or > is this something that needs to be put into Redmine?


Dominic Cleal
Red Hat Engineering

That looks like the same issue I'm having, except this applies to all
interfaces that are not the host's primary interface.

Updated my gists [1] to word around this issue for DNS.

  • Trey

[1] - https://gist.github.com/treydock/9220796

··· On Wednesday, February 26, 2014 2:49:23 AM UTC-6, Dominic Cleal wrote: > > On 26/02/14 00:27, Trey Dockendorf wrote: > > I have uploaded a script [1] that does DNS re-creation for the host > > and all interfaces as well as one for DHCP [2]. Unfortunately the DNS > > A records never get created for interfaces because they lack a domain > > when sent to the proxy. > > > > When I run the script and create host records I see output like this... > > > > vmstore1.domain.edu...vmstore1.domain.edu/192.168.202.245...VALID > > vmstore1.domain.edu...192.168.202.245/vmstore1.domain.edu...VALID > > > > When I remove line #41 and to create the interface DNS records, I see > > output like this... > > > > vmstore1-bmc...vmstore1-bmc/192.168.205.245...missing..recreating..DONE > > vmstore1-bmc...192.168.205.245/vmstore1-bmc...VALID > > > > Notice the domain does not exist in the output. I see the same in the > > foreman-proxy.log files: > > > > D, [2014-02-25T18:10:13.132870 #26653] DEBUG -- : running > > /usr/bin/nsupdate -k /etc/rndc.key > > D, [2014-02-25T18:10:13.175770 #26653] DEBUG -- : nsupdate: executed - > > server 127.0.0.1 > > D, [2014-02-25T18:10:13.210169 #26653] DEBUG -- : nsupdate: executed - > > update add vmstore1-bmc. 86400 A 192.168.205.245 > > > > DNS A records that actually get created have the FQDN in the logs. > > Using the rails console I find that the "vmstore1-bmc" interface does > > have the correct domain associated to it in Rails. > > > > interface = Nic::BMC.find_by_name('vmstore1-bmc') > > Nic::BMC Load (0.3ms) SELECT `nics`.* FROM `nics` WHERE > > `nics`.`type` IN ('Nic::BMC') AND `nics`.`name` = 'vmstore1-bmc' LIMIT > > 1 > > => # > type: "Nic::BMC", name: "vmstore1-bmc", host_id: 47, subnet_id: 2, > > domain_id: 1, attrs: {:username=>"", :password=>"", > > :provider=>"IPMI"}, created_at: "2014-01-03 19:13:29", updated_at: > > "2014-01-03 19:13:29"> > > > > interface.domain > > Domain Load (0.3ms) SELECT `domains`.* FROM `domains` WHERE > > `domains`.`id` = 1 ORDER BY domains.name LIMIT 1 > > => # > created_at: "2013-01-10 16:37:08", updated_at: "2014-01-15 20:32:32", > > dns_id: 1> > > > > I'm still on Foreman 1.3.2. Has this bug been resolved in 1.4.x, or > > is this something that needs to be put into Redmine? > > Hmm, it's quite possible this is related to > http://projects.theforeman.org/issues/2750, which is unresolved. > > -- > Dominic Cleal > Red Hat Engineering >