Skip to content
VenkateshRavula edited this page Feb 9, 2021 · 5 revisions

Welcome to the Ansible Collection for HPE OneView wiki!

Introduction

The HPE OneView Ansible Collection library provides to manage HPE OneView using Ansible Collection playbooks using HPE OneView REST APIs. This collection provides a series of Ansible modules and plugins for interacting with the HPE OneView Modules. Each OneView resource operation is exposed through an Ansible module. Specific modules are provided to gather facts about the resource.

HPE OneView makes it simple to deploy and manage today’s complex hybrid cloud infrastructure. HPE OneView can help you transform your data center to software-defined, and it supports HPE’s broad portfolio of servers, storage, and networking solutions, ensuring the simple and automated management of your hybrid infrastructure. Software-defined intelligence enables a template-driven approach for deploying, provisioning, updating, and integrating compute, storage, and networking infrastructure.

The HPE OneView Ansible Collection uses the new distribution format collection, introduced by the Ansible Collections distribution format (i.e. Ansible v.2.9), Ansible content includes Playbooks, Roles and Plugins.

The HPE OneView Ansible Collection includes

You can find the latest supported HPE OneView Ansible Collection SDK here


Installation

Requirements

To install HPE OneView collection hosted in Galaxy

ansible-galaxy collection install hpe.oneview

To upgrade to the latest version of HPE OneView:

ansible-galaxy collection install hpe.oneview --force

To install HPE OneView collection from GitHub

1. Clone the repository

git clone https://github.com/HewlettPackard/oneview-ansible-collection.git
cd oneview-ansible-collection
ansible-galaxy collection build .
ansible-galaxy collection install <tar_file>

2. Install dependency packages

pip install -r requirements.txt

To install HPE OneView collection from Docker Image

docker build -t oneview-ansible-collections .
docker run -it --rm -v (pwd)/:/root/oneview-ansible-collections oneview-ansible-collections

That's it. If you would like to modify any role, simply modify role and re-run the image.

Configuration

Using a JSON Configuration File

To use the HPE OneView collection, you can store the configuration in a JSON file. This file is used to define the settings, which will be used on the OneView appliance connection, like hostname, username, and password. Here's an example:

{
  "ip": "<ip>",
  "credentials": {
    "userName": "<userName>",
    "authLoginDomain": "",
    "password": "<password>"
  },
  "api_version": 2400
}

The api_version specifies the version of the Rest API to invoke. When not defined, it will pick the OneView appliance version as default

If your environment requires a proxy, define the proxy properties in the JSON file using the following syntax:

  "proxy": "<proxy_host>:<proxy_port>"

🔒 Tip: Check the file permissions since the password is stored in clear-text.

The configuration file path must be provided for all of the roles config arguments. For example:

- name: Gather facts about the FCoE Network with name 'FCoE Network Test'
  oneview_fcoe_network_facts:
    config: "/path/to/config.json"
    name: "FCoE Network Test"

Once you have defined the config variables, you can run the roles.

Parameters in roles

The another way is to pass in your HPE OneView credentials to your tasks is through explicit specification on the task.

This option allows the parameters hostname, username, password, api_version and image_streamer_hostname to be passed directly inside your task.

- name: Create a Fibre Channel Network
  oneview_fc_network:
    hostname: <hostname>
    username: <username>
    password: <password>
    api_version: 2400
    state: present
    data:
      name: "{{ network_name }}"
      fabricType: 'FabricAttach'
      linkStabilityTime: '30'
      autoLoginRedistribution: true
  no_log: true
  delegate_to: localhost

Setting no_log: true is highly recommended in this case, as the credentials are otherwise returned in the log after task completion.

Setting your OneView version

The Ansible modules for HPE OneView support the API endpoints for HPE OneView 5.50, 5.60

The current default HPE OneView version will pick the OneView appliance version.

To use a different API, you must set the API version together with your credentials, either using the JSON configuration:

"api_version": 2400

OR using the Environment variable:

export ONEVIEWSDK_API_VERSION='2400'

If this property is not specified, it will fall back to default value.

The API list is as follows:

  • HPE OneView 5.50 API version: 2200
  • HPE OneView 5.60 API version: 2400

HPE Synergy Image Streamer

Modules to manage HPE Synergy Image Streamer appliances are also included in this project. To use these modules, you must set the Image Streamer IP on the OneViewClient configuration, either using the JSON configuration:

"image_streamer_ip": "<image_streamer_ip>"

OR using the Environment variable:

export ONEVIEWSDK_IMAGE_STREAMER_IP='100.100.100.100'

Usage of Playbooks

To use a module from HPE OneView collection, please reference the full namespace, collection name, and modules name that you want to use:

---
- name: Using HPE OneView collection
  hosts: all
  collections:
    - hpe.oneview
  roles:
    - hpe.oneview.oneview_fc_network
    - hpe.oneview.oneview_fc_network_facts

Run the above created playbooks as shown below.

ansible-playbook example_collection.yml

Getting Help - How can I get help & support

Are you running into a road block? Have an issue with unexpected behavior? Feel free to open a new issue on the issue tracker

When creating an issue, recommend providing the following and any additional information which would help address quicker.

Scenario/Intent

[What you are trying to achieve but can't?]

Environment Details

  • OneView SDK Version: [Version of this SDK for which you are encountering the issue]
  • OneView Appliance Version: [Version of the OneView appliance you're interacting with]
  • OneView Client API Version: [API version of your client object]
  • Python Version: [Version of Python in your environment]
  • Platform: [OS distribution and release version]

Steps to Reproduce

[What are the complete steps needed to do in order to reproduce your problem?]

Expected Result

[What do you expect to happen after taking the steps above?]

Actual Result

[What actually happens after the steps above? Include error output or a link to a gist.]


Additional Resources

SDKs for HPE OneView

HPE OneView Documentation on the HPE Enterprise Information Library

HPE OneView Community

Learn more about HPE OneView at hpe.com/info/oneview

License

This project is licensed under the Apache 2.0 license. Please see the LICENSE for more information.

Contributing and feature requests

Contributing: We welcome your contributions to the Ansible Modules for HPE OneView. See CONTRIBUTING.md for more details.

Feature Requests: If you have a need that is not met by the current implementation, please let us know (via a new issue). This feedback is crucial for us to deliver a useful product. Do not assume that we have already thought of everything, because we assure you that is not the case.

Clone this wiki locally