community.general.redhat_subscription 模块 – 使用 subscription-manager
管理 RHSM 的注册和订阅
注意
此模块是 community.general 集合(版本 10.1.0)的一部分。
如果您正在使用 ansible
包,您可能已经安装了此集合。它不包含在 ansible-core
中。要检查是否已安装,请运行 ansible-galaxy collection list
。
要安装它,请使用: ansible-galaxy collection install community.general
。您需要进一步的要求才能使用此模块,请参阅 要求 了解详细信息。
要在 playbook 中使用它,请指定: community.general.redhat_subscription
。
概要
使用
subscription-manager
命令管理红帽订阅管理授权平台的注册和订阅,并在可能的情况下使用 D-Bus 进行注册。
要求
在执行此模块的主机上需要以下要求。
subscription-manager
可选的
dbus
Python 库;它通常包含在操作系统中,因为它被subscription-manager
使用。
参数
参数 |
注释 |
---|---|
提供一个激活密钥以用于注册 |
|
成功注册后,自动使用可用的订阅 请注意,别名 选项
|
|
引用现有的消费者 ID,以恢复使用此系统的先前注册。如果系统的身份证书丢失或损坏,此选项允许它恢复使用其先前的身份和订阅。默认情况下不指定消费者 ID,因此会创建一个新的 ID。 |
|
要注册的系统名称,默认为主机名 |
|
要注册的单元类型,默认为系统 |
|
在目标组织中注册到特定环境。与 Red Hat Satellite 或 Katello 一起使用 |
|
即使系统已注册,也注册该系统 选项
|
|
与 activationkey 结合使用的组织 ID |
|
access.redhat.com 或 Red Hat Satellite 或 Katello 密码 |
|
指定要使用的订阅池 ID。池 ID 可以指定为 默认值: |
|
设置发布版本 |
|
指定 CDN baseurl |
|
指定 CDN 的 CA 证书的备用位置 |
|
指定备用的 Red Hat 订阅管理或 Red Hat Satellite 或 Katello 服务器。 |
|
连接到 |
|
注册到 Red Hat 订阅管理或 Red Hat Satellite 或 Katello 服务器时指定端口。 |
|
注册到 Red Hat 订阅管理或 Red Hat Satellite 或 Katello 服务器时指定前缀。 |
|
指定 HTTP 代理主机名。 |
|
使用基本身份验证指定 HTTP 代理的密码 |
|
指定 HTTP 代理端口。 |
|
指定 HTTP 代理方案,例如 |
|
使用基本身份验证指定 HTTP 代理的用户 |
|
是否注册和订阅( 选项
|
|
在文件 |
|
Syspurpose 属性 addons |
|
Syspurpose 属性 role |
|
Syspurpose 属性 service_level_agreement |
|
当此选项为 选项
|
|
Syspurpose 属性用法 |
|
sso.redhat.com API 访问令牌。 |
|
access.redhat.com 或 Red Hat Satellite 或 Katello 用户名 |
属性
属性 |
支持 |
描述 |
---|---|---|
支持: 无 |
可以在 |
|
支持: 无 |
在 diff 模式下,将返回有关已更改的内容(或可能需要在 |
说明
注意
该模块尝试使用 D-Bus
rhsm
服务(subscription-manager
的一部分)进行注册,从 community.general 6.5.0 开始:这样做是为了可以安全地将凭据(用户名、密码、激活密钥)传递给rhsm
。subscription-manager
本身仅将凭据作为命令行参数的参数获取,这不安全,因为可以通过检查系统上的进程列表轻松窃取它们。由于rhsm
的 D-Bus 接口的限制,当尝试使用token
进行注册,或者在指定environment
时,或者当系统较旧时(通常是 RHEL 7 早于 7.4、RHEL 6 以及更旧版本),该模块将不使用 D-Bus 进行注册。为了注册系统,subscription-manager 需要用户名和密码,或者激活密钥和组织 ID。
从 2.5 开始,
server_hostname
、server_insecure
、rhsm_baseurl
、server_proxy_hostname
、server_proxy_port
、server_proxy_user
和server_proxy_password
的值不再从/etc/rhsm/rhsm.conf
配置文件中获取,默认值为null
。只能以 root 身份与
subscription-manager
交互,因此需要 root 权限才能成功运行此模块。从 community.general 6.5.0 开始,只有在系统未注册或指定
force_register
时,才需要凭据(即username
和password
、activationkey
或token
)。这样就可以使用该模块来调整已注册的系统,例如将其附加到池(使用pool_ids
),以及修改syspurpose
属性(使用syspurpose
)。
示例
- name: Register as user (joe_user) with password (somepass) and auto-subscribe to available content.
community.general.redhat_subscription:
state: present
username: joe_user
password: somepass
auto_attach: true
- name: Same as above but subscribe to a specific pool by ID.
community.general.redhat_subscription:
state: present
username: joe_user
password: somepass
pool_ids: 0123456789abcdef0123456789abcdef
- name: Register and subscribe to multiple pools.
community.general.redhat_subscription:
state: present
username: joe_user
password: somepass
pool_ids:
- 0123456789abcdef0123456789abcdef
- 1123456789abcdef0123456789abcdef
- name: Same as above but consume multiple entitlements.
community.general.redhat_subscription:
state: present
username: joe_user
password: somepass
pool_ids:
- 0123456789abcdef0123456789abcdef: 2
- 1123456789abcdef0123456789abcdef: 4
- name: Register and pull existing system data.
community.general.redhat_subscription:
state: present
username: joe_user
password: somepass
consumer_id: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
- name: Register as user credentials into given environment (against Red Hat Satellite or Katello), and auto-subscribe.
community.general.redhat_subscription:
state: present
username: joe_user
password: somepass
environment: Library
auto_attach: true
- name: Register as user (joe_user) with password (somepass) and a specific release
community.general.redhat_subscription:
state: present
username: joe_user
password: somepass
release: 7.4
- name: Register as user (joe_user) with password (somepass), set syspurpose attributes and synchronize them with server
community.general.redhat_subscription:
state: present
username: joe_user
password: somepass
auto_attach: true
syspurpose:
usage: "Production"
role: "Red Hat Enterprise Server"
service_level_agreement: "Premium"
addons:
- addon1
- addon2
sync: true
返回值
常见的返回值在此处记录 此处,以下是此模块独有的字段
键 |
描述 |
---|---|
系统现在订阅的池 ID 列表 返回: 成功 示例: |