neděle 15. ledna 2017

Deploying ManageIQ to oVirt with Ansible

In this blog post I will show you how to deploy ManageIQ appliance to oVirt engine using Ansible.
Prerequisites:
- Ansible 2.2 - Ansible modules for oVirt are available since Ansible 2.2.
- oVirt 4.0.4 - ImageIO is avaible since 4.0.4 (used to upload qcow disk).
The playbook here created will assume that you will run the playbook from the oVirt engine machine. So first please ssh to your oVirt machine. Now install the role which will handle the deploying the ManageIQ, it's called machacekondra.ovirt-manageiq and in order to install it run following command:
$ ansible-galaxy install machacekondra.ovirt-manageiq

Now please ensure that oVirt imageio is properly setup and running. As noted here you should check the ovirt-imageio-proxy service is running on your oVirt engine and ovirt-imageio-daemon service on your hosts. The other important thing is to use proper CA of your oVirt engine, the path can be specified using ovirt_ca variable in your playbook, which is by default /etc/pki/ovirt-engine/ca.pem.
That's it, if you did all steps before correctly, you can now create the playbook:
- name: Deploy ManageIQ to oVirt engine
hosts: localhost
gather_facts: no
vars:
ovirt_url: https://CHANGEME/ovirt-engine/api
ovirt_user: admin@internal
ovirt_password: CHANGEME
vm_cluster: Default
vm_memory: 4GiB
vm_cpu: 1
disk_storage_domain: data
disk_size: 50GiB
vm_cloud_init:
user_name: root
root_password: password
roles:
- machacekondra.ovirt-manageiq

Please change the URL of you oVirt engine and the password of your user, you can also change other variables as needed, you can find the explanation of variables here. I am strongly suggesting using Ansible vault for your passwords. Now save your playbook to some yaml file, for example manageiq.yml.
Now run the playbook:
$ omachace ~/workspace $ ansible-playbook -v manageiq.yml
Using /home/omachace/.ansible.cfg as config file
PLAY [Deploy ManageIQ to oVirt engine] *****************************************
TASK [ovirt-manageiq : Download the OVA image of ManageIQ] *********************
changed: [example.com] => {"changed": true, "checksum_dest": null, "checksum_src": "7641fb36babcb85db8348a020bac384d34d99ff2", "dest": "/tmp/manageiq.ova", "gid": 0, "group": "root", "md5sum": "f5bd3388b0fcd0e6b563ee26f2c193fa", "mode": "0644", "msg": "OK (1108479736 bytes)", "owner": "root", "secontext": "unconfined_u:object_r:user_tmp_t:s0", "size": 1108479736, "src": "/tmp/tmpfyCvx5", "state": "file", "uid": 0, "url": "http://releases.manageiq.org/manageiq-ovirt-euwe-1.ova"}
TASK [ovirt-manageiq : Create a directory for extract the OVA image] ***********
changed: [example.com] => {"changed": true, "gid": 0, "group": "root", "mode": "0755", "owner": "root", "path": "/tmp/manageiq/", "secontext": "unconfined_u:object_r:user_tmp_t:s0", "size": 6, "state": "directory", "uid": 0}
TASK [ovirt-manageiq : Extract the qcow image from OVA] ************************
changed: [example.com] => {"changed": true, "dest": "/tmp/manageiq/", "extract_results": {"cmd": ["/usr/bin/gtar", "--extract", "-C", "/tmp/manageiq/", "-z", "-f", "/tmp/ansible_c6VazY/manageiq-ovirt-euwe-1.ova"], "err": "", "out": "", "rc": 0}, "gid": 0, "group": "root", "handler": "TgzArchive", "mode": "0755", "owner": "root", "secontext": "unconfined_u:object_r:user_tmp_t:s0", "size": 34, "src": "/tmp/ansible_c6VazY/manageiq-ovirt-euwe-1.ova", "state": "directory", "uid": 0}
TASK [ovirt-manageiq : Find the name of the qcow image] ************************
ok: [example.com] => {"changed": false, "examined": 3, "failed": false, "failed_when_result": false, "files": [{"atime": 1484484081.7455075, "ctime": 1484484151.4001844, "dev": 64768, "gid": 0, "inode": 16844986, "isblk": false, "ischr": false, "isdir": false, "isfifo": false, "isgid": false, "islnk": false, "isreg": true, "issock": false, "isuid": false, "mode": "0755", "mtime": 1482258336.0, "nlink": 1, "path": "/tmp/manageiq/images/28c5e3ae-6937-4621-9128-1be8f0a97e81/04a5f050-3956-4bc0-b953-0e11e068b320", "rgrp": true, "roth": true, "rusr": true, "size": 3412459520, "uid": 0, "wgrp": false, "woth": false, "wusr": true, "xgrp": true, "xoth": true, "xusr": true}], "matched": 1, "msg": ""}
TASK [ovirt-manageiq : Login to oVirt engine] **********************************
ok: [example.com] => {"ansible_facts": {"ovirt_auth": {"ca_file": "/etc/pki/ovirt-engine/ca.pem", "compress": true, "insecure": false, "kerberos": false, "timeout": 0, "token": "KCd..SNIP..WA", "url": "https://example.com/ovirt-engine/api"}}, "changed": false}
TASK [ovirt-manageiq : Deploy the qcow image to oVirt engine] ******************
changed: [example.com] => {"changed": true, "disk": {"actual_size": 0, "alias": "manageiq_disk", "disk_profile": {"href": "/ovirt-engine/api/diskprofiles/d86a2403-8bbf-4080-8f16-fd907f38e5c9", "id": "d86a2403-8bbf-4080-8f16-fd907f38e5c9"}, "format": "cow", "href": "/ovirt-engine/api/disks/fbe63434-8d49-4567-ad08-9360dabf98d6", "id": "fbe63434-8d49-4567-ad08-9360dabf98d6", "image_id": "d09da2f6-edc4-4012-ad0f-3f4e064b7ae8", "name": "manageiq_disk", "permissions": [], "propagate_errors": false, "provisioned_size": 53687091200, "quota": {"id": "23744f08-7b5c-45e2-b0b0-5daa685912e6"}, "shareable": false, "sparse": true, "statistics": [], "status": "locked", "storage_domains": [{"id": "c7b4115e-2b37-46f8-a9ed-33c285a0a810"}], "storage_type": "image", "wipe_after_delete": false}, "id": "fbe63434-8d49-4567-ad08-9360dabf98d6"}
TASK [ovirt-manageiq : Create virtual machine for the ManageIQ] ****************
changed: [example.com] => {"changed": true, "id": "854b817b-b8e4-4f42-b45b-b2ebea8f4d7e", "vm": {"affinity_labels": [], "applications": [], "bios": {"boot_menu": {"enabled": false}}, "cdroms": [], "cluster": {"href": "/ovirt-engine/api/clusters/75faab86-1b23-406c-b675-1eca339ae734", "id": "75faab86-1b23-406c-b675-1eca339ae734"}, "cpu": {"architecture": "x86_64", "topology": {"cores": 2, "sockets": 1, "threads": 1}}, "cpu_profile": {"href": "/ovirt-engine/api/cpuprofiles/40804dbc-d37f-4547-9ded-b7ec998483fc", "id": "40804dbc-d37f-4547-9ded-b7ec998483fc"}, "cpu_shares": 0, "creation_time": "2017-01-15 14:47:01.328000+02:00", "delete_protected": false, "disk_attachments": [], "display": {"allow_override": false, "copy_paste_enabled": true, "disconnect_action": "LOCK_SCREEN", "file_transfer_enabled": true, "monitors": 1, "single_qxl_pci": false, "smartcard_enabled": false, "type": "spice"}, "graphics_consoles": [], "high_availability": {"enabled": false, "priority": 0}, "host_devices": [], "href": "/ovirt-engine/api/vms/854b817b-b8e4-4f42-b45b-b2ebea8f4d7e", "id": "854b817b-b8e4-4f42-b45b-b2ebea8f4d7e", "io": {"threads": 0}, "katello_errata": [], "large_icon": {"href": "/ovirt-engine/api/icons/642e318c-32cf-40db-b9a8-fbf510ca655d", "id": "642e318c-32cf-40db-b9a8-fbf510ca655d"}, "memory": 6442450944, "memory_policy": {"ballooning": true, "guaranteed": 1073741824}, "migration": {"auto_converge": "inherit", "compressed": "inherit"}, "migration_downtime": -1, "name": "manageiq", "next_run_configuration_exists": false, "nics": [], "numa_nodes": [], "numa_tune_mode": "interleave", "origin": "ovirt", "original_template": {"href": "/ovirt-engine/api/templates/00000000-0000-0000-0000-000000000000", "id": "00000000-0000-0000-0000-000000000000"}, "os": {"boot": {"devices": ["hd"]}, "type": "rhel_7x64"}, "permissions": [], "placement_policy": {"affinity": "migratable"}, "quota": {"id": "23744f08-7b5c-45e2-b0b0-5daa685912e6"}, "reported_devices": [], "sessions": [], "small_icon": {"href": "/ovirt-engine/api/icons/b5107cab-7f80-4149-8add-d8c5aa9fa65d", "id": "b5107cab-7f80-4149-8add-d8c5aa9fa65d"}, "snapshots": [], "sso": {"methods": [{"id": "guest_agent"}]}, "start_paused": false, "stateless": false, "statistics": [], "status": "down", "stop_time": "2017-01-15 14:47:01.370000+02:00", "tags": [], "template": {"href": "/ovirt-engine/api/templates/00000000-0000-0000-0000-000000000000", "id": "00000000-0000-0000-0000-000000000000"}, "time_zone": {"name": "Etc/GMT"}, "type": "server", "usb": {"enabled": false}, "watchdogs": []}}
TASK [ovirt-manageiq : Logout from oVirt engine] *******************************
ok: [example.com] => {"ansible_facts": {"ovirt_auth": {}}, "changed": false}
PLAY RECAP *********************************************************************
example.com : ok=7 changed=4 unreachable=0 failed=0
view raw playbook_run.sh hosted with ❤ by GitHub

Wait until the playbook exit, then check your oVirt engine VMs, you should find there manageiq VM running.
Note, that there is now new better role under oVirt organization on galaxy.

Žádné komentáře:

Okomentovat