summaryrefslogtreecommitdiffstats
path: root/roles/subscription-manager/tasks
diff options
context:
space:
mode:
authorVinny Valdez <vvaldez@redhat.com>2016-03-29 16:52:05 -0500
committerVinny Valdez <vvaldez@redhat.com>2016-04-20 09:28:48 -0500
commit80c3d3332507fe620fcab99e65f2ffd81d48a69e (patch)
treebe5d04b76b6aabc7e1aed3562f83ed2337392108 /roles/subscription-manager/tasks
parented0c9e5e46bdd1da003f399392c891912dbd07dc (diff)
downloadopenshift-80c3d3332507fe620fcab99e65f2ffd81d48a69e.tar.gz
openshift-80c3d3332507fe620fcab99e65f2ffd81d48a69e.tar.bz2
openshift-80c3d3332507fe620fcab99e65f2ffd81d48a69e.tar.xz
openshift-80c3d3332507fe620fcab99e65f2ffd81d48a69e.zip
Add subscription-manager support for Hosted or Satellite
Diffstat (limited to 'roles/subscription-manager/tasks')
-rw-r--r--roles/subscription-manager/tasks/main.yml93
1 files changed, 93 insertions, 0 deletions
diff --git a/roles/subscription-manager/tasks/main.yml b/roles/subscription-manager/tasks/main.yml
new file mode 100644
index 000000000..2e04a7a22
--- /dev/null
+++ b/roles/subscription-manager/tasks/main.yml
@@ -0,0 +1,93 @@
+---
+- name: Initializing Subscription Manager authenticaiton method
+ set_fact:
+ rhsm_authentication: false
+
+# 'rhsm_activationkey' will take precedence even if 'rhsm_username' and 'rhsm_password' are also set
+- name: Setting Subscription Manager Activation Key Fact
+ set_fact:
+ rhsm_authentication: "key"
+ when:
+ - rhsm_activationkey is defined
+ - rhsm_activationkey is not none
+ - rhsm_activationkey|trim != ''
+ - not rhsm_authentication
+
+# If 'rhsm_username' and 'rhsm_password' are set but not 'rhsm_activationkey', set 'rhsm_authentication' to password
+- name: Setting Subscription Manager Username and Password Fact
+ set_fact:
+ rhsm_authentication: "password"
+ when:
+ - rhsm_username is defined and rhsm_username is not none and rhsm_username|trim != ''
+ - rhsm_password is defined and rhsm_password is not none and rhsm_password|trim != ''
+ - not rhsm_authentication
+
+- name: Initializing registration status
+ set_fact:
+ registered: false
+
+- name: Checking subscription status (a failure means it is not registered and will be)
+ command: "/usr/bin/subscription-manager status"
+ ignore_errors: yes
+ changed_when: no
+ register: check_if_registered
+
+- name: Set registration fact
+ set_fact:
+ registered: true
+ when: check_if_registered.rc == 0
+
+- name: Cleaning any old subscriptions
+ command: "/usr/bin/subscription-manager clean"
+ when:
+ - not registered
+ - rhsm_authentication is defined
+
+- name: Install Satellite certificate
+ command: "rpm -Uvh --force http://{{ rhsm_server }}/pub/katello-ca-consumer-latest.noarch.rpm"
+ when:
+ - not registered
+ - rhsm_method == 'satellite'
+
+- name: Register to Satellite using activation key
+ command: "/usr/bin/subscription-manager register --activationkey={{ rhsm_activationkey }} --org={{ rhsm_org }}"
+ when:
+ - not registered
+ - rhsm_authentication == 'key'
+ - rhsm_method == 'satellite'
+
+# This can apply to either Hosted or Satellite
+- name: Register using username and password
+ command: "/usr/bin/subscription-manager register --username={{ rhsm_username }} --password={{ rhsm_password }}"
+ when:
+ - not registered
+ - rhsm_authentication != "key"
+
+- name: Auto-attach to Subscription Manager Pool
+ command: "/usr/bin/subscription-manager attach --auto"
+ when:
+ - not registered
+ - rhsm_authentication != "key"
+
+- name: Attach to a specific pool
+ command: "/usr/bin/subscription-manager attach --pool={{ rhsm_pool }}"
+ when:
+ - rhsm_pool is defined and rhsm_pool is not none and rhsm_pool|trim != ''
+ - and not registered
+ - rhsm_authentication != "key"
+
+- name: Disable all repositories
+ command: "/usr/bin/subscription-manager repos --disable=*"
+ when:
+ - not registered
+ - not rhsm_authentication == "key"
+
+- name: Enable specified repositories
+ command: "/usr/bin/subscription-manager repos --enable={{ item }}"
+ with_items: rhsm_repos
+ when:
+ - not registered
+ - not rhsm_authentication == "key"
+
+- name: Cleaning yum repositories
+ command: "yum clean all"