-
Notifications
You must be signed in to change notification settings - Fork 3
QuickStart
The chef-cuisine repository is just a template you are supposed to use for your Infrastructure project. Our example project has codename Tanabata so we will rename repo to tanabata-cuisine.
realloc@yuki:~$ git clone [email protected]:realloc/chef-cuisine.git tanabata-cuisine
realloc@yuki:~$ cd tanabata-cuisine
The fresh clone is empty. You have to run rake
to populate
cookbooks
directory with Berkshelf and pack a tarball for future use
with chef-solo.
realloc@yuki:~/tanabata-cuisine$ rake
One of the ideas of this project is to have the same code work in development environment and in production. For local development Vagrant and VirtualBox are used to create virtual machines. This pair was chosen because it works on most Linux distributions and MacOS X.
Let's create a sample VM named ryoko
. The basebox for it was already
created and should be downloaded from teh Interwebs.
realloc@yuki:~/tanabata-cuisine$ vagrant up ryoko
When vagrant is done we will have clean virtual machine ready to run chef. To be as close as possible to production environment this box would be provisioned the same way, via running chef-solo with a set of roles and recipes from tarball packed at previous step.
The task of Vagrant here is just create a box, put cuisine tarball into shared folder inside VM and configure chef-solo to use that tarball.
Let's ssh inside the box and run chef-solo.
realloc@yuki:~/tanabata-cuisine$ vagrant ssh ryoko
vagrant@ryoko:~$ sudo chef-solo
When chef-solo is done we will have configured VM! In this example we have only configured timezone and NTP. Let's check it's set to MSK, as it defined in role.
vagrant@ryoko:~$ date
Wed Jan 14 15:17:30 MSK 2015
It works! Now let's change timezone to UTC in roles/tanabata-base.rb file.
--- roles/tanabata-base.rb.orig 2015-01-13 19:25:28.000000000 +0300
+++ roles/tanabata-base.rb 2015-01-14 15:29:40.213573346 +0300
@@ -9,5 +9,5 @@
"sync_hw_clock" => true,
"servers" => ["0.ru.pool.ntp.org", "1.ru.pool.ntp.org", "2.ru.pool.ntp.org", "3.ru.pool.ntp.org"]
},
- "tz" => "Europe/Moscow"
+ "tz" => "Etc/UTC"
)
After changing roles we have to pack cuisine tarball again. It will
appear in shared folder inside ryoko
and next chef run will apply
updated cuisine.
realloc@yuki:~/tanabata-cuisine$ rake
realloc@yuki:~/tanabata-cuisine$ vagrant ssh ryoko
vagrant@ryoko:~$ sudo chef-solo
vagrant@ryoko:~$ date
Wed Jan 14 12:35:46 UTC 2015
Timezone changed successfully!
When done with changes just dispose ryoko vm with vagrant destroy ryoko
.