diff --git a/wikijs/files/.env b/wikijs/files/.env new file mode 100644 index 0000000..156e47c --- /dev/null +++ b/wikijs/files/.env @@ -0,0 +1,6 @@ +DB_TYPE=postgres +DB_NAME=hiwikijs +DB_USER=postgres +DB_PASS=123456 +DB_HOST=db +DB_PORT=5432 diff --git a/wikijs/files/nginx.conf.j2 b/wikijs/files/nginx.conf.j2 new file mode 100644 index 0000000..4dc51f3 --- /dev/null +++ b/wikijs/files/nginx.conf.j2 @@ -0,0 +1,13 @@ +server { + + listen 80; + server_name {{ http_host }}; + + location / { + proxy_pass http://localhost:3443; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + } +} diff --git a/wikijs/playbook.yml b/wikijs/playbook.yml new file mode 100755 index 0000000..1c6fb41 --- /dev/null +++ b/wikijs/playbook.yml @@ -0,0 +1,69 @@ +################################################# +# DO Community Playbooks: Docker +################################################# +--- +- hosts: all + become: true + vars_files: + - vars/default.yml + + tasks: + - name: Pull Wiki.js image + docker_image: + name: "{{ image_name }}" + source: pull + state: present + force_source: yes + + - name: Ensure Host Directory exists + file: + path: "/var/lib/{{ host_directory }}" + state: directory + group: www-data + owner: www-data + mode: 0655 + + - name: Upload the .env file + template: + src: "files/.env" + dest: "/var/lib/{{ host_directory }}/.env" + + - name: Create Wiki.js container + docker_container: + name: "{{ container_name }}" + image: "{{ image_name }}" + state: started + restart_policy: "unless-stopped" + env_file: "/var/lib/{{ host_directory }}/.env" + links: + - "postgres:db" + published_ports: + - "127.0.0.1:3443:3000" + + - name: Check if Nginx conf file exists + stat: path="/etc/nginx/sites-available/{{ http_conf }}" + register: status + + - name: No need to reload Nginx + debug: msg= {{ "No need to reload Nginx as sites-available entries have already been created" }} + + - name: Set Nginx conf file + when: status.stat.exists == false + template: + src: "files/nginx.conf.j2" + dest: "/etc/nginx/sites-available/{{ http_conf }}" + + - name: Enable new site + when: status.stat.exists == false + file: + src: "/etc/nginx/sites-available/{{ http_conf }}" + dest: "/etc/nginx/sites-enabled/{{ http_conf }}" + state: link + notify: Reload Nginx + + handlers: + - name: Reload Nginx + service: + name: nginx + state: reloaded + diff --git a/wikijs/readme.md b/wikijs/readme.md new file mode 100644 index 0000000..2be90cb --- /dev/null +++ b/wikijs/readme.md @@ -0,0 +1,45 @@ +# Gitea on Ubuntu + +This playbook will install Gitea on an Ubuntu 19.10 machine. +A number of containers will be created with the options specified in the `vars/default.yml` variable file. + +## Settings + +- `create_containers`: number of containers to create. +- `default_container_name`: default name for new containers. +- `default_container_image`: default image for new containers. +- `default_container_command`: default command to run on new containers. + + +## Running this Playbook + +Quick Steps: + +### 1. Obtain the playbook +```shell +git clone https://github.com/do-community/ansible-playbooks.git +cd ansible-playbooks/docker_ubuntu1804 +``` + +### 2. Customize Options + +```shell +nano vars/default.yml +``` + +```yml +#vars/default.yml +--- +create_containers: 4 +default_container_name: docker +default_container_image: ubuntu +default_container_command: sleep 1d +``` + +### 3. Run the Playbook + +```command +ansible-playbook -l [target] -i [inventory file] -u [remote user] playbook.yml +``` + +For more information on how to run this Ansible setup, please check this guide: [How to Use Ansible to Install and Set Up Docker on Ubuntu 18.04](https://www.digitalocean.com/community/tutorials/how-to-use-ansible-to-install-and-set-up-docker-on-ubuntu-18-04). diff --git a/wikijs/vars/default.yml b/wikijs/vars/default.yml new file mode 100644 index 0000000..fadd349 --- /dev/null +++ b/wikijs/vars/default.yml @@ -0,0 +1,9 @@ +--- +http_host: "wiki.hinchco.in" +http_conf: "wiki.hinchco.in.conf" +http_url: "https://wiki.hinchco.in" + +container_name: wikijs +image_name: ghcr.io/requarks/wiki:latest + +host_directory: hiwikijs