Bug 1981713

Summary: [ansible-freeipa] Required correct error message for removing in/ex/clusive regex with an invalid key from automember rule
Product: Red Hat Enterprise Linux 9 Reporter: Thomas Woerner <twoerner>
Component: ansible-freeipaAssignee: Thomas Woerner <twoerner>
Status: CLOSED CURRENTRELEASE QA Contact: ipa-qe <ipa-qe>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 9.0CC: ipa-qe, mvarun
Target Milestone: betaKeywords: Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: ansible-freeipa-0.3.8-1.el9 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1976926 Environment:
Last Closed: 2021-12-07 21:30:47 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:
Bug Depends On: 1976926    
Bug Blocks:    

Description Thomas Woerner 2021-07-13 08:02:38 UTC
+++ This bug was initially created as a clone of Bug #1976926 +++

Description of problem:
Required correct error message while removing in/ex/clusive regex with an invalid key from automember rule

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


Steps to Reproduce:
[root@ansible ~]# cat automember3_remove.yaml
---
- name: Playbook to ensure group automember is not able to remove with invalid exclusive regex key
  hosts: ipaserver
  become: yes
  
  tasks:
  - ipaautomember:      
      ipaadmin_principal: admin
      Ipaadmin_password: <xxxxxxxxx>
      name: 01automemb_usergroup
      exclusive:
        - key: tesykey
          expression: '^uid=clint'
      action: member
      automember_type: group
      state: absent


[root@ansible ~]# ansible-playbook -vv -i inventory/automember.hosts 
PLAYBOOK: automember3_remove.yaml *****************************************************************************************
1 plays in automember3_remove.yaml

PLAY [Playbook to ensure group automember is not able to remove with invalid exclusive regex key] *************************

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

TASK [ipaautomember] ******************************************************************************************************
task path: /root/automember3_remove.yaml:7
fatal: [master.ipadomain.test]: FAILED! => {"changed": false, "msg": "too many values to unpack (expected 2)"}

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

Actual results:
FAILED! => {"changed": false, "msg": "too many values to unpack (expected 2)"}

Expected results:
tesykey is not a valid attribute.

Additional info:

--- Additional comment from Thomas Woerner on 2021-07-08 19:44:21 UTC ---

Upstream PR: https://github.com/freeipa/ansible-freeipa/pull/590

--- Additional comment from Thomas Woerner on 2021-07-12 12:24:47 UTC ---

The upstream PR has been merged.

Comment 2 Thomas Woerner 2021-07-15 15:54:39 UTC
Here is an additional PR to verify condition keys: https://github.com/freeipa/ansible-freeipa/pull/596

Comment 9 Varun Mylaraiah 2021-08-09 11:39:03 UTC
Verified

ansible-freeipa-0.3.8-1.el9.noarch
ipa-server-4.9.6-4.el9.x86_64

Red Hat Enterprise Linux release 9.0 Beta (Plow)

