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

Remote dwh fresh engine install #137

Merged
merged 19 commits into from Aug 28, 2017
Commits
File filter...
Filter file types
Jump to file or symbol
Failed to load files and symbols.
+164 −3
Diff settings

Always

Just for now

[remote-dwh] role added for postgres installation

Done
====
- Commit for 3vm setup
    - engine (VM1)
    - dwhdb (VM2)

TODO
====
- modify existing roles/ovirt-engine-remote-dwh-setup/ to accomodate the
  3 vm installation config
  • Loading branch information...
tasdikrahman committed Aug 2, 2017
commit d5152c388d2de3bdc4d955561d4a190a9187b62f
Copy path View file
@@ -2,5 +2,3 @@
*.retry
roles/provision_docker

site.yml
inventory
@@ -89,7 +89,69 @@ After this you have to restart your ovirt-engine on the host installed by doing

### Possibility #2: The database of dwh on 3rd machine

This comment has been minimized.

@StLuke

StLuke Jul 27, 2017

Collaborator

this I would add as possibility one with 1 variable ovirt_remote_database

If set to true, few more variables needs to be set (database ip, user, password...)

Maybe reusing the part of engine-setup where engine has remote database

This comment has been minimized.

@tasdikrahman

tasdikrahman Aug 19, 2017

Contributor

Could you check this approach which I have followed for the 3 VM setup for the latest commit which I have made. Here is the linkup of the docs where I have documented the process itself. https://github.com/tasdikrahman/ovirt-ansible/blob/a2964b2cc14b2fcf79efae5ea24337581b9eca7a/roles/ovirt-engine-remote-dwh/README.md#possibility-2-the-database-of-dwh-on-3rd-machine

This comment has been minimized.

@tasdikrahman

tasdikrahman Aug 19, 2017

Contributor

Maybe reusing the part of engine-setup where engine has remote database

I used some parts of the remote engine-db part. But that was after I had already made the commits. Some of the tasks which I have made do the same thing but in a different way. Anyway, let me know if you have any changes in mind in that.

This comment has been minimized.

@tasdikrahman

tasdikrahman Aug 19, 2017

Contributor

this I would add as possibility one with 1 variable ovirt_remote_database

I am specifying this as the var ovirt_engine_dwh_db_host in the playbook

If set to true, few more variables needs to be set (database ip, user, password...)

As I have linked those on the docs already, please check once for the approach that I have followed. Here is the link again. Thanks

https://github.com/tasdikrahman/ovirt-ansible/blob/a2964b2cc14b2fcf79efae5ea24337581b9eca7a/roles/ovirt-engine-remote-dwh/README.md#possibility-2-the-database-of-dwh-on-3rd-machine

cc: @StLuke


TODO
This approach will follow a 3 box VM setup.

For clarity sake, the VM's can be assumed for now as

- VM A: `engine.ovirt.org`: which stored `engine` db and the main engine installation.
- VM B: `dwhservice.ovirt.org`: which will host the dwh service
- VM C: `dwhdb.ovirt.org`: which will store the `ovirt_engine_history` db

##### On VM A

```yaml
---
- hosts: engine
vars:
ovirt_engine_type: 'ovirt-engine'
ovirt_engine_version: '4.1'
ovirt_engine_organization: 'dwhmanualenginetest.ovirt.org'
ovirt_engine_admin_password: 'secret'
ovirt_rpm_repo: 'http://resources.ovirt.org/pub/yum-repo/ovirt-release41.rpm'
ovirt_engine_organization: 'ovirt.org'
ovirt_engine_dwh_db_host: 'remotedwh.ovirt.org'
ovirt_engine_dwh_db_configure: false
roles:
- role: ovirt-common
- role: ovirt-engine-install-packages
- role: ovirt-engine-setup
```

Running this would be

```sh
$ ansible-playbook site.yml -i inventory --skip-tags skip_yum_install_ovirt_engine_dwh,skip_yum_install_ovirt_engine_dwh_setup
```

##### On VM C

the VM has to be setup for the `ovirt_engine_history` VM which is to be used by `dwhservice.ovirt.org` VM.

```yaml
---
- hosts: dwhdb
vars:
# the below vars are explained in `install-postgresql/defaults/main.yml` and
# also the other configurable variables are placed there
engine_vm_network_cidr: '139.162.45.0/24' # Network where the Engine VM lies
dwhservice_vm_network_cidr: '139.162.61.0/24'
ovirt_engine_dwh_db_password: 'password'
roles:
- role: ovirt-engine-remote-dwh-setup/install-postgresql
```

