Skip to content

Commit

Permalink
tests form changine engine from local to remote db added, some fixes
Browse files Browse the repository at this point in the history
- 2 new containers added in containers-deploy, that are used for migration
- new engine added to engine-cleanup
- engine-deploy-local-db added
- test of ovirt-engine-local-to-remote-db added to test-*
- get ip of engine and database from proper variables in ovirt-engine-local-to-remote-db
- reset added to ovirt-engine-local-to-remote-db
  • Loading branch information
leistnerova committed Aug 29, 2017
1 parent 556109f commit 9500dfa
Show file tree
Hide file tree
Showing 12 changed files with 165 additions and 10 deletions.
3 changes: 3 additions & 0 deletions roles/ovirt-engine-local-to-remote-db/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ Role Variables
---
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)

This comment has been minimized.

Copy link
@StLuke

StLuke Aug 29, 2017

Collaborator

this needs better documentation, I dont understand this option

ovirt_engine_drop_local_db: [True, False] Drop local databases after engine is set to remote db, dump will be stored (default: True)
```
Dependencies
Expand Down
42 changes: 36 additions & 6 deletions roles/ovirt-engine-local-to-remote-db/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
---
- 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 %}"
engine_ip: "{% if hostvars[inventory_hostname]['ansible_default_ipv4']['address'] is defined %}{{ hostvars[inventory_hostname]['ansible_default_ipv4']['address'] }}{% else %}{{ inventory_hostname }}{% endif %}"

This comment has been minimized.

Copy link
@StLuke

StLuke Aug 29, 2017

Collaborator

woah, thats dirty... I wounder if there is a more readable way to get the ip.. @lukas-bednar ?

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 %}"

This comment has been minimized.

Copy link
@StLuke

StLuke Aug 29, 2017

Collaborator

the same

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
Expand All @@ -11,19 +23,25 @@
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"
when:
- ovirt_type == "engine"
- ovirt_engine_reset == False

- name: get engine variables from file
include_vars:
file: "{{ playbook_dir }}/engine_dump/engine_variables.json"
name: ovirt_engine_db_dump_engine_db
when: ovirt_engine_to_remote_db == True
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
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
Expand All @@ -47,13 +65,25 @@
type: host
address: "{{ engine_ip }}/32"
method: md5
when: ovirt_type == "remote_db"
when:
- ovirt_type == "remote_db"
- ovirt_engine_reset == False

# set engine from local to remote db
- include: set-engine.yml
when: ovirt_type == "engine"
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 roles/ovirt-engine-local-to-remote-db/tasks/reset-engine.yml
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
6 changes: 3 additions & 3 deletions roles/ovirt-engine-local-to-remote-db/tasks/set-engine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@
replace:
path: "{{ item }}"
regexp: '^(ENGINE.*)localhost'
replace: '\g<1>{{ groups["database"][0] }}'
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: "{{ groups['database'][0] }}"
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>{{ groups["database"][0] }}'
replace: '\g<1>{{ remote_db_ip }}'
with_items: "{{ ovirt_engine_etc_conf_files }}"
when: ovirt_engine_dwh_to_remote_db == True

Expand Down
6 changes: 5 additions & 1 deletion tests/containers-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@
provision_docker_inventory_group: "{{ groups['remote-db'] }}"
- role: provision_docker
provision_docker_inventory_group: "{{ groups['engine'] }}"
- role: provision_docker
provision_docker_inventory_group: "{{ groups['engine-local-db'] }}"
- role: provision_docker
provision_docker_inventory_group: "{{ groups['remote-db-migrate'] }}"

- name: "Update python because of ovirt-imageio-proxy"
hosts: engine
hosts: engine engine-local-db
tasks:
- name: Update python
yum:
Expand Down
11 changes: 11 additions & 0 deletions tests/engine-cleanup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,14 @@
ovirt_engine_dwh_db_host: "{{ hostvars['remote_db_centos7']['ansible_default_ipv4']['address'] }}"
roles:
- role: ovirt-engine-cleanup # This role must be last
- name: Run ovirt-engine-cleanup on engine with local db
hosts: engine-local-db
vars:
ovirt_engine_type: "ovirt-engine"
ovirt_engine_version: "{{ ovirt_engine_version }}"
ovirt_engine_hostname: "localhost"
ovirt_engine_db_host: "localhost"
ovirt_engine_dwh: true
ovirt_engine_dwh_db_host: "localhost"
roles:
- role: ovirt-engine-cleanup # This role must be last
32 changes: 32 additions & 0 deletions tests/engine-deploy-local-db.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
- name: Run ovirt-ansible roles on containerized environments
hosts: engine-local-db
vars:
ovirt_engine_type: "ovirt-engine"
ovirt_engine_version: "{{ ovirt_engine_version }}"
ovirt_rpm_repo: "{{ ovirt_rpm_repo }}"
ovirt_engine_hostname: "localhost"
ovirt_engine_organization: "example.com"
ovirt_engine_admin_password: "123456"
ovirt_engine_db_host: "localhost"
ovirt_engine_dwh: true
ovirt_engine_dwh_db_host: "localhost"
ovirt_engine_configure_iso_domain: true
ovirt_engine_firewall_manager: null
ovirt_engine_config:
-
key: "VmPoolMonitorIntervalInMinutes"
value: "1"
version: "general"
-
key: "UserDefinedNetworkCustomProperties"
value: "ethtool_opts=.*"
version: "{{ ovirt_engine_version }}"
ovirt_collect_logs_from_system: "engine"
roles:
- role: ovirt-common
- role: ovirt-engine-install-packages
- role: ovirt-engine-setup
- role: ovirt-engine-config
- role: ovirt-iso-uploader-conf
# - role: ovirt-collect-logs # Issue #102
5 changes: 5 additions & 0 deletions tests/engine-local-to-remote-db.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
- name: Change engines local to remote db
hosts: engine-local-db remote-db-migrate
roles:
- role: ovirt-engine-local-to-remote-db
12 changes: 12 additions & 0 deletions tests/inventory
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,15 @@ engine_centos7 image="chrismeyers/centos7"

[remote-db]
remote_db_centos7 image="chrismeyers/centos7"

[engine-local-db]
engine_centos7 image="chrismeyers/centos7"

[engine-local-db:vars]
ovirt_type=engine

[remote-db-migrate]
remote_db_centos7 image="chrismeyers/centos7"

[remote-db-migrate:vars]
ovirt_type=remote_db
5 changes: 5 additions & 0 deletions tests/test-4.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
ovirt_engine_version: "4.0"
ovirt_rpm_repo: "http://plain.resources.ovirt.org/pub/yum-repo/ovirt-release40.rpm"
- include: engine-rename.yml
- include: engine-deploy-local-db.yml
vars:
ovirt_engine_version: "4.0"
ovirt_rpm_repo: "http://plain.resources.ovirt.org/pub/yum-repo/ovirt-release40.rpm"
- include: engine-local-to-remote-db.yml
- include: engine-cleanup.yml
vars:
ovirt_engine_version: "4.0"
5 changes: 5 additions & 0 deletions tests/test-4.1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
ovirt_engine_version: "4.1"
ovirt_rpm_repo: "http://plain.resources.ovirt.org/pub/yum-repo/ovirt-release41.rpm"
- include: engine-rename.yml
- include: engine-deploy-local-db.yml
vars:
ovirt_engine_version: "4.1"
ovirt_rpm_repo: "http://plain.resources.ovirt.org/pub/yum-repo/ovirt-release41.rpm"
- include: engine-local-to-remote-db.yml
- include: engine-cleanup.yml
vars:
ovirt_engine_version: "4.1"
5 changes: 5 additions & 0 deletions tests/test-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
ovirt_engine_version: "4.2"
ovirt_rpm_repo: "http://plain.resources.ovirt.org/pub/yum-repo/ovirt-release-master.rpm"
- include: engine-rename.yml
- include: engine-deploy-local-db.yml
vars:
ovirt_engine_version: "4.2"
ovirt_rpm_repo: "http://plain.resources.ovirt.org/pub/yum-repo/ovirt-release-master.rpm"
- include: engine-local-to-remote-db.yml
- include: engine-cleanup.yml
vars:
ovirt_engine_version: "4.2"

1 comment on commit 9500dfa

@StLuke
Copy link
Collaborator

@StLuke StLuke commented on 9500dfa Aug 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be nice if we can add this role even after upgrade 4.1->master 4.0->4.1 should be easy enough

Please sign in to comment.