Passed	ansible_freeipa_tests/automember/test_automember.py::TestAutomember::()::test_automember_group_rule_remove_with_invalid_exclusive_regex_key	6.84	
------------------------------ Captured log call -------------------------------
transport.py               397 INFO     RUN ['/usr/bin/rpm', '-q', 'ansible-freeipa']
transport.py               519 DEBUG    RUN ['/usr/bin/rpm', '-q', 'ansible-freeipa']
transport.py               563 DEBUG    bash: line 1: cd: /root/multihost_tests: No such file or directory
transport.py               563 DEBUG    bash: line 2: /root/multihost_tests/env.sh: No such file or directory
transport.py               563 DEBUG    ansible-freeipa-0.3.8-1.el9.noarch
transport.py               217 DEBUG    Exit code: 0
transport.py               397 INFO     RUN ['kinit', 'admin']
transport.py               519 DEBUG    RUN ['kinit', 'admin']
transport.py               563 DEBUG    bash: line 1: cd: /root/multihost_tests: No such file or directory
transport.py               563 DEBUG    bash: line 2: /root/multihost_tests/env.sh: No such file or directory
transport.py               563 DEBUG    Password for admin: 
transport.py               217 DEBUG    Exit code: 0
transport.py               397 INFO     RUN ['ipa', 'automember-show', '--type=group', '02automemb_usergroup']
transport.py               519 DEBUG    RUN ['ipa', 'automember-show', '--type=group', '02automemb_usergroup']
transport.py               563 DEBUG    bash: line 1: cd: /root/multihost_tests: No such file or directory
transport.py               563 DEBUG    bash: line 2: /root/multihost_tests/env.sh: No such file or directory
transport.py               563 DEBUG      Automember Rule: 02automemb_usergroup
transport.py               563 DEBUG      Inclusive Regex: manager=^uid=miles, manager=^uid=vrns
transport.py               563 DEBUG      Exclusive Regex: cn=^uid=miles, cn=^uid=clint
transport.py               217 DEBUG    Exit code: 0
transport.py               397 INFO     RUN ['kdestroy', '-A']
transport.py               519 DEBUG    RUN ['kdestroy', '-A']
transport.py               563 DEBUG    bash: line 1: cd: /root/multihost_tests: No such file or directory
transport.py               563 DEBUG    bash: line 2: /root/multihost_tests/env.sh: No such file or directory
transport.py               217 DEBUG    Exit code: 0
transport.py               433 INFO     PUT inventory/automember.hosts
transport.py               519 DEBUG    RUN ['tee', 'inventory/automember.hosts']
transport.py               217 DEBUG    Exit code: 0
transport.py               433 INFO     PUT automember_module.yml
transport.py               519 DEBUG    RUN ['tee', 'automember_module.yml']
transport.py               217 DEBUG    Exit code: 0
transport.py               397 INFO     RUN ['ansible-playbook', '--ssh-extra-args="-o StrictHostKeyChecking=no"', '-vv', '-i', 'inventory/automember.hosts', 'automember_module.yml']
transport.py               519 DEBUG    RUN ['ansible-playbook', '--ssh-extra-args="-o StrictHostKeyChecking=no"', '-vv', '-i', 'inventory/automember.hosts', 'automember_module.yml']
transport.py               563 DEBUG    bash: line 1: cd: /root/multihost_tests: No such file or directory
transport.py               563 DEBUG    bash: line 2: /root/multihost_tests/env.sh: No such file or directory
transport.py               563 DEBUG    ansible-playbook 2.9.24
transport.py               563 DEBUG      config file = None
transport.py               563 DEBUG      configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
transport.py               563 DEBUG      ansible python module location = /usr/local/lib/python3.9/site-packages/ansible
transport.py               563 DEBUG      executable location = /usr/local/bin/ansible-playbook
transport.py               563 DEBUG      python version = 3.9.6 (default, Jul 29 2021, 00:00:00) [GCC 11.1.1 20210623 (Red Hat 11.1.1-6)]
transport.py               563 DEBUG    No config file found; using defaults
transport.py               563 DEBUG    Skipping callback 'actionable', as we already have a stdout callback.
transport.py               563 DEBUG    Skipping callback 'counter_enabled', as we already have a stdout callback.
transport.py               563 DEBUG    Skipping callback 'debug', as we already have a stdout callback.
transport.py               563 DEBUG    Skipping callback 'dense', as we already have a stdout callback.
transport.py               563 DEBUG    Skipping callback 'dense', as we already have a stdout callback.
transport.py               563 DEBUG    Skipping callback 'full_skip', as we already have a stdout callback.
transport.py               563 DEBUG    Skipping callback 'json', as we already have a stdout callback.
transport.py               563 DEBUG    Skipping callback 'minimal', as we already have a stdout callback.
transport.py               563 DEBUG    Skipping callback 'null', as we already have a stdout callback.
transport.py               563 DEBUG    Skipping callback 'oneline', as we already have a stdout callback.
transport.py               563 DEBUG    Skipping callback 'selective', as we already have a stdout callback.
transport.py               563 DEBUG    Skipping callback 'skippy', as we already have a stdout callback.
transport.py               563 DEBUG    Skipping callback 'stderr', as we already have a stdout callback.
transport.py               563 DEBUG    Skipping callback 'unixy', as we already have a stdout callback.
transport.py               563 DEBUG    Skipping callback 'yaml', as we already have a stdout callback.
transport.py               563 DEBUG    
transport.py               563 DEBUG    PLAYBOOK: automember_module.yml ************************************************
transport.py               563 DEBUG    1 plays in automember_module.yml
transport.py               563 DEBUG    
transport.py               563 DEBUG    PLAY [Playbook to ensure group automember is not able to remove with invalid exclusive regex key] ***
transport.py               563 DEBUG    
transport.py               563 DEBUG    TASK [Gathering Facts] *********************************************************
transport.py               563 DEBUG    task path: /root/automember_module.yml:2
transport.py               563 DEBUG    ok: [master.ipadomain.test]
transport.py               563 DEBUG    META: ran handlers
transport.py               563 DEBUG    [DEPRECATION WARNING]: Distribution rhel 9.0 on host master.ipadomain.test 
transport.py               563 DEBUG    should use /usr/libexec/platform-python, but is using /usr/bin/python for 
transport.py               563 DEBUG    backward compatibility with prior Ansible releases. A future Ansible release 
transport.py               563 DEBUG    will default to using the discovered platform python for this host. See https:/
transport.py               563 DEBUG    /docs.ansible.com/ansible/2.9/reference_appendices/interpreter_discovery.html 
transport.py               563 DEBUG    for more information. This feature will be removed in version 2.12. Deprecation
transport.py               563 DEBUG     warnings can be disabled by setting deprecation_warnings=False in ansible.cfg.
transport.py               563 DEBUG    
transport.py               563 DEBUG    TASK [ipaautomember] ***********************************************************
transport.py               563 DEBUG    task path: /root/automember_module.yml:7
transport.py               563 DEBUG    fatal: [master.ipadomain.test]: FAILED! => {"changed": false, "msg": "Invalid automember condition key 'tesykey'"}
transport.py               563 DEBUG    
transport.py               563 DEBUG    PLAY RECAP *********************************************************************
transport.py               563 DEBUG    master.ipadomain.test      : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
transport.py               563 DEBUG    
transport.py               217 DEBUG    Exit code: 2
transport.py               397 INFO     RUN ['kinit', 'admin']
transport.py               519 DEBUG    RUN ['kinit', 'admin']
transport.py               563 DEBUG    bash: line 1: cd: /root/multihost_tests: No such file or directory
transport.py               563 DEBUG    bash: line 2: /root/multihost_tests/env.sh: No such file or directory
transport.py               563 DEBUG    Password for admin: 
transport.py               217 DEBUG    Exit code: 0
transport.py               397 INFO     RUN ['ipa', 'automember-show', '--type=group', '02automemb_usergroup']
transport.py               519 DEBUG    RUN ['ipa', 'automember-show', '--type=group', '02automemb_usergroup']
transport.py               563 DEBUG    bash: line 1: cd: /root/multihost_tests: No such file or directory
transport.py               563 DEBUG    bash: line 2: /root/multihost_tests/env.sh: No such file or directory
transport.py               563 DEBUG      Automember Rule: 02automemb_usergroup
transport.py               563 DEBUG      Inclusive Regex: manager=^uid=miles, manager=^uid=vrns
transport.py               563 DEBUG      Exclusive Regex: cn=^uid=miles, cn=^uid=clint
transport.py               217 DEBUG    Exit code: 0
transport.py               397 INFO     RUN ['kdestroy', '-A']
transport.py               519 DEBUG    RUN ['kdestroy', '-A']
transport.py               563 DEBUG    bash: line 1: cd: /root/multihost_tests: No such file or directory
transport.py               563 DEBUG    bash: line 2: /root/multihost_tests/env.sh: No such file or directory
transport.py               217 DEBUG    Exit code: 0