chef

how to run a java program at background from chef recipe

大憨熊 提交于 2019-11-29 05:16:50
I am a chef rookie. I want to create a recipe to run a jar at background. bash 'run_jar' do code <<-EOH wget https://github.com/kiwiwin/jar-repo/releases/download/kiwi/helloworld-1.0.jar -O hello.jar java -jar hello.jar & EOH end The helloworld-1.0.jar is a program first print "Hello World", then execute a while(true) loop. I expect when I login to the chef-client machine. It should indicate there is a jar running using "jps" command. But there is no such jar running. And I can see the hello.jar is downloaded which indicates the code block has been executed already. What's wrong with this

How to use chef to update-alternatives for java using execute?

送分小仙女□ 提交于 2019-11-29 05:13:59
I am having syntax errors and I am unsure how to resolve them. In the roles file I have defined the fallowing: default_attributes( 'jdk' => { 'version' => '1.8.0_31' }, 'java' => { 'home' => '/usr/lib/jvm/jdk1.8.0_31' }, ) I try to use the java home in the following, but it fails to run execute "update_alt_java" do command "update-alternatives --install "/usr/bin/java" "java" "#{node['java']['home']}/bin/java" 1" action :creates end I get the following error SyntaxError ----------- /etc/chef/src/cookbooks/jdk/recipes/default.rb:50: syntax error, unexpected tSTRING_BEG, expecting keyword_do or

Access Node attributes in Chef Library

℡╲_俬逩灬. 提交于 2019-11-29 03:07:08
问题 I'd like to create a Chef library that: Provides a few namespaced functions Accesses the node's attributes That library is meant to interface with an external system and retrieve some inputs from there. I need to access the node attributes to allow the user to override the inputs received from the external system: Desired Usage (Recipe) inputs = MyLib.get_inputs Library (What I have now) This is inspired by those docs. class Chef::Recipe::MyLib def self.get_inputs override_inputs = node.fetch

use ssh keys with passphrase on a vagrant+chef setup

心已入冬 提交于 2019-11-29 02:32:44
问题 I've got a vm running using vagrant, and I'm provisioning it with Chef. One of the steps involves cloning a git repo, but my ssh-key (on my host machine) has a passphrase on it. When I run vagrant up , the process fails at the git clone step with the following error: Permission denied (publickey). fatal: The remote end hung up unexpectedly (The key has been added on the host machine, with the passphrase) I tried to solve this with ssh agent forwarding by doing the following: Added config.ssh

What does `Chef::Config[:file_cache_path]` do exactly?

痴心易碎 提交于 2019-11-29 01:44:59
问题 First off, I apologize for asking such a dumb question. But the reason I ask is because I'm having a hard time finding an answer. I've tried searching Chef's docs, but I have not found a clear explanation. So what exactly does Chef::Config[:file_cache_path] provide? I've read that its better to use this instead of harding coding a filepath. But what does it evaluate to? In this particular snippet newrelic_agent = Chef::Config[:file_cache_path] + '/rewrelic_nginx_agent.tar.gz' remote_file

Git authentication in Chef

限于喜欢 提交于 2019-11-28 19:12:58
When deploying an application with Chef, I've got the code base set to be cloned from a private github repository with the following resource: git '/mnt/application' do repository 'git@github.com:organization/repository' reference 'master' action :sync user node.application.user group node.application.user end However, after scanning the documentation for the git resource, I can't see how you supply the key file for authentication. I'm also confused as to how to store this key in a data bag, as the file contains a bunch of new lines. Any ideas? psamaan ssh_wrapper "ssh -i /some/path/id_rsa" In

Chef and Puppet recommendations [closed]

自作多情 提交于 2019-11-28 18:00:45
问题 I'd like to ask about when and in what circumstances you'd use puppet and when you'd use chef. I've also found rump which is a puppet-solo type of thing where you iterate a single server to its configuration and then push that to a series of servers, allowing you to see changes directly. My question: which of the above should I use and in what ways? Could someone help me? My aim is in the context of continuous integration, continuous deployment in a mono/.Net environment with rake and git. I

Docker for GUI-based environments?

萝らか妹 提交于 2019-11-28 16:06:14
Problem I have a set of client machines that are a part of an enterprise web application. Each machine runs identical software, which is a PyQT-based web client that connects to a server. This client software is updated regularly and I would like to have some configuration/provisioning tool that allows to have the same environment on each machine and hence provide easy deployment and configuration of the software onto each of the clients' machines. The problem is that I have tried to use Chef, but it takes a lot of effort to actually maintain Chef knowledge and skills (we do not have a

To setup chef workstation

♀尐吖头ヾ 提交于 2019-11-28 14:44:40
Trying to setup chef workstation knife configure -i previous it worked but now its not working i am unable to create knife.rb it says the following error: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.0/lib/chef/config_fetcher.rb:53:in `realpath': Not a directory - /home/ubuntu/.chef/knife.rb (Errno::ENOTDIR) from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.0/lib/chef/config_fetcher.rb:53:in `realpath' from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.0/lib/chef/config_fetcher.rb:53:in `config_missing?' from /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.10.0

How do you abort/end a Chef run?

我怕爱的太早我们不能终老 提交于 2019-11-28 14:44:10
问题 Under certain conditions, I need to abort/end a Chef run with a non-zero status code, that will then propagate back through our deployment chain and eventually to Jenkins resulting in a big, fat red ball. What is the best way to do this? 回答1: For the readers coming to this question and answer in the future that may not be familiar with Chef, a Chef run "converges" the node, or brings it in line with the policy declared in the recipe(s) it is running. This is also called "convergence." This