theforeman.foreman.host module – Manage Hosts
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.host
.
New in theforeman.foreman 1.0.0
Synopsis
Create, update, and delete Hosts
Aliases: foreman_host
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. |
|
Architecture name |
|
Whether or not to setup build context for the host Choices:
|
|
Comment about the host. |
|
Additional compute resource specific attributes. When this parameter is set, the module will not be idempotent. When you provide a cluster here and compute_resource is set, the cluster id will be automatically looked up. |
|
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. |
|
Domain name |
|
Include this host within reporting Choices:
|
|
Puppet environment name |
|
Title of related hostgroup Example: A child hostgroup bar within a parent hostgroup foo would have the title foo/bar. |
|
The image to use when provision_method=image. The compute_resource parameter is required to find the correct image. |
|
Additional interfaces specific attributes. |
|
Identifiers of attached interfaces, e.g. [‘eth1’, ‘eth2’]. For bond interfaces those are the slaves. Only for bond and bridges interfaces. |
|
Identifier of the interface to which this interface belongs, e.g. eth1. Only for virtual interfaces. |
|
Space separated options, e.g. miimon=100. Only for bond interfaces. |
|
Additional compute resource specific attributes for the interface. When this parameter is set, the module will not be idempotent. When you provide a network here and compute_resource is set, the network id will be automatically looked up. On oVirt/RHV cluster is required in the hosts compute_attributes for the lookup to work. |
|
Domain name Required for primary interfaces on managed hosts. |
|
Should this interface be used for Remote Execution? Each managed hosts should have one remote execution interface. Choices:
|
|
Device identifier, e.g. eth0 or eth1.1 You need to set one of identifier, name or mac to be able to update existing interfaces and make execution idempotent. |
|
IPv4 address of interface |
|
IPv6 address of interface |
|
MAC address of interface. Required for managed interfaces on bare metal. Please include leading zeros and separate nibbles by colons, otherwise the execution will not be idempotent. Example EE:BB:01:02:03:04 You need to set one of identifier, name or mac to be able to update existing interfaces and make execution idempotent. |
|
Should this interface be managed via DHCP and DNS smart proxy and should it be configured during provisioning? Choices:
|
|
Bond mode of the interface. Only for bond interfaces. Choices:
|
|
MTU, this attribute has precedence over the subnet MTU. |
|
Interface’s DNS name You need to set one of identifier, name or mac to be able to update existing interfaces and make execution idempotent. |
|
Password for BMC authentication. Only for BMC interfaces. |
|
Should this interface be used for constructing the FQDN of the host? Each managed hosts needs to have one primary interface. Choices:
|
|
Interface provider, e.g. IPMI. Only for BMC interfaces. Choices:
|
|
Should this interface be used for TFTP of PXELinux (or SSH for image-based hosts)? Each managed hosts needs to have one provision interface. Choices:
|
|
IPv4 Subnet name |
|
IPv6 Subnet name |
|
VLAN tag, this attribute has precedence over the subnet VLAN ID. Only for virtual interfaces. |
|
Interface type. Choices:
|
|
Username for BMC authentication. Only for BMC interfaces. |
|
Alias or VLAN device Choices:
|
|
IP address of the primary interface of the host. |
|
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. |
|
Name of related location |
|
MAC address of the primary interface of the host. Please include leading zeros and separate nibbles by colons, otherwise the execution will not be idempotent. Example EE:BB:01:02:03:04 |
|
Whether a host is managed or unmanaged. Forced to true when build=true Choices:
|
|
Medium name Mutually exclusive with kickstart_repository. |
|
Fully Qualified Domain Name of host |
|
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. |
|
Name of related organization |
|
Owner (user) of the host. Users are looked up by their Mutually exclusive with owner_group. |
|
Owner (user group) of the host. Mutually exclusive with owner. |
|
Entity domain specific host parameters |
|
Name of the parameter |
|
Type of the parameter Choices:
|
|
Value of the parameter |
|
Password of the user accessing the Foreman server. If the value is not specified in the task, the value of environment variable |
|
The method used to provision the host. provision_method=bootdisk is only available if the bootdisk plugin is installed. Choices:
|
|
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 |
|
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 host"
theforeman.foreman.host:
username: "admin"
password: "changeme"
server_url: "https://foreman.example.com"
name: "new_host"
hostgroup: my_hostgroup
state: present
- name: "Create a host with build context"
theforeman.foreman.host:
username: "admin"
password: "changeme"
server_url: "https://foreman.example.com"
name: "new_host"
hostgroup: my_hostgroup
build: true
state: present
- name: "Create an unmanaged host"
theforeman.foreman.host:
username: "admin"
password: "changeme"
server_url: "https://foreman.example.com"
name: "new_host"
managed: false
state: present
- name: "Create a VM with 2 CPUs and 4GB RAM"
theforeman.foreman.host:
username: "admin"
password: "changeme"
server_url: "https://foreman.example.com"
name: "new_host"
compute_attributes:
cpus: 2
memory_mb: 4096
state: present
- name: "Create a VM and start it after creation"
theforeman.foreman.host:
username: "admin"
password: "changeme"
server_url: "https://foreman.example.com"
name: "new_host"
compute_attributes:
start: "1"
state: present
- name: "Create a VM on specific ovirt network"
theforeman.foreman.host:
username: "admin"
password: "changeme"
server_url: "https://foreman.example.com"
name: "new_host"
interfaces_attributes:
- type: "interface"
compute_attributes:
name: "nic1"
network: "969efbe6-f9e0-4383-a19a-a7ee65ad5007"
interface: "virtio"
state: present
- name: "Create a VM with 2 NICs on specific ovirt networks"
theforeman.foreman.host:
username: "admin"
password: "changeme"
server_url: "https://foreman.example.com"
name: "new_host"
interfaces_attributes:
- type: "interface"
primary: true
compute_attributes:
name: "nic1"
network: "969efbe6-f9e0-4383-a19a-a7ee65ad5007"
interface: "virtio"
- type: "interface"
name: "new_host_nic2"
managed: true
compute_attributes:
name: "nic2"
network: "969efbe6-f9e0-4383-a19a-a7ee65ad5008"
interface: "e1000"
state: present
- name: "Delete a host"
theforeman.foreman.host:
username: "admin"
password: "changeme"
server_url: "https://foreman.example.com"
name: "new_host"
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 hosts. Returned: success |