Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

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

未关闭
#187 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
1/5
预计耗时
1 小时以内
新手友好度
45/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
停滞
技术栈
ruby
领域
cli, networking

调研方向

从 lib/simp/cli/config/items/data/simp_options_dns_servers.rb 第 33 行附近开始,检查 nmcli 输出如何成为 DNS 服务器默认值。验证以管道分隔的服务器是否被分别解析,重复值或空值是否得到处理,以及生成的默认值是否通过验证;如果相关的现有测试套件可用,请运行它。

由索引模型根据 Issue 内容生成。

描述

community

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.

主要语言
Ruby
星标
2
派生
12
平均合并
6 天 6 小时
30 天内合并 PR
3

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

simp/rubygem-simp-cli 的其他 Issue

查看 simp/rubygem-simp-cli 的全部 Issue

相似的 Issue

更多 Ruby Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。