Here is How To Deploy OctoPress on OpenStack Swift, Example Given With HP Helion Cloud With Only Python Swift Client & a Custom Shebang Script. Previously, we have shown how to deploy OctoPress on OpenShift PaaS with our custom shebang script and how to upload Static Objects on on OpenStack Swift (HP Cloud). Most funny part is that – we need no middleware like Pyrax for the whole work.
Deploy OctoPress on OpenStack Swift (HP Cloud) : Basic is OctoPress Not OpenStack Swift
The most important part of this guide to deploy OctoPress on OpenStack Swift is the philosophy – we basically need not to work hard behind OpenStack Swift, rather working on OctoPress makes the thing easier to deploy. The previous approaches by Rackspace were by not much deeper work with OctoPress.
When we are installing WordPress on Heroku versus OpenShift versus Rackspace versus HP Helion Cloud – the way needs to get modified. Minor modification of the web software gives better mileage. It is near impossible to know everything about all the backend softwares.
---
The trick is, essentially within the OctoPress configuration file – _config.yml
. Except knowing about basics on OpenStack – like about OpenStack RC file and configuring Python Swift Client, only knowing the fact that HP Cloud CDN can host Static HTML websites – we need not much to know about OpenStack.
Deploy OctoPress on OpenStack Swift (HP Cloud) : How The Things Can Be Done
We have created a shebang script for the whole work to get fully semi-automated. You can check our GitHub repo for the script to deploy OctoPress on HP Helion Cloud’s OpenStack Swift.
You can dry run the script. First download the script and run these commands :
1 2 | chmod +x shiftoctopress.sh sh shiftoctopress.sh |
Do not use iTerm2 on OS X, use Terminal. You should place this script at your $HOME
directory and execute it. You need to have Python Swift Client installed and configured on your local computer. Here is the whole script :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | #!/bin/bash -e # echo "This Script Will Deploy OctoPress on OpenStack Swift Object Storage." read -p "Hit Y or N " -n 1 -r echo "+++++" echo "You Should Place This Script at Your $HOME Directory and Execute it." echo "++++++" echo " " echo "Is everything is fine?" echo if [[ $REPLY =~ ^[Yy]$ ]] then echo "Run this script in a separate new Terminal Window with Sudo Privilege" echo "You can get sudo privilege by running :" echo "sudo su" fi read -p "Read the instruction? Y will proceed, N will Quit " -n 1 -r RUBY_VERSION=1.9.3-p448 echo "We will cd to $HOME" echo " " cd ~ echo "Your OctoPress on local computer is at" pwd echo " " echo "We will delete any existing directory with the name octopress." rm -r -f octopress echo " " echo "Supply the container name below:" read container echo " " echo "Now, visit :" echo "https://horizon.hpcloud.com/project/containers/" echo "and make the container named $container public & enable CDN." echo " " echo "You should create a custom _config.yml file. We will delete the default one " echo "and ask you a custom _config.yml file's URL, you can use Github Gist's RAW URL." echo "A basic example is like :" echo "https://gist.githubusercontent.com/AbhishekGhosh/d8283097c50c2b5d64a1/raw/3b6b914d88b5c7f49dded82ff71d1c696fc7bcfb/_config.yml" echo " " echo "copy that url and paste when we will ask you." git clone git://github.com/imathis/octopress.git octopress && cd octopress sudo gem install bundler rbenv rehash bundle install rake install cd .. mkdir _deployment && cd _deployment cp ../octopress/config.ru . cp ../octopress/Gemfile . bundle install mkdir public/ git init . git add . git commit -am 'initial deploy' cd .. mv _deployment octopress cd octopress rm -r _config.yml echo "Supply the full URL of the _config.yml file:" read yml echo " " wget $yml echo " " git add _deployment/ rake install echo "Depending on your environment, use bundle exec" echo "Edit and save the file in source/_posts/2015-02-09-Hello-World.markdown" echo "Proceed? Y/N" echo if [[ $REPLY =~ ^[Yy]$ ]] then rake new_post['Hello World'] echo "sudo su" fi rake generate rm -rf _deployment/public/* cp -R public/* _deployment/public/ swift upload $container * finish=`date "+%Y-%m-%d-%H-%M-%S"` echo "Deployment at Swift container $container completed at ${finish}" read -p "OK. This Script Will Quit. That is Desired. Hit Y or N " -n 1 -r echo if [[ $REPLY =~ ^[Yy]$ ]] then exit fi |
For readability purpose, we have made the above one shorter than the real script. When you will execute the script, it will look like this :
Quite obviously, the Container needs to be Public and CDN enabled. The script is quite complex, it is not that easy to combine so many works together.
_config.yml Matters the Most
Here is custom sample gist of the _config.yml file. A running live example of OctoPress is here.
There are OctoPress specific issues which needs to be fixed (which we are not interested to fix). You’ll notice that, the hyperlinks are not working, like Blog Archives link will not work. This is nothing because the links should be like :
Main : /_deployment/public/index.html
Archive : /_deployment/public/blog/archives/index.html
Blog Post : /_deployment/public/blog/2015/03/26/hello-world/index.html
Feed : /_deployment/public/atom.xml
These are permalink related stuffs and expect the noobs, they are not quite difficult to fix. If you set those -Meta content headers, you can omit the index.html
part.
Why the _deployment Directory?
If you follow Rackspace Pyrax way, it will give the way to directory browsing :
http://ha5b38a50fda888a7851b261ba7835f0a.cdn.hpcloudsvc.com
But browsing _deployment
directory is not possible :
try to access :
you can only access :
/_deployment/public/index.html
and other static files.
So, if you only upload the _deployment
directory and set container sync, versioning; it becomes a safer setup. Now, after a bit working and pointing a naked domain or subdomain towards it, it will be quite safer. At the same time, the localhost setup is git based. If you simply add remote, you can change from OpenStack Swift to normal server or PaaS. Wider easy compatibility. The work might be more with OctoPress, but this approach is the proper approach.