Skip to content
Ansible role for installing the Python iLOrest library and showcasing a few examples.
Branch: master
Clone or download
Yergidy Merge pull request #6 from hgomez/master
Remove useless retry
Latest commit 6561a07 May 31, 2019
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples initial commit May 1, 2017
library Small code cleanup on module to remove unused calls and states Nov 9, 2017
LICENSE initial commit May 1, 2017 updating readme May 1, 2017
ansible_main.yml initial commit May 1, 2017
hosts initial commit May 1, 2017

iLOrest Ansible Role

Build Status GitHub license

Table of Contents

  1. Overview
  2. Usage
  3. Writing a Module
  4. Writing a Playbook
  5. Usage
  6. History
  7. License
  8. Authors


This Ansible iLO REST role for HPE iLO is intended to provide an simple solution for user to manage server setting


Examples should be run in the root folder. Note that the library folder is automatically searched by Ansible for modules when running from playbooks.

Example command to run restart_server.yml:

ansible-playbook restart_server.yml

A verbose version can be run with

ansible-playbook restart_server.yml -v

ansible_main.yml is the updated playbook.


The example modules provided here are based off the example scripts in the python-ilorest-library. These are run through local login, thus ensuring playbooks will work for every assigned server without issue.

Due to the nature of ansible, and the need for modules to be self-contained, we have to integrate the contents of and into our module first.

Additionally, we need the boilerplate code from ansible.module_tils.basic:

from ansible.module_utils.basic import AnsibleModule
if __name__ == '__main__':

Do note that in our case, we use the * import. prior to Ansible-2.1.0 importing only what you required did not work, hence the use of a wildcard import.

Next, the module class needs to be instantiated like so:

def main():
    module = AnsibleModule(
        argument_spec = dict(
            state     = dict(default='present', choices=['present', 'absent']),
            name      = dict(required=True),
            enabled   = dict(required=True, type='bool'),
            something = dict(aliases=['whatever'])

The arguments provided here can be set to correspond to the arguments passed in the playbook, enabling the setting of values and commands.


Playbooks are a series of tasks that are performed on the remote machine.

Debug core module can be used to return debug messages.

Debug Examples

# Example that prints the loopback address and gateway for each host
- debug: msg="System {{ inventory_hostname }} has uuid {{ ansible_product_uuid }}"

- debug: msg="System {{ inventory_hostname }} has gateway {{ ansible_default_ipv4.gateway }}"
  when: ansible_default_ipv4.gateway is defined

- shell: /usr/bin/uptime
  register: result

- debug: var=result verbosity=2

- name: Display all variables/facts known for a host
  debug: var=hostvars[inventory_hostname] verbosity=4


  • 05/01/2017: Initial Commit


Copyright 2017 Hewlett Packard Enterprise Development LP

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.


You can’t perform that action at this time.