Skip to content

Commit d329be7

Browse files
Merge pull request #36 from oci-hpc/FIX-mysql-shell
Fix mysql shell
2 parents 0ad2b21 + e5941c1 commit d329be7

File tree

6 files changed

+228
-8
lines changed

6 files changed

+228
-8
lines changed

playbooks/resize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def update_cluster(mode,hostnames=[],slurm_only_update='false'):
213213
my_env = os.environ.copy()
214214
my_env["ANSIBLE_HOST_KEY_CHECKING"] = "False"
215215
rc = 0
216-
p = subprocess.Popen(["/tmp/configure.sh",playbook,inv_file],env=my_env,stderr = subprocess.PIPE, stdout=subprocess.PIPE)
216+
p = subprocess.Popen(["/opt/oci-hpc/bin/configure.sh",playbook,inv_file],env=my_env,stderr = subprocess.PIPE, stdout=subprocess.PIPE)
217217
while True:
218218
output = p.stdout.readline().decode()
219219
if output == '' and p.poll() is not None:

playbooks/roles/autoscaling_mon/tasks/el.yml renamed to playbooks/roles/autoscaling_mon/tasks/el7.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,14 @@
7979
no_log: false
8080
register: existing_api_keys
8181

82-
- name: install mysql
82+
- name: install EL7 mysql release file
8383
become: true
8484
yum:
85-
name: https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
85+
name: https://dev.mysql.com/get/mysql80-community-release-el7-5.noarch.rpm
8686

8787
- name: install mysql-shell
8888
become: true
89-
yum:
89+
yum:
9090
name: mysql-shell
9191

