Item::SimpOptionsDNSServers does not account for existing DNS servers properly
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 2
- Forks
- 12
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 4
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with lib/simp/cli/config/items/data/simp_options_dns_servers.rb around line 33 and inspect how nmcli output becomes the DNS server default. Verify that pipe-delimited servers are parsed separately, duplicate or empty values are handled, and the resulting default passes validation; run the relevant existing test suite if available.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- cli, networking
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- Under an hour
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100