theforeman.foreman.resource_info 模块 – 收集资源信息

注意

此模块是 theforeman.foreman 集合(版本 4.2.0)的一部分。

如果您正在使用 ansible 包,您可能已经安装了此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用:ansible-galaxy collection install theforeman.foreman。您需要进一步的要求才能使用此模块,请参阅要求了解详细信息。

要在 playbook 中使用它,请指定:theforeman.foreman.resource_info

theforeman.foreman 1.0.0 中的新功能

概要

  • 收集有关资源的信息

别名:foreman_search_facts

要求

执行此模块的主机需要满足以下要求。

  • requests

参数

参数

注释

full_details

别名:info

布尔值

如果为 True,则返回有关找到的资源的所有详细信息

选项

  • false ← (默认)

  • true

organization

字符串

按组织限定搜索范围

params

字典

如果需要,将参数添加到 API 调用

如果未指定,则不传递其他参数

password

字符串 / 必需

访问 Foreman 服务器的用户的密码。

如果未在任务中指定该值,则将使用环境变量 FOREMAN_PASSWORD 的值。

resource

字符串 / 必需

要搜索的资源

设置为无效的选项,如foo,查看所有可用选项。

字符串

要使用的搜索查询

如果为 None,则返回所有资源

server_url

字符串 / 必需

Foreman 服务器的 URL。

如果未在任务中指定该值,则将使用环境变量 FOREMAN_SERVER_URL 的值。

username

字符串 / 必需

访问 Foreman 服务器的用户名。

如果未在任务中指定该值,则将使用环境变量 FOREMAN_USERNAME 的值。

validate_certs

布尔值

是否验证 Foreman 服务器的 TLS 证书。

如果未在任务中指定该值,则将使用环境变量 FOREMAN_VALIDATE_CERTS 的值。

选项

  • false

  • true ← (默认)

属性

属性

支持

描述

check_mode

支持:完整

可以在 check_mode 中运行,并返回已更改状态预测,而无需修改实体

diff_mode

支持:完整

在 diff 模式下运行时,将返回有关已更改内容(或在 check_mode 中可能需要更改的内容)的详细信息

备注

注意

  • 某些资源不支持范围限定,当您在 params 中传递 organization 或未知数据时,将返回错误。

示例

- name: "Read a Setting"
  theforeman.foreman.resource_info:
    username: "admin"
    password: "changeme"
    server_url: "https://foreman.example.com"
    resource: settings
    search: name = foreman_url
  register: result
- debug:
    var: result.resources[0].value

- name: "Read all Registries"
  theforeman.foreman.resource_info:
    username: "admin"
    password: "changeme"
    server_url: "https://foreman.example.com"
    resource: registries
  register: result
- debug:
    var: item.name
  with_items: "{{ result.resources }}"

- name: "Read all Organizations with full details"
  theforeman.foreman.resource_info:
    username: "admin"
    password: "changeme"
    server_url: "https://foreman.example.com"
    resource: organizations
    full_details: true
  register: result
- debug:
    var: result.resources

- name: Get all existing subscriptions for organization with id 1
  theforeman.foreman.resource_info:
    username: "admin"
    password: "changeme"
    server_url: "https://foreman.example.com"
    resource: subscriptions
    params:
      organization_id: 1
  register: result
- debug:
    var: result

- name: Get all existing activation keys for organization ACME
  theforeman.foreman.resource_info:
    username: "admin"
    password: "changeme"
    server_url: "https://foreman.example.com"
    resource: activation_keys
    organization: ACME
  register: result
- debug:
    var: result

返回值

常见的返回值记录在 此处,以下是此模块独有的字段

描述

resources

列表 / 元素=字符串

资源信息

返回:始终

作者

  • Sean O’Keeffe (@sean797)