9292
- name: install mysql connector
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
- include: el.yml
2-
when: ansible_os_family == 'RedHat'
1+
- include: ol7.yml
2+
when: ansible_os_family == 'RedHat' and ansible_distribution == 'OracleLinux' and ansible_distribution_major_version == '7'
3+
4+
- include: el7.yml
5+
when: ansible_os_family == 'RedHat' and ansible_distribution == 'CentOS' and ansible_distribution_major_version == '7'
Lines changed: 217 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,217 @@
1+
---
2+
- name: Ensure monitoring directory exists
3+
file:
4+
path: "/opt/oci-hpc/monitoring"
5+
state: directory
6+
owner: opc
7+
group: opc
8+
9+
- name: Copy files
10+
become: true
11+
copy:
12+
src: '{{ item }}'
13+
dest: '/opt/oci-hpc/monitoring/{{ item }}'
14+
force: no
15+
owner: opc
16+
group: opc
17+
with_items:
18+
- dashboard.json
19+
- initial.sql
20+
21+
- name: Copy scripts
22+
become: true
23+
copy:
24+
src: '{{ item }}'
25+
dest: '/opt/oci-hpc/monitoring/{{ item }}'
26+
force: no
27+
owner: opc
28+
group: opc
29+
mode: 0755
30+
with_items:
31+
- initial.sh
32+
- monitor_oci.sh
33+
- monitor_slurm.sh
34+
35+
- name: Generate env file
36+
template:
37+
src: env.j2
38+
dest: /opt/oci-hpc/monitoring/env
39+
40+
- name: add grafana repository
41+
become: true
42+
yum_repository:
43+
name: grafana
44+
description: grafana
45+
baseurl: https://packages.grafana.com/oss/rpm
46+
repo_gpgcheck: 1
47+
enabled: 1
48+
gpgcheck: 1
49+
gpgkey: https://packages.grafana.com/gpg.key
50+
sslverify: 1
51+
sslcacert: /etc/pki/tls/certs/ca-bundle.crt
52+
53+
- name: install grafana
54+
become: true
55+
yum:
56+
name: grafana
57+
state: latest
58+
59+
- name: start grafana
60+
become: true
61+
service:
62+
name: grafana-server
63+
state: restarted
64+
enabled: true
65+
66+
- name: Ensure grafana key directory exists
67+
file:
68+
path: "/etc/opt/oci-hpc/passwords/grafana"
69+
state: directory
70+
delegate_to: localhost
71+
72+
- name: Check api key list
73+
uri:
74+
url: "{{ grafana_api_url }}/api/auth/keys"
75+
user: "{{ grafana_security.admin_user }}"
76+
password: "{{ grafana_security.admin_password }}"
77+
force_basic_auth: true
78+
return_content: true
79+
no_log: false
80+
register: existing_api_keys
81+
82+
- name: install OL7 mysql release file
83+
become: true
84+
yum:
85+
name: mysql-release-el7
86+
87+
- name: install mysql-shell
88+
become: true
89+
yum:
90+
name: mysql-shell
91+
92+
- name: install mysql connector
93+
become: true
94+
pip:
95+
name: mysql-connector-python
96+
executable: pip-3
97+
98+
- name: Get root password from /etc/opt/oci-hpc/passwords
99+
set_fact:
100+
mysql_root_pwd: "{{ lookup('password',
101+
'/etc/opt/oci-hpc/passwords/mysql/root.txt
102+
chars=ascii_letters,digits') }}"
103+
when: not autoscaling_mysql_service | bool
104+
105+
- name: Get root password from configuration
106+
set_fact:
107+
mysql_root_pwd: "{{ admin_password }}"
108+
when: autoscaling_mysql_service | bool
109+
110+
- name: Generate mysql_service_initial file
111+
template:
112+
src: mysql_service_initial.j2
113+
dest: /opt/oci-hpc/monitoring/mysql_service_initial.sql
114+
when: autoscaling_mysql_service | bool
115+
116+
- name: Create database 'cluster_log'
117+
mysql_db:
118+
login_user: "{{ admin_username }}"
119+
login_password: "{{ mysql_root_pwd }}"
120+
name: cluster_log
121+
state: present
122+
when: not autoscaling_mysql_service | bool
123+
124+
- name: Create database user with name 'logger' and password
125+
mysql_user:
126+
login_user: "{{ admin_username }}"
127+
login_password: "{{ mysql_root_pwd }}"
128+
name: logger
129+
password: Monitor2021!
130+
priv: cluster_log.*:SELECT,INSERT,UPDATE,DELETE
131+
state: present
132+
when: not autoscaling_mysql_service | bool
133+
134+
- name: Create initial DB
135+
shell: "source /opt/oci-hpc/monitoring/env; mysqlsh {{ admin_username }}@{{ monitoring_mysql_ip }} -p{{ mysql_root_pwd }} --sql --file /opt/oci-hpc/monitoring/mysql_service_initial.sql"
136+
ignore_errors: yes
137+
when: autoscaling_mysql_service | bool
138+
139+
- name: Create initial DB
140+
shell: "source /opt/oci-hpc/monitoring/env; mysqlsh {{ admin_username }}@{{ monitoring_mysql_ip }} -p{{ mysql_root_pwd }} --sql --file /opt/oci-hpc/monitoring/initial.sql"
141+
ignore_errors: yes
142+
143+
- name: Monitoring activated
144+
shell: "echo OK >> /opt/oci-hpc/monitoring/activated"
145+
146+
- name: Create mysql datasource
147+
grafana_datasource:
148+
name: "autoscaling"
149+
grafana_url: "{{ grafana_api_url }}"
150+
grafana_user: "{{ grafana_security.admin_user }}"
151+
grafana_password: "{{ grafana_security.admin_password }}"
152+
org_id: "1"
153+
ds_type: "mysql"
154+
ds_url: "{{ monitoring_mysql_ip }}:3306"
155+
database: "cluster_log"
156+
password: "Monitor2021!"
157+
user: "logger"
158+
ignore_errors: yes
159+
160+
# - name: Import grafana dashboards through API
161+
# uri:
162+
# url: "{{ grafana_api_url }}/api/dashboards/db"
163+
# user: "{{ grafana_security.admin_user }}"
164+
# password: "{{ grafana_security.admin_password }}"
165+
# force_basic_auth: true
166+
# method: POST
167+
# body_format: json
168+
# body: >
169+
# {
170+
# "dashboard": {{ lookup("file", item) }},
171+
# "overwrite": true,
172+
# "message": "Updated by ansible"
173+
# }
174+
# no_log: false
175+
# with_fileglob:
176+
# - files/dashboard.json
177+
# ignore_errors: yes
178+
179+
#- name: Create influxdb datasource
180+
# grafana_datasource:
181+
# name: "InfluxDB"
182+
# grafana_url: "{{ grafana_api_url }}"
183+
# grafana_user: "{{ grafana_security.admin_user }}"
184+
# grafana_password: "{{ grafana_security.admin_password }}"
185+
# org_id: "1"
186+
# ds_type: "influxdb"
187+
# ds_url: "http://localhost:8086"
188+
# database: "telegraf"
189+
# time_interval: ">10s"
190+
191+
#- name: Import grafana dashboards through API
192+
# uri:
193+
# url: "{{ grafana_api_url }}/api/dashboards/db"
194+
# user: "{{ grafana_security.admin_user }}"
195+
# password: "{{ grafana_security.admin_password }}"
196+
# force_basic_auth: true
197+
# method: POST
198+
# body_format: json
199+
# body: >
200+
# {
201+
# "dashboard": {{ lookup("file", item) }},
202+
# "overwrite": true,
203+
# "message": "Updated by ansible"
204+
# }
205+
# no_log: false
206+
# with_fileglob:
207+
# - files/cluster.json
208+
209+
#- name: Import Grafana dashboard foo
210+
# community.grafana.grafana_dashboard:
211+
# grafana_url: "{{ grafana_api_url }}"
212+
# grafana_user: "{{ grafana_security.admin_user }}"
213+
# grafana_password: "{{ grafana_security.admin_password }}"
214+
# state: present
215+
# message: Updated by ansible
216+
# overwrite: yes
217+
# path: files/cluster.json

playbooks/site.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@
174174
when: slurm|default(false)|bool
175175
- include_role:
176176
name: autoscaling_mon
177-
when: autoscaling_monitoring|default(false)|bool
177+
when: autoscaling_monitoring|default(false)|bool and autoscaling|default(false)|bool
178178
- include_role:
179179
name: cron
180180

variables.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ variable "compute_username" {
135135

136136
variable "autoscaling_monitoring" {
137137
type= bool
138-
default = true
138+
default = false
139139
}
140140

141141
variable "autoscaling_mysql_service" {

0 commit comments

Comments
 (0)