Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1788024

Summary: [ansible-freeipa] In sudo rule module, variable "cmdgroup" is not supporting.
Product: Red Hat Enterprise Linux 8 Reporter: Varun Mylaraiah <mvarun>
Component: ansible-freeipaAssignee: Rafael Jeffman <rjeffman>
Status: CLOSED ERRATA QA Contact: ipa-qe <ipa-qe>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 8.2CC: rjeffman, twoerner
Target Milestone: rcFlags: pm-rhel: mirror+
Target Release: 8.0   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: ansible-freeipa-0.1.8-2.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-04-28 16:01:57 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Varun Mylaraiah 2020-01-06 07:54:40 UTC
Description of problem:
The variable "cmdgroup" is not supporting in the Sudo rule module.

Version-Release number of selected component (if applicable):
ansible-freeipa-0.1.8-1.el8.noarch

Steps to Reproduce:
  # cat 022_sudorule_add_cmd_cmdgroup.yaml
---
- name: Playbook to handle sudorules
  hosts: ipaserver
  become: true

  tasks:
  - ipasudorule:
      ipaadmin_password: <xxxxxxx>
      name: sudorule1
      cmdgroup: sudogroup01
      action: member
      state: present

[root@ansible ~]# vim 022_sudorule_add_cmd_cmdgroup.yaml 
[root@ansible ~]# ansible-playbook -v -i inventory/server.hosts 022_sudorule_add_cmd_cmdgroup.yaml
Using /etc/ansible/ansible.cfg as config file

PLAY [Playbook to handle sudorules] **********************************************************************************

TASK [Gathering Facts] ***********************************************************************************************
ok: [master.ipadomain.test]

TASK [ipasudorule] ***************************************************************************************************
fatal: [master.ipadomain.test]: FAILED! => {"changed": false, "msg": "Unsupported parameters for (ipasudorule) module: cmdgroup Supported parameters include: action, cmd, cmdcategory, description, group, host, hostcategory, hostgroup, ipaadmin_password, ipaadmin_principal, name, nomembers, runasgroupcategory, runasusercategory, state, user, usercategory"}

PLAY RECAP ***********************************************************************************************************
master.ipadomain.test      : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   


Actual results:
"Unsupported parameters for (ipasudorule) module: cmdgroup 

Expected results:
Should support cmdgroup variable in Sudo rule module

Comment 1 Rafael Jeffman 2020-02-04 12:06:45 UTC
Here is the upstream PR https://github.com/freeipa/ansible-freeipa/pull/178

Comment 4 Varun Mylaraiah 2020-03-05 11:57:33 UTC
[root@master ~]# ipa sudorule-show sudorule024
  Rule name: sudorule024
  Enabled: TRUE



[root@ansible ~]# cat sudo_024.yaml
---
- name: Playbook to handle sudorules
  hosts: ipaserver
  become: true

  tasks:
  - ipasudorule:
      ipaadmin_password: <xxxxx>
      name: sudorule024
      allow_sudocmdgroup: testgp1
      action: member
      state: present

[root@ansible ~]# ansible-playbook -vv -i inventory/server.hosts sudo_024.yaml 
ansible-playbook 2.9.5
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python3.6/site-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 3.6.8 (default, Dec  5 2019, 15:45:45) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]
Using /etc/ansible/ansible.cfg as config file

PLAYBOOK: sudo_024.yaml **********************************************************************************************
1 plays in sudo_024.yaml

PLAY [Playbook to handle sudorules] **********************************************************************************

TASK [Gathering Facts] ***********************************************************************************************
task path: /root/sudo_024.yaml:2
ok: [master.ipadomain.test]
META: ran handlers

TASK [ipasudorule] ***************************************************************************************************
task path: /root/sudo_024.yaml:7
changed: [master.ipadomain.test] => {"changed": true}
META: ran handlers
META: ran handlers

PLAY RECAP ***********************************************************************************************************
master.ipadomain.test      : ok=2    changed=1    unreachable=0    failed=0    skipped=0    rescued=0    ignored=0   


[root@master ~]# ipa sudorule-show sudorule024
  Rule name: sudorule024
  Enabled: TRUE
  Sudo Allow Command Groups: testgp1

Comment 5 Varun Mylaraiah 2020-03-06 06:02:38 UTC
Automated test console output:
===============================

2020-03-06T05:52:42 ansible_freeipa_tests/sudo_module.py::Testsudorule01_02_09_07::test_add_sudorule_members 
2020-03-06T05:52:42 [1m-------------------------------- live log call ---------------------------------[0m
2020-03-06T05:52:42 [pytest_multihost.host.Host.master.ParamikoTransport] [32mINFO[0m RUN ['kinit', 'admin']
2020-03-06T05:52:43 [pytest_multihost.host.Host.master.ParamikoTransport] [32mINFO[0m RUN ['ipa', 'sudorule-find']
2020-03-06T05:52:44 [pytest_multihost.host.Host.master.ParamikoTransport] [32mINFO[0m RUN ['kdestroy', '-A']
2020-03-06T05:52:44 [pytest_multihost.host.Host.ansible.ParamikoTransport] [32mINFO[0m WRITE inventory/sudo.hosts
2020-03-06T05:52:44 [pytest_multihost.host.Host.ansible.ParamikoTransport] [32mINFO[0m PUT sudo_module.yml
2020-03-06T05:52:44 [pytest_multihost.host.Host.ansible.ParamikoTransport] [32mINFO[0m RUN ['ansible-playbook', '--ssh-extra-args="-o StrictHostKeyChecking=no"', '-vv', '-i', 'inventory/sudo.hosts', 'sudo_module.yml']
2020-03-06T05:52:49 [pytest_multihost.host.Host.master.ParamikoTransport] [32mINFO[0m RUN ['kinit', 'admin']
2020-03-06T05:52:49 [pytest_multihost.host.Host.master.ParamikoTransport] [32mINFO[0m RUN ['ipa', 'sudorule-show', 'sudorule_1788024']
2020-03-06T05:52:50 [pytest_multihost.host.Host.master.ParamikoTransport] [32mINFO[0m RUN ['kdestroy', '-A']
2020-03-06T05:52:50 [32mPASSED[0m[36m [ 71%][0m
2020-03-06T05:52:50 ansible_freeipa_tests/sudo_module.py::Testsudorule01_02_09_07::test_delet_sudorule

Comment 7 errata-xmlrpc 2020-04-28 16:01:57 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/RHBA-2020:1705