theforeman.foreman.repository_set (4.0.0) — module

Enable/disable Red Hat Repositories available through subscriptions

| "added in version" 1.0.0 of theforeman.foreman"

Authors: Andrew Kofink (@akofink)

Install collection

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


Add to requirements.yml

  collections:
    - name: theforeman.foreman
      version: 4.0.0

Description

Enable/disable Red Hat Repositories that are available through subscriptions


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Enable RHEL 7 RPMs repositories"
  theforeman.foreman.repository_set:
    username: "admin"
    password: "changeme"
    server_url: "https://foreman.example.com"
    name: "Red Hat Enterprise Linux 7 Server (RPMs)"
    organization: "Default Organization"
    product: "Red Hat Enterprise Linux Server"
    repositories:
    - releasever: "7.0"
      basearch: "x86_64"
    - releasever: "7.1"
      basearch: "x86_64"
    - releasever: "7.2"
      basearch: "x86_64"
    - releasever: "7.3"
      basearch: "x86_64"
    state: enabled
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Enable RHEL 7 RPMs repositories with label"
  theforeman.foreman.repository_set:
    username: "admin"
    password: "changeme"
    server_url: "https://foreman.example.com"
    organization: "Default Organization"
    label: rhel-7-server-rpms
    repositories:
    - releasever: "7.0"
      basearch: "x86_64"
    - releasever: "7.1"
      basearch: "x86_64"
    - releasever: "7.2"
      basearch: "x86_64"
    - releasever: "7.3"
      basearch: "x86_64"
    state: enabled
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Disable RHEL 7 Extras RPMs repository"
  theforeman.foreman.repository_set:
    username: "admin"
    password: "changeme"
    server_url: "https://foreman.example.com"
    name: Red Hat Enterprise Linux 7 Server - Extras (RPMs)
    organization: "Default Organization"
    product: Red Hat Enterprise Linux Server
    state: disabled
    repositories:
      - basearch: x86_64
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Enable RHEL 8 BaseOS RPMs repository with label"
  theforeman.foreman.repository_set:
    username: "admin"
    password: "changeme"
    server_url: "https://foreman.example.com"
    organization: "Default Organization"
    label: rhel-8-for-x86_64-baseos-rpms
    repositories:
      - releasever: "8"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Enable Red Hat Virtualization Manager RPMs repository with label"
  theforeman.foreman.repository_set:
    username: "admin"
    password: "changeme"
    server_url: "https://foreman.example.com"
    organization: "Default Organization"
    label: "rhel-7-server-rhv-4.2-manager-rpms"
    repositories:
      - basearch: x86_64
    state: enabled
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Enable Red Hat Virtualization Manager RPMs repository without specifying basearch"
  theforeman.foreman.repository_set:
    username: "admin"
    password: "changeme"
    server_url: "https://foreman.example.com"
    organization: "Default Organization"
    label: "rhel-7-server-rhv-4.2-manager-rpms"
    all_repositories: true
    state: enabled
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Search for possible repository sets of a product"
  theforeman.foreman.resource_info:
    username: "admin"
    password: "changeme"
    server_url: "https://foreman.example.com"
    organization: "Default Organization"
    resource: repository_sets
    search: product_name="Red Hat Virtualization Manager"
  register: data
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Output found repository sets, see the contentUrl section for possible repository substitutions"
  debug:
    var: data
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Search for possible repository sets by label"
  theforeman.foreman.resource_info:
    username: "admin"
    password: "changeme"
    server_url: "https://foreman.example.com"
    organization: "Default Organization"
    resource: repository_sets
    search: label=rhel-7-server-rhv-4.2-manager-rpms
  register: data
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Output found repository sets, see the contentUrl section for possible repository substitutions"
  debug:
    var: data
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: Enable set with and without all_repositories at the same time
  theforeman.foreman.repository_set:
    username: "admin"
    password: "changeme"
    server_url: "https://foreman.example.com"
    organization: "Default Organization"
    label: "{{ item.label }}"
    repositories: "{{ item.repositories | default(omit) }}"
    all_repositories: "{{ item.repositories is not defined }}"
    state: enabled
  loop:
    - label: rhel-7-server-rpms
      repositories:
        - releasever: "7Server"
          basearch: "x86_64"
    - label: rhel-7-server-rhv-4.2-manager-rpms

Inputs

    
name:
    description:
    - Name of the repository set
    required: false
    type: str

label:
    description:
    - Label of the repository set, can be used in place of I(name) & I(product)
    required: false
    type: str

state:
    choices:
    - enabled
    - disabled
    default: enabled
    description:
    - Whether the repositories are enabled or not
    required: false
    type: str

product:
    description:
    - Name of the parent product
    required: false
    type: str

password:
    description:
    - Password of the user accessing the Foreman server.
    - If the value is not specified in the task, the value of environment variable C(FOREMAN_PASSWORD)
      will be used instead.
    required: true
    type: str

username:
    description:
    - Username accessing the Foreman server.
    - If the value is not specified in the task, the value of environment variable C(FOREMAN_USERNAME)
      will be used instead.
    required: true
    type: str

server_url:
    description:
    - URL of the Foreman server.
    - If the value is not specified in the task, the value of environment variable C(FOREMAN_SERVER_URL)
      will be used instead.
    required: true
    type: str

organization:
    description:
    - Organization that the entity is in
    required: true
    type: str

repositories:
    description:
    - Release version and base architecture of the repositories to enable.
    - Some reposotory sets require only I(basearch) or only I(releasever) to be set.
    - See the examples how you can obtain this information using M(theforeman.foreman.resource_info).
    - Required when I(all_repositories) is unset or C(false).
    elements: dict
    required: false
    suboptions:
      basearch:
        description:
        - Basearch of the repository to enable.
        type: str
      releasever:
        description:
        - Releasever of the repository to enable.
        type: str
    type: list

validate_certs:
    default: true
    description:
    - Whether or not to verify the TLS certificates of the Foreman server.
    - If the value is not specified in the task, the value of environment variable C(FOREMAN_VALIDATE_CERTS)
      will be used instead.
    type: bool

all_repositories:
    description:
    - Affect all available repositories in the repository set instead of listing them
      in I(repositories).
    - Required when I(repositories) is unset or an empty list.
    required: false
    type: bool

Outputs

entity:
  contains:
    repository_sets:
      description: List of repository sets.
      elements: dict
      type: list
  description: Final state of the affected entities grouped by their type.
  returned: success
  type: dict