Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kt_activation_keys in parameters get duplicated #1268

Closed
evgeni opened this issue Jul 23, 2021 · 9 comments · Fixed by #1271
Closed

kt_activation_keys in parameters get duplicated #1268

evgeni opened this issue Jul 23, 2021 · 9 comments · Fixed by #1271

Comments

@evgeni
Copy link
Member

evgeni commented Jul 23, 2021

SUMMARY

if you pass

parameters:
  - name: kt_activation_keys
    value: lol

to hostgroup, you end up with the duplicate param error on the second run of the playbook, as the below code doesn't check if the param actually needs to be appended again

if 'activation_keys' in self.foreman_params:
if 'parameters' not in self.foreman_params:
parameters = [param for param in (entity or {}).get('parameters', []) if param['name'] != 'kt_activation_keys']
else:
parameters = self.foreman_params['parameters']
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)

ISSUE TYPE
  • Bug Report
ANSIBLE VERSION

COLLECTION VERSION

KATELLO/FOREMAN VERSION

STEPS TO REPRODUCE
EXPECTED RESULTS
ACTUAL RESULTS

@KoffiemokmetThee
Copy link

I have this problem as well. It would be nice if a parameter exists it would return "ok" in the Ansible run.

@evgeni
Copy link
Member Author

evgeni commented Jul 29, 2021

@KoffiemokmetThee the cleanest solution should be to use the dedicated activation_keys parameter (which will get translated to the right Foreman parameter internally, and is working fine right now), but the syntax with kt_activation_keys should also work and we will fix that.

@evgeni
Copy link
Member Author

evgeni commented Aug 10, 2021

@KoffiemokmetThee there is a patch in #1271 if you want to try it out :)

evgeni added a commit to evgeni/foreman-ansible-modules that referenced this issue Aug 11, 2021
@Fodoj
Copy link

Fodoj commented Aug 24, 2021

With 2.2.0 this bug still occurs to me - I have set kt_activation_keys via "params" and it breaks on a second run. I could not find dedicated "activation_keys" parameter in hostgroup.py - is it provided by HostMixing somehow?

@evgeni
Copy link
Member Author

evgeni commented Aug 24, 2021

It's provided by the HostMixin, yeah:

activation_keys=dict(no_log=False),

let me spin up a fresh katello and try that out again.

@evgeni
Copy link
Member Author

evgeni commented Aug 24, 2021

Hum, works for me.

Can you show me your playbook please?

I essentially do:

- theforeman.foreman.hostgroup:
  
  parameters:
    - name: kt_activation_keys
      parameter_type: string
      value: new_key

@evgeni
Copy link
Member Author

evgeni commented Aug 24, 2021

I've added tests here: #1278

@Fodoj
Copy link

Fodoj commented Aug 24, 2021

Basically the same:

parameters: "{{ hg.parameters | default(omit) }}"  

where hg has:

 parameters:
    - name: kt_activation_keys
      value: my-ket
   - name: another-param
     value: val

Difference is lack of "parameter_type" and multiple other params except besides kt_activation_keys.

FYI I've switched to activation_keys and it works.

@evgeni
Copy link
Member Author

evgeni commented Aug 25, 2021

Nope, neither dropping the parameter_type, nor adding another parameter helps reproducing it :(

But glad activation_keys works for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants