Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- Create a stroom node entry linked to the first rack we find
-- (as rack is pretty much depreacted)
-- Only works on v6
UPDATE ND SET
VER = VER + 1,
UPD_USER = 'INTERNAL_PROCESSING_USER',
CLSTR_URL = 'http://{{ stroom_hostname }}:{{ stroom_app_port }}/stroom/clustercall.rpc',
UPD_MS = UNIX_TIMESTAMP() * 1000
WHERE NAME = '{{ stroom_node_name }}';

-- vim: set shiftwidth=2 tabstop=2 expandtab filetype=sql:
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ db_port: 3306
stroom_db_root_password: "my-secret-pw"
stroom_databases:

- name: stroom
stroom:
user: stroomuser
password: stroompassword1

- name: stats
stats:
user: statsuser
password: stroompassword1

- name: auth
auth:
user: authuser
password: stroompassword1

Expand Down
29 changes: 29 additions & 0 deletions stroom/install_mixed_cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,32 @@

- import_role:
name: non_docker_proxy/deploy

########### One of stroom_and_proxy HOSTS ###########

# TODO start up services stack then start up one stroom node to build the DB
# In v7 we could just run the migrate.sh script.

#- hosts:
#- stroom_and_proxy[0]
#become: true
#become_user: "{{ stroom_user }}"
#tasks:

#- import_role:
#name:

########### stroom_database HOSTS ###########

- name: "Initialise database"
hosts:
- stroom_database
gather_facts: true
tasks:

- import_role:
name: db_init/nodes
tags:
- deploy
- configure
- db_init
15 changes: 15 additions & 0 deletions stroom/install_stack_cluster.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,18 @@
name: stack/deploy
tags:
- deploy

########### stroom_database HOSTS ###########

- name: "Initialise database"
hosts:
- stroom_database
gather_facts: true
tasks:

- import_role:
name: db_init/nodes
tags:
- deploy
- configure
- db_init
8 changes: 8 additions & 0 deletions stroom/roles/db_init/nodes/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---

stroom_database_name: "stroom"
stroom_app_port: 8080
db_username: "{{ stroom_databases[stroom_database_name]['user'] }}"
db_password: "{{ stroom_databases[stroom_database_name]['password'] }}"

db_init_files_and_templates_dir: "{{ local_config_dir }}/files_and_templates/db_init_scripts"
5 changes: 5 additions & 0 deletions stroom/roles/db_init/nodes/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---

- name: "Loop over Stroom nodes"
include_tasks: update_cluster_url.yml
loop: "{{ groups['stroom_and_proxy'] }}"
53 changes: 53 additions & 0 deletions stroom/roles/db_init/nodes/tasks/update_cluster_url.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---

# This assumes the stroom node name is the same as the ansible host name

- debug:
msg:
- "Node name: {{ hostvars[item]['inventory_hostname_short'] }}"
- "User: {{ stroom_databases[stroom_database_name]['user'] }}"

- name: "Checking if node {{ item }} has a cluster URL set in the database"
shell:
cmd: >
echo "select count(*) from ND where NAME='{{ hostvars[item]['inventory_hostname_short'] }}' and CLSTR_URL is not null;"
| mysql
-s
-u {{ db_username }}
-p'{{ db_password }}'
{{ stroom_database_name }}
changed_when: false
register: query_info

- name: "Set cluster call url for node {{ item }}"
when: query_info.stdout == '0'
block:

- name: "Create temp file"
tempfile:
state: file
prefix: stroom_db_init_create_node_
suffix: .sql
register: temp_sql_file_info

# TODO need a conditional alternative for stroom v7
- name: "Copy template onto remote host, into tempfile"
template:
src: "{{ db_init_files_and_templates_dir }}/create_node_record_v6.sql.j2"
dest: temp_sql_file_info.path
vars:
stroom_hostname: "{{ hostvars[item]['inventory_hostname'] }}"
stroom_node_name: "{{ hostvars[item]['inventory_hostname_short'] }}"

- name: "Execute temp sql file {{ temp_sql_file_info }}"
mysql_db:
state: import
name: "{{ stroom_database_name }}"
login_user: "{{ db_username }}"
login_password: "{{ db_password }}"
target: temp_sql_file_info.path

- name: "Delete temp sql file {{ temp_sql_file_info.path }}"
file:
path: temp_sql_file_info.path
state: absent
6 changes: 3 additions & 3 deletions stroom/roles/setup/mysql/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ stroom_db_root_password: "my-secret-pw"

stroom_databases:

- name: stroom
stroom:
user: stroomuser
password: stroompassword1
privs: "stroom.*:ALL"
host: "%"

- name: stats
stats:
user: statsuser
password: stroompassword1
privs: "stats.*:ALL"
host: "%"

- name: auth
auth:
user: authuser
password: stroompassword1
privs: "auth.*:ALL"
Expand Down
26 changes: 17 additions & 9 deletions stroom/roles/setup/mysql/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,28 @@
name: test
state: absent

- name: Debug
debug:
var: "{{ item }}"
verbosity: 2
loop: "{{ stroom_databases | dict2items }}"
loop_control:
label: "{{ item.key }}"

- name: Create mysql databases
mysql_db:
name: "{{ item.name }}"
name: "{{ item.key }}"
state: present
loop: "{{ stroom_databases | flatten(levels=1) }}"
loop: "{{ stroom_databases | dict2items }}"
loop_control:
label: "{{ item.name }}"
label: "{{ item.key }}"

- name: Setup MySQL users
mysql_user:
name: "{{ item.user }}"
password: "{{ item.password | default('stroompassword1') }}"
host: "{{ item.host | default('%') }}"
priv: "{{ item.privs | default(item.name + '.*:ALL') }}"
loop: "{{ stroom_databases | flatten(levels=1) }}"
name: "{{ item.value.user }}"
password: "{{ item.value.password | default('stroompassword1') }}"
host: "{{ item.value.host | default('%') }}"
priv: "{{ item.value.privs | default(item.key + '.*:ALL') }}"
loop: "{{ stroom_databases | dict2items }}"
loop_control:
label: "{{ item.name }}, {{ item.user }}, {{ item.host | default('%') }}, {{ item.privs | default(item.name + '.*:ALL') }}"
label: "{{ item.key }}, {{ item.value.user }}, {{ item.value.host | default('%') }}, {{ item.value.privs | default(item.key + '.*:ALL') }}"