Skip to content

Commit

Permalink
Merge pull request #65 from ONLYOFFICE/feature/fix-test
Browse files Browse the repository at this point in the history
Feature/fix test
  • Loading branch information
agolybev authored Nov 22, 2023
2 parents fd66de9 + 49b180f commit f3ca1d3
Show file tree
Hide file tree
Showing 14 changed files with 129 additions and 87 deletions.
1 change: 1 addition & 0 deletions .ansible-lint
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
skip_list:
- package-latest # Package installs should not use latest
- command-instead-of-shell # Use shell only when shell functionality is required
- no-changed-when
32 changes: 7 additions & 25 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
---
name: Test
'on':
on:
pull_request:
push:
schedule:
- cron: '0 0 1 * *'

defaults:
run:
working-directory: 'ansible-role-documentserver'

jobs:

molecule:
name: Molecule test on
runs-on: ubuntu-20.04
Expand All @@ -19,12 +19,13 @@ jobs:
distro:
- centos7
- centos8
- debian9
- rockylinux9
- debian10
- debian11
- ubuntu1604
- debian12
- ubuntu1804
- ubuntu2004
- ubuntu2204
proto:
- http
- https
Expand All @@ -48,26 +49,7 @@ jobs:
python-version: '3.x'

- name: Install test dependencies.
run: pip3 install ansible molecule[lint,docker] docker yamllint ansible-lint

- name: Downgrade docker
run: |
sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt-get update
sudo apt-get install \
ca-certificates \
curl \
gnupg \
lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
apt-cache madison docker-ce | awk '{ print $3 }'
export VERSION_STRING=5:19.03.9~3-0~ubuntu-focal
sudo apt-get install docker-ce=$VERSION_STRING docker-ce-cli=$VERSION_STRING containerd.io docker-compose-plugin
run: pip3 install ansible ansible-lint molecule molecule-plugins[docker] docker

- name: Create test ssl certificate and key
run: |
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ on:
- 'v*'

jobs:
build:
release:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v2
- name: galaxy
uses: robertdebock/galaxy-action@1.1.0
uses: robertdebock/galaxy-action@1.2.1
with:
galaxy_api_key: ${{ secrets.galaxy_api_key }}
git_branch: master
6 changes: 3 additions & 3 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
- name: Restart-ds
community.general.supervisorctl:
ansible.builtin.systemd:
name: "{{ item }}"
state: restarted
with_items:
- 'ds:converter'
- 'ds:docservice'
- 'ds-converter'
- 'ds-docservice'
become: yes

- name: Restart-nginx
Expand Down
1 change: 1 addition & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ galaxy_info:
versions:
- "7"
- "8"
- "9"
- name: Ubuntu
versions:
- "trusty"
Expand Down
15 changes: 12 additions & 3 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@
- name: "{{ db_server_user }}"
password: "{{ db_server_pass }}"



rabbitmq_users:
- name: "{{ rabbitmq_server_user }}"
- user: "{{ rabbitmq_server_user }}"
password: "{{ rabbitmq_server_pass }}"
vhost: "{{ rabbitmq_server_vpath }}"
configure_priv: .*
Expand All @@ -42,6 +40,17 @@
cert_file: "test.crt"
package_url: "{{ lookup('env', 'PACKAGE') }}"

# workaround to pass molecule tests on RockyLinux
pre_tasks:
- name: Install en_US.UTF-8 locale
ansible.builtin.yum:
name: glibc-langpack-en
state: present
when: ansible_distribution == 'Rocky'
- name: Set locale to en_US.UTF-8
ansible.builtin.command: localectl set-locale LANG=en_US.UTF-8
when: ansible_distribution == 'Rocky'

roles:
- geerlingguy.postgresql
- onlyoffice.rabbitmq
Expand Down
20 changes: 11 additions & 9 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ verifier:
name: ansible
scenario:
test_sequence:
- lint
- destroy
- dependency
- syntax
- create
- prepare
- converge
- verify
- destroy
- dependency
- cleanup
- destroy
- syntax
- create
- prepare
- converge
- side_effect
- verify
- cleanup
- destroy
lint: |
set -e
yamllint .
Expand Down
43 changes: 11 additions & 32 deletions molecule/default/prepare.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,15 @@
become: true

tasks:
- name: Install PostgreSQL Python libraries.
apt:
update_cache: yes
pkg:
- python3-psycopg2
- gnupg
state: present
- name: Prepare block
when: ansible_os_family == "Debian"
changed_when: false
failed_when: false

- name: Install apt-utils
apt:
name: apt-utils
update_cache: yes
when: ansible_os_family == "Debian"

- name: Install apt-transport-https
apt:
name: apt-transport-https
when: ansible_os_family == "Debian"

