2012-10-31

Simple blog using git, tinkerer and ansible

  • Tinkerer helps to create a blog using .rst files and renders them as static pages.
  • Ansible helps to configure systems using simple YAML files
  • Git helps to keep trac of changes on files
  • All together, it gives a simple way to get a blog easily maintainable from a shell :)

1 Initialize git repo

git init myblog
cd myblog

2 Configure the git repo

  • set gitignore
env
ansible

3 Virtualenv setup

virtualenv env
. env/bin/activate

4 Install tinkerer

pip install Tinkerer

5 Configure tinkerer

  • edit conf.py and set following variables as desired
# Website's information
project = 'Site name'
tagline = 'This site is about ...'
author = u'A Name With an accent é'
copyright = '2010-2012, ' + author
website = 'http://website.url'
# To get disqus comments
# create an account on Disqus and set the shortname
disqus_shortname = 'shtnme'
# theme
html_theme = 'minimal' # or modern5 or boilerplate
# Number of blog posts per page
posts_per_page = 5
# Add templates to be rendered in sidebar here
html_sidebars = {
    "**": ["recent.html",
          "searchbox.html",
          "categories.html",
          "tags_cloud.html"]

6 Install Ansible

  • add Ansible's repo as a git submodule, just needed once
git submodules add https://github.com/ansible/ansible.git
  • pull Ansible's repo
git submodules update

7 Configure deployement

  • Ansible needs a 'hosts' file ie: ./hosts
# if the name comes from ~/.ssh/config use -c ssh when deploying
myhostname 
# host with a port
my.fqdn.com:1234
  • Ansible needs a playbook to know what to do ie: deploy.yml
---
- hosts: myhostname
  user: deployuser
  tasks:
    - file: |
        dest=/var/www/website
        state=directory
    - git: |
        repo=user@reposerver:reponame
        dest=/var/www/website
        version=master force=yes

8 Create content

  • Create a draft
tinker -d "My Post title"
  • Add a post or publish a draft
tinker -p "My Post title"
  • Add a page
tinker --page "My Page Name"
  • Render the website
tinker -b
  • Test the website
x-www-browser index.html

9 Deploy

  • commit the modifications
git add -A
git commit -m "git commit message"
  • activate ansible's environment
. ansible/hacking/env-setup
  • deploy
ansible-playbook deploy.yml -i hosts -c ssh