-
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
Open
leistnerova
wants to merge
32
commits into
rhevm-qe-automation:master
Choose a base branch
from
leistnerova:local_to_remote_db
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
a5e9ac7
new role for dumping engine and dwh databases
leistnerova e24a787
Merge remote-tracking branch 'upstream/master'
leistnerova 19b558e
new role ovirt-engine-local-to-remote-db for changing engine from loc…
leistnerova 556109f
update according to comments
leistnerova 0bedcf8
Merge branch 'master' of https://github.com/rhevm-qe-automation/ovirt…
leistnerova 9500dfa
tests form changine engine from local to remote db added, some fixes
leistnerova 739d1ad
fixing whitespaces
leistnerova 36ddc5e
separate test created
lukas-bednar 3235a69
default value in engine-cleanup fixed
leistnerova 9870d31
removed local to remove db flow from other tests
leistnerova e5543e0
check of engine status, reset if not running, remove db in the end
leistnerova a5e1f2a
Merge branch 'master' into local_to_remote_db
leistnerova bf33241
Update .travis.yml
leistnerova 66b4438
text fixed, example of inventory
leistnerova 8994178
Merge branch 'local_to_remote_db' of github.com:leistnerova/ovirt-ans…
leistnerova e57c2e3
travis.yml fix
leistnerova 9691c80
Merge remote-tracking branch 'upstream/master'
leistnerova 532616e
fix for test-promote-db-local-to-remote.yml - load all containers facts
leistnerova 1a389c9
fix of become postgres user
leistnerova e1399a1
changes for ovirt >= 4.2
leistnerova 7f7d264
fix on getting variables from engine settings
leistnerova 12bc29c
condition of dwh db added back to dump db
leistnerova 90e4605
update of README
leistnerova 90aaca1
change of remove db variable, fix ovirt_engine_version
leistnerova 3169b17
fix ovirt_engine_version
leistnerova 29d776e
gix db_dump_local_dir variable use
leistnerova 0c1ad97
Merge remote-tracking branch 'upstream/master'
leistnerova e8ab3ff
Merge branch 'master' into local_to_remote_db
leistnerova 951141f
test in README added, fix restoring db
leistnerova 064bffb
fixing only reset usage
leistnerova 0df0b0e
Merge branch 'master' into local_to_remote_db
leistnerova 9a29cbb
Merge branch 'master' into local_to_remote_db
petr-balogh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
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 el7/linux based operating system on remote server. | ||
|
||
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) | ||
|
||
ovirt_engine_reset: [True, False] True - set back engine to local db (default: False) | ||
ovirt_engine_drop_local_db: [True, False] Drop local databases after engine is set to remote db, dump will be stored (default: True) | ||
``` | ||
|
||
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] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
--- | ||
galaxy_info: | ||
author: "Lucie Leistnerova" | ||
description: "oVirt change engine/dwh local to remote database" | ||
company: "Red Hat" | ||
license: "GPLv3" | ||
min_ansible_version: 1.9 | ||
platforms: | ||
- name: EL | ||
versions: | ||
- all | ||
galaxy_tags: | ||
- migration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
--- | ||
- name: set engine variables | ||
set_fact: | ||
engine_ip: "{% if hostvars[inventory_hostname]['ansible_default_ipv4']['address'] is defined %}{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}{% else %}{{ inventory_hostname }}{% endif %}" | ||
delegate_to: "{{ item }}" | ||
delegate_facts: True | ||
with_items: "{{ groups['all'] }}" | ||
when: ovirt_type == "engine" | ||
|
||
- name: set db variables | ||
set_fact: | ||
remote_db_ip: "{% if hostvars[inventory_hostname]['ansible_default_ipv4']['address'] is defined %}{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}{% else %}{{ inventory_hostname }}{% endif %}" | ||
delegate_to: "{{ item }}" | ||
delegate_facts: True | ||
with_items: "{{ groups['all'] }}" | ||
when: ovirt_type == "remote_db" | ||
|
||
# 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" | ||
- ovirt_engine_reset == False | ||
|
||
- 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 | ||
- ovirt_engine_reset == False | ||
|
||
- 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 | ||
- ovirt_engine_reset == False | ||
|
||
# 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" | ||
- ovirt_engine_reset == False | ||
|
||
# set engine from local to remote db | ||
- include: set-engine.yml | ||
when: | ||
- ovirt_type == "engine" | ||
- ovirt_engine_reset == False | ||
|
||
# reset engine back to local db | ||
- include: reset-engine.yml | ||
when: | ||
- ovirt_type == "engine" | ||
- ovirt_engine_reset == True | ||
|
||
# clean | ||
- name: remove dump files from local | ||
local_action: | ||
file path={{ playbook_dir }}/engine_dump state=absent | ||
when: | ||
- ovirt_engine_reset == False |
43 changes: 43 additions & 0 deletions
43
roles/ovirt-engine-local-to-remote-db/tasks/reset-engine.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
# 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.*){{ remote_db_ip }}' | ||
replace: '\g<1>localhost' | ||
with_items: "{{ ovirt_engine_etc_conf_files }}" | ||
when: ovirt_engine_to_remote_db == True | ||
|
||
- name: update aaa settings | ||
replace: | ||
path: "{{ item }}" | ||
regexp: "{{ remote_db_ip }}" | ||
replace: "localhost" | ||
with_items: "{{ ovirt_engine_etc_conf_files_aaa }}" | ||
when: ovirt_engine_to_remote_db == True | ||
|
||
- name: update dwh settings | ||
replace: | ||
path: "{{ item }}" | ||
regexp: '^(DWH.*){{ remote_db_ip }}' | ||
replace: '\g<1>localhost' | ||
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 |
43 changes: 43 additions & 0 deletions
43
roles/ovirt-engine-local-to-remote-db/tasks/set-engine.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
# 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>{{ remote_db_ip }}' | ||
with_items: "{{ ovirt_engine_etc_conf_files }}" | ||
when: ovirt_engine_to_remote_db == True | ||
|
||
- name: update aaa settings | ||
replace: | ||
path: "{{ item }}" | ||
regexp: "localhost" | ||
replace: "{{ remote_db_ip }}" | ||
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>{{ remote_db_ip }}' | ||
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 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.