This playbook helps you set up and manage your Uberspace(s).
It configures a few common things that I find essential for Uberspaces and it is extensible for other stuff.
- Let's Encrypt SSL certificates
- WordPress using the awesome Bedrock boilerplate
- Ruby on Rails apps
- An Uberspace, get one at uberspace.de
- Ansible
- Copy uberspaces.exampletouberspacesand add your Uberspace host(s) and username(s)
- Copy host_vars/UBERSPACE_NAME.UBERSPACE_HOST.uberspace.de.exampleto a new file named without the.examplesuffix and replaceUBERSPACE_NAMEwith your username, e.g.juliaandUBERSPACE_HOSTwith your Uberspace host, e.g.eridanus.
- Add the domains you'd like to run on the respective Uberspace to the file created in step 2.
- Repeat steps 2 and 3 for all your Uberspaces.
- Run the playbook using ansible-playbook --ask-pass site.yml.
- Enjoy!
If you have an SSH keypair and your public key is installed in ~/.ssh/id_rsa.pub on your local computer, the key will be stored in ~/.ssh/authorized_keys on your Uberspace and you won't need the --ask-pass argument in subsequent runs.
Nothing to do or configure here. This works automagically for all your domains.
- To set up a WordPress instance, simply create an entry under wordpress_instancesin yourhost_varsfile (seehost_vars/UBERSPACE_NAME.UBERSPACE_HOST.uberspace.de.examplefor an example)
- Use the default bedrock_repofromhttps://github.com/yeah/bedrock.gitor use your own forked repo of the boilerplate (Your Uberspace's public keys will be conveniently downloaded for you topublic_keys/so you can use them as deploy keys for your private Git repos.)
- Add the domains through which your WordPress should be accessible
- Make sure to add these domains to the top-level domainssection in thehost_varsfile as well!
Normally, your WordPress instances will be updated from your repo daily via a cron job. However, if you want to deploy your WordPress whenever your repository changes, you can specify a value for the optional webhook_key in each of your WordPress configs.
With a webhook_key defined, you will be able to create a post-receive hook on your Git server or use your Uberspace as a webhook URL on repository hosting services such as Planio.
Your webhook URLs will be composed like this:
https://{{ uberspace name }}.{{ uberspace host }}.uberspace.de/cgi-bin/wordpress-update-{{ wordpress instance name }}.cgi?{{ wordpress instance webhook key }}
A simple post-receive hook on your Git server could look like this, it would have to go in hooks/post-receive:
#!/bin/sh
curl -s 'https://julia.eridanus.uberspace.de/cgi-bin/wordpress-update-example_blog.cgi?secretsauce123'Or if you use Planio, simply enter your URL via Settings → Repositories → your repo → Edit → Post-Receive webhook URL
Setting up and deploying your Ruby on Rails apps involves a little bit more work, but it's definitely worth it. Where else do you get such awesome Rails hosting for the price? Let's get started:
- To set up a Rails app, create an entry under rails_appsin yourhost_varsfile (seehost_vars/UBERSPACE_NAME.UBERSPACE_HOST.uberspace.de.examplefor an example)
- Make sure to give it a namewhich should be only characters, numbers and maybe the underscore character – no spaces!
- Add the domains through which your Rails app should be accessible
- Make sure to add these domains to the top-level domainssection in thehost_varsfile as well!
- For secret_key_basegenerate a secret usingrake secretin your Rails app
- For portchoose an unused port on your Uberspace between 32000 and 65000
That's it for Ansible. You can now run your playbook using ansible-playbook site.yml.
To actually deploy your app, we're going to use Capistrano. Git clone your Rails app on your local computer and perform the following modifications:
- Add or uncomment gem 'capistrano-rails', group: :development
- Run bundle installand thenbundle exec cap install
- Add or uncomment require 'capistrano/bundler'
- Add or uncomment require 'capistrano/rails/migrations'if your app is using MySQL
Your Capfile should now look similar to this:
require "capistrano/setup"
require "capistrano/deploy"
require 'capistrano/bundler'
require 'capistrano/rails/migrations'
Dir.glob("lib/capistrano/tasks/*.rake").each { |r| import r }- Find the line set :application, 'my_app_name'and replacemy_app_namewith the exact same name you chose earlier for therails_appsentry in yourhost_varsfile.
- Find the line set :repo_url, '[email protected]:me/my_repo.git'and add your Rails app's repo URL. If your repo is private, please add the keys you find inpublic_keys/within your playbook as deploy keys to your repository hoster.
- Find the line # set :deploy_to, '/var/www/my_app_name', uncomment it and set the value to"~/www/rails/#{fetch :application}"(notice the double quotes!)
- Add the line set :linked_files, fetch(:linked_files, []).push('config/database.yml')
- Add the line after :publishing, :restart { execute :svc, "-du ~/service/rails-app-#{fetch :application}" }within thenamespace :deployblock
Your config/deploy.rb should now look similar to this:
lock '3.5.0'
set :application, 'example_app'
set :repo_url, '[email protected]:example-app.git'
set :deploy_to, "~/www/rails/#{fetch :application}"
set :linked_files, fetch(:linked_files, []).push('config/database.yml')
namespace :deploy do
  after :publishing, :restart { execute :svc, "-du ~/service/rails-app-#{fetch :application}" }
end- Find and uncomment the line # server 'example.com', user: 'deploy', roles: %w{app db web}, my_property: :my_valueand replaceexample.comwith the hostname of your Uberspace, e.g.eridanus.uberspace.deanddeploywith your Uberspace username.
Your config/deploy/production.rb should now look similar to this:
server 'eridanus.uberspace.de', user: 'julia', roles: %w{app db web}That's it. You should be able to deploy your app using bundle exec cap production deploy. After some time, your Rails app should be humming nicely on your configured domain.
As the Uberspace Playbook is still in development, it would make sense for you to run the cleanup tasks after every update from this repo. The cleanup tasks remove any files/configurations on your Uberspace which previous versions of the playbook may have installed but which are no longer needed. You can run the cleanup tasks like so:
ansible-playbook cleanup.yml
MIT.
To contribute something you usually configure on your Uberspace, please fork this repo, create a new role (or add to an existing one if it makes sense) and submit a pull request.
I built this. By myself. On my computer.