HewlettPackard/ansible-ilorest-role

Name: ansible-ilorest-role

Owner: Hewlett Packard Enterprise

Description: Ansible role for installing the Python iLOrest library and showcasing a few examples.

Created: 2017-04-28 19:24:44.0

Updated: 2018-05-22 14:28:50.0

Pushed: 2017-11-09 19:22:26.0

Homepage:

Size: 68

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

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
Overview

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

Usage

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.

Module

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 _restobject.py and _redfishobject.py into our module first.

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

 ansible.module_utils.basic import AnsibleModule
_name__ == '__main__':
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:

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.

Playbook

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

ample that prints the loopback address and gateway for each host
bug: msg="System {{ inventory_hostname }} has uuid {{ ansible_product_uuid }}"

bug: msg="System {{ inventory_hostname }} has gateway {{ ansible_default_ipv4.gateway }}"
en: ansible_default_ipv4.gateway is defined

ell: /usr/bin/uptime
gister: result

bug: var=result verbosity=2

me: Display all variables/facts known for a host
bug: var=hostvars[inventory_hostname] verbosity=4
History
License

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

http://www.apache.org/licenses/LICENSE-2.0

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.

Authors

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.