From a6d9be49dd270f391638736ee6fd1e3cd3d48b3d Mon Sep 17 00:00:00 2001 From: Blallo Date: Thu, 25 Feb 2021 23:41:11 +0100 Subject: [PATCH] Update docker case, improve readme and add testable docker case with vagrant --- README.md | 42 +++++++++++++++++++++++++--- Vagrantfile | 8 +++++- playbook_docker.yml | 27 ++++++++++++++++++ playbook.yml => playbook_systemd.yml | 2 +- tasks/docker.yml | 9 ++++-- test/vars_docker.yml | 4 +++ test/{vars.yml => vars_systemd.yml} | 0 7 files changed, 84 insertions(+), 8 deletions(-) create mode 100644 playbook_docker.yml rename playbook.yml => playbook_systemd.yml (75%) create mode 100644 test/vars_docker.yml rename test/{vars.yml => vars_systemd.yml} (100%) diff --git a/README.md b/README.md index 7fa6de1..2cff6b5 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/Vagrantfile b/Vagrantfile index 131b0ac..04f3511 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -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 diff --git a/playbook_docker.yml b/playbook_docker.yml new file mode 100644 index 0000000..df2003c --- /dev/null +++ b/playbook_docker.yml @@ -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 diff --git a/playbook.yml b/playbook_systemd.yml similarity index 75% rename from playbook.yml rename to playbook_systemd.yml index 0448317..f709811 100644 --- a/playbook.yml +++ b/playbook_systemd.yml @@ -2,7 +2,7 @@ - hosts: debiantest gather_facts: yes vars_files: - - ./test/vars.yml + - ./test/vars_systemd.yml roles: - ansible-bibliogram diff --git a/tasks/docker.yml b/tasks/docker.yml index 31c0cda..1aa0ad1 100644 --- a/tasks/docker.yml +++ b/tasks/docker.yml @@ -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" diff --git a/test/vars_docker.yml b/test/vars_docker.yml new file mode 100644 index 0000000..41f73ea --- /dev/null +++ b/test/vars_docker.yml @@ -0,0 +1,4 @@ +--- +ansible_bibliogram_base_url: "http://debiantest:10407" +ansible_bibliogram_with_docker: true +ansible_bibliogram_tor_enabled: true diff --git a/test/vars.yml b/test/vars_systemd.yml similarity index 100% rename from test/vars.yml rename to test/vars_systemd.yml