Foreman non PXE-Flow


#1

Hello,

Currently starting to switch some parts of my/our infrastructure to foreman (non pxe discovery with booting isos).

I finally got so far that i got a running setup with USB-Stick running forman discovery-image 3.5.1 with against foreman discovery-plugin v14 and Version 1.20.1.

Currently im in the following state:

  • (Discovery) USB Stick highest boot prio
  • Disks lower then the discovery

The host is discovered (hell yeah!) by foreman, i setup all the fancy things regarding OS including architecture, partition tables, preseeds and preeseed finish callbacksā€¦

So what happens now:

  • Server boots
  • Its registered by foreman
  • I tell foreman to install the OS
  • Server installes the OS, starts partioning the disksā€¦ installs grubā€¦
  • After its done, it reboots

So far so good, now i have an understanding issue/dont know how it (should) go furtherā€¦

Whats currently happening:

  • Server reboots into discovery again
  • Registers into foreman (new discovery host pops up) and waits for further kexec
  • Server is useless, because its in discoveryā€¦

When i switch boot priority to Disk first instead of Discovery USB (i dont think its needed?!)

  • Server boots into ubuntu 18.04
  • Server registers to foreman
  • Puppet goes on to install everything
  • Everything is fine

But for sure, when i now trigger rebuild through foreman nothing happens without manual interaction (delete host, switch boot priority, remap host to settingsā€¦)

So now to my question:
Shouldnt the host be ā€œrediscoveredā€ by the discovery image and then detect: ā€œno rebuild needed, lets boot the osā€, without touching any other bios settings (leaving USB stick primary boot device).

What do i have to do (which settings?) to archive ā€˜rediscoveryā€™?

Played arround with settings like:

  • Type of name generator
  • Use short name for VMs
  • Token duration
  • Force DNS
  • Error on existing NIC

Is there a missing template which handle this?
Do i have to modify the discovery image for this purpose?

Sounds for me like a ā€œnormalā€ non pxe flow to reinstall the machines without interacting so im a bit stuck if i have to manage this my ownā€¦


#2

invested more time and figured out that:

discovery_bootif fact is missing on the host which is installed, when booted by the iso the fact shows up in discovered hostsā€¦

theres some high and lower case mac addresses, i hope something like this doesnt bring trouble for rediscovery?!


#3

still hardly fighting with thisā€¦

i figured out that the process should be supported how i guessed it:

boot discovery (first boo prio) -> discover host -> install os -> reboot -> boot discovery (first boo prio) -> REdiscover host -> see its installed (not pending for a reinstall) -> skip discovery -> go on with next boot prio

but since it fails on rediscovery (creates a new host) i still have no prove that it really worksā€¦

Nobody out there having issues like this / any idears?


#4

This happens according to production.log:

so it finds the old host (managed) but still creates a new oneā€¦

