Skip to content

Commit

Permalink
change register with system identity to fallback to other defined reg…
Browse files Browse the repository at this point in the history
…istration methods on failure
  • Loading branch information
flyemsafe committed Dec 28, 2020
1 parent e398daa commit 5cbcc1d
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions tasks/register.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,27 @@
when: katello_ca_installed|default(false)|bool == false and rhsm_is_satellite|bool
tags: [register]

# This has not been tested againist Satellite
# Attempt to register system using an existing identity if defined
# undefine use_system_identity if registration fails
- name: Register {{ inventory_hostname }} system using rhsm_identity
when: use_system_identity|bool and not use_activation_key|bool
tags: [register]
block:
redhat_subscription:
state: present
activationkey: "{{ rhsm_activationkey }}"
server_hostname: "{{ server_url | default(omit) }}"
rhsm_baseurl: "{{ base_url | default(omit) }}"
org_id: "{{ rhsm_org_id }}"
use_system_identity: "{{ rhsm_identity }}"
syspurpose: "{{ system_purpose | default(omit) }}"
register: is_registered_use_system_identity
rescue:
- name: set fact use_system_identity when rhsm_identity is defined
set_fact:
use_system_identity: false

- name: Register {{ inventory_hostname }} to RHSM using activation key
redhat_subscription:
state: present
Expand All @@ -39,22 +60,7 @@
register: is_registered_actkey
when: use_activation_key|bool and not use_system_identity|bool
tags: [register]

# This has not been tested againist Satellite
- name: Register {{ inventory_hostname }} system using rhsm_identity
redhat_subscription:
state: present
activationkey: "{{ rhsm_activationkey }}"
server_hostname: "{{ server_url | default(omit) }}"
rhsm_baseurl: "{{ base_url | default(omit) }}"
org_id: "{{ rhsm_org_id }}"
use_system_identity: "{{ rhsm_identity }}"
syspurpose: "{{ system_purpose | default(omit) }}"
register: is_registered_use_system_identity
when: use_system_identity|bool and not use_activation_key|bool
failed_when: "'The system has been registered with ID' not in is_registered_use_system_identity.stdout"
tags: [register]


- name: Register {{ inventory_hostname }} system using rhsm_user and rhsm_password
redhat_subscription:
state: present
Expand Down

0 comments on commit 5cbcc1d

Please sign in to comment.