Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
feat: default java version has been switched from 8 to 11 (#37)
Browse files Browse the repository at this point in the history
* feat: openjdk has been switched from 8 to 11

* fix: ansible and yamllint should be installed

* fix: lint error

* chore: update python version due to ansible deprecation warning

* fix: ansible-lint errors have been removed

* fix: adjust vm.max_map_count value for elasticsearch

* chore: quotes for name values have been added
  • Loading branch information
oukooveu authored Oct 19, 2021
1 parent ab627d0 commit a619486
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 28 deletions.
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
language: python

python:
- "3.6" # current default Python on Travis CI
- "3.8"

cache: pip

Expand All @@ -17,6 +17,8 @@ env:
# - MOLECULE_DISTRO=debian10

install:
- pip install --quiet yamllint
- pip install --quiet ansible
- pip install --quiet molecule
- pip install --quiet 'molecule[docker]'
- pip install --quiet ansible-lint
Expand Down
19 changes: 3 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Requirements
------------

[SonarQube requirements](https://docs.sonarqube.org/display/SONAR/Requirements) are:
- Oracle JRE 8 onwards or OpenJDK 8 onwards installed on your machine.
- Oracle JRE 11 onwards or OpenJDK 11 onwards installed on your machine.

For production environment, make sure to set the `sonar_db_embedded` variable to false and to configure sonar_db_* variables.

Expand Down Expand Up @@ -288,7 +288,7 @@ Available variables along with default values are listed below (see `defaults/ma
# Access log is the list of all the HTTP requests received by server. If enabled, it is stored
# in the file {sonar.path.logs}/access.log. This file follows the same rolling policy as for
# sonar.log (see sonar.log.rollingPolicy and sonar.log.maxFiles).
sonar_web_accessLogs_enable: true
sonar_web_access_logs_enable: true

# Format of access log. It is ignored if sonar.web.accessLogs.enable=false. Possible values are:
# - "common" is the Common Log Format, shortcut to: %h %l %u %user %date "%r" %s %b
Expand Down Expand Up @@ -362,24 +362,13 @@ Available variables along with default values are listed below (see `defaults/ma
Dependencies
------------
This role need the following Ansible Galaxy dependencies:
- [geerlingguy.java](https://galaxy.ansible.com/geerlingguy/java/)
Override the default `java_packages` variable to set a java package that match SonarQube requirements on JAVA version (depending on SonarQube version)

As it use the following Ansible modules, it also need some packages on role target:

- module `unarchive`: unzip package
There are no direct dependencies. JDK should be installed first.
Example Playbook
----------------
```
- hosts: servers
vars:
java_packages:
- java-1.8.0-openjdk
pre_tasks:
- name: Install package dependencies.
package:
Expand All @@ -388,7 +377,6 @@ Example Playbook
with_items:
- unzip
roles:
- geerlingguy.java
- lrk.sonarqube
```
Expand Down Expand Up @@ -422,7 +410,6 @@ Apache License Version 2.0

References
----------
- [geerlingguy.java](https://galaxy.ansible.com/geerlingguy/java/)
- [SonarQube Documentation](https://docs.sonarqube.org/display/SONAR/Documentation)

Author Information
Expand Down
2 changes: 1 addition & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ sonar_log_max_files: 7
# Access log is the list of all the HTTP requests received by server. If enabled, it is stored
# in the file {sonar.path.logs}/access.log. This file follows the same rolling policy as for
# sonar.log (see sonar.log.rollingPolicy and sonar.log.maxFiles).
sonar_web_accessLogs_enable: true
sonar_web_access_logs_enable: true

# Format of access log. It is ignored if sonar.web.accessLogs.enable=false. Possible values are:
# - "common" is the Common Log Format, shortcut to: %h %l %u %user %date "%r" %s %b
Expand Down
4 changes: 1 addition & 3 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
galaxy_info:
author: lrk
role_name: sonarqube
description: "An Ansible Role that install SonarQube."
license: "Apache License Version 2.0"

Expand All @@ -22,6 +23,3 @@ galaxy_info:
- 'development'
- 'monitoring'
- 'sonarqube'

dependencies:
- geerlingguy.java
19 changes: 17 additions & 2 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,26 @@
version: "6.4"
commercial: false
url: "https://github.com/felipebz/sonar-l10n-pt/releases/download/v6.4/sonar-l10n-pt-plugin-6.4.jar"

- name: "sonar-l10n-es"
version: "1.14"
commercial: false
url: "https://github.com/acalero/sonar-l10n-es/releases/download/sonar-l10n-es-plugin-1.14/sonar-l10n-es-plugin-1.14.jar"
pre_tasks:
- name: install openjdk (redhat)
package:
name: java-11-openjdk
state: present
when: ansible_facts['os_family'] == "RedHat"
- name: add backports repository
apt_repository:
repo: deb http://ftp.debian.org/debian stretch-backports main
state: present
update_cache: yes
when: ansible_facts['os_family'] == "Debian"
- name: install openjdk (debian)
apt:
name: openjdk-11-jdk
state: present
when: ansible_facts['os_family'] == "Debian"
roles:
- role: geerlingguy.java
- role: ansible-role-sonarqube
3 changes: 0 additions & 3 deletions molecule/default/requirements.yml

This file was deleted.

9 changes: 8 additions & 1 deletion tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
- "{{ sonar_data_dir }}"
- "{{ sonar_temp_dir }}"

- name: "set max_map_count value (required by elasticsearch)"
sysctl:
name: vm.max_map_count
value: 262144
state: present

- name: "Ensure JAVA is installed"
command: "java -version"
register: prereq_java
Expand All @@ -51,7 +57,8 @@
loop_control:
loop_var: "sonar_cplugin"

- meta: flush_handlers
- name: "flush handlers"
meta: flush_handlers

- name: "Ensure target version matches"
uri:
Expand Down
2 changes: 1 addition & 1 deletion templates/sonar.properties.j2
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ sonar.log.level={{ sonar_log_level | default('INFO') }}
sonar.path.logs={{ sonar_logs_dir | default('logs') }}
sonar.log.rollingPolicy={{ sonar_log_rolling_policy | default('time:yyyy-MM-dd') }}
sonar.log.maxFiles={{ sonar_log_max_files | default('7') }}
sonar.web.accessLogs.enable={{ sonar_web_accessLogs_enable | default('true') | lower }}
sonar.web.access_logs.enable={{ sonar_web_access_logs_enable | default('true') | lower }}
sonar.web.accessLogs.pattern={{ sonar_web_access_logs_pattern | default('combined')}}


Expand Down

0 comments on commit a619486

Please sign in to comment.