DevOp's Blog

jakshi's devop blog.

Chef Shortcuts

Add a recipe to the end of run list on certain environment

Test run, not actually add a recipe:

1
knife exec -E 'nodes.transform ("chef_environment:beta") {|n| puts n.run_list << "recipe[logentries_ng]" }'

Add a recipe for real:

1
knife exec -E 'nodes.transform ("chef_environment:beta") {|n| puts n.run_list << "recipe[logentries_ng]"; n.save }'

Rewriting Git Commit

Sometimes when you commit something nasty, you need to rewrite it. Or you may need to split commit into parts. Or whatever.

Use case: You want to remove some files that you added with your commit.

Accessing Chef Attributes in Serverspec Tests

I presume that you are familiar with:

  • Chef
  • test-kitchen
  • serverspec

When you write serverspec integration tests, it would be great to have access to chef attributes of cookbook that you’re testing. There’s a fast and simple way to do this.

Chef Cookbook Templating With Cookiecutter

One of the challenges in chef cookbook development - create a comprehensive cookbook template.

Good cookbook template might:

  • standartize your cookbooks
  • fill them with convenient predefinitions
  • save your time.

If you are not python averse, you could find that cookiecutter pretty useful tool for creating your cookbooks templates. This article describes my experience in creating chef cookbook template with cookiecutter.

Backup Gem and Chef

Intro

  • There’s a nice tool for doing fast and easy backup to AWS S3: backup gem
  • There should be done a lot of steps for setup a backup though.
  • So it could be automated with chef.
  • In this article I’ll write log of creation backup gem’s cookbook.
  • Essentially this cookbook will install backup gem, that will backup /var/www folder to AWS S3 every day in 01:00. It will store last 14 backups.

Rewriting Your Email in Git Commits

Sometimes you need to rewrite your email in your commits in some git repository. Do it with command:

git filter-branch --env-filter 'if [ $GIT_AUTHOR_EMAIL = bad@email ]; then GIT_AUTHOR_EMAIL=correct@email; fi; export GIT_AUTHOR_EMAIL'

For your collaborators this operatioin might be dangerous. According to Jakub Narębski collaborators will need to:

  • if they didn’t base their work on history pre-rewrite, just git reset --hard origin/master or just git pull origin (which should fast-forward).
  • If they based their change, they have to rebase using git rebase origin/master or just git pull --rebase origin

More info:

2013 Year Sum Up

  • 5 important things that I did this year:
    • Learn how to drive a car.
    • go to second big travel to Asia, living in Thailand, Krabi during 2013/2014 winter.
    • go for two short travels to Malaysia. By plane from Ko Samui to Kuala Lumpur, by car from Krabi to Penang island.
    • go for short travel to Germany.
    • Finish Introduction to Finance course on Coursera