theforeman.foreman.host_power (4.0.0) — module

Manage Power State of Hosts

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

Authors: Bernhard Hopfenmueller (@Fobhep) 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

Manage power state of a host

This beta version can start and stop an existing foreman host and question the current power state.


Requirements

Usage examples

  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Switch a host on"
  theforeman.foreman.host_power:
    username: "admin"
    password: "changeme"
    server_url: "https://foreman.example.com"
    hostname: "test-host.domain.test"
    state: on
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Switch a host off"
  theforeman.foreman.host_power:
    username: "admin"
    password: "changeme"
    server_url: "https://foreman.example.com"
    hostname: "test-host.domain.test"
    state: off
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- name: "Query host power state"
  theforeman.foreman.host_power:
    username: "admin"
    password: "changeme"
    server_url: "https://foreman.example.com"
    hostname: "test-host.domain.test"
    state: state
    register: result
  • Success
    Steampunk Spotter scan finished with no errors, warnings or hints.
- debug:
    msg: "Host power state is {{ result.power_state }}"

Inputs

    
name:
    aliases:
    - hostname
    description: Name (FQDN) of the host
    required: true
    type: str

state:
    choices:
    - 'on'
    - start
    - 'off'
    - stop
    - soft
    - reboot
    - cycle
    - reset
    - state
    - status
    default: state
    description: Desired power state
    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

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

Outputs

power_state:
  description: current power state of host
  returned: always
  sample: 'off'
  type: str