-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasks_sonar.yml
51 lines (45 loc) · 1.56 KB
/
tasks_sonar.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
---
- name: Install SonarQube
unarchive:
src: https://sonarsource.bintray.com/Distribution/sonarqube/{{ sonar_version }}.zip
dest: /opt
copy: no
owner: '{{ user }}'
group: '{{ user }}'
creates: /opt/{{ sonar_version }}
- name: Create SonarQube database
postgresql_db:
name: sonarqube
become: yes
become_user: postgres
- name: Configure SonarQube (wrapper)
replace:
dest: /opt/{{ sonar_version }}/conf/wrapper.conf
regexp: ^wrapper.java.command.*
replace: wrapper.java.command=/opt/{{ java_version }}/bin/java
- name: Configure SonarQube (app)
replace:
dest: /opt/{{ sonar_version }}/conf/sonar.properties
regexp: '{{ item.regexp }}'
replace: '{{ item.line }}'
with_items:
- { regexp: '^#?sonar.jdbc.username.*', line: 'sonar.jdbc.username=postgres' }
- { regexp: '^#?sonar.jdbc.password.*', line: 'sonar.jdbc.password={{ pg_pwd }}' }
- { regexp: '^#?sonar.jdbc.url=jdbc:postgresql.*', line: 'sonar.jdbc.url=jdbc:postgresql://localhost/sonarqube' }
- { regexp: '^#?sonar.web.host.*', line: 'sonar.web.host=localhost' }
- name: Configure SonarQube service
template:
src: '{{ item.src }}'
dest: '{{ item.dest }}'
with_items:
- { src: files/systemd.sonar.service, dest: /usr/lib/systemd/system/sonar.service }
- { src: files/nginx.sonar.conf, dest: /etc/nginx/conf.d/sonar.conf }
- name: Enable SonarQube service
service:
name: sonar
enabled: yes
state: started
- name: Restart nginx
service:
name: nginx
state: restarted