2019-02-09T15:25:01 [I|app|e2a26]   Parameters: {"facts"=>"[FILTERED]", "apiv"=>"v2", "discovered_host"=>{"facts"=>"[FILTERED]"}}
2019-02-09T15:25:01 [W|app|e2a26] One or more existing managed hosts found: neal-gene-bolivar-tuzzio.xxx.com/44:8a:5b:2c:31:46
2019-02-09T15:25:01 [I|aud|e2a26] Nic::Managed (39) create event on mac
2019-02-09T15:25:01 [I|aud|e2a26] Nic::Managed (39) create event on ip
2019-02-09T15:25:01 [I|aud|e2a26] Nic::Managed (39) create event on type Nic::Managed
2019-02-09T15:25:01 [I|aud|e2a26] Nic::Managed (39) create event on name mac448a5b2c3146
2019-02-09T15:25:01 [I|aud|e2a26] Nic::Managed (39) create event on host_id 39
2019-02-09T15:25:01 [I|aud|e2a26] Nic::Managed (39) create event on subnet_id
2019-02-09T15:25:01 [I|aud|e2a26] Nic::Managed (39) create event on domain_id
2019-02-09T15:25:01 [I|aud|e2a26] Nic::Managed (39) create event on attrs {}
2019-02-09T15:25:01 [I|aud|e2a26] Nic::Managed (39) create event on provider
2019-02-09T15:25:01 [I|aud|e2a26] Nic::Managed (39) create event on username
2019-02-09T15:25:01 [I|aud|e2a26] Nic::Managed (39) create event on password [redacted]
2019-02-09T15:25:01 [I|aud|e2a26] Nic::Managed (39) create event on virtual false
2019-02-09T15:25:01 [I|aud|e2a26] Nic::Managed (39) create event on link true
2019-02-09T15:25:01 [I|aud|e2a26] Nic::Managed (39) create event on identifier
2019-02-09T15:25:01 [I|aud|e2a26] Nic::Managed (39) create event on tag
2019-02-09T15:25:01 [I|aud|e2a26] Nic::Managed (39) create event on attached_to
2019-02-09T15:25:01 [I|aud|e2a26] Nic::Managed (39) create event on managed true
2019-02-09T15:25:01 [I|aud|e2a26] Nic::Managed (39) create event on mode balance-rr
2019-02-09T15:25:01 [I|aud|e2a26] Nic::Managed (39) create event on attached_devices
2019-02-09T15:25:01 [I|aud|e2a26] Nic::Managed (39) create event on bond_options
2019-02-09T15:25:01 [I|aud|e2a26] Nic::Managed (39) create event on primary true
2019-02-09T15:25:01 [I|aud|e2a26] Nic::Managed (39) create event on provision true
2019-02-09T15:25:01 [I|aud|e2a26] Nic::Managed (39) create event on compute_attributes {}
2019-02-09T15:25:01 [I|aud|e2a26] Nic::Managed (39) create event on ip6
2019-02-09T15:25:01 [I|aud|e2a26] Nic::Managed (39) create event on subnet6_id
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on name mac448a5b2c3146
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on last_compile
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on root_pass
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on architecture_id
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on operatingsystem_id
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on environment_id
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on ptable_id
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on medium_id
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on build false
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on comment
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on disk
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on installed_at
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on model_idk
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on hostgroup_id
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on owner_id
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on owner_type
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on enabled true
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on puppet_ca_proxy_id
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on managed false
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on use_image
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on image_file
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on uuid
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on compute_resource_id
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on puppet_proxy_id
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on certname
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on image_id
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on organization_id
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on location_id
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on otp
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on realm_id
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on compute_profile_id
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on provision_method
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on grub_pass
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on global_status 0
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on lookup_value_matcher
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on pxe_loader
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on initiated_at
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on build_errors
2019-02-09T15:25:01 [I|aud|e2a26] Host::Base (39) create event on discovery_rule_id
2019-02-09T15:25:02 [I|app|e2a26] Import facts for 'mac448a5b2c3146' completed. Added: 155, Updated: 0, Deleted 0 facts
2019-02-09T15:25:02 [I|aud|e2a26] Nic::Managed (39) update event on mac , 44:8a:5b:2c:31:46
2019-02-09T15:25:02 [I|aud|e2a26] Nic::Managed (39) update event on identifier , enp2s0
2019-02-09T15:25:02 [I|app|e2a26] Detected subnet: hetzner-1 with taxonomy []/[]
2019-02-09T15:25:02 [I|aud|e2a26] Host::Base (39) update event on model_id , 2
2019-02-09T15:25:02 [I|aud|e2a26] Host::Base (39) update event on owner_id , 1
2019-02-09T15:25:02 [I|aud|e2a26] Host::Base (39) update event on owner_type , User
2019-02-09T15:25:02 [I|aud|e2a26] Nic::Managed (39) update event on subnet_id , 1
2019-02-09T15:25:02 [I|app|e2a26] Completed 201 Created in 1226ms (Views: 2.8ms | ActiveRecord: 376.3ms)

i digged in the code which is responsible for this:

https://github.com/theforeman/foreman_discovery/blob/develop/app/models/host/discovered.rb#L76 heres its finding the old managed host.

But still it creates a new host here: https://github.com/theforeman/foreman_discovery/blob/develop/app/models/host/discovered.rb#L88

I guess it should not do this? :frowning:


#5

Hello,

PXE-less workflow is built on fact that you have the BIOS order set as following:

  • boot from USB media (if present)
  • boot from HDD

Then an operator with a generic USB sticks boots servers into discovery and as they appear as discovered the operator removes the USB stick. Itā€™s no longer needed as the whole live system is loaded into memory.

It is what it is. Foreman does not manage boot order itself, at least not in this workflow.


#6

@lzap thanks a lot! This helps out a lot for me. Prob it makes sense in this case:

  1. writing it somewhere in the discovery plugin section
  2. Whenever a node is discovered via the non pxe flow, that it gives feedback to foreman and disables reinstall buttons as well show somewhere this information in the ui.

@lzap i also read about the foreman bootdisk plugin. Does this plugin provide the functionality about reinstall, skipping install if its not in provision mode and keep the usb stick attached without changing the boot order?

before i invest hours for thisā€¦


#7

Please go ahead and expand our manual at Foreman :: Plugin Manuals

Itā€™s just a markdown here: https://github.com/theforeman/theforeman.org

Bootdisk is the same story for baremetal, however Foreman can manage boot order for VMs, I am sure about VMWare and libvirt. For VMWare Foreman supports automatic attaching of bootdisks to VMs, so this should work seamlessly. Not sure about reprovisioning tho.