Skip to content

Commit

Permalink
don't accidentally duplicate kt_activation_keys param
Browse files Browse the repository at this point in the history
Fixes: #1268
  • Loading branch information
evgeni committed Aug 11, 2021
1 parent 604f60b commit 87a7d4c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/1268-ak_param_duplicate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- host, hostgroup - don't accidentally duplicate ``kt_activation_keys`` param (https://github.com/theforeman/foreman-ansible-modules/issues/1268)
7 changes: 4 additions & 3 deletions plugins/module_utils/foreman_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,10 @@ def run(self, **kwargs):
ak_param = {'name': 'kt_activation_keys', 'parameter_type': 'string', 'value': self.foreman_params.pop('activation_keys')}
self.foreman_params['parameters'] = parameters + [ak_param]
elif 'parameters' in self.foreman_params and entity is not None:
ak_param = next((param for param in entity.get('parameters') if param['name'] == 'kt_activation_keys'), None)
if ak_param:
self.foreman_params['parameters'].append(ak_param)
current_ak_param = next((param for param in entity.get('parameters') if param['name'] == 'kt_activation_keys'), None)
desired_ak_param = next((param for param in self.foreman_params['parameters'] if param['name'] == 'kt_activation_keys'), None)
if current_ak_param and desired_ak_param is None:
self.foreman_params['parameters'].append(current_ak_param)

self.validate_parameters()

Expand Down

0 comments on commit 87a7d4c

Please sign in to comment.