小编Sau*_*rav的帖子

如何让厨师执行特定用户并加载其环境值

嗨我正在创建一个WCS实例,我必须使用wcs用户(webadmin)执行create instance命令,因为它无法获取所需的env变量而无法连接到DB.

所以我把一些示例代码检查

我使用以下代码

bash "wcs-create-instance" do
    user "webadmin"
    group "webspher"
    code <<-EOH        
        ###{node[:websphere][:wcs][:wcs_installLocation]}/bin/config_ant.sh -DinstanceName=#{node[:websphere][:wcs][:wcs_instance]} CreateInstance  
    whoami > /tmp/whoami
    env > /tmp/env              
EOH
    notifies :run, "bash[fix-permission]", :immediately 
    #This not_if is just temporary, a proper mechanism has to be implemented here to loop through all the WCS APars,
    #For the POC keeping it neat and simple such that this does not rerun on execution
    not_if {File.directory?("#{node[:websphere][:wcs][:wcs_installLocation]}/instances/#{node[:websphere][:wcs][:wcs_instance]}/starterstores")}
    #action :nothing
end
Run Code Online (Sandbox Code Playgroud)

对于whoami我得到了用户

WebAdmin的

但是对于env我得到了用户"root"的env,它没有为env变量获取.bash_profile.有任何想法吗

chef-infra chef-recipe

9
推荐指数
1
解决办法
6564
查看次数

覆盖chef bash返回代码

我正在运行一个厨师收件人来安装Websphere fixpacks.fixpack retuns和exitcode [2]用于部分安装.这是一种预期的行为,但厨师只是将其视为错误.有没有办法覆盖它.

我希望厨师继续完成下一个任务,即使返回退出代码是[2]

================================================================================
Error executing action `run` on resource 'bash[was-install-fixpacks]'
================================================================================


Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '2'
Run Code Online (Sandbox Code Playgroud)

chef-infra chef-recipe

6
推荐指数
1
解决办法
6771
查看次数

无法在厨师中使用not_if

我正在尝试使用bash属性时实现not_if

我正在尝试启动WAS部署管理器,但只有当它没有运行时,我使用一个简单的grep命令来获取正在进行的进程的pid,如下面的日志中所示

#Start the DMGR process
bash "start-dmgr" do
  user "root"
  code %(#{node[:websphere][:was][:was_installLocation]}/bin/startManager.sh)
  not_if ("ps -f|grep dmgr|grep -v grep| awk {'print $2'}")
end
Run Code Online (Sandbox Code Playgroud)

以下是来自Chef客户端的调试日志

当DMGR过程*正在运行*

[2013-06-07T15:13:54-04:00] DEBUG: Skipping bash[was-install-fixpacks] due to not_if command `/apps/websphere/ws70/bin/versionInfo.sh -maintenancePackages | grep `echo /mnt/newInstallers/WAS/APARs/7.0.0.19-WS-WAS-IFPM73674.pak | awk -F '-' '{print $4}' | awk -F '.' '{print $1}'``
Recipe: WAS_NPE::was_startdmgr
  * bash[start-dmgr] action run[2013-06-07T15:13:54-04:00] INFO: Processing bash[start-dmgr] action run (WAS_NPE::was_startdmgr line 2)
1973
 (skipped due to not_if)
Run Code Online (Sandbox Code Playgroud)

当DMGR过程*未运行时*

[2013-06-07T15:31:03-04:00] DEBUG: Skipping bash[was-install-fixpacks] due …
Run Code Online (Sandbox Code Playgroud)

chef-infra chef-recipe

2
推荐指数
1
解决办法
7046
查看次数

安装sensu服务器时,使用厨师食谱配方[sensu :: redis]安装redis时出错

无法使用redisio cookbook安装redis.安装sensu服务器,sensu :: redis cookbook正在尝试安装redis并因以下错误而失败.这里有什么遗漏

Chef::Exceptions::ResourceNotFound
----------------------------------
Cannot find a resource matching service[redis6379] (did you define it first?)


Cookbook Trace:
---------------
  /var/chef/cache/cookbooks/redisio/recipes/enable.rb:25:in `block in from_file'
  /var/chef/cache/cookbooks/redisio/recipes/enable.rb:23:in `each'
  /var/chef/cache/cookbooks/redisio/recipes/enable.rb:23:in `from_file'
  /var/chef/cache/cookbooks/sensu/recipes/redis.rb:23:in `from_file'


Relevant File Content:
----------------------
/var/chef/cache/cookbooks/redisio/recipes/enable.rb:

 18:  # limitations under the License.
 19:  #
 20:
 21:  redis = node['redisio']
 22:
 23:  redis['servers'].each do |current_server|
 24:    server_name = current_server["name"] || current_server["port"]
 25>>   resource = resources("service[redis#{server_name}]")
 26:    resource.action Array(resource.action)
 27:    resource.action << :start
 28:    resource.action << :enable
 29:  end
 30:
Run Code Online (Sandbox Code Playgroud)

chef-infra sensu

1
推荐指数
1
解决办法
1059
查看次数

标签 统计

chef-infra ×4

chef-recipe ×3

sensu ×1