AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题

问题[chef](server)

Martin Hope
Daniel Carrington
Asked: 2024-05-23 04:02:13 +0800 CST

由于 SSH 密钥算法错误,Test Kitchen 无法运行 Inspec 测试

  • 5

我不熟悉测试厨房工具的深度,因为我通常使用它们进行简单的食谱测试,并且通常不会遇到问题。

目前,我正在尝试测试食谱的更新,但是当我运行“厨房测试”时,我看到收敛正在发生,并且似乎完成得很好。但是当它尝试在收敛后运行 Inspec 测试时,我收到错误:

>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: 1 actions failed.
>>>>>>     Failed to complete #verify action: [Transport error, can't connect to 'ssh' backend: SSH command failed (host key algorithm mismatch for signature 'rsa-sha2-256' != 'ssh-rsa')] on default-rhel-9
>>>>>> ----------------------
>>>>>> Please see .kitchen/logs/kitchen.log for more details
>>>>>> Also try running `kitchen diagnose --all` for configuration

如果我尝试运行“厨房登录”,它工作得很好,我认为这表明厨房工具使用的关键算法是完全有效的。

我尝试这样做:

kitchen create

然后,在另一个 shell 中,

kitchen login

登录后,我运行:

sshd -T | grep kex

返回以下内容:

kexalgorithms curve25519-sha256,[email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512

kitchen converge运行相同的命令后返回:

kexalgorithms [email protected],ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256

作为我们安全合规性的一部分,我们的食谱中删除了非安全算法。过去在 RHEL6-8、CentOS 7-8 或 AmazonLinux2 和 2023 上没有发生过此错误。当我开始使用 RHEL9 进行测试时,才开始发生此错误。

我很感激任何能帮助我指明正确方向的事情。

chef
  • 1 个回答
  • 46 Views
Martin Hope
runningraptor
Asked: 2022-10-28 09:32:34 +0800 CST

在 Chef 中更改文件后重新启动服务的命令是什么?

  • 8

我无法找出正确的解决方案,因为只有在更新文件(即服务的 conf 文件)时,服务才会重新启动(停止然后启动)。

这就是我foo.rb文件中的内容。

cookbook_file '/etc/foo/foo.conf' do
  source 'foo.conf'
  action :touch
end

service 'foo' do
  subscribes :restart, 'file[/etc/foo/foo.conf]', :immediately
end

以及我sudo chef-client在服务器上运行后得到的

cookbook_file[/etc/foo/foo.conf] action touch
    - update content in file /etc/foo/foo.conf from 695507 to 06105e

* service[foo] action nothing (skipped due to action :nothing)

据我了解,它识别出文件已更改,但服务未重新启动。

chef
  • 1 个回答
  • 51 Views
Martin Hope
ClickThisNick
Asked: 2019-01-01 07:11:51 +0800 CST

shell命令内的厨师noop

  • 0

如果 bash 命令返回某个值,我想摆脱厨师。

execute 'noop' do
  command <<-EOH
    cmd_output=$(echo "test")
    if [ "$cmd_output" == "test" ]; then
       return
    fi
  EOH
end

我遇到了一个错误return: can only 'return' from a function or sourced script

获取 bash 命令的输出然后基于此返回的最佳方法是什么?

chef
  • 1 个回答
  • 63 Views
Martin Hope
Kevin Buchs
Asked: 2018-02-07 10:42:58 +0800 CST

chef:knife deps - 如何指定食谱版本

  • 1

回复:https ://docs.chef.io/knife_deps.html

使用knife deps --remote选项,我可以查询我们的厨师服务器。刀食谱列表 -a将返回所有食谱版本。如何使用Knife deps查询特定版本的食谱的依赖关系?我尝试了各种分隔符将版本号附加到食谱名称,并且我已经尝试将它们作为单独的参数。试图深入研究 ruby​​ 代码,发现这很难做到——所有这些 gem 的目的和组织都非常不清楚。

chef
  • 2 个回答
  • 807 Views
Martin Hope
FlayRonin
Asked: 2017-10-20 01:46:06 +0800 CST

Chef-Server 12 在节点未时间同步时出现错误

  • 0

当我的节点上的时钟与我的厨师服务器相差 15 分钟时,我收到此错误。

授权错误:

无法向厨师服务器进行身份验证 (http 401)。在此处输入代码`请求失败,因为您的时钟已偏移超过 15 分钟。

将时钟与 NTP 时间源同步应该可以解决问题。

有人知道如何更改服务器上的设置或其他方法以避免此检查吗?谢谢。

chef
  • 2 个回答
  • 1211 Views
Martin Hope
barthelemypousset
Asked: 2017-10-03 03:53:38 +0800 CST

厨师无法找到食谱中存在的文件 - Chef::Exceptions::FileNotFound

  • 1

我正在为在厨师中部署食谱而苦苦挣扎。但是,它没有找到它正在寻找的目录中存在的文件。

我的食谱安装并启动 Apache,然后应该用我生成的简单模板替换默认 index.html,但它在食谱中找不到我修改过的 index.html.erb,所以不要替换它。

这是我的环境:

印刷版,可能有用:

[root@centos-bpo1 cookbooks]# chef --version
Chef Development Kit Version: 2.3.4
chef-client version: 13.4.19
delivery version: master (73ebb72a6c42b3d2ff5370c476be800fee7e5427)
berks version: 6.3.1
kitchen version: 1.17.0
inspec version: 1.36.1

打印我的食谱“httpd_deploy”的内容:

[root@centos-bpo1 cookbooks]# cd httpd_deploy/
[root@centos-bpo1 httpd_deploy]# tree
.
├── Berksfile
├── chefignore
├── httpd_deploy
│   └── templates
│       └── index.html.erb
├── LICENSE
├── metadata.rb
├── README.md
├── recipes
│   └── default.rb
├── spec
│   ├── spec_helper.rb
│   └── unit
│       └── recipes
│           └── default_spec.rb
└── test
    └── smoke
        └── default
            └── default_test.rb

打印配方“httpd_deploy”的内容:

[root@centos-bpo1 httpd_deploy]# cat recipes/default.rb
#
# Cookbook:: httpd_deploy
# Recipe:: default
#
# Copyright:: 2017, The Authors, All Rights Reserved.
package 'httpd'
service 'httpd' do
action [:enable, :start]
end
template '/var/www/html/index.html' do
source 'index.html.erb'
end

打印源文件“index.html.erb”的内容:

[root@centos-bpo1 httpd_deploy]# cat httpd_deploy/templates/index.html.erb
Welcome to Chef Apache Deployment 

我将这本食谱作为本地测试推出:

[root@centos-bpo1 httpd_deploy]# cd ..
[root@centos-bpo1 cookbooks]# chef-client --local-mode --runlist 'recipe[httpd_deploy]'

以下是结果(截断):

[2017-10-02T10:58:22+02:00] ERROR: template[/var/www/html/index.html] (httpd_deploy::default line 10) had an error: Chef::Exceptions::FileNotFound: Cookbook 'httpd_deploy' (0.1.0) does not contain a file at any of these locations:
  templates/centos-7.4.1708/index.html.erb
  templates/centos/index.html.erb
  templates/default/index.html.erb
  templates/index.html.erb
chef
  • 1 个回答
  • 1215 Views
Martin Hope
eternaltyro
Asked: 2017-09-22 23:58:16 +0800 CST

Chef 模板:通过另一个变量查找哈希键

  • 0

我正在尝试为不同的环境构建 nginx 文件。我的食谱有一个像这样的哈希图:

domain = {
  production: {
    public: 'example.com',
    internal: 'example.dev'
  },
  staging: {
    public: 'examplestage.com',
    internal: 'examplestage.dev'
  }
}

template '/etc/nginx/conf.d/example.conf' do
  source 'example.conf.erb'
  variables(
    :domain => domain,
  )
end

在我的模板中,我想做这样的事情:

...
server <%= @domain[node.chef_environment][:public] %> <%= @domain[node.chef_environment][:public] %>;
...

我试图让它评估为这样的东西,具体取决于节点所属的环境staging或production:

server example.com example.dev;

问题是,该node.chef_environment部分没有被插值。我该如何解决这个问题?

chef
  • 1 个回答
  • 1400 Views
Martin Hope
Yuri
Asked: 2017-02-28 11:02:41 +0800 CST

具有外部供应依赖关系的厨师食谱

  • 2

在我见过的所有 Chef 示例中,自动缩放的工作都非常简单——您先配置 DB 主机,然后再配置 Web 服务器。您可以根据需要创建任意数量的网络服务器——它们都将使用相同的数据库主机(无需更改)。

但是,如果我的配方/节点配置说明书需要在其他一些后端节点上进行配置更改怎么办?我怎么能用厨师做到这一点?例如,我有现有的 BGP 路由反射器(鸟),我提供新的鸟边缘节点,并且作为依赖项,我必须生成新的 iBGP 对等配置并​​重新读取 BGP 路由反射器节点上的配置文件。

最佳做法是什么?我应该使用 chef-push-jobs 将更改推送到 BGP 路由反射器节点吗?

chef bird
  • 1 个回答
  • 59 Views
Martin Hope
Jeff W
Asked: 2017-02-21 13:01:42 +0800 CST

使用 chef,我如何确保在客户端之前根据服务器配置服务器?

  • 1

我正在部署一个分布式服务,它在少数节点上使用 NFS 共享。在这种情况下,有一个导出 NFS 共享的主节点和一些必须挂载此导出的从属节点。

使用 chef,我可以配置主节点。主节点完成后,我可以并行配置从节点。但是,如果 chef-client 在所有节点上(大致)同时启动,则从服务器失败,因为服务器上的 NFS 共享尚不存在。

使用chef,如何确保在slave启动之前完成master的配置?我想从服务器暂停(并且可能在几分钟后超时)等待 NFS 导出可用是可以接受的,尽管最好能保证主服务器已完全配置(所有配方/角色) 在允许奴隶上的厨师客户继续之前。

chef chef-zero
  • 1 个回答
  • 65 Views
Martin Hope
Steve K
Asked: 2017-02-11 22:02:30 +0800 CST

如何使用 Chef 在 linux 上创建后台服务?

  • 0

我有一个screen在 ubuntu 主机上使用的 Python 脚本,我想使用 Chef 配方将其转换为适当的后台服务。python 脚本只是启动一个丢弃所有电子邮件的 SMTP 服务器(一个“黑洞”服务器,对测试很有用),然后调用 pythonasyncore.loop()永远运行。

我如何把它变成厨师食谱?我正在使用该cookbook_file资源来上传我的 python 脚本,并且我知道我需要使用该service 资源来启动服务,但我不确定如何实际创建服务。我是否需要在操作系统级别写入文件/etc/init.d或/etc/systemd创建服务,或者是否有一些厨师食谱/资源我可以使用给定的命令调用来为我创建后台服务?

我正在使用 Chef 11.18.12并且无法升级,因此排除了一些需要 12+ 的食谱(如runit )。主机操作系统是 Ubuntu 14.04.3。

这是我到目前为止所得到的:

include_recipe 'apt'
include_recipe 'python'

# the python script to run as a background service    
cookbook_file '/usr/local/bin/smtp_server_blackhole.py' do
  source 'smtp_blackhole_server.py'
  owner 'root'
  group 'root'
  mode '0755'
end

# the init.d file which defines the service? Not sure about this part...
cookbook_file "init.d_smtp_server_blackhole" do
    path "/etc/init.d/smtp_server_blackhole.py"
    source "init.d_smtp_server_blackhole"
    owner "root"
    group "root"
    mode "0755"
end

service "smtp_blackhole_server.py" do
  # this doesn't work, because the command doesn't reference an existing service?
  start_command 'python /usr/local/bin/smtp_blackhole_server.py -c bounce'
  action [ :enable, :start ]

  # I think I need to do something like this, to wait for the init.d file to be written
  subscribes :restart, "cookbook_file[init.d_smtp_server_blackhole]", :immediately
end

潜在的解决方案

  1. daemontools是一个 LWRP,它允许您使用运行命令的模板文件创建服务。但是,它已经有几年没有更新了,它需要您svscan为“适当的 init 系统”设置服务。
  2. 这个问题对于如何使用各种代码示例和 Python 库(例如python-daemon和daemonize)编写 Python 守护程序服务有一些很好的答案,但它不包括如何在厨师食谱中以幂等方式执行操作系统命令.
  3. https://github.com/poise/poise-service看起来像我需要的,但它不支持 Chef 11.18,因为 poise 2.0 需要 Chef 12+。
ubuntu python chef
  • 1 个回答
  • 1002 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve