-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added role for installing 3rd party SonarQube plugins (#355)
* Added role for installing 3rd party SonarQube plugins * Improve readability and simplify
- Loading branch information
1 parent
8875bb0
commit f00f7a1
Showing
5 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Overview | ||
|
||
This role uses the OpenShift command-line tool to upload a JAR based SonarQube plugin into a running SonarQube instance, then restarts that running SonarQube instance so that the plugin gets loaded. | ||
|
||
# Usage | ||
|
||
```yaml | ||
- name: Install C++ Community Plugin For SonarQube | ||
hosts: ocp-sonarqube | ||
|
||
roles: | ||
- add-sonar-plugin | ||
vars: | ||
plugin_url: https://github.com/SonarOpenCommunity/sonar-cxx/releases/download/cxx-1.2.2/sonar-cxx-plugin-1.2.2.1653.jar | ||
install_location: /opt/sonarqube/extensions/plugins | ||
namespace: labs-ci-cd | ||
pod_prefix: sonarqube | ||
``` | ||
# Testing | ||
* Deploy a [Labs CI/CD environment](https://github.com/rht-labs/labs-ci-cd) | ||
* Apply the role using the test playbook: `ansible-playbook -i inventory test.yml | ||
* Verify deployment after SonarQube restarts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
--- | ||
|
||
- name: Get JAR name | ||
set_fact: | ||
jar_name: "{{ plugin_url.split('/')[-1] }}" | ||
|
||
- name: Download the SonarQube plugin | ||
get_url: | ||
url: "{{ plugin_url }}" | ||
dest: "/tmp/{{ jar_name }}" | ||
mode: 0440 | ||
|
||
## The Jinja2 template and the Go template in the following task conflict, | ||
## so the weird double-curly-braces surrounded by double-curly-braces is required. | ||
- name: Find sonarqube pod | ||
command: >- | ||
oc get pods --namespace={{ namespace }} -l="app==sonarqube" | ||
-o jsonpath="{.items[0].metadata.name}" | ||
register: pod_name_lines | ||
|
||
- name: Extract pod name | ||
set_fact: | ||
pod_name: "{{ pod_name_lines.stdout }}" | ||
|
||
- name: Copy plugin to SonarQube pod | ||
command: "oc cp /tmp/{{ jar_name }} {{ namespace }}/{{ pod_name }}:{{ install_location }}/{{ jar_name }}" | ||
|
||
- name: Redeploy SonarQube | ||
command: "oc rollout latest --namespace={{ namespace }} {{ pod_prefix }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[ocp-sonarqube] | ||
localhost ansible_connection=local |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../.. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
- name: Install C++ Community Plugin For SonarQube | ||
hosts: ocp-sonarqube | ||
|
||
roles: | ||
- role: add-sonar-plugin | ||
vars: | ||
plugin_url: https://github.com/SonarOpenCommunity/sonar-cxx/releases/download/cxx-1.2.2/sonar-cxx-plugin-1.2.2.1653.jar | ||
install_location: /opt/sonarqube/extensions/plugins | ||
namespace: deven-role-test | ||
pod_prefix: sonarqube |