-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsonar_qube_stuff.yml
executable file
·120 lines (99 loc) · 4.03 KB
/
sonar_qube_stuff.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
---
- hosts: localhost
connection: local
tasks:
### based on http://dev.mamikon.net/installing-sonarqube-on-ubuntu/
- apt: pkg=python-pip state=present
- apt: name=python-setuptools state=latest
- apt: name=python-dev state=present
- apt: name=libmysqlclient-dev state=latest
- pip: name=MySQL-python
- mysql_db:
name: sonar
state: present
login_host: localhost
login_port: 3306
login_user: root
login_password: root
encoding: utf8
collation: utf8_general_ci
# check if user exists
- shell: mysql -u root -e 'select user from mysql.user where User = "sonar";'
environment:
MYSQL_PWD: root
register: result
# create the user, the stupid "mysql_user" module does not suport "when" and "register"
- mysql_user:
name: sonar
password: sonar
state: present
login_host: localhost
login_port: 3306
login_user: root
login_password: root
# only do it if user did not exists before
- shell: mysql -u root -proot -e 'GRANT ALL ON sonar.* TO "sonar"@"%" IDENTIFIED BY "sonar";'
environment:
MYSQL_PWD: root
when: "'\nsonar' not in '{{result.stdout}}'"
# only do it if user did not exists before
- shell: mysql -u root -e 'GRANT ALL ON sonar.* TO "sonar"@"localhost" IDENTIFIED BY "sonar";'
environment:
MYSQL_PWD: root
when: "'\nsonar' not in '{{result.stdout}}'"
# only do it if user did not exists before
- shell: mysql -u root -e 'FLUSH PRIVILEGES;'
environment:
MYSQL_PWD: root
when: "'\nsonar' not in '{{result.stdout}}'"
- get_url:
url: "https://sonarsource.bintray.com/Distribution/sonarqube/sonarqube-5.6.4.zip"
dest: /mnt/hdd2/sonarqube-5.6.4.zip
mode: 0777
- unarchive:
src: /mnt/hdd2/sonarqube-5.6.4.zip
dest: /mnt/hdd2
- lineinfile:
dest: /mnt/hdd2/sonarqube-5.6.4/conf/sonar.properties
line: 'sonar.jdbc.username=sonar'
- lineinfile:
dest: /mnt/hdd2/sonarqube-5.6.4/conf/sonar.properties
line: 'sonar.jdbc.password=sonar'
- lineinfile:
dest: /mnt/hdd2/sonarqube-5.6.4/conf/sonar.properties
line: 'sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance'
- lineinfile:
dest: /mnt/hdd2/sonarqube-5.6.4/conf/sonar.properties
line: 'sonar.web.host=127.0.0.1'
- lineinfile:
dest: /mnt/hdd2/sonarqube-5.6.4/conf/sonar.properties
line: 'sonar.web.context=/sonar'
- lineinfile:
dest: /mnt/hdd2/sonarqube-5.6.4/conf/sonar.properties
line: 'sonar.web.port=9000'
- get_url:
url: "https://sonarsource.bintray.com/Distribution/sonar-scanner-cli/sonar-scanner-2.8.zip"
dest: /mnt/hdd2/sonar-scanner-2.8.zip
mode: 0777
- unarchive:
src: /mnt/hdd2/sonar-scanner-2.8.zip
dest: /mnt/hdd2
- lineinfile:
dest: /mnt/hdd2/sonar-scanner-2.8/conf/sonar-scanner.properties
line: 'sonar.host.url=http://localhost:9000/sonar'
- lineinfile:
dest: /mnt/hdd2/sonar-scanner-2.8/conf/sonar-scanner.properties
line: 'sonar.sourceEncoding=UTF-8'
- lineinfile:
dest: /mnt/hdd2/sonar-scanner-2.8/conf/sonar-scanner.properties
line: 'sonar.jdbc.username=sonar'
- lineinfile:
dest: /mnt/hdd2/sonar-scanner-2.8/conf/sonar-scanner.properties
line: 'sonar.jdbc.password=sonar'
- lineinfile:
dest: /mnt/hdd2/sonar-scanner-2.8/conf/sonar-scanner.properties
line: 'sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8'
####start the sonar server by: "sudo /mnt/hdd2/sonarqube-5.6.4/bin/linux-x86-64/sonar.sh start"
####stop : "sudo /mnt/hdd2/sonarqube-5.6.4/bin/linux-x86-64/sonar.sh stop"
####check sonar-scanenr install: "/mnt/hdd2/sonar-scanner-2.8/bin/sonar-scanner -v"
#mysql -u root -proot -e 'show databases;'