Bug 1446167

Summary: [downstream clone - 4.1.3] [Test Only] Test Ansible playbook for registration
Product: Red Hat Enterprise Virtualization Manager Reporter: rhev-integ
Component: rhev-hypervisor-ngAssignee: Douglas Schilling Landgraf <dougsland>
Status: CLOSED CURRENTRELEASE QA Contact: dguo
Severity: high Docs Contact:
Priority: medium    
Version: 4.1.0CC: bgraveno, cshao, danken, dfediuck, dguo, dougsland, eheftman, huzhao, jiawu, mgoldboi, mperina, qiyuan, rbarry, sbonazzo, stirabos, weiwang, yaniwang, ycui, yzhao
Target Milestone: ovirt-4.1.3Keywords: ZStream
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1422676 Environment:
Last Closed: 2017-07-06 13:43:35 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Node RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1422676, 1458126    
Bug Blocks: 1475678    

Description rhev-integ 2017-04-27 11:30:11 UTC
+++ This bug is a downstream clone. The original bug is: +++
+++   bug 1422676 +++
======================================================================

Description of problem:

Users might want to register multiple hosts via ansible, we must test and document it.

How reproducible:

Requires on the machine that will trigger the registration:
  - Ansible 2.3
  - ovirt-engine-sdk-python version 4 or higher

To work with hosts via ansible it's required version 2.3 (currently in devel tree)

Steps to Reproduce:
1. Install RHVH (Requires set root password and network so ansible can access)

   Example of kickstart: 
      https://github.com/dougsland/misc-ovirt/blob/master/ansible/kickstart-autoinstall-ovirt-node-ng.ks
  
2. Example of ansible files are available here:
      https://github.com/dougsland/misc-ovirt/blob/master/ansible/vars.yml
      https://github.com/dougsland/misc-ovirt/blob/master/ansible/register-hosts.yml

   - Download both files, change the files with proper credentials.
   - Register the hosts
     $ ansible-playbook register-hosts.yml 

In case needed, there is README file here:
https://github.com/dougsland/misc-ovirt/tree/master/ansible

(Originally by dougsland)

Comment 2 rhev-integ 2017-04-27 11:30:30 UTC
Moving this bug to MODIFIED status because it is set to ovirt-4.2-0, no build yet for 4.2.

(Originally by Ying Cui)

Comment 3 rhev-integ 2017-04-27 11:30:37 UTC
Ansible 2.3 should become available in 4.1.1

(Originally by Sandro Bonazzola)

Comment 4 rhev-integ 2017-04-27 11:30:44 UTC
Douglas,

We need to clarify that whether the ansible 2.3 package will be build into rhvh4.1.1 from comment 3?

Besides, we wonder the customer's use scenario, ansible-playbook in  https://github.com/dougsland/misc-ovirt/blob/master/ansible/ will be documented  to customer, or we QE just test this ansible way can be supported in node is enough?

(Originally by Daijie Guo)

Comment 5 rhev-integ 2017-04-27 11:30:50 UTC
(In reply to dguo from comment #4)
> Douglas,
> 
> We need to clarify that whether the ansible 2.3 package will be build into
> rhvh4.1.1 from comment 3?
>

We will need to check.

> Besides, we wonder the customer's use scenario, ansible-playbook in 
> https://github.com/dougsland/misc-ovirt/blob/master/ansible/ will be
> documented  to customer, or we QE just test this ansible way can be
> supported in node is enough?

Probably both, I can see at least two scenarios for justifying the tests/documentation of registration:

#1 Users already use ansible for others automation tasks in their environment.
   Based on that, they would like to use ansible to automate rhv deploy.

#2 Users would like to automate their install/registration/approval/manage rhv/
   of several hundreds servers by kickstart and ansible.

(Originally by dougsland)

Comment 6 rhev-integ 2017-04-27 11:30:57 UTC
ansible 2.3 not yet available,postponing to 4.1.2

(Originally by Sandro Bonazzola)

Comment 8 Sandro Bonazzola 2017-04-28 10:00:20 UTC
ansible 2.3 not yet available,postponing to 4.1.3

Comment 10 Sandro Bonazzola 2017-05-31 12:53:09 UTC
Moving to ON_QA being ansible 2.3.0.0 available now

Comment 11 dguo 2017-06-06 02:56:50 UTC
 When bug 1458126 is fixed, will verify this bug.

Comment 12 dguo 2017-06-13 08:27:49 UTC
On rhvh-4.1-0.20170609.0+1, the ovirt-engine-sdk-python version does not meet the requirements which is version 4 or higher from description

[root@dhcp-9-52 yum.repos.d]# imgbase w
2017-06-13 04:16:48,108 [INFO] You are on rhvh-4.1-0.20170609.0+1
[root@dhcp-9-52 yum.repos.d]# rpm -qa|grep ovirt-engine-sdk-python
ovirt-engine-sdk-python-3.6.9.1-1.el7ev.noarch
[root@dhcp-9-52 ansible]# ansible-playbook register-hosts.yml 
 [WARNING]: provided hosts list is empty, only localhost is available


PLAY [localhost] ************************************************************************************************************************************************************************

TASK [Gathering Facts] ******************************************************************************************************************************************************************
ok: [localhost]

TASK [Obtain SSO token] *****************************************************************************************************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "failed": true, "msg": "ovirtsdk4 version 4.0.0 or higher is required for this module"}
	to retry, use: --limit @/root/misc-ovirt/ansible/register-hosts.retry

PLAY RECAP ******************************************************************************************************************************************************************************
localhost                  : ok=1    changed=0    unreachable=0    failed=1

Comment 13 Sandro Bonazzola 2017-06-13 09:22:16 UTC
Martin what do you suggest? Running on the RHV-H side or ssh to engine and runt here using sdk4 installed onthe engine?

Comment 14 Martin Perina 2017-06-13 11:00:38 UTC
Several notes:

1. ovirt-engine-sdk-python provides Python SDK v3, but you need to use Python SDK v4 (provided by python-ovirt-engine-sdk4) which is required by Ansible modules for oVirt


2. It depends on the usage:

  - if you want register single host, then the Ansible playbook can be executed on this host, but you need to have installed python-ovirt-engine-sdk4 on this host

  - if you want to register multiple hosts, then Ansible playbook can be executed on different hosts (either engine host or any other host which has installed python-ovirt-engine-sdk4)


3. If you want to execute on engine host, you don't need to SSH to it and execute Ansible there, you can tell Ansible where playbook should be executed and Ansible will connect to the host automatically (but you need to install all dependencies like python-ovirt-engine-sdk4 on that host manually, Ansible does not install dependencies automatically)

Comment 15 Douglas Schilling Landgraf 2017-06-13 19:25:29 UTC
I'd say (In reply to Martin Perina from comment #14)
> Several notes:
> 
> 1. ovirt-engine-sdk-python provides Python SDK v3, but you need to use
> Python SDK v4 (provided by python-ovirt-engine-sdk4) which is required by
> Ansible modules for oVirt
> 

Could you please share the ansible ovirt module name for downstream?

> 
> 2. It depends on the usage:
> 
>   - if you want register single host, then the Ansible playbook can be
> executed on this host, but you need to have installed
> python-ovirt-engine-sdk4 on this host
> 
>   - if you want to register multiple hosts, then Ansible playbook can be
> executed on different hosts (either engine host or any other host which has
> installed python-ovirt-engine-sdk4)
> 
> 
> 3. If you want to execute on engine host, you don't need to SSH to it and
> execute Ansible there, you can tell Ansible where playbook should be
> executed and Ansible will connect to the host automatically (but you need to
> install all dependencies like python-ovirt-engine-sdk4 on that host
> manually, Ansible does not install dependencies automatically)

Would be nice to see this documented in a way that users could follow steps to install packages/channels needed and enable the usage of ansible for registering/approving the hosts. In others words, doesn't matter if it's RHVM, RHVH or RHEL host.

Does it make sense?

Comment 16 Martin Perina 2017-06-14 06:26:35 UTC
(In reply to Douglas Schilling Landgraf from comment #15)
> I'd say (In reply to Martin Perina from comment #14)
> > Several notes:
> > 
> > 1. ovirt-engine-sdk-python provides Python SDK v3, but you need to use
> > Python SDK v4 (provided by python-ovirt-engine-sdk4) which is required by
> > Ansible modules for oVirt
> > 
> 
> Could you please share the ansible ovirt module name for downstream?

Ansible modules for oVirt have the same name for both upstream and downstream (always ovirt_???), no renaming "craziness" as we performed with RPM packages ...

> 
> > 
> > 2. It depends on the usage:
> > 
> >   - if you want register single host, then the Ansible playbook can be
> > executed on this host, but you need to have installed
> > python-ovirt-engine-sdk4 on this host
> > 
> >   - if you want to register multiple hosts, then Ansible playbook can be
> > executed on different hosts (either engine host or any other host which has
> > installed python-ovirt-engine-sdk4)
> > 
> > 
> > 3. If you want to execute on engine host, you don't need to SSH to it and
> > execute Ansible there, you can tell Ansible where playbook should be
> > executed and Ansible will connect to the host automatically (but you need to
> > install all dependencies like python-ovirt-engine-sdk4 on that host
> > manually, Ansible does not install dependencies automatically)
> 
> Would be nice to see this documented in a way that users could follow steps
> to install packages/channels needed and enable the usage of ansible for
> registering/approving the hosts. In others words, doesn't matter if it's
> RHVM, RHVH or RHEL host.
> 
> Does it make sense?

We are still discussion with Documentation team, how our docs around Ansible integration will look like

Comment 17 Douglas Schilling Landgraf 2017-06-16 17:55:21 UTC
(In reply to Martin Perina from comment #16)
> (In reply to Douglas Schilling Landgraf from comment #15)
> > I'd say (In reply to Martin Perina from comment #14)
> > > Several notes:
> > > 
> > > 1. ovirt-engine-sdk-python provides Python SDK v3, but you need to use
> > > Python SDK v4 (provided by python-ovirt-engine-sdk4) which is required by
> > > Ansible modules for oVirt
> > > 
> > 
> > Could you please share the ansible ovirt module name for downstream?
> 
> Ansible modules for oVirt have the same name for both upstream and
> downstream (always ovirt_???), no renaming "craziness" as we performed with
> RPM packages ...
> 

If we add python-ovirt-engine-sdk4 into ovirt-release-host-node should be enough to get all packages required?

> > 
> > > 
> > > 2. It depends on the usage:
> > > 
> > >   - if you want register single host, then the Ansible playbook can be
> > > executed on this host, but you need to have installed
> > > python-ovirt-engine-sdk4 on this host
> > > 
> > >   - if you want to register multiple hosts, then Ansible playbook can be
> > > executed on different hosts (either engine host or any other host which has
> > > installed python-ovirt-engine-sdk4)
> > > 
> > > 
> > > 3. If you want to execute on engine host, you don't need to SSH to it and
> > > execute Ansible there, you can tell Ansible where playbook should be
> > > executed and Ansible will connect to the host automatically (but you need to
> > > install all dependencies like python-ovirt-engine-sdk4 on that host
> > > manually, Ansible does not install dependencies automatically)
> > 
> > Would be nice to see this documented in a way that users could follow steps
> > to install packages/channels needed and enable the usage of ansible for
> > registering/approving the hosts. In others words, doesn't matter if it's
> > RHVM, RHVH or RHEL host.
> > 
> > Does it make sense?
> 
> We are still discussion with Documentation team, how our docs around Ansible
> integration will look like

Sure, let me know if you guys need anything from our side.

Comment 18 Martin Perina 2017-06-16 17:57:53 UTC
(In reply to Douglas Schilling Landgraf from comment #17)
> (In reply to Martin Perina from comment #16)
> > (In reply to Douglas Schilling Landgraf from comment #15)
> > > I'd say (In reply to Martin Perina from comment #14)
> > > > Several notes:
> > > > 
> > > > 1. ovirt-engine-sdk-python provides Python SDK v3, but you need to use
> > > > Python SDK v4 (provided by python-ovirt-engine-sdk4) which is required by
> > > > Ansible modules for oVirt
> > > > 
> > > 
> > > Could you please share the ansible ovirt module name for downstream?
> > 
> > Ansible modules for oVirt have the same name for both upstream and
> > downstream (always ovirt_???), no renaming "craziness" as we performed with
> > RPM packages ...
> > 
> 
> If we add python-ovirt-engine-sdk4 into ovirt-release-host-node should be
> enough to get all packages required?

Yes, that should pull all requirements for Python SDK v4

Comment 19 Douglas Schilling Landgraf 2017-06-16 18:15:34 UTC
I have added a patch in the ovirt-release-host-node for review, even if we are going to write a documentation requiring such packages, the node should be ready to go distro.

Comment 22 dguo 2017-06-26 07:40:08 UTC
Verified on rhvh-4.1-0.20170622.0

Test version:
redhat-virtualization-host-4.1-20170622.3
python-ovirt-engine-sdk4-4.1.5-1.el7ev.x86_64
ansible-2.3.0.0-4.el7.noarch
Red Hat Virtualization Manager Version: 4.1.3.1-0.1.el7
vdsm-4.19.20-1.el7ev.x86_64

Test step:
1. Install rhvh via pxe 
2. Check the ansible version and python-ovirt-engine-sdk version
[root@dhcp-9-52 ansible]# rpm -qa|grep python-ovirt
python-ovirt-engine-sdk4-4.1.5-1.el7ev.x86_64
[root@dhcp-9-52 ansible]# rpm -qa|grep ansible
ansible-2.3.0.0-4.el7.noarch=
3. Clone the ansible registration codes from https://github.com/dougsland/misc-ovirt based on this bug Description
4. Modify the corresponding value in the register-host.yml
5. "ansible-playbook register-host.yml"

Test result:
After step #5, the two hosts are added to the rhvm

Comment 26 cshao 2017-07-06 03:13:32 UTC
Re-verify this bug according #c22.

Comment 27 Douglas Schilling Landgraf 2017-07-06 13:30:55 UTC
Hi Emma,

Should we open a specific bug report for doc team ? Would be nice to have such step by step in our official docs.

Thanks!

Comment 28 Douglas Schilling Landgraf 2017-07-06 13:38:43 UTC
(In reply to Martin Perina from comment #16)
> (In reply to Douglas Schilling Landgraf from comment #15)
> > I'd say (In reply to Martin Perina from comment #14)
> > > Several notes:
> > > 
> > > 1. ovirt-engine-sdk-python provides Python SDK v3, but you need to use
> > > Python SDK v4 (provided by python-ovirt-engine-sdk4) which is required by
> > > Ansible modules for oVirt
> > > 
> > 
> > Could you please share the ansible ovirt module name for downstream?
> 
> Ansible modules for oVirt have the same name for both upstream and
> downstream (always ovirt_???), no renaming "craziness" as we performed with
> RPM packages ...
> 
> > 
> > > 
> > > 2. It depends on the usage:
> > > 
> > >   - if you want register single host, then the Ansible playbook can be
> > > executed on this host, but you need to have installed
> > > python-ovirt-engine-sdk4 on this host
> > > 
> > >   - if you want to register multiple hosts, then Ansible playbook can be
> > > executed on different hosts (either engine host or any other host which has
> > > installed python-ovirt-engine-sdk4)
> > > 
> > > 
> > > 3. If you want to execute on engine host, you don't need to SSH to it and
> > > execute Ansible there, you can tell Ansible where playbook should be
> > > executed and Ansible will connect to the host automatically (but you need to
> > > install all dependencies like python-ovirt-engine-sdk4 on that host
> > > manually, Ansible does not install dependencies automatically)
> > 
> > Would be nice to see this documented in a way that users could follow steps
> > to install packages/channels needed and enable the usage of ansible for
> > registering/approving the hosts. In others words, doesn't matter if it's
> > RHVM, RHVH or RHEL host.
> > 
> > Does it make sense?
> 
> We are still discussion with Documentation team, how our docs around Ansible
> integration will look like

@Martin, are you synced with Emma? Do we have a doc bug for ansible registration/auto approve/etc?

Comment 29 Emma Heftman 2017-07-26 09:18:34 UTC
(In reply to Douglas Schilling Landgraf from comment #27)
> Hi Emma,
> 
> Should we open a specific bug report for doc team ? Would be nice to have
> such step by step in our official docs.
> 
> Thanks!

Sorry Douglas, this slipped through the cracks.
I know Byron has been looking into some Ansible-related documentation.

Byron, is there anything new here that needs to be documented?

Comment 30 Byron Gravenorst 2017-07-27 06:54:46 UTC
Hi,

We currently have some overview information about Ansible here:

- https://access.redhat.com/documentation/en-us/red_hat_virtualization/4.1/html/administration_guide/chap-automating_rhv_configuration_using_ansible

I think we will need to add the content of this bug to our documentation. I will raise a separate docs bug.