Overriding attributes in the recipe

default.nginx_upstreams is the same as default[:nginx_upstreams] and default[‘nginx_upstreams’] – the convention is to use 1 of the latter two. And as you are using strings further, use them here too. The way you init nginx_upstreams in attribute file is the same as doing it this way: default[‘nginx_upstreams’][‘service1’] = [‘service1.server.com’] default[‘nginx_upstreams’][‘service2’] = [‘service2.server.com’] And you don’t … Read more

How to move/copy files locally with Chef

How to copy single file First way I use file statement to copy file (compile-time check) file “/etc/init.d/someService” do owner ‘root’ group ‘root’ mode 0755 content ::File.open(“/home/someService”).read action :create end here : “/etc/init.d/someService” – target file, “/home/someService” – source file Also you can wrap ::File.open(“/home/someService”).read in lazy block … lazy { ::File.open(“/home/someService”).read } … Second … Read more

Chef ‘cookbook’ in Berksfile vs ‘depends’ in metadata.rb

The Berksfile is Berkshelf specific, while the metadata file is built into Chef. Adding your dependencies to the metadata file allows other applications, like librarian-chef or the supermarket, to read your dependencies as well. Note that Berkshelf reads the dependencies from metadata as well, as long as you add the metadata line to the Berksfile. … Read more

Why do people use Puppet/Chef with Amazon Cloud Formation instead of just using CloudInit?

Is there an advantage over CloudInit? Yes, absolutely, many of them! Sure, you can write top to bottom run once CloudInit scripts to provision a server. But what happens when you need to change a configuration file, add a user, update a package, or install a new package? You will end up logging into servers … Read more