Dereklai chef | 27 Feb 01:01 2015
Picon

migration from Chef on aws to Chef on OpenStack

Hi


It would seem like there should be others who have blazed this trail already.

We are migrating from Chef on AWS to Chef on OpenStack. So others in the company is working on standing up an OpenStack environment. I'm trying to figure out what we need to do to get our cookbooks working in the OpenStack environment.

I'm told that OpenStack has a lot of AWS emulation so there is very little work needed to get the cookbooks working. Is this really true?

My cookbook is currently using the aws_ebs_volume resource and aws_s3_file resource from the aws cookbook from github. Is there already a cookbook/resource that I can use in place of these?

Any and all pointers appreciated!


Derek


Medya | 26 Feb 22:32 2015
Picon

which resource to use to create a user like this "ORAINST ALL= NOPASSWD: /bin/su - orainst"

the user resource does not do what I wanna do

I wanna have the following in my soduers file

User_Alias     FULLTIMERS = appsautm"
User_Alias      ORAINST = orainst"
FULLTIMERS      ALL =NOPASSWD: ALL
ORAINST    ALL=(orainst) NOPASSWD: ALL
ORAINST    ALL= NOPASSWD: /bin/su - orainst

I looked at the sudoer's cookbook but I didnt figure out how to use it
Anthony Kong | 26 Feb 20:35 2015
Picon

How to ignore some exception in a cookbook


In one of my receipt I need to install a gem

gem hipchat do
  action: install
end

However from time to time it fails due to network or other issue. 

I do not want it to fail the overall installation process. I would rather have the whole provision completed and then go in later and fix it manually myself.

Is there any way I can prevent its failure from stopping the convergence? 

Cheers
Sachin Gupta | 26 Feb 19:53 2015
Picon

Read windows registry Key values

Hi All,

I am working on a use case where I need to read two registry key values and compare there data in a recipe

HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\ComputerName\\ActiveComputerName

HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Control\\ComputerName\\ComputerName

both are having a value name(ComputerName) and value data(may be same or different). I need to compare there value data.

Do I need to write like this:; or some other better way??

Win32::Registry::HKEY_LOCAL_MACHINE.open(keynameComp, access) do |reg|
reg.each{|name, value, keys | compName = keys}
end
Win32::Registry::HKEY_LOCAL_MACHINE.open(keynameActive, access) do |reg|
reg.each{|name, value, keys | compNameActive = keys}
end


Any idea??


Thanks & Regards,
Sachin Gupta
Fabien Delpierre | 26 Feb 18:40 2015
Picon

Malformed array causing Chef to error out

Hi there,
I can't figure out what I'm doing wrong with this. It seems trivial enough but I'm not a software developer and this is puzzling me right now. I think my issue has more to do with pure Ruby than Chef but either way, I can't figure it out.
If it matters, I'm working with chef-solo 12.0.3 and provisioning things via Vagrant 1.7.2.

I'm doing something that should be pretty straightforward: creating a number of directories declared in an array:

dirs = [ Chef::Config[:data_bag_path], "#{Chef::Config[:data_bag_path]}/#{node['data_bag']}" ]

dirs.each do |dir|
  directory dir do
    owner "foo"
    group "foo"
    mode 00440
    recursive true
    action :create
  end
end


This results in the following error during provisioning
==> default: Compiled Resource:
==> default: ------------------
==> default: # Declared in /tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/cookbooks/nap/recipes/default.rb:90:in `block in from_file'
==> default:
==> default: directory("["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data_bags"]") do
==> default:   action [:create]
==> default:   retries 0
==> default:   retry_delay 2
==> default:   default_guard_interpreter :default
==> default:   path ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data_bags"]
==> default:   recursive true
==> default:   declared_type :directory
==> default:   cookbook_name :nap
==> default:   recipe_name "default"
==> default:   owner "foo"
==> default:   group "foo"
==> default:   mode 288
==> default: end
==> default:
==> default: [2015-02-26T12:09:20-05:00] INFO: Running queued delayed notifications before re-raising exception
==> default: [2015-02-26T12:09:20-05:00] ERROR: Running exception handlers
==> default: [2015-02-26T12:09:20-05:00] ERROR: Exception handlers complete
==> default: [2015-02-26T12:09:20-05:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
==> default: [2015-02-26T12:09:20-05:00] ERROR: directory[["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data_bags"]] (nap::default line 90) had an error: Chef::Exceptions::ValidationFailed: Option path must be a kind of String!  You passed ["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data_bags"].
==> default: [2015-02-26T12:09:21-05:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)


I ran this through chef-shell as well:
$ chef-shell -s -c solo.rb
loading configuration: solo.rb
Session type: solo
Loading.............done.
Ohai2u vagrant <at> nap-cookbook!
chef > puts Chef::Config[:data_bag_path]
/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data_bags
 => nil
chef > dirs = [ Chef::Config[:data_bag_path], "#{Chef::Config[:data_bag_path]}/#{node['foo']['bar']}" ]
NoMethodError: undefined method `[]' for nil:NilClass
    from (irb):3
    from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:75:in `block in start'
    from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:74:in `catch'
    from /opt/chef/embedded/apps/chef/lib/chef/shell.rb:74:in `start'
    from /opt/chef/embedded/apps/chef/bin/chef-shell:37:in `<top (required)>'
    from /usr/bin/chef-shell:40:in `load'
    from /usr/bin/chef-shell:40:in `<main>'
chef > dirs = []
 => []
chef > dirs = [ Chef::Config[:data_bag_path] ]
 => [["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data_bags"]]
chef > puts dirs
/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data_bags
 => nil
chef > dirs = [ Chef::Config[:data_bag_path], "#{Chef::Config[:data_bag_path]}/test" ]
 => [["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data_bags"], "[\"/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data_bags\"]/test"]
chef > puts dirs
/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data_bags
["/tmp/vagrant-chef/c0f72feb81f20d85ca657a73371fcecb/data_bags"]/test
 => nil
chef >


So as you can see in the above output, it's adding brackets around some of the things stored in the array and that seems to be why the Chef run is failing, but I don't understand why adding the brackets to begin with.

I also have no idea why this line produces an error:
chef > dirs = [ Chef::Config[:data_bag_path], "#{Chef::Config[:data_bag_path]}/#{node['foo']['bar']}" ]

Would somebody please mind explaining what I'm doing wrong? Thank you!
Jimmy Huang | 26 Feb 08:30 2015

Chef Web Manager Data Bag Output Not Matching Knife Data Bag Output

Our users data bag on the web manager is out of sync with what we see from this command:

$ knife data bag show users 

Whereas I see 75 users listed when I use the knife command, I only see 15 on the web manager.  When I ran `knife download .` on my laptop, I am able to download all 75 user json files under the data_bags/users folder.  We are currently running Chef server at API version 12.0.0 on a private subnet on AWS.

If I were to "edit" a users data bag item and close the file without making any change, the missing users data bag item would reappear on the web manager upon refresh.  For example:

1.  User "aaron" is currently missing from the users data bag on the web manager;

2.  knife data bag edit users aaron

3.  Simply close the text editor without making any change.  The update will be committed on the Chef server;

4.  Refresh the browser, and I can see user "aaron" on the web manager.

On my end I can fix the web console view by uploading the json files:

$ knife data bag from file users /path/to/user.json

There are two likely suspects that may be the cause.  One is that the web manager is somehow getting the users data bag from a corrupted cached version.  The other is that the web manager display may be a little buggy.

To get past the issue I just described, I reuploaded all the missing users to our data bag.  I verified all 75 users are present by doing a manual search on each user.  I had to do that, because I found the default display behavior to be unreliable, as I had just alluded.  When I went to the Data Bags section and selected the users data bag, I noticed that the browser only showed a fraction of the total users under the Items tab.  When I scrolled down, I saw the page fetched more users but not all.  Also the fetching only happens once consistently on Firefox, Chrome, and Safari.  I was also able to replicate the behavior upon multiple browser refreshes.

Unfortunately I do not know enough about Chef servers to know how I'd even go about testing my hypothesis.  Any insight on what could have caused the apparent mismatch between the web manager and knife output would be greatly appreciated.  Thank you so much for your help.

Christine Draper | 25 Feb 23:53 2015

How to pass machine_options into machine_image resource

Is there a way to pass machine_options to a machine_image resource specifically (rather than having to specify 'with_machine_options' globally)? 

Regards,
Christine


Jeff Byrnes | 25 Feb 22:59 2015

Announcing a cookbook for mcrouter

We’ve a need to use mcrouter here at EverTrue, and since there’s no Facebook-official cookbook, I went ahead & wrote one: https://supermarket.chef.io/cookbooks/mcrouter

Suggestions, criticisms, and pull requests are very welcome; it’s usable, but there’s plenty to improve here. Biggest issue would be the initial build time (it builds folly and mcrouter from source, since that’s the FB-approved method of installing mcrouter).

Config & CLI options for mcrouter are handled via a (hopefully) flexible hash attribute, and enjoys some help from Sean Clemmer’s magic cookbook.

-- 
Jeff Byrnes
<at> thejeffbyrnes
Lead DevOps Engineer
704.516.4628
Ed Ropple | 25 Feb 18:15 2015

stdout poisoning in knife commands

Hi,

So a big problem I keep running into with `knife`, as I move away from habitual chef-solo/chef-zero use and into an environment with a Chef server, is a lot of stdout poisoning from these commands. It's very nonstandard for something like 'knife search' to emit unrelated text, such as "N items found", on stdout. It makes it much harder than it needs or, to be honest, _ought_ to be to work with Chef, and it's a real drag. Are there any plans for better stdout/stderr discipline during the Chef 12 lifecycle?

Thanks,
Ed
Indra k | 25 Feb 11:44 2015

reg chef::mixin

HI all,

How to use Chef::mixin::commnand?

          Whether its a deprecated  one ,Chef::mixin::shellout?
My command is like this:
Chef::Mixin::Command.run_command(:command => "tar xvfC  "


Tha nks ,
Indu
Anthony Kong | 25 Feb 05:41 2015
Picon

How to add all the groups to a newly created user?

Hi, 

it is my user json file in the data bag

{                                                                                                                                                         

    "id": "project",

    "shell": "/bin/bash",

     "groups": ["vagrant", "wheel", "admin", "sensu", "chef", "adm", "cdrom", "sudo", "dip", "plugdev", "lpadamin"]

   }



In my default.rb cookbook, I have these lines



include_recipe "users" 


users_manage "admin" do

  action [:create]

end


After the user is created, it looks like this:


$ id

uid=1000(project) gid=1000(project) groups=1000(project),2302(admin)


How can I get the user to be member of all the groups mentioned in the json file?



Cheers, 


Tony


Gmane