Skip to content

Commit

Permalink
setup - updated db init-script
Browse files Browse the repository at this point in the history
  • Loading branch information
superstes committed Oct 30, 2021
1 parent 8fb8bfb commit 059d450
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 deletions.
7 changes: 6 additions & 1 deletion setup/roles/web/tasks/init_db.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,16 @@
- 'create_user.py'
- 'crypto.py'

- name: GA | Web | Init | Getting encrypted password
- name: GA | Web | Init | Getting encrypted core-password
ansible.builtin.shell: "/usr/bin/python3 /tmp/crypto.py {{ ga_core_path | quote }} encrypt {{ ga_sql_pwd_core | quote }}"
no_log: true
register: ga_sql_pwd_core_encrypted

- name: GA | Web | Init | Getting encrypted web-password
ansible.builtin.shell: "/usr/bin/python3 /tmp/crypto.py {{ ga_core_path | quote }} encrypt {{ ga_sql_pwd_web | quote }}"
no_log: true
register: ga_sql_pwd_web_encrypted

- name: GA | Web | Init | Copying database initialization script
ansible.builtin.template:
src: "templates/tmp/config_init.sql.j2"
Expand Down
21 changes: 15 additions & 6 deletions setup/roles/web/templates/tmp/config_init.sql.j2
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
INSERT IGNORE INTO {{ ga_sql_db }}.ga_objectcontrollermodel
(created, updated, name, description, path_root, path_log, path_backup, sql_server, sql_port, sql_user, sql_secret, sql_database,
log_level, debug, security, backup, timezone, device_fail_count, device_fail_sleep, device_log, web_cdn, web_warn)
/* This script is used to initialize the main configuration-objects - without those the core and web-interface won't work properly */

INSERT IGNORE INTO {{ ga_sql_db }}.ga_systemservermodel
(created, updated, name, description, path_core, path_web, path_web_static, path_home_core, path_home_web, path_log, sql_server, sql_port, sql_user, sql_secret, sql_database,
log_level, debug, security, timezone, web_cdn, web_warn, ga_cloud, ga_cloud_uuid, ga_cloud_token, ga_cloud_ddns)
VALUES
(NOW(), NOW(), '{{ ga_core_controller_name }}', 'Controller created by setup', '{{ ga_core_path }}', '{{ ga_path_log }}', '{{ ga_path_backup }}',
'{{ ga_sql_server }}', {{ ga_sql_port }}, '{{ ga_sql_user_core }}', '{{ ga_sql_pwd_core_encrypted.stdout }}', '{{ ga_sql_db }}', {{ ga_log_level }}, 0,
{% if ga_security_mode %}1{% else %}0{% endif %}, 0, '{{ ga_timezone }}', 5, 3600, 1, 0, 1);
(NOW(), NOW(), '{{ ga_core_controller_name }}', 'Server created by setup', '{{ ga_core_path }}', '{{ ga_web_path }}', '{{ ga_web_path_static }}', '{{ ga_core_path_home }}',
'{{ ga_web_path_home }}', '{{ ga_path_log }}', '{{ ga_sql_server }}', {{ ga_sql_port }}, '{{ ga_sql_user_web }}', '{{ ga_sql_pwd_web_encrypted.stdout }}', '{{ ga_sql_db }}',
{{ ga_log_level }}, 0, {% if ga_security_mode %}1{% else %}0{% endif %}, '{{ ga_timezone }}', 0, 1, 0, NULL, NULL, 0);

INSERT IGNORE INTO {{ ga_sql_db }}.ga_systemagentmodel
(created, updated, name, description, path_root, path_home, path_log, sql_server, sql_port, sql_user, sql_secret, sql_database,
log_level, debug, device_fail_count, device_fail_sleep, device_log, svc_interval_status, svc_interval_reload, subprocess_timeout)
VALUES
(NOW(), NOW(), '{{ ga_core_controller_name }}', 'Agent created by setup', '{{ ga_core_path }}', '{{ ga_core_path_home }}', '{{ ga_path_log }}', '{{ ga_sql_server }}', {{ ga_sql_port }},
'{{ ga_sql_user_core }}', '{{ ga_sql_pwd_core_encrypted.stdout }}', '{{ ga_sql_db }}', {{ ga_log_level }}, 0, 3, 3600, 1, 3600, 21600, 60);
6 changes: 4 additions & 2 deletions setup/vars/hardcoded.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ ga_core_service_user: 'ga_core'
ga_web_service_user: 'ga_web'
ga_update_service_user: 'ga_update'
ga_service_group: 'ga'
ga_core_path_venv: "/home/{{ ga_core_service_user }}/venv"
ga_web_path_venv: "/home/{{ ga_web_service_user }}/venv"
ga_core_path_home: "/home/{{ ga_core_service_user }}"
ga_core_path_venv: "{{ ga_core_path_home }}/venv"
ga_web_path_home: "/home/{{ ga_core_service_user }}"
ga_web_path_venv: "{{ ga_web_path_home }}/venv"

# core
ga_core_packages:
Expand Down

0 comments on commit 059d450

Please sign in to comment.