Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

Missing org_id and activationkey lookup for redhat subscription #249

Closed
guillaumevincent opened this issue Sep 22, 2017 · 4 comments · Fixed by #250
Closed

Missing org_id and activationkey lookup for redhat subscription #249

guillaumevincent opened this issue Sep 22, 2017 · 4 comments · Fixed by #250

Comments

@guillaumevincent
Copy link
Contributor

Hello,

I got an issue with actual tests. I running improved-sanity-test against a RHEL-Atomic-7.4 virtual machine. My virtual machine is already activated.

So I got one question:

  • Why are we trying to run the subscription-manager against a machine with an active subscription?
    If we want to force the subscription to be sure the subscription-manager works, could we move this to another test?

If this is not possible, could we fix roles/redhat_subscription/tasks/main.yml to lookup for org_id and activationkey also.

I need to be able to activate my Red Hat subscription with org_id and activationkey only.

Thanks

@guillaumevincent
Copy link
Contributor Author

My first idea to solve this issue is the following code

- name: get RHSM variables
  set_fact:
    RHSM_USERNAME: "{{ lookup('csvfile', 'username file={} delimiter=,'.format(subscription_file)) }}"
    RHSM_PASSWORD: "{{ lookup('csvfile', 'password file={} delimiter=,'.format(subscription_file)) }}"
    RHSM_ACTIVATION_KEY: "{{ lookup('csvfile', 'activationkey file={} delimiter=,'.format(subscription_file)) }}"
    RHSM_ORG_ID: "{{ lookup('csvfile', 'org_id file={} delimiter=,'.format(subscription_file)) }}"
    RHSM_BASE_URL: "{{ lookup('csvfile', 'baseurl file={} delimiter=,'.format(subscription_file)) }}"
    RHSM_SERVER_URL: "{{ lookup('csvfile', 'serverurl file={} delimiter=,'.format(subscription_file)) }}"

- name: Register with subscription-manager with username and password
  redhat_subscription:
    state: present
    force_register: true
    rhsm_baseurl: '{{ RHSM_BASE_URL }}'
    server_hostname: '{{ RHSM_SERVER_URL }}'
    username: '{{ RHSM_USERNAME }}'
    password: '{{ RHSM_PASSWORD }}'
  when: RHSM_USERNAME != "" and RHSM_PASSWORD != ""


- name: Register with subscription-manager with activationkey and org_id
  redhat_subscription:
    state: present
    force_register: true
    rhsm_baseurl: '{{ RHSM_BASE_URL }}'
    server_hostname: '{{ RHSM_SERVER_URL }}'
    activationkey: '{{ RHSM_ACTIVATION_KEY }}'
    org_id: '{{ RHSM_ORG_ID }}'
  when: RHSM_ACTIVATION_KEY != "" and RHSM_ORG_ID != ""

guillaumevincent pushed a commit to guillaumevincent/atomic-host-tests that referenced this issue Sep 22, 2017
subscription_data.csv.sample got an extra parameter.
We can use this extra parameter to subscribe with activationkey for example.

extra,--activationkey='...' --org='...'

If we do so, roles/redhat_subscription/tasks/main.yml:46 raise an error:

    "Error: Activation keys cannot be used with --auto-attach."

Move --auto-attach in subscription file sample.
Remove --force because extra param is already set

This PR fixes projectatomic#249
@miabbott
Copy link
Collaborator

Why are we trying to run the subscription-manager against a machine with an active subscription?

The honest answer is because we are lazy. :)

When this test suite first began, we were always testing systems that had been freshly booted and had no subscriptions present.

It is perfectly reasonable to check for a valid subscription before trying to register. I'm pleased to see you have a PR for this, so I'll be sure to review it in the near future.

@guillaumevincent
Copy link
Contributor Author

No problems :)
My pull request is a workaround. We can add activationkey and org_id in extra parameters. And it works.

Like this user can decide how they want to use subscription-manager

Let me know if you don't like this solution. I will implement the conditional subscription playbook.

@miabbott
Copy link
Collaborator

Adding support for the activationkey and org_id seems like a smart move. Feel free to implement this in the existing PR or an additional one.

miabbott pushed a commit that referenced this issue Sep 26, 2017
…250)

subscription_data.csv.sample got an extra parameter.
We can use this extra parameter to subscribe with activationkey for example.

extra,--activationkey='...' --org='...'

If we do so, roles/redhat_subscription/tasks/main.yml:46 raise an error:

    "Error: Activation keys cannot be used with --auto-attach."

Move --auto-attach in subscription file sample.
Remove --force because extra param is already set

This PR fixes #249
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants