theforeman.foreman.hostgroup module – Manage Hostgroups
Note
This module is part of the theforeman.foreman collection (version 3.15.0).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
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.hostgroup
.
New in theforeman.foreman 1.0.0
Synopsis
Create, update, and delete Hostgroups
Aliases: foreman_hostgroup
Requirements
The below requirements are needed on the host that executes this module.
requests
Parameters
Parameter |
Comments |
---|---|
Activation Keys used for deployment. Comma separated list. Only available for Katello installations. |
|
A list of ansible roles to associate with the hostgroup. The foreman-ansible plugin must be installed to use this parameter. |
|
Architecture name |
|
Compute profile name |
|
Compute resource name |
|
Config groups list |
|
Content Source (Smart Proxy with Content) name. Only available for Katello installations. |
|
Content view. Only available for Katello installations. |
|
Description of hostgroup |
|
Domain name |
|
Puppet environment name |
|
Kickstart repository name. You need to provide this to use the “Synced Content” feature. Mutually exclusive with medium. Only available for Katello installations. |
|
Lifecycle environment. Only available for Katello installations. |
|
List of locations the entity should be assigned to |
|
Medium name Mutually exclusive with kickstart_repository. |
|
Name of hostgroup |
|
OpenSCAP proxy name. Only available when the OpenSCAP plugin is installed. |
|
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. |
|
Organization for scoped resources attached to the hostgroup. Only used for Katello installations. This organization will implicitly be added to the organizations parameter if needed. |
|
List of organizations the entity should be assigned to |
|
Hostgroup specific host parameters |
|
Name of the parameter |
|
Type of the parameter Choices:
|
|
Value of the parameter |
|
Hostgroup parent name |
|
Password of the user accessing the Foreman server. If the value is not specified in the task, the value of environment variable |
|
Partition table name |
|
Puppet CA proxy name |
|
Puppet server proxy name |
|
List of puppet classes to include in this host group. Must exist for hostgroup’s puppet environment. |
|
PXE Bootloader Choices:
|
|
Realm name |
|
Root password. Will result in the entity always being updated, as the current password cannot be retrieved. |
|
URL of the Foreman server. If the value is not specified in the task, the value of environment variable |
|
State of the entity Choices:
|
|
IPv4 Subnet name |
|
IPv6 Subnet name |
|
New name of hostgroup. When this parameter is set, the module will not be idempotent. |
|
Username accessing the Foreman server. If the value is not specified in the task, the value of environment variable |
|
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 Choices:
|
Attributes
Attribute |
Support |
Description |
---|---|---|
Support: full |
Can run in check_mode and return changed status prediction without modifying the entity |
|
Support: full |
Will return details on what has changed (or possibly needs changing in check_mode), when in diff mode |
Examples
- 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
- 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
- name: "My nested hostgroup"
theforeman.foreman.hostgroup:
parent: "new_hostgroup"
name: "my nested hostgroup"
- 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
- 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"
- name: "Delete a Hostgroup"
theforeman.foreman.hostgroup:
name: "new_hostgroup"
server_url: "https://foreman.example.com"
username: "admin"
password: "changeme"
state: absent
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
Final state of the affected entities grouped by their type. Returned: success |
|
List of hostgroups. Returned: success |