Bug 1783976

Summary: [ansible-freeipa] Expecting error message while updating invalid ip-address in hosts
Product: Red Hat Enterprise Linux 8 Reporter: Varun Mylaraiah <mvarun>
Component: ansible-freeipaAssignee: Thomas Woerner <twoerner>
Status: CLOSED ERRATA QA Contact: ipa-qe <ipa-qe>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 8.2   
Target Milestone: rc   
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:56 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 2019-12-16 11:26:41 UTC
Description of problem:
Expecting error message while updating invalid IP-address in hosts.


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



Steps to Reproduce:
---
- name: Playbook to handle hosts
  hosts: ipaserver
  become: true

  tasks:
  # Ensure host is present with wrong IP
  - ipahost:
      ipaadmin_password: <xxxxxx>
      name: host01.ipadomain.test
      description: Example host-1
      ip_address: 10.701.12.11


# ansible-playbook -vv -i inventory/server.hosts update_host_with_invalid_IP.yaml 
ansible-playbook 2.9.2
  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: update_host_with_invalid_IP.yaml ***************************************************************************
1 plays in update_host_with_invalid_IP.yaml

PLAY [Playbook to handle hosts] **************************************************************************************

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

TASK [ipahost] *******************************************************************************************************
task path: /root/update_host_with_invalid_IP.yaml:8
ok: [master.ipadomain.test] => {"changed": false, "host": {}}
META: ran handlers
META: ran handlers

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




Actual results:
Here I did not get any error message.


Expected results:
fatal: [master.ipadomain.test]: FAILED! => {"changed": false, "msg": "host_add: host01.ipadomain.test: invalid 'ip_address': failed to detect a valid IP address from '10.701.12.11'"}

Comment 1 Thomas Woerner 2020-02-14 14:10:14 UTC
Here is the upstream PR: Here is the upstream PR: https://github.com/freeipa/ansible-freeipa/pull/203

Comment 4 Varun Mylaraiah 2020-02-25 07:12:21 UTC
Verified

Manual execution console output:
================================
# rpm -q ansible-freeipa
ansible-freeipa-0.1.8-2.el8.noarch


[root@master ~]# ipa host-find host1783976.ipadomain.test
---------------
0 hosts matched
---------------
----------------------------
Number of entries returned 0
----------------------------

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

  tasks:
  # Ensure host is not present with invalid IP
  - ipahost:
      ipaadmin_password: <xxxxxxxx>
      name: host1783976.ipadomain.test
      description: bug1783976
      ip_address: 10.701.12.11

[root@ansible ~]# ansible-playbook -vv -i inventory/server.hosts bz1783976.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: bz1783976.yaml *********************************************************************************************
1 plays in bz1783976.yaml

PLAY [Playbook to handle hosts] **************************************************************************************

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

TASK [ipahost] *******************************************************************************************************
task path: /root/bz1783976.yaml:8
fatal: [master.ipadomain.test]: FAILED! => {"changed": false, "msg": "'10.701.12.11' is not a valid IP address."}

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


[root@master ~]# ipa host-find host1783976.ipadomain.test
---------------
0 hosts matched
---------------
----------------------------
Number of entries returned 0
----------------------------

Comment 5 Varun Mylaraiah 2020-02-25 07:13:17 UTC
Automated test console output:
===============================

ansible_freeipa_tests/host_module.py::Testhost27::test_add_host_with_invalid_IP 
-------------------------------- live log call ---------------------------------
[paramiko.transport] INFO Connected (version 2.0, client OpenSSH_8.0)
[paramiko.transport] INFO Authentication (publickey) successful!
[pytest_multihost.host.Host.master.ParamikoTransport] INFO RUN ['ipactl', 'status']
[pytest_multihost.host.Host.master.ParamikoTransport] INFO RUN ['kinit', 'admin']
[pytest_multihost.host.Host.master.ParamikoTransport] INFO RUN ['ipa', 'host-find']
[pytest_multihost.host.Host.master.ParamikoTransport] INFO RUN ['kdestroy', '-A']
[paramiko.transport] INFO Connected (version 2.0, client OpenSSH_8.0)
[paramiko.transport] INFO Authentication (publickey) successful!
[pytest_multihost.host.Host.ansible.ParamikoTransport] INFO WRITE inventory/host.hosts
[paramiko.transport.sftp] INFO [chan 0] Opened sftp connection (server version 3)
[pytest_multihost.host.Host.ansible.ParamikoTransport] INFO PUT host_module.yml
[pytest_multihost.host.Host.ansible.ParamikoTransport] INFO RUN ['ansible-playbook', '--ssh-extra-args="-o StrictHostKeyChecking=no"', '-vv', '-i', 'inventory/host.hosts', 'host_module.yml']
[pytest_multihost.host.Host.master.ParamikoTransport] INFO RUN ['kinit', 'admin']
[pytest_multihost.host.Host.master.ParamikoTransport] INFO RUN ['ipa', 'host-find']
[pytest_multihost.host.Host.master.ParamikoTransport] INFO RUN ['kdestroy', '-A']
PASSED                                                                   [100%]

------------- generated xml file: /opt/mytests/af_host_1/junit.xml -------------
-------- generated html file: file:///opt/mytests/af_host_1/report.html --------

Comment 7 errata-xmlrpc 2020-04-28 16:01:56 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