Bug 1836288

Summary: [ansible-freeipa] Expecting valid error message while adding service with missing service name.
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.3CC: 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.11-1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-11-04 02:46:35 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-05-15 14:50:59 UTC
Description of problem:
Expecting valid error message while adding service with missing service name in the ansible-freeipa service module

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

Steps to Reproduce:
---
- name: Playbook to manage IPA service.
  hosts: ipaserver
  become: true
  gather_facts: false

  tasks:
  - name: Get Domain from server name
    set_fact:
      ipaserver_domain: "{{ groups.ipaserver[0].split('.')[1:] | join ('.') }}"
  - name: Get Realm from server name
    set_fact:
      ipaserver_realm: "{{ groups.ipaserver[0].split('.')[1:] | join ('.') | upper }}"      
  # Ensure testing service
  - ipaservice:
      Ipaadmin_password: <xxxxxxxxxxxxxxx>
      name: "{{'master.' + ipaserver_domain + '@' + ipaserver_realm }}"

[root@ansible ~]# ansible-playbook -vv -i inventory/server.hosts 03_1.yaml 
ansible-playbook 2.9.7
  config file = /root/ansible.cfg
  configured module search path = ['/root/ansible-freeipa/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, Apr  3 2020, 16:09:51) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]
Using /root/ansible.cfg as config file

PLAYBOOK: 03_1.yaml ***********************************************************************
1 plays in 03_1.yaml

PLAY [Playbook to manage IPA service.] ****************************************************
META: ran handlers

TASK [Get Domain from server name] ********************************************************
task path: /root/03_1.yaml:8
ok: [master.ipadomain.test] => {"ansible_facts": {"ipaserver_domain": "ipadomain.test"}, "changed": false}

TASK [Get Realm from server name] *********************************************************
task path: /root/03_1.yaml:11
ok: [master.ipadomain.test] => {"ansible_facts": {"ipaserver_realm": "IPADOMAIN.TEST"}, "changed": false}

TASK [ipaservice] *************************************************************************
task path: /root/03_1.yaml:15
fatal: [master.ipadomain.test]: FAILED! => {"ansible_facts": {"discovered_interpreter_python": "/usr/libexec/platform-python"}, "changed": false, "msg": "There is more than one service 'master.ipadomain.test'"}

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

Actual results:
changed": false, "msg": "There is more than one service 'master.ipadomain.test'"

Expected results:
invalid 'canonical_principal': Service principal is required

CLI Console Output:
[root@master ~]# ipa service-add master.ipadomain.test
ipa: ERROR: invalid 'canonical_principal': Service principal is required

Comment 1 Rafael Jeffman 2020-06-02 22:14:50 UTC
There is an upstream PR for the issue: https://github.com/freeipa/ansible-freeipa/pull/290

Comment 3 Rafael Jeffman 2020-06-05 23:26:15 UTC
Update PR was merged.

Comment 6 Varun Mylaraiah 2020-07-23 11:42:16 UTC
Verified

ansible-freeipa-0.1.12-5.el8.noarch

Automation test result:
ansible-freeipa-tests/ansible_freeipa_tests/service_module.py::TestServiceAddandRemove::()::test_service_add_without_servicename
------------------------------ Captured log call -------------------------------
transport.py               293 INFO     WRITE inventory/service.hosts
sftp.py                    158 DEBUG    [chan 0] open(b'inventory/service.hosts', 'wb')
sftp.py                    158 DEBUG    [chan 0] open(b'inventory/service.hosts', 'wb') -> 00000000
sftp.py                    158 DEBUG    [chan 0] close(00000000)
transport.py               329 INFO     PUT service_module.yml
sftp.py                    158 DEBUG    [chan 0] open(b'service_module.yml', 'wb')
sftp.py                    158 DEBUG    [chan 0] open(b'service_module.yml', 'wb') -> 00000000
sftp.py                    158 DEBUG    [chan 0] close(00000000)
sftp.py                    158 DEBUG    [chan 0] stat(b'service_module.yml')
channel.py                1212 DEBUG    [chan 3] Max packet in: 32768 bytes
channel.py                1212 DEBUG    [chan 3] Max packet out: 32768 bytes
transport.py              1819 DEBUG    Secsh channel 3 opened.
transport.py               318 INFO     RUN ['ansible-playbook', '--ssh-extra-args="-o StrictHostKeyChecking=no"', '-vv', '-i', 'inventory/service.hosts', 'service_module.yml']
transport.py               519 DEBUG    RUN ['ansible-playbook', '--ssh-extra-args="-o StrictHostKeyChecking=no"', '-vv', '-i', 'inventory/service.hosts', 'service_module.yml']
channel.py                1212 DEBUG    [chan 3] Sesch channel 3 request ok
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.11
transport.py               563 DEBUG      config file = /root/ansible.cfg
transport.py               563 DEBUG      configured module search path = ['/root/ansible-freeipa/plugins/modules', '/usr/share/ansible/plugins/modules']
transport.py               563 DEBUG      ansible python module location = /usr/lib/python3.6/site-packages/ansible
transport.py               563 DEBUG      executable location = /usr/bin/ansible-playbook
transport.py               563 DEBUG      python version = 3.6.8 (default, Jun 26 2020, 12:10:09) [GCC 8.3.1 20191121 (Red Hat 8.3.1-5)]
transport.py               563 DEBUG    Using /root/ansible.cfg as config file
transport.py               563 DEBUG    
transport.py               563 DEBUG    PLAYBOOK: service_module.yml ***************************************************
transport.py               563 DEBUG    1 plays in service_module.yml
transport.py               563 DEBUG    
transport.py               563 DEBUG    PLAY [Playbook to ensure service is not able to add without service name.] *****
transport.py               563 DEBUG    
transport.py               563 DEBUG    TASK [Gathering Facts] *********************************************************
transport.py               563 DEBUG    task path: /root/service_module.yml:2
transport.py               563 DEBUG    ok: [master.ipadomain.test]
transport.py               563 DEBUG    META: ran handlers
transport.py               563 DEBUG    
transport.py               563 DEBUG    TASK [Get Domain from server name] *********************************************
transport.py               563 DEBUG    task path: /root/service_module.yml:6
transport.py               563 DEBUG    ok: [master.ipadomain.test] => {"ansible_facts": {"ipaserver_domain": "ipadomain.test"}, "changed": false}
transport.py               563 DEBUG    
transport.py               563 DEBUG    TASK [Get Realm from server name] **********************************************
transport.py               563 DEBUG    task path: /root/service_module.yml:9
transport.py               563 DEBUG    ok: [master.ipadomain.test] => {"ansible_facts": {"ipaserver_realm": "IPADOMAIN.TEST"}, "changed": false}
transport.py               563 DEBUG    
transport.py               563 DEBUG    TASK [ipaservice] **************************************************************
transport.py               563 DEBUG    task path: /root/service_module.yml:13
transport.py               563 DEBUG    fatal: [master.ipadomain.test]: FAILED! => {"changed": false, "msg": "service_add: master.ipadomain.test: invalid 'canonical_principal': Service principal is required"}
transport.py               563 DEBUG    
transport.py               563 DEBUG    PLAY RECAP *********************************************************************
transport.py               563 DEBUG    master.ipadomain.test      : ok=3    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0   
transport.py               563 DEBUG    
channel.py                1212 DEBUG    [chan 3] EOF received (3)
channel.py                1212 DEBUG    [chan 3] EOF sent (3)
transport.py               217 DEBUG    Exit code: 2

Comment 9 errata-xmlrpc 2020-11-04 02:46:35 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 (ansible-freeipa bug fix and enhancement update), 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/RHEA-2020:4663