Update docker case, improve readme and add testable docker case with vagrant

master
blallo 2021-02-25 23:41:11 +01:00
parent 2d7ab9bedc
commit a6d9be49dd
Signed by: blallo
GPG Key ID: 0CBE577C9B72DC3F
7 changed files with 84 additions and 8 deletions

View File

@ -2,12 +2,46 @@
## Dependencies
This role compiles the [bibliogram][1] artifact from the source. To make it
easiery, a `Dockerfile` is provided. So you need `docker` installed.
This role sets up a [bibliogram][1] node with one of two methods:
## Run
- orchestrating it via `systemd`
- orchestrating it via `docker`
Just use it as an ansible role in your playbook.
You have to choose which method to use.
## Variables
These are the default values
```
---
ansible_bibliogram_port: "10407"
ansible_bibliogram_with_docker: false
ansible_bibliogram_with_systemd: false
ansible_bibliogram_backup_frequency: "daily"
ansible_bibliogram_root_directory: "/var/www/bibliogram"
ansible_bibliogram_tor_enabled: false
```
It is **mandatory** to set a value for `ansible_bibliogram_base_url`, that
points to the public url (together with the protocol and port if not default!)
the service is available at.
## Develop
A `Vagrantfile` is provided. You can run the `systemd` case with
```
$ vagrant up --provider=libvirt --provision
```
or the `docker` case with
```
$ ANSIBLE_BIBLIOGRAM_DOCKER=1 vagrant up --provider=libvirt --provision
```
Then, if you put `debiantest 192.168.123.2` in your `/etc/hosts`, you should be
able to reach a bibliogram instance at `http://debiantest:10407`.
[1]: https://git.sr.ht/~cadence/bibliogram

8
Vagrantfile vendored
View File

@ -3,6 +3,8 @@
# to upgrade instead of disabling the requirement below.
Vagrant.require_version ">= 1.7.0"
docker = ENV['ANSIBLE_BIBLIOGRAM_DOCKER'] == '1'
Vagrant.configure(2) do |config|
config.vm.box = "debian/buster64"
@ -25,7 +27,11 @@ Vagrant.configure(2) do |config|
config.vm.provision "ansible" do |ansible|
ansible.become = true
ansible.verbose = "v"
ansible.playbook = "playbook.yml"
if docker == true
ansible.playbook = "playbook_docker.yml"
else
ansible.playbook = "playbook_systemd.yml"
end
ansible.inventory_path = "inventory"
end
end

View File

@ -0,0 +1,27 @@
---
- hosts: debiantest
gather_facts: yes
vars_files:
- ./test/vars_docker.yml
pre_tasks:
- debug: var=ansible_python_interpreter
- debug: var=ansible_python_version
- name: Install docker
shell: |
apt-get update
apt-get install -y \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common
curl -fsSL https://download.docker.com/linux/debian/gpg | apt-key add -
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/debian \
$(lsb_release -cs) \
stable"
apt-get update
apt-get install -y docker-ce docker-ce-cli containerd.io
roles:
- ansible-bibliogram

View File

@ -2,7 +2,7 @@
- hosts: debiantest
gather_facts: yes
vars_files:
- ./test/vars.yml
- ./test/vars_systemd.yml
roles:
- ansible-bibliogram

View File

@ -1,9 +1,14 @@
---
- name: Ensure dependency is present
apt:
name: python3-docker
state: present
- name: Grab official docker image and start it
docker_container:
name: bibliogram
image: cloudrac3r/bibliogram
registry: docker.io
restart: always
restart_policy: always
pull: yes
volumes:
- "db:/app/db"

View File

@ -0,0 +1,4 @@
---
ansible_bibliogram_base_url: "http://debiantest:10407"
ansible_bibliogram_with_docker: true
ansible_bibliogram_tor_enabled: true