Bug 1783979

Summary: [ansible-freeipa] Expecting error message while updating same ip-address to the existing host
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: Unspecified   
OS: Unspecified   
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:53:54 UTC
Description of problem:
 Expecting error message while updating the same IP-address to the existing host.


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


Steps to Reproduce:
ADD HOST
#########
# cat addhost1.yaml
---
- name: Playbook to handle hosts
  hosts: ipaserver
  become: true

  tasks:
  - ipahost:
      ipaadmin_password: Secret.123
      name: host11.ipadomain.test
      description: Example host-11
      ip_address: 11.11.11.11
  - ipahost:
      ipaadmin_password: Secret.123
      name: host12.ipadomain.test
      description: Example host-12
      ip_address: 12.12.12.12

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

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

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

TASK [ipahost] *******************************************************************************************************
task path: /root/addhost1.yaml:7
changed: [master.ipadomain.test] => {"changed": true, "host": {}}

TASK [ipahost] *******************************************************************************************************
task path: /root/addhost1.yaml:12
changed: [master.ipadomain.test] => {"changed": true, "host": {}}
META: ran handlers
META: ran handlers

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


Update host
###########

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

  tasks:
  - ipahost:
      ipaadmin_password: Secret.123
      name: host12.ipadomain.test
      description: Example host-12
      ip_address: 11.11.11.11


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

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

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

TASK [ipahost] *******************************************************************************************************
task path: /root/updatehost.yaml:7
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: host13.ipadomain.test: IP address 11.11.11.11 is already assigned in domain ipadomain.test.."}

Comment 1 Thomas Woerner 2020-02-12 16:25:26 UTC
IPA API dnsrecord-add is allowing to add the same IP address for different hosts. This is not an issue of the ipahost module. ipahost has ignored IP addresses though with ipahost-mod as this is not allowing to change IP addresses at all.

Comment 2 Thomas Woerner 2020-02-14 09:40:42 UTC
There are no IP address conclict checks in the ipahost module as this would lead into issues with updating an existing host that already is using a duplicate IP address for example for round-robin (RR). Also this might lead into issues with ensuring a new host with several IP addresses in this case. Also to ensure a list of hosts with changing the IP address of one host to another in the list would result in issues here.

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

Comment 7 Varun Mylaraiah 2020-03-02 09:04:37 UTC
According to Comment1 now we can update the same IP-address to the existing hosts. 

Verified

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

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

  tasks:
  - ipahost:
      ipaadmin_password: <XXXXXX>
      name: host11.ipadomain.test
      description: Example host-11
      ip_address: 11.11.11.11
  - ipahost:
      ipaadmin_password: <XXXXXX>
      name: host12.ipadomain.test
      description: Example host-12
      ip_address: 12.12.12.12
[root@ansible ~]# ansible-playbook -vv -i server.hosts bz1783979.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: bz1783979.yaml *************************************************************************************************
1 plays in bz1783979.yaml

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

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

TASK [ipahost] ***********************************************************************************************************
task path: /root/bz1783979.yaml:7
changed: [master.ipadomain.test] => {"changed": true, "host": {}}

TASK [ipahost] ***********************************************************************************************************
task path: /root/bz1783979.yaml:12
changed: [master.ipadomain.test] => {"changed": true, "host": {}}
META: ran handlers
META: ran handlers

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

[root@master ~]# ipa dnsrecord-show ipadomain.test host11
  Record name: host11
  A record: 11.11.11.11
[root@master ~]# ipa dnsrecord-show ipadomain.test host12
  Record name: host12
  A record: 12.12.12.12



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

  tasks:
  - ipahost:
      ipaadmin_password: <XXXXXX>
      name: host12.ipadomain.test
      ip_address: 11.11.11.11
      action: member
[root@ansible ~]# ansible-playbook -vv -i server.hosts bz1783979_1.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: bz1783979_1.yaml ***********************************************************************************************
1 plays in bz1783979_1.yaml

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

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

TASK [ipahost] ***********************************************************************************************************
task path: /root/bz1783979_1.yaml:7
changed: [master.ipadomain.test] => {"changed": true, "host": {}}
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 dnsrecord-show ipadomain.test host11
  Record name: host11
  A record: 11.11.11.11
[root@master ~]# ipa dnsrecord-show ipadomain.test host12
  Record name: host12
  A record: 12.12.12.12, 11.11.11.11

Comment 8 Varun Mylaraiah 2020-03-02 09:06:23 UTC
Automated test console output:
===============================

2020-03-02T08:35:54 ansible_freeipa_tests/host_module.py::Testhost03_29::test_add_same_IP_for_another_host 
2020-03-02T08:35:54 [1m-------------------------------- live log call ---------------------------------[0m
2020-03-02T08:35:54 [pytest_multihost.host.Host.master.ParamikoTransport] [32mINFO[0m RUN ['kinit', 'admin']
2020-03-02T08:35:54 [pytest_multihost.host.Host.master.ParamikoTransport] [32mINFO[0m RUN ['ipa', 'dnsrecord-show', 'ipadomain.test', 'myhost03a']
2020-03-02T08:35:55 [pytest_multihost.host.Host.ansible.ParamikoTransport] [32mINFO[0m WRITE inventory/host.hosts
2020-03-02T08:35:55 [pytest_multihost.host.Host.ansible.ParamikoTransport] [32mINFO[0m PUT host_module.yml
2020-03-02T08:35:55 [pytest_multihost.host.Host.ansible.ParamikoTransport] [32mINFO[0m RUN ['ansible-playbook', '--ssh-extra-args="-o StrictHostKeyChecking=no"', '-vv', '-i', 'inventory/host.hosts', 'host_module.yml']
2020-03-02T08:36:02 [pytest_multihost.host.Host.master.ParamikoTransport] [32mINFO[0m RUN ['kinit', 'admin']
2020-03-02T08:36:02 [pytest_multihost.host.Host.master.ParamikoTransport] [32mINFO[0m RUN ['ipa', 'dnsrecord-show', 'ipadomain.test', 'myhost03c']
2020-03-02T08:36:04 [32mPASSED[0m[36m [ 85%][0m

Comment 10 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