theforeman / foreman-ansible-modules

Ansible modules for interacting with the Foreman API and various plugin APIs such as Katello
GNU General Public License v3.0
147 stars 163 forks source link

foreman_subnet fails on subsequent re-runs #428

Closed m-czernek closed 5 years ago

m-czernek commented 5 years ago
SUMMARY

It seems like foreman_subnet is not idempotent. On the first pass, I can create a network. On the second pass, I get an error.

(latest Ansible, latest foreman-ansible-modules, latest Satellite, running on RHEL)

ISSUE TYPE
ACTUAL RESULTS
WARNING: The below traceback may *not* be related to the actual failure.
  File "/tmp/ansible_foreman_subnet_payload_1mnM8N/ansible_foreman_subnet_payload.zip/ansible/module_utils/foreman_helper.py", line 457, in resource_action
    result = self.foremanapi.resource(resource).call(action, resource_payload, options=options, data=data, files=files)
  File "/home/ansible/foreman-ansible-modules-venv/lib/python2.7/site-packages/apypie/resource.py", line 30, in call
    return self.api.call(self.name, action, params, headers, options, data, files)
  File "/home/ansible/foreman-ansible-modules-venv/lib/python2.7/site-packages/apypie/api.py", line 157, in call
    action.validate(params, data, files)
  File "/home/ansible/foreman-ansible-modules-venv/lib/python2.7/site-packages/apypie/action.py", line 53, in validate
    self._validate(self.params, values, data, files)
  File "/home/ansible/foreman-ansible-modules-venv/lib/python2.7/site-packages/apypie/action.py", line 74, in _validate
    raise MissingArgumentsError(message)

failed: [dh2.test.local -> localhost] (item={u'dns_primary': u'192.168.20.1', u'to_ip': u'192.168.20.30', u'name': u'test-network', u'from_ip': u'192.168.20.10', u'domains': [u'test.local'], u'cidr': 24, u'gateway': u'192.168.20.1', u'network': u'192.168.20.0'}) => {"ansible_loop_var": "item", "changed": false, "item": {"cidr": 24, "dns_primary": "192.168.20.1", "domains": ["test.local"], "from_ip": "192.168.20.10", "gateway": "192.168.20.1", "name": "test-network", "network": "192.168.20.0", "to_ip": "192.168.20.30"}, "msg": "Error while performing update on subnets: The following required parameters are missing: subnet"}
evgeni commented 5 years ago

Weird. Can you post the corresponding play book?

evgeni commented 5 years ago

Hmm, this could be a bug in how _entity_spec_helper generates the "flat" entries, but I'd need to check on a real setup and not my phone.

evgeni commented 5 years ago

Hah, we don't test idempotency with domains set in https://github.com/theforeman/foreman-ansible-modules/blob/master/tests/test_playbooks/subnet.yml and thats most probably your bug

evgeni commented 5 years ago

Nope, added domains and still works for me.

evgeni commented 5 years ago

After debugging on IRC, it seems to be the assignment of remote_execution_proxies that breaks here. Still not sure why.

evgeni commented 5 years ago

More digging: rex proxies are not part of the apidoc (https://projects.theforeman.org/issues/19086) so this fails as entries not in the apidoc are dropped from the request.

cc @bagasse for awarenes