diff --git a/README.md b/README.md index 64cd336..72191ec 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,8 @@ concise area of concern. - [`roles/jellyfin`](roles/jellyfin/README.md): Deploy [jellyfin.org](https://jellyfin.org), the free software media system for streaming stored media to any device. +- [`roles/openproject`](roles/openproject/README.md): Deploys an [openproject.org](https://www.openproject.org) installation using the upstream provided docker-compose setup. + ## License [CNPLv7+](LICENSE.md): Cooperative Nonviolent Public License diff --git a/playbooks/openproject.yml b/playbooks/openproject.yml new file mode 100644 index 0000000..31190e8 --- /dev/null +++ b/playbooks/openproject.yml @@ -0,0 +1,6 @@ +--- +- name: Install openproject + hosts: "{{ openproject_hosts | default('openproject') }}" + become: "{{ openproject_become | default(true, false) }}" + roles: + - role: finallycoffee.services.openproject diff --git a/roles/openproject/README.md b/roles/openproject/README.md new file mode 100644 index 0000000..63e8442 --- /dev/null +++ b/roles/openproject/README.md @@ -0,0 +1,21 @@ +# `finallycoffee.services.openproject` ansible role + +Deploys [openproject](https://www.openproject.org/) using docker-compose. + +## Configuration + +To set configuration variables for OpenProject, set them in `openproject_compose_overrides`: +```yaml +openproject_compose_overrides: + version: "3.7" + services: + proxy: + [...] + volumes: + pgdata: + driver: local + driver_opts: + o: bind + type: none + device: /var/lib/postgresql +``` diff --git a/roles/openproject/defaults/main.yml b/roles/openproject/defaults/main.yml new file mode 100644 index 0000000..e32fd7a --- /dev/null +++ b/roles/openproject/defaults/main.yml @@ -0,0 +1,11 @@ +--- +openproject_base_path: "/opt/openproject" + +openproject_upstream_git_url: "https://github.com/opf/openproject-deploy.git" +openproject_upstream_git_branch: "stable/13" + +openproject_compose_project_path: "{{ openproject_base_path }}/compose" +openproject_compose_project_name: "openproject" +openproject_compose_project_env_file: "{{ openproject_compose_project_path }}/.env" +openproject_compose_project_override_file: "{{ openproject_compose_project_path }}/docker-compose.override.yml" +openproject_compose_project_env: {} diff --git a/roles/openproject/tasks/main.yml b/roles/openproject/tasks/main.yml new file mode 100644 index 0000000..cd60b32 --- /dev/null +++ b/roles/openproject/tasks/main.yml @@ -0,0 +1,39 @@ +--- +- name: Ensure base directory '{{ openproject_base_path }}' is present + ansible.builtin.file: + path: "{{ openproject_base_path }}" + state: directory + +- name: Ensure upstream repository is cloned + ansible.builtin.git: + dest: "{{ openproject_base_path }}" + repo: "{{ openproject_upstream_git_url }}" + version: "{{ openproject_upstream_git_branch }}" + clone: true + depth: 1 + +- name: Ensure environment is configured + ansible.builtin.lineinfile: + line: "{{ item.key}}={{ item.value}}" + path: "{{ openproject_compose_project_env_file }}" + state: present + create: true + loop: "{{ openproject_compose_project_env | dict2items(key_name='key', value_name='value') }}" + +- name: Ensure docker compose overrides are set + ansible.builtin.copy: + dest: "{{ openproject_compose_project_override_file }}" + content: "{{ openproject_compose_overrides | default({}) | to_nice_yaml }}" + +- name: Ensure containers are pulled + community.docker.docker_compose: + project_src: "{{ openproject_compose_project_path }}" + project_name: "{{ openproject_compose_project_name }}" + pull: true + +- name: Ensure services are running + community.docker.docker_compose: + project_src: "{{ openproject_compose_project_path }}" + project_name: "{{ openproject_compose_project_name }}" + state: "present" + build: false