草庐IT

chef-validator

全部标签

ruby - 使用 Knife 更新 Chef 中的运行列表

我有一本包含Recipe列表的Recipe。在chefknife中使用命令行工具从Recipe中添加一些特定Recipe(不是全部)的命令是什么?我知道将整个Recipe添加到运行列表的命令是knifenoderun_listaddservernamerecipe[cookbookname]。 最佳答案 所以你的想法是对的,knifenoderun_listadd$nodename$item就是你想要的命令。recipe[mycookbook]没有添加“整个Recipe”,而只是recipe[mycookbook::default]

ruby - Chef 11 : any way to turn attributes into a ruby hash?

我在chef属性中为我的服务生成一个配置。但是,在某些时候,我需要将属性混搭转换为简单的ruby​​散列。这曾经在Chef10中运行良好:node.myapp.config.to_hash但是,从Chef11开始,这不起作用。只有属性的顶层被转换为散列,然后嵌套值仍然是不可变的混搭对象。修改它们会导致如下错误:Chef::Exceptions::ImmutableAttributeModification------------------------------------------------Nodeattributesareread-onlywhenyoudonotspecif

ruby - Chef - 使用动态变量创建模板?

我在ChefRecipe上遇到了一些挑战。我是Chef的新手,所以请多多包涵。第1步:我的ChefRecipe安装了RubyPassenger,然后将Passengernginx模块与Nginx一起编译。#Installpassengerandnginxmodulebash"InstallPassenger"docode0}end#Installpassenger#NotethatwehavetoexplicitlyincludetheRVMscriptotherwiseitwon'tsetuptheenvironmentcorrectlybash"Installpassengerng

ruby - Chef 和 ruby​​ 模板——如何遍历键值对?

1)我有一个数据包如下:"zookeeper":{"server1":"111.111.111.111","server2":"222.222.222.222"},2)在我的Recipe中,我得到的散列如下。data_bag("mydb")db=data_bag_item("mydb","rtb")ZOOKEEPER=db['zookeeper']3)在我的Recipe中还有一个模板如下:template"/etc/zookeeper/conf/zoo.cfg"dopath"/etc/zookeeper/conf/"source"zoo.cfg.erb"owner"root"group

ruby - 如何使用 Chef 设置环境变量?

有一个与此类似的问题,但无法使其正常工作:我想简单地设置一个环境变量,然后使用它:execute"startzookeeper"docwd"/opt/zookeeper-3.4.5/bin"command"./zkServer.shstart"environment"JVMFLAGS"=>"-Xmx#{heap_jvm}-Xms#{heap_jvm}"user"root"action:runend我也尝试过使用bash来"exportJVMFLAGS='-blabla'"但它仍然运行sh而没有设置变量。是否存在阻止我的sh脚本检查变量的问题?我可以像模板一样使用sh并替换JVMFLAG

ruby - Chef : cannot load such file -- moneta/basic_file

我正在运行一个我以前使用过无数次的Recipe,当我用chef+knife启动一个新的EC2实例时,我遇到了这些错误。[2013-01-30T23:44:48+00:00]INFO:Processinguser[dan]actioncreate(/var/chef/cache/cookbooks/users/providers/manage.rbline65)[2013-01-30T23:44:48+00:00]INFO:user[dan]created[2013-01-30T23:44:48+00:00]INFO:Processingdirectory[/home/dan/.ssh]

ruby-on-rails - Ruby on Rails : How to validate nested attributes on certain condition?

我有这些模型:classOrganisation:addressable,:dependent=>:destroyaccepts_nested_attributes_for:address,:allow_destroy=>trueendclassPerson:addressable,:dependent=>:destroyaccepts_nested_attributes_for:address,:allow_destroy=>true#Thesetwomethodsseemtohavenoeffectatall!validates_presence_of:organisation,:

ruby-on-rails - rails : Using form fields that are unassociated with a model in validations

在RubyonRails应用程序中,我尝试使用来自与验证模型无关的字段的信息。这里以模型的一部分为例(整个模型有点大):classScorecard那么如何从模型中访问params呢? 最佳答案 不要让参数偷偷靠近模型。在这种情况下没有Controller的意义。相反,从Railscasts查看这一集它讨论了不进入数据库但仍可用于验证的虚拟属性。虚拟属性不需要相应的模型属性。定义类的局部属性,例如保存状态的@no_fairways。classScoreCard现在在你的表单中,你可以写:

ruby - 检查 Chef 中是否存在嵌套属性的正确方法是什么?

有多种方法可以检查Chef中是否存在嵌套属性,我不确定哪种方法是正确的/最好的,如果有的话会导致空属性存储在节点上:node[:parent]andnode[:parent][:child]node.attribute?(:parent)andnode[:parent].attribute?(:child))node[:parent].nil?andnode[:parent][:child].nil?如果能够同时检查父项和子项会更好,但我不知道这是否可能。我使用的是Chef10,而不是Chef11,但欢迎回答解释这两个问题。 最佳答案

ruby - "Error validating client secret."404 与 Facebook Oauth 和 ruby

我正在尝试使用warden为应用程序实现facebook身份验证,在用户允许facebook身份验证并使用token重定向到我的应用程序回调后,我在使用api时得到400。我的典狱长策略是这样的:classFacebook'https://graph.facebook.com'enddefparams@params||=Rack::Utils.parse_query(request.query_string)enddefauthorize_urlclient.web_server.authorize_url:redirect_uri=>request.url,:scope=>'emai