Ter*_*ang 1 ruby chef-infra chef-recipe chef-solo
我和Roles一起玩Solo(11.4.4和11.6.0).有点困惑.
根据官方文档:关于角色,角色可以存储为特定于域的Ruby(DSL)文件或JSON数据.
注意:
chef-client使用Ruby for Roles,当这些文件上载到Chef Server时,它们将转换为JSON.每当刷新chef-repo时,所有特定于域的Ruby文件的内容都会重新编译为JSON并重新上载到服务器.
我的问题是,如果要求是在没有服务器且需要角色的情况下以独奏模式运行Chef,那么角色应该用Ruby还是JSON编写(我们没有服务器将Ruby转换为JSON)?
我的猜测是后者.有谁知道正确的答案?
BTW:我见过人们在角色文件中混合使用Ruby和JSON ......
例如,运行rbenv+ ruby-buildcookbook在Ubuntu上安装rbenv.
rbenv.json
{
"run_list": ["role[rbenv]"]
}
Run Code Online (Sandbox Code Playgroud)
角色/ rbenv.rb
name "rbenv"
description "rbenv + ruby-build"
run_list(
"recipe[rbenv]",
"recipe[ruby_build]"
)
override_attributes(
:rbenv => {
:git_repository => "https://github.com/sstephenson/rbenv.git"
},
:ruby_build => {
:git_repository => "https://github.com/sstephenson/ruby-build.git"
}
)
Run Code Online (Sandbox Code Playgroud)
Chef Solo run chef-solo -c solo.rb -j rbenv.json -l debug按预期工作.这是通过HTTPS实现克隆,因为它更容易在防火墙后面.
但是,使用Ruby DSL版本的角色rbenv.rb如下所示
name "rbenv"
description "rbenv + ruby-build"
run_list "recipe[rbenv]", "recipe[ruby_build]"
# default_attributes ":rbenv" => {":install_prefix" => "/opt"}
override_attributes ":rbenv" => {":git_repository" => "https://github.com/sstephenson/rbenv.git"}, ":ruby_build" => {":git_repository" => "https://github.com/sstephenson/ruby-build.git"}
Run Code Online (Sandbox Code Playgroud)
它似乎没有用,因为它仍然使用默认属性(通过git URL而不是HTTPS克隆).
我是Ruby的新手,所以我很可能在DSL代码中犯了一些错误,请帮忙;-)
* git[/opt/rbenv] action sync[2013-09-03T03:44:53+00:00] INFO: Processing git[/opt/rbenv] action sync (rbenv::default line 91)
[2013-09-03T03:44:53+00:00] DEBUG: git[/opt/rbenv] finding current git revision
[2013-09-03T03:44:53+00:00] DEBUG: git[/opt/rbenv] resolving remote reference
================================================================================
Error executing action `sync` on resource 'git[/opt/rbenv]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '128'
---- Begin output of git ls-remote "git://github.com/sstephenson/rbenv.git" master* ----
STDOUT:
STDERR: fatal: unable to connect to github.com:
github.com[0: 192.30.252.128]: errno=Connection timed out
---- End output of git ls-remote "git://github.com/sstephenson/rbenv.git" master* ----
Ran git ls-remote "git://github.com/sstephenson/rbenv.git" master* returned 128
Run Code Online (Sandbox Code Playgroud)
我希望尽可能使用JSON格式,原因很简单 - 使用脚本很容易解析和验证.如果所有Chef数据都是JSON格式,您可以执行以下三项操作:
--format json论点在这里很有用.| 归档时间: |
|
| 查看次数: |
2852 次 |
| 最近记录: |