chef

Vagrant + Chef: Error in provision “Shared folders that Chef requires are missing on the virtual machine.”

本秂侑毒 提交于 2019-12-02 16:53:20
I've installed a Vagrant + Virtualbox using Chef (+library chef). When I do vagrant up first time, cookbooks get loaded correctly. However, when I do provision afterwards (be it vagrant provision , vagrant reload --provision or vagrant up --provision I get this error: Shared folders that Chef requires are missing on the virtual machine. This is usually due to configuration changing after already booting the machine. The fix is to run a `vagrant reload` so that the proper shared folders will be prepared and mounted on the VM. I searched everywhere and the only solution given is to do vagrant

How can I get Chef to run apt-get update before running other recipes

久未见 提交于 2019-12-02 16:08:29
Right now I have the following in my Vagrantfile: config.vm.provision :chef_solo do |chef| chef.cookbooks_path = "cookbooks" chef.add_recipe "apt" chef.add_recipe "build-essential" chef.add_recipe "chef-redis::source" chef.add_recipe "openssl" chef.add_recipe "git" chef.add_recipe "postgresql::server" chef.add_recipe "postgresql::client" end In order to install the software added to my recipe_list, I need to get the VM to issue an apt-get update before installing the other software. I was under the impression that this was one of the features of the 'apt' recipe - that it would run the update

How to match a path with the first five characters [duplicate]

不羁的心 提交于 2019-12-02 15:51:18
问题 This question already has answers here : Split the string to get only the first 5 characters (2 answers) Closed last year . I have to reach the location /var/log/acpchef/commv123 , where 123 can change to 456 . I tired Dir.glob . I need /var/log/acpchef/commv*** . My execution will be in mixlibshellout . begin cwd_kernel = Dir.glob('/var/cache/acpchef/commv***') cmd = Mixlib::ShellOut.new("commandrun", :cwd => cwd_kernel) cmd.run_command log 'run' end 回答1: This will match a filenename with

Vagrant provisioning shell vs puppet vs chef

感情迁移 提交于 2019-12-02 14:39:25
I have the following setup: Many different projects which are separate git repositories, but all have mostly the same server configuration Each project in turn depends on many other projects and we use the composer dependency manager to get them together (PHP language here). I want to use Vagrant and include a Vagrant file in each repository, so my team members can clone a repository, run vagrant up and be ready to go. My question is now directed towards the provisioning. I need to install several tools and packages like apache, git, mysql and several php packages, then download some files

How to match a path with the first five characters [duplicate]

一笑奈何 提交于 2019-12-02 12:39:07
This question is an exact duplicate of: Split the string to get only the first 5 characters 2 answers I have to reach the location /var/log/acpchef/commv123 , where 123 can change to 456 . I tired Dir.glob . I need /var/log/acpchef/commv*** . My execution will be in mixlibshellout . begin cwd_kernel = Dir.glob('/var/cache/acpchef/commv***') cmd = Mixlib::ShellOut.new("commandrun", :cwd => cwd_kernel) cmd.run_command log 'run' end This will match a filenename with the first five characters and anything after that: Dir.glob('/var/cache/acpchef/commv*') # will match /var/cache/acpchef

Vagrant & Chef - Cookbook *** not found

久未见 提交于 2019-12-02 11:51:25
I am trying to set up a simple development VM using vagrant and Chef as a provisioner. I am able to install chef using shell provisioner but it seems to me that the folder with chef recipes does not get mounted to the VM. It keeps complaining that cookbook *** not found. Here is my vagrant file and output I am getting # -*- mode: ruby -*- # vi: set ft=ruby : Vagrant::Config.run do |config| # This strange method defines the name of the Vagrant Machine config.vm.define "SubscriptionAPI" do |foobar| end # Every Vagrant virtual environment requires a box to build off of. config.vm.box = "chef

Chef: Undefined node attribute or method `<<' on `node' when trying to add

风流意气都作罢 提交于 2019-12-02 10:26:55
问题 In my attributes file for postgresql recipe I have: default['postgresql']['pg_hba'] = { :comment => '# IPv4 local connections', :type => 'host', :db => 'all', :user => 'all', :addr => '127.0.0.1/32', :method => 'md5' } I want to my recipe automatically add my servers to pg_hga config file like this: lambda { if Chef::Config[:solo] return (Array.new.push node) end search(:node, "recipes:my_server AND chef_environment:#{node.chef_environment} ") }.call.each do |server_node| node['postgresql'][

How to determine if any file in a directory has changed

我是研究僧i 提交于 2019-12-02 10:09:45
问题 Is there a way for Chef to determine if it has changed any file in a given directory? I'd like to restart a server process if any settings in a conf.d directory are updated. I'm sure it's possible to write a list of md5sums to a file on each chef-client run, and compare current to previous iterations. But that's a fair bit of code to address what seems to be a common scenario. Is there a better way? 回答1: Chef provides a concept called notifications. This allows you to define that a change in

node search is giving nothing in test kitchen

﹥>﹥吖頭↗ 提交于 2019-12-02 08:21:39
No output from search in test kitchen Throwing error check the recipe and suggest me some details Node JSON file { "id": "cldb", "chef_type": "node", "json_class": "Chef::Node", "run_list": [], "automatic": { "hostname": "cldb.net", "fqdn":"127.0.0.1", "name": "cldb.net", "ipaddress": "127.0.0.1", "roles": [], "cldb" : true } } Recipe cldbNodes = search(:node, "cldb:true") cldb = "#{cldbNodes["fqdn"]}" file '/tmp/test.txt' do content "#{cldb}" end To summarize from the comments above, search(...) returns an array so you need to get a specific element, usually the first, before you can access

How run cookbook with dependencies in chef?

a 夏天 提交于 2019-12-02 08:16:02
问题 I have configured workstation up this step in get started (OS redhat 6.5). I have launched a node. I modified a cookbook like that: myCookbook/metadata.rb name 'myCookbook' maintainer 'YOUR_COMPANY_NAME' maintainer_email 'YOUR_EMAIL' license 'All rights reserved' description 'Installs/Configures myCookbook' long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) version '0.1.0' depends 'maven' E.g. only depends 'maven' string was added after knife cookbook create myCookbook