theforeman.foreman.hostgroup (4.0.0) — module

Manage Hostgroups

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

Authors: Manisha Singhal (@Manisha15) ATIX AG, Baptiste Agasse (@bagasse)

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

Create, update, and delete Hostgroups


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Create a Hostgroup"
  theforeman.foreman.hostgroup:
    name: "new_hostgroup"
    architecture: "architecture_name"
    operatingsystem: "operatingsystem_name"
    medium: "media_name"
    ptable: "Partition_table_name"
    server_url: "https://foreman.example.com"
    username: "admin"
    password: "changeme"
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Update a Hostgroup"
  theforeman.foreman.hostgroup:
    name: "new_hostgroup"
    architecture: "updated_architecture_name"
    operatingsystem: "updated_operatingsystem_name"
    organizations:
      - Org One
      - Org Two
    locations:
      - Loc One
      - Loc Two
      - Loc One/Nested loc
    medium: "updated_media_name"
    ptable: "updated_Partition_table_name"
    root_pass: "password"
    server_url: "https://foreman.example.com"
    username: "admin"
    password: "changeme"
    state: present
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "My nested hostgroup"
  theforeman.foreman.hostgroup:
    parent: "new_hostgroup"
    name: "my nested hostgroup"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "My hostgroup with some proxies"
  theforeman.foreman.hostgroup:
    name: "my hostgroup"
    environment: production
    puppet_proxy: puppet-proxy.example.com
    puppet_ca_proxy: puppet-proxy.example.com
    openscap_proxy: openscap-proxy.example.com
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "My katello related hostgroup"
  theforeman.foreman.hostgroup:
    organization: "My Org"
    name: "kt hostgroup"
    content_source: capsule.example.com
    lifecycle_environment: "Production"
    content_view: "My content view"
    parameters:
      - name: "kt_activation_keys"
        value: "my_prod_ak"
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Delete a Hostgroup"
  theforeman.foreman.hostgroup:
    name: "new_hostgroup"
    server_url: "https://foreman.example.com"
    username: "admin"
    password: "changeme"
    state: absent

Inputs

    
name:
    description: Name of hostgroup
    required: true
    type: str

realm:
    description: Realm name
    required: false
    type: str

state:
    choices:
    - present
    - absent
    default: present
    description:
    - State of the entity
    type: str

domain:
    description: Domain name
    required: false
    type: str

medium:
    aliases:
    - media
    description:
    - Medium name
    - Mutually exclusive with I(kickstart_repository).
    required: false
    type: str

parent:
    description: Hostgroup parent name
    required: false
    type: str

ptable:
    description: Partition table name
    required: false
    type: str

subnet:
    description: IPv4 Subnet name
    required: false
    type: str

subnet6:
    description: IPv6 Subnet name
    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

locations:
    description: List of locations the entity should be assigned to
    elements: str
    type: list

root_pass:
    description:
    - Root password.
    - Will result in the entity always being updated, as the current password cannot be
      retrieved.
    required: false
    type: str

parameters:
    description:
    - Hostgroup specific host parameters
    elements: dict
    required: false
    suboptions:
      name:
        description:
        - Name of the parameter
        required: true
        type: str
      parameter_type:
        choices:
        - string
        - boolean
        - integer
        - real
        - array
        - hash
        - yaml
        - json
        default: string
        description:
        - Type of the parameter
        type: str
      value:
        description:
        - Value of the parameter
        required: true
        type: raw
    type: list

pxe_loader:
    choices:
    - PXELinux BIOS
    - PXELinux UEFI
    - Grub UEFI
    - Grub2 BIOS
    - Grub2 ELF
    - Grub2 UEFI
    - Grub2 UEFI SecureBoot
    - Grub2 UEFI HTTP
    - Grub2 UEFI HTTPS
    - Grub2 UEFI HTTPS SecureBoot
    - iPXE Embedded
    - iPXE UEFI HTTP
    - iPXE Chain BIOS
    - iPXE Chain UEFI
    - None
    description: PXE Bootloader
    required: false
    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

description:
    description: Description of hostgroup
    required: false
    type: str

environment:
    description: Puppet environment name
    required: false
    type: str

architecture:
    description: Architecture name
    required: false
    type: str

content_view:
    description:
    - Content view.
    - Only available for Katello installations.
    required: false
    type: str

organization:
    description:
    - Organization for scoped resources attached to the hostgroup.
    - Only used for Katello installations.
    - This organization will implicitly be added to the I(organizations) parameter if
      needed.
    required: false
    type: str

puppet_proxy:
    description: Puppet server proxy name
    required: false
    type: str

updated_name:
    description: New name of hostgroup. When this parameter is set, the module will not
      be idempotent.
    type: str

ansible_roles:
    description:
    - A list of ansible roles to associate with the hostgroup.
    - The foreman-ansible plugin must be installed to use this parameter.
    elements: str
    required: false
    type: list
    version_added: 2.1.0
    version_added_collection: theforeman.foreman

config_groups:
    description: Config groups list
    elements: str
    required: false
    type: list

organizations:
    description: List of organizations the entity should be assigned to
    elements: str
    type: list

puppetclasses:
    description: List of puppet classes to include in this host group. Must exist for
      hostgroup's puppet environment.
    elements: str
    required: false
    type: list

content_source:
    description:
    - Content Source (Smart Proxy with Content) name.
    - Only available for Katello installations.
    required: false
    type: str

openscap_proxy:
    description:
    - OpenSCAP proxy name.
    - Only available when the OpenSCAP plugin is installed.
    required: false
    type: str

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

activation_keys:
    description:
    - Activation Keys used for deployment.
    - Comma separated list.
    - Only available for Katello installations.
    required: false
    type: str

compute_profile:
    description: Compute profile name
    required: false
    type: str

operatingsystem:
    description:
    - Operating systems are looked up by their title which is composed as "<name> <major>.<minor>".
    - You can omit the version part as long as you only have one operating system by that
      name.
    required: false
    type: str

puppet_ca_proxy:
    description: Puppet CA proxy name
    required: false
    type: str

compute_resource:
    description: Compute resource name
    required: false
    type: str

kickstart_repository:
    description:
    - Kickstart repository name.
    - You need to provide this to use the "Synced Content" feature.
    - Mutually exclusive with I(medium).
    - Only available for Katello installations.
    required: false
    type: str

lifecycle_environment:
    description:
    - Lifecycle environment.
    - Only available for Katello installations.
    required: false
    type: str

Outputs

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