theforeman.foreman.repository_set module – Enable/disable Red Hat Repositories available through subscriptions

Note

This module is part of the theforeman.foreman collection (version 3.14.0).

To install it, use: ansible-galaxy collection install theforeman.foreman. You need further requirements to be able to use this module, see Requirements for details.

To use it in a playbook, specify: theforeman.foreman.repository_set.

New in theforeman.foreman 1.0.0

Synopsis

  • Enable/disable Red Hat Repositories that are available through subscriptions

Aliases: katello_repository_set

Requirements

The below requirements are needed on the host that executes this module.

  • requests

Parameters

Parameter

Comments

all_repositories

boolean

Affect all available repositories in the repository set instead of listing them in repositories.

Required when repositories is unset or an empty list.

Choices:

  • false

  • true

label

string

Label of the repository set, can be used in place of name & product

name

string

Name of the repository set

organization

string / required

Organization that the entity is in

password

string / required

Password of the user accessing the Foreman server.

If the value is not specified in the task, the value of environment variable FOREMAN_PASSWORD will be used instead.

product

string

Name of the parent product

repositories

list / elements=dictionary

Release version and base architecture of the repositories to enable.

Some reposotory sets require only basearch or only releasever to be set.

See the examples how you can obtain this information using theforeman.foreman.resource_info.

Required when all_repositories is unset or false.

basearch

string

Basearch of the repository to enable.

releasever

string

Releasever of the repository to enable.

server_url

string / required

URL of the Foreman server.

If the value is not specified in the task, the value of environment variable FOREMAN_SERVER_URL will be used instead.

state

string

Whether the repositories are enabled or not

Choices:

  • "enabled" ← (default)

  • "disabled"

username

string / required

Username accessing the Foreman server.

If the value is not specified in the task, the value of environment variable FOREMAN_USERNAME will be used instead.

validate_certs

boolean

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 FOREMAN_VALIDATE_CERTS will be used instead.

Choices:

  • false

  • true ← (default)

Attributes

Attribute

Support

Description

check_mode

Support: full

Can run in check_mode and return changed status prediction without modifying the entity

diff_mode

Support: full

Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode

Examples

- 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

- 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

- 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

- 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"

- 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

- 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

- 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
- name: "Output found repository sets, see the contentUrl section for possible repository substitutions"
  debug:
    var: data

- 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
- name: "Output found repository sets, see the contentUrl section for possible repository substitutions"
  debug:
    var: data

- 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

Return Values

Common return values are documented here, the following are the fields unique to this module:

Key

Description

entity

dictionary

Final state of the affected entities grouped by their type.

Returned: success

repository_sets

list / elements=dictionary

List of repository sets.

Returned: success

Authors

  • Andrew Kofink (@akofink)