Skip to content

ttafsir/dogsheep-automation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dogsheep Automation

This repo contains Ansible automation playbooks to get a personal dogsheep project up and running. The playbooks are written in Ansible to follow instructions from Simon Willison's Weeknotes.

The playbook will:

  • Install Python, NGINX, and SQLite
  • Install and Configure Certbot for NGINX
  • Create a user and virtualenv for service
  • Install datasette and its dependencies
  • Create a datasette service
  • Create database files based on your input in the config.yaml file
  • Create NGINX configurations
  • Limit access to your dogsheep instance with a username and password you can set via environment variables or through prompts
  • test the generated NGINX configuration and validate your dogsheep instance is working

Requirements

  • Ansible
  • Python 3.6+

TESTED ON: DigitalOcean Ubuntu 20.04 (LTS)

Install Requirements

pip install -r requirements.txt

⚙️ Configuration

Update your inventory

update the hosts inventory file to point the IP address or hostname of your Digital Ocean droplet. I had already set a DNS record to point dogsheep.ttafsir.me to my droplet's IP address. You'll want to do the same for your other droplet.

[dogsheep_hosts]
dogsheep.ttafsir.me ansible_user=root

Note: ansible_user is the user you want to use to connect to your droplet using SSH.

Export Environment Variables for your Login

By default, the configuration file config.yaml is set to require authentication to your instance. Set the following environment variables to set the username and password for your instance.

export DATASETTE_USERNAME=<username>
export DATASETTE_PASSWORD=<password>

Update config.yaml for your instance

---
dogsheep_site_title: Tafsir's personal data service
dogsheep_site_description: Personal data collection from public services
dogsheep_user: dogsheep
dogsheep_user_shell: /bin/bash
dogsheep_dbs:
  - twitter
  - swarm
  - photos
  - pocket
  - hacker-news
  - memories

The dogsheep_dbs list is the list of databases you want to create. These will be created as empty SQLite database files in WAL mode.

Update your Certbot configuration

Your email address is used to register and agree to the certbot TOS.

certbot_email: ttafsir@gmail.com
certbot_domain: dogsheep.ttafsir.me

Note: I had to set up DNS records to point my DigitalOcean droplet to dogsheep.ttafsir.me before I could get certbot to work.

Additional datasette settings

The configuration file config.yaml has a few additional settings that you can set to customize your instance. Any key/value pair under datasette_settings will be passed with the --setting flag to datasette when the service is created.

Below are the settings that are currently configured:

datasette_settings:
  sql_time_limit_ms: 20000
  facet_time_limit_ms: 5000
  template_debug: 1
  force_https_urls: 1

🚀 Deployment

Assuming you have your public key setup to allow you to SSH to your droplet, you can run the following command to deploy the service.

cd ansible
ansible-playbook pb-deploy.yaml

Optionally, you can pass the -k flag to prompt for your SSH password.

cd ansible
ansible-playbook pb-deploy.yaml -k

About

Automate process to build my personal dogsheep data

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages