From 95b73daa36b23565a8566f71f9b202d3459b685f Mon Sep 17 00:00:00 2001 From: Sam Chudnick Date: Sun, 25 Jun 2023 09:52:36 -0400 Subject: Initial Commit --- .../containers/bookstack/handlers/main.yml | 4 + roles/services/containers/bookstack/tasks/main.yml | 118 +++++++++++++++++++++ 2 files changed, 122 insertions(+) create mode 100644 roles/services/containers/bookstack/handlers/main.yml create mode 100644 roles/services/containers/bookstack/tasks/main.yml (limited to 'roles/services/containers/bookstack') diff --git a/roles/services/containers/bookstack/handlers/main.yml b/roles/services/containers/bookstack/handlers/main.yml new file mode 100644 index 0000000..5463835 --- /dev/null +++ b/roles/services/containers/bookstack/handlers/main.yml @@ -0,0 +1,4 @@ +- name: restart nginx + service: + name: nginx + state: restarted diff --git a/roles/services/containers/bookstack/tasks/main.yml b/roles/services/containers/bookstack/tasks/main.yml new file mode 100644 index 0000000..3965143 --- /dev/null +++ b/roles/services/containers/bookstack/tasks/main.yml @@ -0,0 +1,118 @@ +- name: set image fact + set_fact: + image: linuxserver/bookstack:version-v23.05 + +- name: set other facts + vars: + array: "{{ image.split('/', 1) }}" + set_fact: + repo_tag: "{{ array.1 }}" + custom_registry: "{{ docker_registry_url + '/' + docker_registry_username }}" + +- name: create bookstack directory + file: + path: "{{ docker_home }}/bookstack" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0755' + +- name: create data directory + file: + path: "{{ docker_home }}/bookstack/data" + state: directory + owner: "{{ docker_username }}" + group: "{{ docker_username }}" + mode: '0755' + +- name: create bookstack docker network + become: yes + become_user: "{{ docker_username }}" + docker_network: + name: "{{ bookstack_network_name }}" + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + driver: bridge + ipam_config: + - subnet: "{{ bookstack_subnet }}" + gateway: "{{ bookstack_gateway }}" + +- name: create and deploy bookstack db + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_container: + name: "bookstack-db" + hostname: "bookstack-db" + image: linuxserver/mariadb:10.11.4 + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + purge_networks: yes + networks: + - name: "{{ bookstack_network_name }}" + ipv4_address: "{{ bookstack_db_ipv4 }}" + volumes: + - "{{ docker_home }}/bookstack/data:/config" + env: + "TZ": "{{ timezone }}" + "MYSQL_ROOT_PASSWORD": "{{ bookstack_mysql_root_password }}" + "MYSQL_DATABASE": "bookstack" + "MYSQL_USER": "bookstack" + "MYSQL_PASSWORD": "{{ bookstack_mysql_password }}" + state: 'started' + recreate: yes + restart_policy: unless-stopped + +- name: create and deploy bookstack container + become: yes + become_user: "{{ docker_username }}" + environment: + XDG_RUNTIME_DIR: "/run/user/{{ docker_uid }}" + docker_container: + name: "bookstack" + hostname: "bookstack" + image: "{{ image }}" + docker_host: "unix://run/user/{{ docker_uid }}/docker.sock" + purge_networks: yes + networks: + - name: "{{ bookstack_network_name }}" + ipv4_address: "{{ bookstack_ipv4 }}" + ports: + - "127.0.0.1:{{ bookstack_external_port }}:80" + volumes: + - "{{ docker_home }}/bookstack/data:/config" + env: + "DB_HOST": "bookstack-db" + "DB_PORT": "3306" + "DB_USER": "bookstack" + "DB_PASS": "{{ bookstack_mysql_password }}" + "DB_DATABASE": "bookstack" + "APP_URL": "https://{{ bookstack_server_name }}" + "AUTH_METHOD": "oidc" + "OIDC_NAME": "SSO" + "OIDC_DISPLAY_NAME_CLAIMS": "name" + "OIDC_CLIENT_ID": "bookstack" + "OIDC_CLIENT_SECRET": "{{ bookstack_oidc_secret }}" + "OIDC_ISSUER": "{{ oidc_issuer }}" + "OIDC_ISSUER_DISCOVER": "true" + "APP_DEFAULT_DARK_MODE": "true" + #"OIDC_DUMP_USER_DETAILS": "true" + state: 'started' + recreate: yes + restart_policy: unless-stopped + +- name: deploy nginx configuration + notify: restart nginx + template: + src: "{{ bookstack_nginx_config }}" + dest: /etc/nginx/sites-available/bookstack.conf + owner: root + group: root + mode: '0644' + +- name: symlink site + file: + src: /etc/nginx/sites-available/bookstack.conf + dest: /etc/nginx/sites-enabled/bookstack.conf + owner: root + group: root + state: link -- cgit v1.2.3