Red Hat Training

A Red Hat training course is available for OpenShift Container Platform

22.4. 使用 OpenShift Container Platform 实例注册 Subscription Manager

成功置备节点后,下一步是确保通过 subscription-manager 成功注册所有节点,以安装成功 OpenShift Container Platform 安装的所有必要软件包。为简单起见,已创建了一个并提供了 repos.yml 文件。

$ cat ~/repos.yml
---
- name: Enable the proper repositories for OpenShift installation
  hosts: OSEv3
  become: yes
  tasks:
  - name: Register with activationkey and consume subscriptions matching Red Hat Cloud Suite or Red Hat OpenShift Container Platform
    redhat_subscription:
      state: present
      activationkey: <key-name>
      org_id: <orig_id>
      pool: '^(Red Hat Cloud Suite|Red Hat OpenShift Container Platform)$'

  - name: Disable all current repositories
    rhsm_repository:
      name: '*'
      state: disabled

  - name: Enable Repositories
    rhsm_repository:
      name: "{{ item }}"
      state: enabled
    with_items:
      - rhel-7-server-rpms
      - rhel-7-server-extras-rpms
      - rhel-7-server-ansible-2.6-rpms
      - rhel-7-server-ose-3.11-rpms
注意

请参阅 Set Up Repositories 来确认要启用的软件仓库和版本。以上文件只是一个示例。

使用 repos.yml,运行 ansible-playbook 命令:

$ ansible-playbook repos.yml

上例使用 Ansible 的 redhat_subscriptionrhsm_repository 模块来进行所有注册,禁用和启用存储库。本特定示例使用了使用红帽激活码。如果您没有激活码,请确保访问 Ansible redhat_subscription 模块以使用用户名和密码进行修改,如下例所示: https://docs.ansible.com/ansible/2.6/modules/redhat_subscription_module.html

注意

有时候,redhat_subscription 模块可能会在某些节点上失败。如果出现这个问题,请使用 subscription-manager 手动注册 OpenShift Container Platform 实例。