theforeman.foreman.foreman_search_facts (0.8.1) — module

Gather facts about Foreman resources

Authors: Sean O'Keeffe (@sean797)

preview | supported by community

Install collection

Install with ansible-galaxy collection install theforeman.foreman:==0.8.1


Add to requirements.yml

  collections:
    - name: theforeman.foreman
      version: 0.8.1

Description

Gather facts about Foreman resources


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Read a Setting"
  foreman_search_facts:
    username: "admin"
    password: "changeme"
    server_url: "https://foreman.example.com"
    resource: settings
    search: name = foreman_url
  register: result
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- debug:
    var: result.resources[0].value
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Read all Registries (Katello)"
  foreman_search_facts:
    username: "admin"
    password: "changeme"
    server_url: "https://foreman.example.com"
    resource: registries
  register: result
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- debug:
    var: item.name
  with_items: "{{ result.resources }}"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Read all Organizations with full details"
  foreman_search_facts:
    username: "admin"
    password: "changeme"
    server_url: "https://foreman.example.com"
    resource: organizations
    full_details: true
  register: result
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- debug:
    var: result.resources
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Get all existing subscriptions for organization with id 1 (Katello)
  foreman_search_facts:
    username: "admin"
    password: "changeme"
    server_url: "https://foreman.example.com"
    resource: subscriptions
    params:
      organization_id: 1
  register: result
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- debug:
    var: result
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Get all existing activation keys for organization ACME (Katello)
  foreman_search_facts:
    username: "admin"
    password: "changeme"
    server_url: "https://foreman.example.com"
    resource: activation_keys
    organization: ACME
  register: result
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- debug:
    var: result

Inputs

    
params:
    description:
    - Add parameters to the API call if necessary
    - If not specified, no additional parameters are passed
    type: dict

search:
    description:
    - Search query to use
    - If None, all resources are returned
    type: str

password:
    description: Password of the user accessing the Foreman server
    required: true
    type: str

resource:
    description:
    - Resource to search
    - Set to an invalid choice like I(foo) see all available options.
    required: true
    type: str

username:
    description: Username accessing the Foreman server
    required: true
    type: str

server_url:
    description: URL of the Foreman server
    required: true
    type: str

full_details:
    aliases:
    - info
    default: false
    description:
    - If C(True) all details about the found resources are returned
    type: bool

organization:
    description:
    - Scope the searched resource by organization
    type: str

validate_certs:
    aliases:
    - verify_ssl
    default: true
    description: Whether or not to verify the TLS certificates of the Foreman server
    type: bool

Outputs

resources:
  description: Search results from Foreman
  returned: always
  type: list