Modules to manage HPE OneView using Ansible playbooks.
- Ansible >= 2.1
- Python >= 2.7.9
- HPE OneView Python SDK (Install HPE OneView Python SDK)
Each OneView resource operation is exposed through an Ansible module. We also provide a specific module to gather facts about the resource.
The detailed documentation for each module is available at: HPE OneView Ansible Modules Documentation
- hosts: all
tasks:
- name: Ensure that the Fibre Channel Network is present with fabricType 'DirectAttach'
oneview_fc_network:
config: "/path/to/config.json"
state: present
data:
name: 'New FC Network'
fabricType: 'DirectAttach'
- name: Ensure that Fibre Channel Network is absent
oneview_fc_network:
config: "/path/to/config.json"
state: absent
data:
name: 'New FC Network'
- name: Gather facts about the FCoE Network with name 'Test FCoE Network Facts'
oneview_fcoe_network_facts:
config: "/path/to/config.json"
name: "Test FCoE Network Facts"
Sample playbooks and instructions on how to run the modules can be found in the examples
directory.
-
An end-to-end DevOps example using HPE OneView for the bare metal server provisioning, HPE ICsp for OS deployment, and Ansible modules for software setup is provided at: Accelerating DevOps with HPE OneView and Ansible sample.
-
A collection of examples of how to use HPE OneView with HPE Synergy Image Streamer for OS Deployment is available at: HPE Synergy OS Deployment Sample and HPE Image Streamer Samples
-
An example of how to upload an artifact bundle for HPE Synergy Image Streamer and deploy a blade server in HPE OneView using the OS build plan provided in the artifact bundle is available at: HPE Synergy + OneView Sample.
-
Examples of bare metal infrastructure setup using HPE OneView and Ansible are available at:
To run the Ansible modules provided in this project, you should execute the following steps:
Run:
$ git clone https://github.com/HewlettPackard/oneview-ansible.git
Set the environment variables ANSIBLE_LIBRARY
and ANSIBLE_MODULE_UTILS
, specifying the library
full path from the cloned project:
$ export ANSIBLE_LIBRARY=/path/to/oneview-ansible/library
$ export ANSIBLE_MODULE_UTILS=/path/to/oneview-ansible/library/module_utils/
To use the Ansible OneView modules, you can store the configuration on 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": "172.25.105.12",
"credentials": {
"userName": "Administrator",
"authLoginDomain": "",
"password": "secret123"
},
"api_version": 200
}
The api_version
specifies the version of the Rest API to invoke. When not defined, it will use 300
as the
default value.
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 playbooks 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"
If you prefer, the configuration can also be stored in environment variables.
# Required
export ONEVIEWSDK_IP='172.25.105.12'
export ONEVIEWSDK_USERNAME='Administrator'
export ONEVIEWSDK_PASSWORD='secret123'
# Optional
export ONEVIEWSDK_API_VERSION='200' # default value is 300
export ONEVIEWSDK_AUTH_LOGIN_DOMAIN='authdomain'
export ONEVIEWSDK_PROXY='<proxy_host>:<proxy_port>'
๐ Tip: Make sure no unauthorised person has access to the environment variables, since the password is stored in clear-text.
In this case, you shouldn't provide the config
argument. For example:
- name: Gather facts about the FCoE Network with name 'FCoE Network Test'
oneview_fcoe_network_facts:
name: "FCoE Network Test"
Once you have defined the environment variables, you can run the plays.
The third way 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: 172.16.101.48
username: administrator
password: my_password
api_version: 600
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.
The Ansible modules for HPE OneView support the API endpoints for HPE OneView 2.0, 3.0 and 3.10.
The current default
HPE OneView version used by the modules is 3.00
, API 300
.
To use a different API, you must set the API version together with your credentials, either using the JSON configuration:
"api_version": 600
OR using the Environment variable:
export ONEVIEWSDK_API_VERSION='600'
If this property is not specified, it will fall back to the 300
default value.
The API list is as follows:
- HPE OneView 2.0 API version:
200
- HPE OneView 3.0 API version:
300
- HPE OneView 3.10 API version:
500
- HPE OneView 4.0 API version:
600
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": "100.100.100.100"
OR using the Environment variable:
export ONEVIEWSDK_IMAGE_STREAMER_IP='100.100.100.100'
You can find sample playbooks in the examples folder. Just look for the playbooks with the image_streamer_
prefix.
This project is licensed under the Apache 2.0 license. Please see the LICENSE for more information.
Contributing: You know the drill. Fork it, branch it, change it, commit it, and pull-request it. We are passionate about improving this project, and glad to accept help to make it better. However, keep the following in mind:
- You must sign a Contributor License Agreement first. Contact one of the authors (from Hewlett Packard Enterprise) for details and the CLA.
- We reserve the right to reject changes that we feel do not fit the scope of this project, so for feature additions, please open an issue to discuss your ideas before doing the work.
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.
By adding support for a new resource, 3 files are required: self-contained module, test and example. The following is a summary of the code structure and naming conventions for the oneview-ansible modules.
Modules
Modules are located in library folder. All modules need to be self-contained, without external dependencies except hpOneView. The module is named according to the HPE OneView API Reference resource title, but in singular. The name should have the "oneview_" prefix, with all characters in lowercase, replacing spaces by underscores. For example: oneview_fc_network
Tests
Tests are located in tests folder. The name of the test modules should start with "test_" prefix in addition to the tested module name, for example: test_oneview_fc_network
Playbook Examples
Examples are located in examples folder with the same name of corresponding module, for example: oneview_fc_network.yml
Facts
Modules that implement facts follow the same rules of any other modules, but the filenames have a suffix: "_facts", for example: oneview_fc_network_facts
The basic test execution can be achieved by executing the build.sh
file.
Please refer to TESTING.md for further testing information.