Skip to content

Commit a9ac7c4

Browse files
authored
Add ansible-playbook example (#25)
* Add ansible proxy description * Fix spaces typo * Add proxy to upstream * Add some descriptions * Small fix * Small fix * Add molecule tests * Add molecule tests folder * Readme small changes * Add extra-vars for correct testing * Add test action * Refactoring code * Fix upper case syntax error * Remove nginx install from prepare stage * Refactoring code * Fix typo * Add tests status bage * Add status bage * Set remove default vhost * Change nginx package name * Move description in separate file * Change the installation order of roles * Add ds_port variable * Remove centos tests * Refactoring tests * Add preinstall nginx-extras * Fix typo * Enable centos tests * Refactoring code * Fix centos tests * Add task for check dirs * Add debug * Refactoring * Fix centos port settup * Enable another distributions * Update playbook nginx config * Remove extra configs * Refactoring molecule test * Refacoring testing virtual path * Change ci-tests triggers * Fix useless changes * Refactoring * Refactoring ansible proxy config * Some readme changes * Set 1 file convegre * Remove overhead converge file * Remove file * Fix typo * Fix spaces * Change port number * Refactoring code * Fix typo * Refactoring readme * Refactor: refactoring readme file
1 parent 2a68412 commit a9ac7c4

File tree

8 files changed

+273
-0
lines changed

8 files changed

+273
-0
lines changed

.github/workflows/ci.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
name: Test
3+
'on':
4+
push:
5+
branches:
6+
- 'feature/*'
7+
- 'butfix/*'
8+
- 'master'
9+
10+
defaults:
11+
run:
12+
working-directory: 'document-server-proxy/tests/nginx'
13+
14+
jobs:
15+
16+
molecule:
17+
name: Molecule test on
18+
runs-on: ubuntu-latest
19+
strategy:
20+
fail-fast: false
21+
matrix:
22+
distro:
23+
- centos7
24+
- centos8
25+
- debian9
26+
- debian10
27+
- debian11
28+
- ubuntu1604
29+
- ubuntu1804
30+
- ubuntu2004
31+
32+
steps:
33+
- name: Check out the codebase.
34+
uses: actions/checkout@v2
35+
with:
36+
path: 'document-server-proxy'
37+
38+
- name: Set up Python 3.
39+
uses: actions/setup-python@v2
40+
with:
41+
python-version: '3.x'
42+
43+
- name: Install test dependencies.
44+
run: pip3 install ansible molecule[lint,docker] docker yamllint ansible-lint
45+
46+
- name: Run Molecule tests.
47+
run: molecule test
48+
env:
49+
PY_COLORS: '1'
50+
ANSIBLE_FORCE_COLOR: '1'
51+
MOLECULE_NO_LOG: 'false'
52+
MOLECULE_DISTRO: ${{ matrix.distro }}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# ONLYOFFICE Document Server example configurations for proxy
22

3+
[![Config Test](https://github.com/ONLYOFFICE/document-server-proxy/actions/workflows/ci.yml/badge.svg)](https://github.com/ONLYOFFICE/document-server-proxy/actions/workflows/ci.yml)
34
[![Build Status](https://travis-ci.org/ONLYOFFICE/document-server-proxy.svg?branch=master)](https://travis-ci.org/ONLYOFFICE/document-server-proxy)
45

56
This reposotory contains the configuration files for the web-servers to proxy traffic to the ONLYOFFICE DocumentServer.

nginx/ansible/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
## Virtual path ansible-playbook
2+
3+
To install a DocumentServer into a virtual directory behind nginx proxy with Ansible, you need to follow a few steps:
4+
5+
### Step 1
6+
7+
Install Ansible if it is not already installed, installation instructions can be found [here](https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html)
8+
9+
### Step 2
10+
11+
Clone this repository on your local machine with the command:
12+
13+
```bash
14+
git clone https://github.com/ONLYOFFICE/document-server-proxy.git
15+
```
16+
17+
### Step 3
18+
19+
Navigate to the cloned repository to the `document-server-proxy/nginx/ansible` directory.
20+
21+
### Step 4
22+
23+
Make your [ansible inventory file](https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html) and execute the ansible playbook with the command:
24+
25+
```bash
26+
ansible-playbook -i <inventory_file_name> virtual-path-playbook.yaml
27+
```
28+
29+
Note: Inside the `virtual-path-playbook.yaml` you can also override the port variable on which the DocumentServer will be run. `9378` is used by default.
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
- hosts: all
2+
3+
vars:
4+
nginx_package_name: "nginx"
5+
ds_port: 9378
6+
7+
nginx_vhosts:
8+
- listen: "80 default_server"
9+
server_name: “”
10+
server_tokens: "off"
11+
template: "{{ nginx_vhost_template }}"
12+
filename: "onlyoffice.conf"
13+
extra_parameters: |
14+
location /ds_path/ {
15+
proxy_set_header Upgrade $http_upgrade;
16+
proxy_set_header Connection $proxy_connection;
17+
proxy_set_header X-Forwarded-Host $the_host/ds_path;
18+
proxy_set_header X-Forwarded-Proto $the_scheme;
19+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
20+
21+
proxy_pass http://localhost:{{ ds_port }}/;
22+
proxy_http_version 1.1;
23+
}
24+
25+
postgresql_global_config_options:
26+
- option: listen_addresses
27+
value: "*"
28+
- option: unix_socket_directories
29+
value: '{{ postgresql_unix_socket_directories | join(",") }}'
30+
- option: log_directory
31+
value: 'log'
32+
33+
postgresql_hba_entries:
34+
- type: local
35+
database: all
36+
user: postgres
37+
auth_method: peer
38+
- type: local
39+
database: all
40+
user: all
41+
auth_method: peer
42+
- type: host
43+
database: all
44+
user: all
45+
address: 127.0.0.1/32
46+
auth_method: md5
47+
- type: host
48+
database: all
49+
user: all
50+
address: ::1/128
51+
auth_method: md5
52+
- type: host
53+
database: all
54+
user: all
55+
address: 0.0.0.0/0
56+
auth_method: md5
57+
58+
postgresql_databases:
59+
- name: "{{ db_server_name }}"
60+
61+
postgresql_users:
62+
- name: "{{ db_server_user }}"
63+
password: "{{ db_server_pass }}"
64+
65+
rabbitmq_users:
66+
- name: "{{ rabbitmq_server_user }}"
67+
password: "{{ rabbitmq_server_pass }}"
68+
vhost: "{{ rabbitmq_server_vpath }}"
69+
configure_priv: .*
70+
read_priv: .*
71+
write_priv: .*
72+
tags: administrator
73+
74+
rabbitmq_users_remove: []
75+
76+
redis_bind_interface: 0.0.0.0
77+
78+
roles:
79+
- geerlingguy.postgresql
80+
- onlyoffice.rabbitmq
81+
- geerlingguy.redis
82+
- onlyoffice.documentserver
83+
- geerlingguy.nginx
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
dependency:
3+
name: galaxy
4+
driver:
5+
name: docker
6+
platforms:
7+
- name: "${MOLECULE_DISTRO:-ubuntu2004}"
8+
image: "geerlingguy/docker-${MOLECULE_DISTRO:-ubuntu2004}-ansible:latest"
9+
command: ${MOLECULE_DOCKER_COMMAND:-""}
10+
volumes:
11+
- /sys/fs/cgroup:/sys/fs/cgroup:ro
12+
privileged: true
13+
pre_build_image: true
14+
provisioner:
15+
name: ansible
16+
options:
17+
extra-vars: "{'nginx_vhost_path': /etc/nginx/conf.d}"
18+
env:
19+
PROTO: ${MOLECULE_PROTO:-http}
20+
MOLECULE_NO_LOG: ${MOLECULE_NO_LOG:-true}
21+
VIRTUAL_PATH: ${VIRTUAL_PATH:-ds_path}
22+
playbooks:
23+
converge: ../../../../nginx/ansible/virtual-path-playbook.yaml
24+
verifier:
25+
name: ansible
26+
scenario:
27+
test_sequence:
28+
- destroy
29+
- dependency
30+
- syntax
31+
- create
32+
- prepare
33+
- converge
34+
- verify
35+
- destroy
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
- name: Prepare
3+
hosts: all
4+
become: true
5+
vars:
6+
os_environment:
7+
- key: DS_PORT
8+
value: 9378
9+
10+
tasks:
11+
- name: Install PostgreSQL Python libraries.
12+
apt:
13+
update_cache: yes
14+
pkg:
15+
- python3-psycopg2
16+
- gnupg
17+
state: present
18+
when: ansible_os_family == "Debian"
19+
changed_when: false
20+
failed_when: false
21+
22+
- name: Set up ds server port
23+
ansible.builtin.debconf:
24+
name: onlyoffice-documentserver
25+
question: onlyoffice/ds-port
26+
value: 9378
27+
vtype: string
28+
become: yes
29+
when: ansible_os_family == "Debian"
30+
31+
- name: Set ds server custom port
32+
ansible.builtin.lineinfile:
33+
dest: "/etc/environment"
34+
state: present
35+
regexp: "^{{ item.key }}="
36+
line: "{{ item.key }}={{ item.value }}"
37+
become: yes
38+
with_items: "{{ os_environment }}"
39+
when: ansible_os_family == "RedHat"
40+
41+
- name: Install nginx
42+
apt:
43+
name: nginx-extras
44+
when: ansible_os_family == "Debian"
45+
46+
- name: restart-nginx
47+
ansible.builtin.service:
48+
name: "nginx"
49+
state: restarted
50+
become: yes
51+
when: ansible_os_family == "Debian"
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
roles:
3+
- src: geerlingguy.nginx
4+
- src: geerlingguy.redis
5+
- src: geerlingguy.postgresql
6+
- src: onlyoffice.rabbitmq
7+
- src: onlyoffice.documentserver
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
- hosts: all
3+
remote_user: root
4+
become: true
5+
vars:
6+
virtual_path: "{{ lookup('env', 'VIRTUAL_PATH') }}"
7+
proto: "{{ lookup('env', 'PROTO') }}"
8+
tasks:
9+
- name: "Get health check status on {{ proto }}://localhost/{{ virtual_path }}/healthcheck/"
10+
uri:
11+
url: "{{ proto }}://localhost/{{ virtual_path }}/healthcheck/"
12+
return_content: yes
13+
validate_certs: no
14+
register: healthcheck
15+
failed_when: "'true' not in healthcheck.content"

0 commit comments

Comments
 (0)