diff --git a/README.md b/README.md index a46284ca1c10ea7a4c16aa7ee16a2b9c98ed4b6e..ccda144a2910aef4f53bbe24f6384ad35acdb480 100644 --- a/README.md +++ b/README.md @@ -4,13 +4,25 @@ Allows booting machines based off of machine UUID instead of - or in addition to Example iPXE boot URLs; -`http://foreman.example.com/unattended/iPXE?uuid=${uuid}` +`http://foreman.example.com/unattended/iPXE?mac=${netX/mac}&uuid=${uuid}` `http://template-proxy.example.com:8000/unattended/iPXE?mac=${netX/mac}&uuid=${uuid}` +Also works with `http://foreman.example.com/unattended/iPXE?bootstrap=true` after extending the iPXE intermediate script with; +```patch +- chain --autofree --replace <%= foreman_url('iPXE', {}, { mac: "${net#{i}/mac}" }) %> || goto net<%= i+1 %> ++ chain --autofree --replace <%= foreman_url('iPXE', {}, { mac: "${net#{i}/mac}", uuid: "${uuid}" }) %> || goto net<%= i+1 %> +``` + ## Installation See the [Plugins install instructions, advanced installation from gems](https://theforeman.org/plugins/#2.3AdvancedInstallationfromGems) for information on how to install this plugins. +To enable legacy fact searching in addition to the UUID boot facet, create a plugin configuration file under `/etc/foreman/plugins` with; +```yaml +--- +:uuidboot_factsearch: true +``` + ## Contributing Bug reports and pull requests are welcome on the LiU GitLab at https://gitlab.liu.se/ITI/foreman_uuid_boot or on GitHub at https://github.com/ananace/foreman_uuid_boot diff --git a/app/services/foreman/unattended_installation/concerns/host_finder_extensions.rb b/app/services/foreman/unattended_installation/concerns/host_finder_extensions.rb index 4abd4395dd8decef985de660099ab91486c0f9b5..54c159b9a911c77f71d1a33f896e0e7805636582 100644 --- a/app/services/foreman/unattended_installation/concerns/host_finder_extensions.rb +++ b/app/services/foreman/unattended_installation/concerns/host_finder_extensions.rb @@ -15,11 +15,13 @@ module HostFinderExtensions facets = ForemanUuidBoot::UuidbootHostFacet.where(uuid: uuid).order(:created_at) if facets.any? - Rails.logger.warn("Multiple hosts found with #{uuid}, picking up the most recent") if facets.count > 1 + Rails.logger.warn("Multiple hosts found with #{uuid}, choosing the most recent") if facets.count > 1 return facets.last.host.reload end + return unless SETTINGS[:uuidboot_factsearch] + # Fallback fact search fact_name_id = FactName.where(name: 'uuid').map(&:id) return unless fact_name_id.any? @@ -27,7 +29,7 @@ module HostFinderExtensions query = { fact_values: { fact_name_id: fact_name_id, value: uuid } } hosts = Host.joins(:fact_values).where(query).order(:created_at) - Rails.logger.warn("Multiple hosts found with #{uuid}, picking up the most recent") if hosts.count > 1 + Rails.logger.warn("Multiple hosts found with #{uuid}, choosing the most recent") if hosts.count > 1 return unless hosts.present?