Skip to content
Snippets Groups Projects
Verified Commit f5e0975c authored by Alexander Olofsson's avatar Alexander Olofsson
Browse files

Disable fact search by default

parent 8637dd48
No related branches found
No related tags found
No related merge requests found
Pipeline #114928 passed
......@@ -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
......
......@@ -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?
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment