Bug #24146
closedForeman-Proxy DHCP ISC - DNS Search set wrong for multiple domains
Description
When setting the DHCP search domains in foreman-proxy, the values are being set incorrectly and causing the dhclient to reject the domain search.
Version: Foreman 1.16.2-1.el7
Summary
My configuration has three different domains that have to be searched so I set the Foreman-Proxy search domains to have that configured in the dhcpd.conf file, as expected. When testing against a host using the DHCP server on the Foreman host the dhclient on the host rejects the search being sent by DHCP since it not the expected format.
Details
Setting the dns-search:
# foreman-installer --foreman-proxy-dhcp-search-domains "mydomain.dick.jane.com","dick.net","jane.com"
Foreman Verbose Output:
+ option domain-search "mydomain.dick.jane.com,dick.net,jane.com";
Expected:
+ option domain-search "mydomain.dick.jane.com","dick.net","jane.com";
Diagnostics
With option domain-search "mydomain.dick.jane.com,dick.net,jane.com" set, the dhclient ignores the search options with the message:
dhclient[2951]: suspect value in domain_search option - discarded
Manually setting the options domain-search "mydomain.dick.jane.com","dick.net","jane.com" corrects the issue on the client, but each time foreman-install is run it reverts to the incorrect forem.
I searched through the various references to domain-search and domain_search under the /usr/share/foreman-installer/modules directory and found entries in /usr/share/foreman-installer/modules/dhcp/templates/dhcpd.pool.erb. When testing in irb this routine sets the parameters correctly.
<% if @search_domains and @search_domains.is_a? Array -%> option domain-search "<%= @search_domains.sort.join('", "') %>"; <% elsif @search_domains -%> option domain-search "<%= @search_domains.split(/[, ]+/).join('", "') %>"; <% end -%>
Tested in IRB
irb(main):014:0> search_domains = ['mydomain.dick.jane.com','dick.net','jane.com'] => ["mydomain.dick.jane.com", "dick.net", "jane.com"] irb(main):016:0> p search_domains.sort.join('", "') "dick.net\", \"jane.com\", \"mydomain.dick.jane.com" => "dick.net\", \"jane.com\", \"mydomain.dick.jane.com" irb(main):017:0> search_domains = "mydomain.dick.jane.com dick.net jane.com" => "mydomain.dick.jane.com dick.net jane.com" irb(main):018:0> p search_domains.split(/[, ]+/).join('", "') "mydomain.dick.jane.com\", \"dick.net\", \"jane.com" => "mydomain.dick.jane.com\", \"dick.net\", \"jane.com"
I haven't yet tracked down where foreman-proxy is setting this value to be the incorrect form:
"mydomain.dick.jane.com,dick.net,jane.com"
The only workaround I have found presently is to manually copy back in the dhcpd.conf backup file to change the settings to work correctly.
I am in the middle of a POC and can't upgrade to Foreman 1.17.1 at this time to see if the problem persists, but I didn't find any bug reports on this particular issue.
Files