-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new role for changing engine from local to remote db #145
base: master
Are you sure you want to change the base?
Changes from 3 commits
a5e9ac7
e24a787
19b558e
556109f
0bedcf8
9500dfa
739d1ad
36ddc5e
3235a69
9870d31
e5543e0
a5e1f2a
bf33241
66b4438
8994178
e57c2e3
9691c80
532616e
1a389c9
e1399a1
7f7d264
12bc29c
90e4605
90aaca1
3169b17
29d776e
0c1ad97
e8ab3ff
951141f
064bffb
0df0b0e
9a29cbb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[engine:vars] | ||
|
||
#### Type flag #### | ||
# flag that it is engine machine | ||
ovirt_type=engine | ||
|
||
[database:vars] | ||
|
||
#### Type flag #### | ||
# flag that it is engine machine | ||
ovirt_type=remote_db |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
# in inventory file engine has ovirt_type=engine, database has ovirt_type=remote_db | ||
- hosts: engine database | ||
vars: | ||
ovirt_engine_dwh_to_remote_db: True | ||
roles: | ||
- ovirt-engine-local-to-remote-db |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ Role Variables | |
--- | ||
ovirt_engine_db_dump_dwh: [True, False] Dump also DWH database (default: False) | ||
ovirt_engine_db_dump_start_services: [True, False] Start engine and DWH service after dump (default: True) | ||
ovirt_engine_db_dump_local_dir: directory on local machine where to store files (default: angine_dump in playbook directory) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Angine_dump? |
||
``` | ||
|
||
Dependencies | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
oVirt Engine Local DB to Remote | ||
=============================== | ||
|
||
- dump engine/dwh database on engine | ||
- create databases/users on remote server and import dump files, install postgres if neccessary | ||
- set engine from local db to remote | ||
|
||
Target systems | ||
-------------- | ||
|
||
* engine | ||
* database | ||
|
||
Requirements | ||
------------ | ||
|
||
Preinstalled engine with local DB. | ||
Preinstalled clean operating system on remote server. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would add el7/linux based operating system |
||
|
||
Role Variables | ||
-------------- | ||
|
||
```yaml | ||
--- | ||
ovirt_engine_to_remote_db: [True, False] Change from local to remote engine database (default: True) | ||
ovirt_engine_dwh_to_remote_db: [True, False] Change from local to remote DWH database (default: False) | ||
``` | ||
|
||
Dependencies | ||
------------ | ||
|
||
Role ovirt-engine-db-dump | ||
Role ovirt-engine-remote-db | ||
|
||
Example Playbook | ||
---------------- | ||
|
||
```yaml | ||
--- | ||
# in inventory file engine has ovirt_type=engine, database has ovirt_type=remote_db | ||
- hosts: engine database | ||
vars: | ||
ovirt_engine_dwh_to_remote_db: True | ||
roles: | ||
- ovirt-engine-local-to-remote-db | ||
``` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would add example inventory as you are hacking around with ovirt_type var in it |
||
|
||
Author Information | ||
------------------ | ||
|
||
Lucie Leistnerova | ||
[email protected] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
ovirt_engine_to_remote_db: True | ||
ovirt_engine_dwh_to_remote_db: False | ||
ovirt_engine_etc_conf_files: | ||
- /etc/ovirt-engine/engine.conf.d/10-setup-database.conf | ||
- /etc/ovirt-engine/engine.conf.d/10-setup-dwh-database.conf | ||
- /etc/ovirt-engine-dwh/ovirt-engine-dwhd.conf.d/10-setup-database.conf | ||
ovirt_engine_etc_conf_files_aaa: | ||
- /etc/ovirt-engine/aaa/internal.properties |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
--- | ||
- name: set engine variables | ||
set_fact: | ||
engine_ip: "{% if hostvars[groups['engine'][0]]['ansible_default_ipv4']['address'] is defined %}{{ hostvars[groups['engine'][0]]['ansible_default_ipv4']['address'] }}{% else %}{{ groups['engine'][0] }}{% endif %}" | ||
# first dump databases on engine and get connection variables | ||
- name: dump databases | ||
include_role: | ||
name: ovirt-engine-db-dump | ||
vars: | ||
ovirt_engine_db_dump_dwh: "{{ ovirt_engine_dwh_to_remote_db }}" | ||
ovirt_engine_db_dump_start_services: False | ||
ovirt_engine_db_dump_local_dir: "{{ playbook_dir }}/engine_dump" | ||
when: ovirt_type == "engine" | ||
- name: get engine variables from file | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. empty space between new tasks |
||
include_vars: | ||
file: "{{ playbook_dir }}/engine_dump/engine_variables.json" | ||
name: ovirt_engine_db_dump_engine_db | ||
when: ovirt_engine_to_remote_db == True | ||
- name: get DWH variables from file | ||
include_vars: | ||
file: "{{ playbook_dir }}/engine_dump/dwh_variables.json" | ||
name: ovirt_engine_db_dump_dwh_db | ||
when: ovirt_engine_dwh_to_remote_db == True | ||
# create databases on remote server and import data | ||
- name: create databases and import data | ||
include_role: | ||
name: ovirt-engine-remote-db | ||
vars: | ||
ovirt_engine_remote_db_port: "{{ ovirt_engine_db_dump_engine_db['ENGINE_DB_PORT']|regex_replace('\"', '') }}" | ||
ovirt_engine_db_name: "{{ ovirt_engine_db_dump_engine_db['ENGINE_DB_DATABASE']|regex_replace('\"', '') }}" | ||
ovirt_engine_db_user: "{{ ovirt_engine_db_dump_engine_db['ENGINE_DB_USER']|regex_replace('\"', '') }}" | ||
ovirt_engine_db_password: "{{ ovirt_engine_db_dump_engine_db['ENGINE_DB_PASSWORD']|regex_replace('\"', '') }}" | ||
ovirt_engine_remote_db: "{{ ovirt_engine_to_remote_db }}" | ||
ovirt_engine_dwh_remote_db: "{{ ovirt_engine_dwh_to_remote_db }}" | ||
ovirt_engine_dwh_db_name: "{{ ovirt_engine_db_dump_dwh_db['DWH_DB_DATABASE']|regex_replace('\"', '') }}" | ||
ovirt_engine_dwh_db_user: "{{ ovirt_engine_db_dump_dwh_db['DWH_DB_USER']|regex_replace('\"', '') }}" | ||
ovirt_engine_dwh_db_password: "{{ ovirt_engine_db_dump_dwh_db['DWH_DB_PASSWORD']|regex_replace('\"', '') }}" | ||
ovirt_engine_remote_db_force: True | ||
ovirt_engine_remote_db_dump: "{{ ovirt_engine_db_dump_local_dir }}/engine.sql" | ||
ovirt_engine_remote_db_dwh_dump: "{{ ovirt_engine_db_dump_local_dir }}/dwh.sql" | ||
ovirt_engine_remote_db_access: | ||
- | ||
type: host | ||
address: "{{ engine_ip }}/32" | ||
method: md5 | ||
when: ovirt_type == "remote_db" | ||
# set engine from local to remote db | ||
- include: set-engine.yml | ||
when: ovirt_type == "engine" | ||
# clean | ||
- name: remove dump files from local | ||
local_action: | ||
file path={{ playbook_dir }}/engine_dump state=absent |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
# to be sure services are stopped | ||
- name: stop necessary service | ||
service: | ||
name: "{{ item }}" | ||
state: stopped | ||
with_items: | ||
- ovirt-engine-dwhd | ||
- ovirt-engine | ||
# change in engine configuration localhost to remote server | ||
- name: update engine settings | ||
replace: | ||
path: "{{ item }}" | ||
regexp: '^(ENGINE.*)localhost' | ||
replace: '\g<1>{{ groups["database"][0] }}' | ||
with_items: "{{ ovirt_engine_etc_conf_files }}" | ||
when: ovirt_engine_to_remote_db == True | ||
- name: update aaa settings | ||
replace: | ||
path: "{{ item }}" | ||
regexp: "localhost" | ||
replace: "{{ groups['database'][0] }}" | ||
with_items: "{{ ovirt_engine_etc_conf_files_aaa }}" | ||
when: ovirt_engine_to_remote_db == True | ||
- name: update dwh settings | ||
replace: | ||
path: "{{ item }}" | ||
regexp: '^(DWH.*)localhost' | ||
replace: '\g<1>{{ groups["database"][0] }}' | ||
with_items: "{{ ovirt_engine_etc_conf_files }}" | ||
when: ovirt_engine_dwh_to_remote_db == True | ||
# restart needed services | ||
- name: start engine and dwh service | ||
service: | ||
name: "{{ item }}" | ||
state: restarted | ||
with_items: | ||
- ovirt-engine | ||
- ovirt-engine-dwhd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please mention new test under
Test
section, on line 105.