My first approach working with chef in local mode
For some projects, I prefer don't work with a chef-server as a chef code repository. I prefer work directly with git and don't use a chef-server. To do it, we can use chef-solo or use chef in local mode. In the next lines I show you my first approach to deploy a system with chef in local mode.
List of components used:
- Git as a code repository.
- Chef in local mode to deploy
- Vagrant to run the development node.
- Ec2 instance to run the production node.
Create the development environment
1.- Create the chef repo and add your chef code.
2.- Create the vagrant node
Configure vagrant to install Chef client. You need to have the vagrant omnibus plugin installed. This is my Vagranfile.
3.- Configure chef client to run in local mode. To do this, I have create the next clitnt.rb file
4.- Create a node definition.
To run chef in local mode we need to create the node definition in the local repository and add a run list. I use the nodes/node_dev.json.
Deploy to development environment
Create the production environment
1.- Create the ec2 instance and install chef client.
2.- Configure chef client to run in local mode. I have created the next /etc/chef/client.rb file in the production node.
3.- Add in your repo the production node definition. nodes/node.json.
Deploy to production environment
1.- Upload chef code to ec2 instance.
To upload the chef code to ec2 node I use the git server, but you can use ssh or you favorite method.
2.- Run chef-client
Future improvements
Using a git hook we can automatize the production deployment task. We can develop a hook that after push you production branch to git server, It connect to the production node and run a git pull and a chef-client.
My new blog based on jekyll
How to install simple-jekyll-search plugin