Running this would be

```bash
$ ansible-playbook site.yml -i inventory
```

##### On VM B

Now VM which hosts the `dwhservice` needs to be setup.

TODO

This will setup your ovirt-engine setup ready for the incoming remote DWH installation setup

@@ -0,0 +1,12 @@
ovirt_engine_dwh_db_name: ovirt_engine_history
ovirt_engine_dwh_db_user: ovirt_engine_history
ovirt_engine_dwh_db_password: password
ovirt_engine_dwh_db_port: 5432

# the below 2 are to be filled in the playbook site.yml at the root when you are
# running the playbook.
engine_vm_network_cidr: ''
# a value of '139.162.45.0/24' would take for 'engine_vm_network_cidr' when the IP
# address of the engine VM is '139.162.45.249'. The value for the value below
# is calculated similarly
dwhservice_vm_network_cidr: ''
@@ -0,0 +1,86 @@
---
- name: install postgresql
yum:
name: postgresql-server
state: installed
update_cache: yes

- name: Check if the db is initialized
stat:
path: /var/lib/pgsql/data
register: db_initialised

- name: Initialize the postgresql db
command: su -l postgres -c "/usr/bin/initdb --locale=en_US.UTF8 --auth='ident' --pgdata=/var/lib/pgsql/data/"
when: db_initialised.stat.isdir is not defined

- name: Start postgresql.service
systemd:
state: started
name: postgresql

- name: creating directory for sql scripts in /tmp/ansible-sql
file:
path: /tmp/ansible-sql
state: directory

- name: copy SQL scripts
template:
src: "{{ item }}.j2"
dest: "/tmp/ansible-sql/{{ item }}"
mode: 0644
owner: postgres
group: postgres
with_items:
- "ovirt-engine-dwh-db-user-create.sql"
- "ovirt-engine-dwh-db-create.sql"

- name: create engine DWH DB and user
become_user: postgres
become: yes
command: psql -p {{ ovirt_engine_dwh_db_port }} -a -f /tmp/ansible-sql/'{{ item }}'
with_items:
- "ovirt-engine-dwh-db-user-create.sql"
- "ovirt-engine-dwh-db-create.sql"

- name: Adding engine and dwhservice vm IP's in the dwhdb conf to be acessed remotely
lineinfile:
dest: /var/lib/pgsql/data/pg_hba.conf
line: "{{ item }}"
with_items:
- 'host {{ ovirt_engine_dwh_db_name }} {{ ovirt_engine_dwh_db_name }} {{ engine_vm_network_cidr }} md5 # engine'
- 'host {{ ovirt_engine_dwh_db_name }} {{ ovirt_engine_dwh_db_name }} {{ dwhservice_vm_network_cidr }} md5 # dwhservice'

- name: Edit the config file /var/lib/pgsql/data/postgresql.conf
command: "{{ item }}"
with_items:
- sed -i -- 's/max_connections = 100/max_connections = 150/g' /var/lib/pgsql/data/postgresql.conf
- sed -i "60ilisten_addresses = '*'" /var/lib/pgsql/data/postgresql.conf

- name: Enable firewalld and open up port 5432
command: "{{ item }}"
with_items:
- systemctl start firewalld
- firewall-cmd --zone=public --add-port=5432/tcp --permanent
- firewall-cmd --reload

- name: Restart postgresql for the loading the newer configs
systemd:
state: restarted
name: postgresql

- name: check PostgreSQL service
service:
name: postgresql
state: started
enabled: yes

- name: clean tmp files
file:
path: '/tmp/ansible-sql'
state: 'absent'

- name: Enable postgresql.service to start at boot time
systemd:
enabled: yes
name: postgresql
@@ -0,0 +1,2 @@
create database {{ovirt_engine_dwh_db_name}} owner {{ovirt_engine_dwh_db_user}} template template0
encoding 'UTF8' lc_collate 'en_US.UTF-8' lc_ctype 'en_US.UTF-8';
@@ -0,0 +1 @@
create user {{ovirt_engine_dwh_db_user}} password '{{ovirt_engine_dwh_db_password}}';
ProTip! Use n and p to navigate between commits in a pull request.