首页 > 解决方案 > 如何在 Chef 中创建测试用户,以便 Pedant (chef-server-ctl test) 可以使用它们

问题描述

chef-server-ctl test每隔一段时间在我的厨师服务器上运行一次,以测试一切是否正常。我使用此测试的输出来使用监控软件监控厨师服务器。但我观察到,即使在 Pedant 的配置中(chef-server-ctl test正在使用),它位于/var/opt/opscode/oc-chef-pedant/etc/pedant_config.rb我有:

delete_org true

chef-server-ctl test运行多次后仍有一些剩菜。我所说的剩菜是指chef-server-ctl test为测试而创建但没有删除的组织和用户:

[example@example /]# chef-server-ctl user-list
pedant_nobody_chef_26547
pedant_testorg_chef_26547_owner
pedant_testorg_chef_30029_owner
pedant_user_chef_26547
pivotal
test-26547

有时 Pedant 正在删除它们,有时它们在测试后仍然没有被删除。我不知道这取决于什么。但这就是为什么我认为我将禁用测试组织的创建,/var/opt/opscode/oc-chef-pedant/etc/pedant_config.rb而是使用现有的组织。我想对用户做同样的事情。但是pedant_config.rb声明它需要五个不同的用户:

# Test users.  The five users specified below are required; their
# names (:user, :non_org_user, etc.) are indicative of their role
# within the tests.  All users must have a ':name' key.  If they have
# a ':create_me' key, Pedant will create these users for you.  If you
# are using pre-existing users, you must supply a ':key_file' key,
# which should be the fully-qualified path /on the machine Pedant is
# running on/ to a private key for that user.

superuser_name 'pivotal'

requestors({
             :clients => {
               :admin => {
                 :name => "pedant_admin_client_#{chef_server_uid}",
                 :create_me => true,
                 :create_knife => true,
                 :admin => true
               },
               :non_admin => {
                 :name => "pedant_client_#{chef_server_uid}",
                 :create_me => true,
                 :create_knife => true,
               },
               :bad => {
                 :name => "bad_client_#{chef_server_uid}",
                 :create_me => true,
                 :bogus => true
               }
             },

             :users => {
               # An administrator in the testing organization
               :admin => {
                 :name => "pedant_admin_user_#{chef_server_uid}",
                 :create_me => true,
                 :create_knife => true,
                 :admin => true
               },

               :non_admin => {
                 :name => "pedant_user_#{chef_server_uid}",
                 :create_me => true,
                 :create_knife => true,
                 :admin => false
               },

               # A user that is not a member of the testing organization
               :bad => {
                 :name => "pedant_nobody_#{chef_server_uid}",
                 :create_me => true,
                 :create_knife => true,
                 :associate => false
               },
             }
           })

而且我了解如何创建将成为测试组织中的管理员的用户(pedant_admin_user_#{chef_server_uid}截至目前在配置中),如何创建将成为一部分或组织但不是管理员(pedant_user_#{chef_server_uid})的用户,以及不会成为成员的用户检测机构(pedant_nobody_#{chef_server_uid})。但是如何从“ :clients =>”部分创建所有这些用户,而不是“ :users =>”?我的意思是那些有名字的人:

pedant_admin_client_#{chef_server_uid}
pedant_client_#{chef_server_uid}
bad_client_#{chef_server_uid}

这个配置对客户端意味着什么以及如何创建它们?

标签: chef-infra

解决方案


不要那样做。Pedant 不适合持续使用。它是一个一致性套件,用作打包过程的一部分。它不供公众使用,也绝对不用于真正的 Chef Server 实例。

如果您想检查事情是否正在运行,请尝试chef-server-ctl status:)


推荐阅读