Skip to content

Item::SimpOptionsDNSServers does not account for existing DNS servers properly #187

@wilrodriguez

Description

@wilrodriguez

One of my test systems I attempted to bootstrap with SIMP 6.6 ran into an issue with the DNS when going through the simp config questionnaire. When it came time to choose the DNS options I ran into some oddities:

cli::network::set_up_nic = true

=== cli::network::dhcp ===
Whether to use DHCP to retrieve your network settings ("dhcp") or to
use static network settings ("static").
----> Recommended value: "static"
cli::network::dhcp: |static| dhcp
cli::network::dhcp = "dhcp"
>> Applying: Configure a network interface...  Succeeded

=== cli::network::hostname ===
The Fully Qualified Domain Name (FQDN) of the system.

This *MUST* contain a domain. Simple hostnames are not allowed.
----> OS value:          "puppet.localhost.local"
----> Recommended value: "puppet.localhost.local"
cli::network::hostname: |puppet.localhost.local|
cli::network::hostname = "puppet.localhost.local"
>> Applying: Set hostname...  Succeeded

Internal error: Default, noninteractive value for simp_options::dns::servers is invalid: '["1.1.1.1 | 1.0.0.1"]'.


/usr/share/simp/ruby/gems/simp-cli-7.0.0/lib/simp/cli/config/items/item.rb:267:in `determine_value_from_default'
/usr/share/simp/ruby/gems/simp-cli-7.0.0/lib/simp/cli/config/items/item.rb:235:in `determine_value'
/usr/share/simp/ruby/gems/simp-cli-7.0.0/lib/simp/cli/config/questionnaire.rb:98:in `process_item'
/usr/share/simp/ruby/gems/simp-cli-7.0.0/lib/simp/cli/config/questionnaire.rb:38:in `process_pass1'
/usr/share/simp/ruby/gems/simp-cli-7.0.0/lib/simp/cli/config/questionnaire.rb:49:in `process_pass1'
/usr/share/simp/ruby/gems/simp-cli-7.0.0/lib/simp/cli/config/questionnaire.rb:49:in `process_pass1'
/usr/share/simp/ruby/gems/simp-cli-7.0.0/lib/simp/cli/config/questionnaire.rb:49:in `process_pass1'
/usr/share/simp/ruby/gems/simp-cli-7.0.0/lib/simp/cli/config/questionnaire.rb:49:in `process_pass1'
/usr/share/simp/ruby/gems/simp-cli-7.0.0/lib/simp/cli/config/questionnaire.rb:49:in `process_pass1'
/usr/share/simp/ruby/gems/simp-cli-7.0.0/lib/simp/cli/config/questionnaire.rb:49:in `process_pass1'

Upon looking into this I found the bug is right here: https://github.com/simp/rubygem-simp-cli/blob/master/lib/simp/cli/config/items/data/simp_options_dns_servers.rb#L33

Turns out that nmcli will return multiple DNS servers with a pipe delimiter. But, good news, this is an easy fix, and we can even simplify the block. We can change line 33 like so:

nameservers = result[:stdout].strip.split("\n").map { |ips| ips.split(/\s*\|\s*/) }.flatten.uniq

One bonus to this approach is that flattening the array will also remove empty values so we don't need the delete_if on the following lines.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions