Bug 1590854 - [RFE] The Ansible features are missing in hammer
Summary: [RFE] The Ansible features are missing in hammer
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Satellite
Classification: Red Hat
Component: Ansible
Version: 6.4
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: 6.7.0
Assignee: satellite6-bugs
QA Contact: tstrych
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-06-13 13:44 UTC by Martin Korbel
Modified: 2020-04-14 13:23 UTC (History)
17 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-04-14 13:22:58 UTC
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 4449281 None None None 2019-09-27 03:18:08 UTC
Red Hat Product Errata RHSA-2020:1454 None None None 2020-04-14 13:23:14 UTC

Description Martin Korbel 2018-06-13 13:44:07 UTC
Description of problem:
The support for ansible features (manage ansible roles, assigning of roles to host, run ansible roles, ...) is missing in hammer.

Version-Release number of selected component (if applicable):
Sat6.4#6

How reproducible:
100%

Steps to Reproduce:
1. > hammer --help | grep -c ansible
0

Actual results:
The support for ansible is missing in hammer.

Expected results:
The same functionality as in WebUI should be in hammer.

Comment 6 Martin Korbel 2018-06-19 11:22:19 UTC
Yes, it is not blocker. 

But there are missing:
* assigning ansible roles to hosts/hostgroups  (as you said)
* import ansible roles

Comment 8 Marek Hulan 2018-07-04 15:15:43 UTC
the plugin should appear in 1.18 repos after next mashing - http://koji.katello.org/koji/buildinfo?buildID=29697

Comment 9 Marek Hulan 2018-07-04 15:21:32 UTC
For QE once delivered:

see 
hammer ansible -h and hammer host 
hammer host ansible-roles -h
hammer hostgroup ansible-roles -h

Comment 11 Marek Hulan 2018-07-17 07:18:44 UTC
In fact, these two commands will not work
hammer host ansible-roles -h
hammer hostgroup ansible-roles -h

to assign ansible roles to host/hostgroup, use following
hammer host update --ansible-role-ids 1,2
hammer hostgroup update --ansible-role-ids 1 --id 1

if you want to start testing before the package hits downstream repos, you can download and install the RPM from http://yum.theforeman.org/plugins/nightly/el7/x86_64/tfm-rubygem-hammer_cli_foreman_ansible-0.1.1-1.fm1_19.el7.noarch.rpm

Comment 12 Martin Korbel 2018-07-24 08:59:15 UTC
Sat6.4#13

few issues:
* The package tfm-rubygem-hammer_cli_foreman_ansible is not installed automatically.
> rpm -q tfm-rubygem-hammer_cli_foreman_ansible
package tfm-rubygem-hammer_cli_foreman_ansible is not installed



* The package tfm-rubygem-hammer_cli_foreman_ansible is not available in capsule repo.
> yum install tfm-rubygem-hammer_cli_foreman_ansible
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
Sat6-CI_Red_Hat_Satellite_Capsule_6_4_Composes_Satellite_Capsule_6_4_RHEL7                      | 2.5 kB  00:00:00     
Sat6-CI_Red_Hat_Satellite_Capsule_6_4_Composes_Satellite_Tools_6_4_RHEL7                        | 2.1 kB  00:00:00     
Sat6-CI_Red_Hat_Satellite_Maintenance_RHEL7                                                     | 2.1 kB  00:00:00     
No package tfm-rubygem-hammer_cli_foreman_ansible available.
Error: Nothing to do



* We can't choose which roles we want to import. The command import all available roles.

> hammer ansible roles import
Result:   
  The following ansible roles were changed
Imported: 
 1) geerlingguy.ntp


> hammer ansible roles import --help
Usage:
    hammer ansible roles import [OPTIONS]

Options:
 --location LOCATION_NAME                Location name
 --location-id LOCATION_ID                
 --location-title LOCATION_TITLE         Location title
 --organization ORGANIZATION_NAME        Organization name
 --organization-id ORGANIZATION_ID       Organization ID
 --organization-title ORGANIZATION_TITLE Organization title
 --proxy-id PROXY_ID                     Capsule to import from
 -h, --help                              Print help



* The option for assign by role name does not work
> hammer host update --help | grep ansible
 --ansible-role-ids ANSIBLE_ROLE_IDS                           IDs of associated ansible roles
 --ansible-roles ANSIBLE_ROLE_NAMES                            Comma separated list of values. Values containing comma should be quoted or escaped with backslash

>  hammer host update --ansible-roles geerlingguy.ntp --id 2
Could not update the host:
  Error: Missing options to search ansible_role.

Comment 13 Marek Hulan 2018-07-24 16:06:21 UTC
> few issues:
* The package tfm-rubygem-hammer_cli_foreman_ansible is not installed automatically.
> rpm -q tfm-rubygem-hammer_cli_foreman_ansible
package tfm-rubygem-hammer_cli_foreman_ansible is not installed

tracked as BZ #1607413 already

please open separate issues for other things you found, not all of them are necessarily 6.4+ I think and they will need to be fixed on different places

Comment 14 Martin Korbel 2018-07-26 08:29:25 UTC
OK Marek,
here are separate bugs for some issues

bz1608699 - The package tfm-rubygem-hammer_cli_foreman_ansible is not available in capsule repo.

bz1608712 - [RFE] the hammer ansible plugin can not filter imported ansible roles 


For this bug is stay for "The option for assign by role name does not work".

Comment 15 Marek Hulan 2018-07-26 12:53:38 UTC
Oleh, could you please take a look on things reported in comment 12? Thanks

Comment 17 Oleh Fedorenko 2018-08-13 11:28:21 UTC
Marek, Martin, I apologize for taking so long to reply.

- The roles import issue was already discussed here: https://bugzilla.redhat.com/show_bug.cgi?id=1608712. So I assume the fix will be with one of the next releases of Foreman Ansible and/or Hammer CLI Ansible plugins.

- I fixed the option for assign by role name which did not work. But I'm afraid the problem was not in the hammer ansible plugin, but in the hammer katello plugin. So, the fix should be available with one of the next releases of Hammer CLI Katello. See: https://github.com/Katello/hammer-cli-katello/pull/575

Comment 21 Martin Korbel 2018-09-11 07:32:29 UTC
By the way, these commands are still displayed in help, but they are not working.

>  hammer host --help
...
Subcommands:
 ansible-roles                  
..

>  hammer host ansible-roles --help
Usage:
    hammer host ansible-roles [OPTIONS]

Options:
 -h, --help                    Print help

Unfortunately the server does not support such operation.


> hammer hostgroup --help
...
Subcommands:
 ansible-roles                  
..


I think,  this commands should be deleted before GA. This feature is new in Sat6.4 (there are not official dependencies for it) and we should remove  these deprecated commands from help.

Comment 22 Oleh Fedorenko 2018-09-12 11:53:21 UTC
They are not deprecated, but the functionality is missing in the Foreman Ansible. Unfortunately now the latest version of the hammer plugin is ahead of the latest version of Foreman Ansible. So, the commands will work when the functionality is added.

P.S. I've already created PRs with the changes to Foreman Ansible and also prepared new version of the hammer plugin. So, with a new version of each plugin everything will work as expected.

Comment 25 steve.whitehouse 2019-08-06 15:35:56 UTC
In Red Hat Satellite 6.5.1 the hammer ansible feature is missing the ability to run an ansible role.
This is a critical feature.



[root@rhsat-oitlab ~]# hammer ansible roles
Usage:
    hammer ansible roles [OPTIONS] SUBCOMMAND [ARG] ...

Parameters:
 SUBCOMMAND                    Subcommand
 [ARG] ...                     Subcommand arguments

Subcommands:

 delete                        Deletes Ansible role
 import                        Import Ansible roles
 info                          Show role
 list                          List Ansible roles
 obsolete                      Obsolete Ansible roles

Options:
 -h, --help                    Print help

Comment 27 Oleh Fedorenko 2019-08-14 16:04:47 UTC
The possibility to run ansible roles from hammer appeared in hammer_cli_foreman_ansible plugin from version 0.2.0 which requires at least 2.3.0 version of foreman_ansible plugin (2.3.2 for better experience).

Unfortunatelly, 6.4.* contains hammer_cli_foreman_ansible-0.1.1 and foreman_ansible-2.2.9 and
6.5.* contains foreman_ansible-2.2.14 and hammer_cli_foreman_ansible-0.1.1, so both 6.4-5 don't have those features.

Marek, could you please suggest a solution?

Comment 30 Marek Hulan 2019-08-30 17:03:05 UTC
I'm sure this can be achieved through regular REX. It's just not that convenient as it will be in 6.6+. E.g. this will run the assigned roles on host foreman.example.tst

> hammer job-invocation create --job-template 'Ansible Roles - Ansible Default' --search-query 'name = foreman.example.tst'

Oleh, could you please confirm the experience improvement in 6.6 and provide a command that will do the same but using ansible hammer command?

Comment 31 Oleh Fedorenko 2019-09-04 10:27:30 UTC
Yes, starting from 6.6 there is (among others)

> hammer host ansible-roles play --id <host-id>

command that will do the same.

Or if you want to play roles on multiple hosts:

> hammer ansible roles play-hosts --host-ids <host-ids>

Comment 34 tstrych 2020-02-05 10:25:53 UTC
With sat 6.7 snap 10 
package versions mentioned in comment #27 are 
tfm-rubygem-hammer_cli_foreman_ansible-0.3.2-1
tfm-rubygem-foreman_ansible_core-3.0.2-1

I've tried functionality of ansible-roles I mentioned below. (only happy paths with necessary arguments)

hammer ansible roles (delete, fetch, import, info, list, obsolete, play-hosts, play-hostgroups)
hammer host ansible-roles (assign, list, play) 
hammer hostgroup ansible-roles (assign, list, play) 

And all works as expected, I look at apidoc, and all ansible roles apicalls seems to be mapped. 

in comment #0 
hammer --help | grep -c ansible 
1
same with  hammer host --help | grep -c ansible, hammer hostgroup --help | grep -c ansible

I find a problem with ansible-roles assign. If the user want to unassign one role he has to use assign option with all the other roles which he wants to keep.

Comment 37 errata-xmlrpc 2020-04-14 13:22:58 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHSA-2020:1454


Note You need to log in before you can comment on or make changes to this bug.