- name: Install nginx
apt:
name: nginx
when: ansible_os_family == "Debian"

- name: restart-nginx
ansible.builtin.service:
name: "nginx"
state: restarted
become: yes
when: ansible_os_family == "Debian"
block:
- name: Install required packages
ansible.builtin.apt:
update_cache: true
pkg:
- python3-psycopg2
- gnupg
- apt-utils
- apt-transport-https
state: present
20 changes: 14 additions & 6 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
---
- hosts: all
- name: Verify the service is up and running
hosts: all
remote_user: root
become: true
vars:
proto: "{{ lookup('env', 'PROTO') }}"

tasks:
- name: Wait 30 seconds
ansible.builtin.pause:
seconds: 30

- name: "Get health check status on {{ proto }}://localhost/healthcheck/"
uri:
ansible.builtin.uri:
url: "{{ proto }}://localhost/healthcheck/"
return_content: yes
validate_certs: no
return_content: true
validate_certs: false
timeout: 10
register: healthcheck
failed_when: "'true' not in healthcheck.content"
until: "'true' in healthcheck.content"
retries: 10
delay: 5
4 changes: 2 additions & 2 deletions tasks/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
notify: restart-ds

- name: Start example service
community.general.supervisorctl:
name: ds:example
ansible.builtin.systemd:
name: ds-example
state: started
when: start_example | bool
54 changes: 54 additions & 0 deletions tasks/RedHat9.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
- name: Add onlyoffice repo
ansible.builtin.dnf:
name: "{{ onlyoffice_repo }}"
disable_gpg_check: true
become: true

- name: Install Epel repository (RedHat)
ansible.builtin.dnf:
name: "{{ epel_release }}"
disable_gpg_check: true
state: present
enablerepo: "{{ crb_for_rhel9 }}"
when: ansible_distribution == 'RedHat'
become: true

- name: Install Epel repository (Not RedHat)
ansible.builtin.dnf:
name: epel-release
state: present
enablerepo: crb
when: ansible_distribution != 'RedHat'
become: true

- name: Install dependency
ansible.builtin.dnf:
name: "{{ item.name }}"
disable_gpg_check: true
with_items:
- { name: "{{ nginx_repo }}", state: present }
become: true

- name: Set ds port (if configured)
ansible.builtin.lineinfile:
path: /root/.bashrc
line: export DS_PORT={{ ds_port }}
when:
- ds_port
become: true

- name: Install documentserver from repo
ansible.builtin.dnf:
name: "{{ package_name }}"
update_cache: true
state: "{{ package_state }}"
become: true

- name: Install the documentserver by URL
ansible.builtin.dnf:
name: "{{ package_url }}"
state: present
validate_certs: true
disable_gpg_check: true
when: package_url | length > 0
4 changes: 2 additions & 2 deletions tasks/RedHat_post.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
when: not is_nonfree_package | bool

- name: Start example service
community.general.supervisorctl:
name: ds:example
ansible.builtin.systemd:
name: ds-example
state: started
when: start_example | bool
6 changes: 3 additions & 3 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
ansible.builtin.include_vars: "{{ ansible_os_family }}.yml"
when: ansible_os_family == "Debian"

- name: Include Centos variables
- name: Include RedHat variables
ansible.builtin.include_vars: "{{ ansible_os_family }}{{ ansible_distribution_major_version }}.yml"
when: ansible_os_family == "RedHat"

- name: Include Debian tasks
ansible.builtin.include_tasks: "{{ ansible_os_family }}.yml"
when: ansible_os_family == "Debian"

- name: Include Centos install tasks
- name: Include RedHat install tasks
ansible.builtin.include_tasks: "{{ ansible_os_family }}{{ ansible_distribution_major_version }}.yml"
when: ansible_os_family == "RedHat"

- name: Include Centos postinstall tasks
- name: Include RedHat postinstall tasks
ansible.builtin.include_tasks: "{{ ansible_os_family }}_post.yml"
when: ansible_os_family == "RedHat"

Expand Down
5 changes: 5 additions & 0 deletions vars/RedHat9.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
onlyoffice_repo: "https://download.onlyoffice.com/repo/centos/main/noarch/onlyoffice-repo.noarch.rpm"
nginx_repo: "https://nginx.org/packages/rhel/9/x86_64/RPMS/nginx-1.24.0-1.el9.ngx.x86_64.rpm"
msttcore_fonts: "https://downloads.sourceforge.net/project/mscorefonts2/rpms/msttcore-fonts-installer-2.6-1.noarch.rpm"
epel_release: "https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm"
crb_for_rhel9: "codeready-builder-for-rhel-9-{{ ansible_architecture }}-rpms"

0 comments on commit f3ca1d3

Please sign in to comment.