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.
ansible_hosts
[blog_server]
nibiru.lgaggini.net
pelican_vars
local_path: ~/code/lgaggini/lgaggini.net/
remote_path: /srv/www/lgaggini.net
www_user: www-data
pelican.yaml
- hosts: blog_server
remote_user: lg
vars_file:
- pelican_vars
tasks:
- name: publish locally pelican blog
local_action: command pelican -s {{ local_path }}publishconf.py {{ 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.