chef-recipe

How can you use a Chef recipe to set an environment variable?

一笑奈何 提交于 2019-12-17 10:44:27
问题 How can you use a Chef recipe to set an environment variable? I need to set an environment variable using a Chef recipe. Can you provide an example of how to accomplish this? 回答1: If you need an env var set strictly within the Chef process, you can use ENV['foo'] = 'bar ' since it's a ruby process. If you need to set one for an execute provider, Chef exposes an environment hash: execute 'Bootstrap the database' do cwd "#{app_dir}/current" command "#{env_cmd} rake db:drop db:create db:schema

How can I change a file with Chef?

人盡茶涼 提交于 2019-12-17 07:18:28
问题 I have 7 files and 1 war. I need to change values when I deploy them. I have this: ##usuario #alfresco.user=***** alfresco.user=******** ##pass #alfresco.password= sfsfs alfresco.password=sfgsf alfresco.rutaAnexos=/gthtfdh/dfgdf/cm: #atributo.type.anexo=ANEXO_INFO_OBJETO atributo.type.anexo=AN atributo.type.observaciones=OBSERVACIONES I need to comment some lines and uncomment some other lines. Then I need to make seven templates and put variables depending on the environments and create a

How can I write a chef recipe to create a new user and password in the Nodes automatically?

你离开我真会死。 提交于 2019-12-13 22:26:30
问题 I'm new to chef. Kindly help! I have tried this user "newuser" do password: xyz end and user 'newuser' do comment 'A random user' uid '1234567' gid '1234567' home '/home/saxuser' shell '/bin/bash' password 'newpassword' end 回答1: The correct format for the user resource is the following: user "newuser" do password crypt_password end Keep in mind that the password must be in shadow format: The password shadow hash. This property requires that ruby-shadow be installed. This is part of the Debian

Chef Vault user creation

醉酒当歌 提交于 2019-12-13 07:29:17
问题 Is there a way to override chef-vault from creating users alphabetically? In order words, if i have a user alf,bob,cain and dave in my vault, is it possible to have user cain get created before alf? 回答1: The admins of a vault are always displayed as a sorted list: $ knife vault show secrets app1 -p admins admins: alf bob cain dave id: app1 .. .. But why should that matter functionally? When accessing the vault each admin user or chef node will be authenticating once, using their private key.

Chef conditional resource argument

為{幸葍}努か 提交于 2019-12-13 01:39:20
问题 I'm creating a user via Chef. His properties are stored in data bag: { "id": "developer", "home": "/home/developer", "shell": "/bin/zsh", "password": "s3cr3t" } The recipe is: developer = data_bag_item('users', 'developer') user developer['id'] do action :create supports :manage_home => true home developer['home'] comment developer['comment'] shell developer['shell'] password developer['password'] end The problem is that if zsh is not installed on node, I cannot login as developer . So, I

Chef NOT_IF and ONLY_IF validation issue in Windows recipes

核能气质少年 提交于 2019-12-12 10:04:07
问题 Im runing this simple recipe block to create a web app in IIS powershell_script "create_site_my_site" do code "New-webapppool -name 'My_Web_App'; New-Website -Name 'My_Web_App' -applicationpool 'My_Web_App' -Port '80' -IPAddress * -PhysicalPath 'c:\webs\My_Web_App' " action :run not_if "get-website | where-object { $_.name -eq 'My_Web_App' }" end The problem here its that the NOT_IF part its allways True PS C:\Users\carlos> PS C:\Users\carlos> get-website | where-object { $_.name -eq

Chef: Enabling Jenkins security causes plugin installation to fail

假装没事ソ 提交于 2019-12-12 06:46:09
问题 I am currently using Chef to deploy a Jenkins instance on a managed node. I am using the following public supermarket cookbook: https://supermarket.chef.io/cookbooks/jenkins . I am using the following code in my recipe file to enable authentication: jenkins_script 'activate global security' do command <<-EOH.gsub(/^ {4}/, '') import jenkins.model.* import hudson.security.* def instance = Jenkins.getInstance() def hudsonRealm = new HudsonPrivateSecurityRealm(false) hudsonRealm.createAccount(

Chef recipe execution order

那年仲夏 提交于 2019-12-12 05:04:07
问题 following is a recipe which I use to copy and install a software on my windows server. batch "Get installed software list" do code "wmic /output:C:\\InstallList.txt product get name,version" end if File.read('C:/InstallList.txt', mode: 'r:BOM|UTF-16:UTF-8') =~ /.NET Framework 4/ print "Dotnet framework 4 is already installed." else remote_file 'c:/repo/dotNetFx40_Full_x86_x64.exe' do source 'file:////10.132.17.53/e$/CHEFREPO/dotNetFx40_Full_x86_x64.exe' end batch "Install Dotnet" do cwd 'c:

Chef Mysql recipe fails

时间秒杀一切 提交于 2019-12-12 04:46:26
问题 Im using the latest Chef 'MYSQL' recipe on Centos7 requiring in a standard role like so name "lamp" description "A full lamp server" run_list "recipe[apache2]", "recipe[apache2::mod_php5]", "recipe[apache2::logrotate]", "recipe[yum]", "recipe[yum-epel]", "recipe[mysql::client]", "recipe[mysql::server]" override_attributes({ "starter_name" => "Jonathan Tizard", "mysql" => { "server_root_password" => 'iloverandompasswordsbutthiswilldo', "server_repl_password" =>

Chef convergence fails with ERROR: Unable to determine node name: configure node_name or configure the system's hostname and fqdn

元气小坏坏 提交于 2019-12-12 03:28:38
问题 My server fails to converge with the following messages. I am unable to figure where this error is coming from. I am copying and pasting the chef stacktrace AFTER the client.log messages below: Weird thing is that the client.rb file stacktrace is refering to does not even exist on this box. Any help will be appreciated! [root@xyz chef]# tail client.log * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * [2016-04-21T11:47:24-06:00] INFO: *** Chef 11.12.8 *** [2016