Date sab 25 gennaio 2014 Category tech

Pelican is a great static site generator, written in Python ans used for this blog. For easy generation and deploy of the blog/site generated with pelican there are two file for automation included, a fabfile for fabric and a shell script. I take the function that I used mostly and I write a very simple ansible playbook.

I use the local_action module for generate the output content locally and the module synchronize, introudced in the version 1.4, to rsync to the remote server(s) the generated output content.




local_path: ~/code/lgaggini/
remote_path: /srv/www/
www_user: www-data


- hosts: blog_server
  remote_user: lg

    - pelican_vars


    - name: publish locally pelican blog
      local_action: command pelican -s {{ local_path }} {{ local_path }}content

    - name: synchronize the pelican output to remote server
      synchronize: src={{ local_path }}output/ dest={{ remote_path }} delete=yes rsync_path="sudo -u {{ www_user }} rsync"

The original scripts for fabric and shell have other interesting function quite easy to implement also in ansible, like the local serve of the generated site and the upload to Rackspace cloud. If you have Pelican installed in a virtualenv you have to pay attention to have the Pelican script available to ansible for local action part.