Skip to content

Latest commit

 

History

History
143 lines (106 loc) · 7.62 KB

File metadata and controls

143 lines (106 loc) · 7.62 KB

Ansible Role jm1.cloudy.ipmi

This role helps with managing IPMI devices from Ansible variables. It allows to change a machine's power state and its boot devices. For example, to power-cycle an Ansible host server.home.arpa and boot it from network, define ipmi_* variables in its group_vars or host_vars as such:

# Hostname or IP address of the BMC
ipmi_host: ipmi.home.arpa

# Username which is used to connect to the BMC
ipmi_username: 'ADMIN'

# Password which is used to connect to the BMC
ipmi_password: 'secret'

Next, run this role as an ad hoc command:

ansible server.home.arpa -m include_role -a name=jm1.cloudy.ipmi \
    -e "ansible_connection=local force_ipmi_boot_from_network=true"

When this role is executed, it will first configure the system to boot from network. Then it will reset the system if it is powered on or boot the system if it is powered off. Finally, this role will wait for the system to come up.

Tested OS images

Available on Ansible Galaxy in Collection jm1.cloudy.

Requirements

This role uses module(s) from collection community.general. To install this collection you may follow the steps described in README.md using the provided requirements.yml.

Variables

Name Default value Required Description
force_ipmi_boot false false Whether boot devices should be changed. ⚠️ This variable is supposed to be a safety guard and as such should be set as extra vars on the command line, NOT in host_vars or group_vars! ⚠️
force_ipmi_power false false Whether machine power state should be changed. ⚠️ This variable is supposed to be a safety guard and as such should be set as extra vars on the command line, NOT in host_vars or group_vars! ⚠️
force_ipmi_boot_from_network false false Whether system should be reset and boot from network. ⚠️ This variable is supposed to be a safety guard and as such should be set as extra vars on the command line, NOT in host_vars or group_vars! ⚠️
impi_boot_persistent false false "If set, ask that system firmware uses this device beyond next boot. Be aware many systems do not honor this."
ipmi_boot_device default false Set boot device to use on next reboot. The choices for the device are: ['network', 'floppy', 'hd', 'safe', 'optical', 'setup', 'default']
ipmi_host undefined true Hostname or IP address of the BMC
ipmi_password ADMIN false Password which is used to connect to the BMC
ipmi_port {{ omit }} false Remote RMCP port
ipmi_power_state on false Possible power states: ['on', 'off']
ipmi_uefiboot false false "If set, request UEFI boot explicitly. Strictly speaking, the spec suggests that if not set, the system should BIOS boot and offers no "don't care" option. In practice, this flag not being set does not preclude UEFI boot on any system I've encountered."
ipmi_username ADMIN false Username which is used to connect to the BMC

Dependencies

None.

Example Playbook

A playbook to change the boot device of an Ansible host server.home.arpa could be defined in ipmi.yml as such:

- hosts: all
  connection: local
  vars:
    # Variables are listed here for convenience and illustration.
    # In a production setup, variables would be defined e.g. in
    # group_vars and/or host_vars of an Ansible inventory.
    # Ref.:
    # https://docs.ansible.com/ansible/latest/user_guide/playbooks_variables.html
    # https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html

    # Hostname or IP address of the BMC
    ipmi_host: ipmi.home.arpa

    # Username which is used to connect to the BMC
    ipmi_username: 'ADMIN'

    # Password which is used to connect to the BMC
    ipmi_password: 'secret'
  roles:
  - name: Manage IPMI devices, e.g. machine power state and its boot device
    role: jm1.cloudy.ipmi
    tags: ["jm1.cloudy.ipmi"]

To execute this playbook, run

ansible-playbook ipmi.yml -l server.home.arpa -e "force_ipmi_boot=true"

Instead of defining a playbook, this role can be run as an ad hoc command. First, define the ipmi_* variables in group_vars or host_vars as shown in the introductory example. Then run:

ansible server.home.arpa -m include_role -a name=jm1.cloudy.ipmi -e "ansible_connection=local force_ipmi_boot=true"

To change the power state of a system only, define the ipmi_power_state and possibly other ipmi_* variables in group_vars or host_vars as shown in the introductory example. Then run:

ansible server.home.arpa -m include_role -a name=jm1.cloudy.ipmi -e "ansible_connection=local force_ipmi_power=true"

To reset a system and boot it from network, refer to the introductory example.

For instructions on how to run Ansible playbooks have look at Ansible's Getting Started Guide.

License

GNU General Public License v3.0 or later

See LICENSE.md to see the full text.

Author

Jakob Meng @jm1 (github, galaxy, web)