Skip to content

Commit

Permalink
New Modules for NDB features for 1.8.0-beta.1 release (#292)
Browse files Browse the repository at this point in the history
* era basic spec design

* database CRUD code

* Handling new fields for era connection and fixing crud flows

* Test automation for database instance crud

* Minor fix

* Feat/era info (#290)

Info modules for NDB features

Co-authored-by: alaa-bish <[email protected]>
Co-authored-by: Pradeepsingh Bhati <[email protected]>
Co-authored-by: Gevorg-Khachatryaan <Gevorg1050.1>

* Add option for version ID in software profile

* Add info tests for database in crud tests

* Minro update

* Handling error cases

* 1. Doc fixes. 2. Let entity class handle failed api errors then client code

* Add example in docs

* Doc fixes

* Add examples

* supress output for ndb tests

* Minor doc update

* fixing tests

* Minor test fix

* use nutanix_* based creds terms for ndb as well

* Minor doc fix

* formatting

* Minor fix

* ADD return

Delete vms in between tests to free up space

fix

fix

fix

Doc fixes

* Doc updates

* Example for postgress database creation

* read me changes

* Docs and examples

* minor fixes

* Add soft delete example

* Release docs update

* Minor change log update

Co-authored-by: Gevorg Khachatryan <[email protected]>
Co-authored-by: alaa-bish <[email protected]>
  • Loading branch information
3 people authored Oct 21, 2022
1 parent 8566a90 commit 99780cd
Show file tree
Hide file tree
Showing 60 changed files with 5,407 additions and 26 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## v1.8.0-beta.1 (20 Oct 2022)

**Features**

**Nutanix Database Service (Era)**
- Ansible module for Single Instance Databases
- Ansible info module for Database Instances
- Ansible info module for NDB Clusters
- Ansible info module for DB server VMs
- Ansible info module for Profiles
- Ansible info module for SLAs
- Ansible info module for Time Machines
- Ansible info module for Database Clones

**Full Changelog:** [here](https://github.com/nutanix/nutanix.ansible/compare/v1.7.0...v1.8.0-beta.1)

## v1.7.0 (30 Sep 2022)

**Feature:**
Expand Down
15 changes: 15 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@ Nutanix.Ncp Release Notes
.. contents:: Topics


v1.8.0-beta.1
=============

New Modules
-----------

- ntnx_ndb_clones_info - info module for database clones
- ntnx_ndb_clusters_info - info module for ndb clusters info
- ntnx_ndb_databases - Module for create, update and delete of single instance database. Currently, postgres type database is officially supported.
- ntnx_ndb_databases_info - info module for ndb database instances
- ntnx_ndb_db_servers_info - info module for ndb db server vms info
- ntnx_ndb_profiles_info - info module for ndb profiles
- ntnx_ndb_slas_info - info module for ndb slas
- ntnx_ndb_time_machines_info - info module for ndb time machines

v1.7.0
======

Expand Down
36 changes: 23 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,14 @@ This collection requires Python 2.7 or greater
> For the 1.7.0 release of the ansible plugin it will have N-2 compatibility with the Prism Central APIs. This release was tested against Prism Central versions pc.2022.6, pc.2022.4 and pc2022.1.0.2.
> For the 1.8.0-beta.1 release of the ansible plugin it will have N compatibility with the Prism Central APIs. This release was tested against Prism Central version pc.2022.6 .
### Notes:
1. Static routes module (ntnx_static_routes) is supported for PC versions >= pc.2022.1

2. Adding cluster references in projects module (ntnx_projects) is supported for PC versions >= pc.2022.1

3. For Users and User Groups modules (ntnx_users and ntnx_user_groups), adding Identity Provider (IdP) & Organizational Unit (OU) based users/groups are supported for PC versions >= pc.2022.1

#### v1.7.0 additions:
1. Added functionality to add cluster reference while using vlan subnet name in vms to pull subnet info from particular cluster. Checkout vm.yml example for same.

2. Added functionality to configure role mappings, collaboration, new user/user groups, vpcs and accounts in ntnx_projects. Checkout projects_with_role_mapping.yml example for same.

3. Added constructed inventory feature to inventory module to construct custom vars and groups based on existing inventory.

4. Now inventory module can fetch 500+ entities.

Prism Central based examples: https://github.com/nutanix/nutanix.ansible/tree/main/examples/

## Foundation
Expand All @@ -66,6 +58,16 @@ Foundation Central based examples : https://github.com/nutanix/nutanix.ansible/t
Karbon based examples : https://github.com/nutanix/nutanix.ansible/tree/main/examples/karbon

## Nutanix Database Service (ERA)
> For the 1.8.0-beta.1 release of the ansible plugin, it will have N-1 compatibility with the Nutanix Database Service (ERA). This release was tested against era versions v2.4.1 and v2.4.0
NDB based examples : https://github.com/nutanix/nutanix.ansible/tree/main/examples/ndb

Nutanix Ansible support for Nutanix Database Service is currently at beta stage.

### Notes:
1. Currently for ntnx_ndb_databases, creation of only postgres type database instance is tested and offically supported.

# Installing the collection
**Prerequisite**

Expand Down Expand Up @@ -150,6 +152,14 @@ ansible-playbook examples/iaas/iaas.yml
| ntnx_karbon_clusters_info | Get clusters info. |
| ntnx_karbon_registries | Create, Delete a karbon private registry entry |
| ntnx_karbon_registries_info | Get karbon private registry registry info. |
| ntnx_ndb_databases | Create, Update and Delete single instance database. |
| ntnx_ndb_databases_info | Get database info. |
| ntnx_ndb_db_servers_info | Get db servers vm info. |
| ntnx_ndb_clusters_info | Get clusters info. |
| ntnx_ndb_slas_info | Get slas info |
| ntnx_ndb_profiles_info | Get profiles info. |
| ntnx_ndb_time_machines_info | Get time machines info. |
| ntnx_ndb_clones_info | Get database clones info. |
| ntnx_pbrs | Create or delete a PBR. |
| ntnx_pbrs_info | List existing PBRs. |
| ntnx_permissions_info | List permissions info |
Expand All @@ -171,6 +181,10 @@ ansible-playbook examples/iaas/iaas.yml
| ntnx_static_routes_info | List existing static routes of a vpc. |
| ntnx_subnets | Create or delete a Subnet. |
| ntnx_subnets_info | List existing Subnets. |
| ntnx_user_groups | Create, Delete user_groups |
| ntnx_user_groups_info | Get user groups info. |
| ntnx_users | Create, Delete users |
| ntnx_users_info | Get users info. |
| ntnx_vms | Create or delete a VM. |
| ntnx_vms_clone | Clone VM. |
| ntnx_vms_ova | Create OVA image from VM. |
Expand All @@ -189,10 +203,6 @@ ansible-playbook examples/iaas/iaas.yml
| ntnx_foundation_central_api_keys_info | List all the api keys created in Foundation Central. |
| ntnx_foundation_central_imaged_clusters_info | List all the clusters created using Foundation Central. |
| ntnx_foundation_central_imaged_nodes_info | List all the nodes registered with Foundation Central. |
| ntnx_user_groups | Create, Delete user_groups |
| ntnx_user_groups_info | Get user groups info. |
| ntnx_users | Create, Delete users |
| ntnx_users_info | Get users info. |

## Inventory Plugins

Expand Down
28 changes: 28 additions & 0 deletions changelogs/changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -282,3 +282,31 @@ releases:
- nutanix.ncp.ntnx_prism_vm_inventory - [Imprv] add functionality constructed
to module inventory [\#235](https://github.com/nutanix/nutanix.ansible/issues/235)
release_date: '2022-09-30'
1.8.0-beta.1:
modules:
- description: info module for database clones
name: ntnx_ndb_clones_info
namespace: ''
- description: info module for ndb clusters info
name: ntnx_ndb_clusters_info
namespace: ''
- description: Module for create, update and delete of single instance database.
Currently, postgres type database is officially supported.
name: ntnx_ndb_databases
namespace: ''
- description: info module for ndb database instances
name: ntnx_ndb_databases_info
namespace: ''
- description: info module for ndb db server vms info
name: ntnx_ndb_db_servers_info
namespace: ''
- description: info module for ndb profiles
name: ntnx_ndb_profiles_info
namespace: ''
- description: info module for ndb slas
name: ntnx_ndb_slas_info
namespace: ''
- description: info module for ndb time machines
name: ntnx_ndb_time_machines_info
namespace: ''
release_date: '2022-10-20'
50 changes: 50 additions & 0 deletions examples/ndb/provision_database_on_registered_db_server.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
- name: Single instance postgres database creation on registered db server
hosts: localhost
gather_facts: false
collections:
- nutanix.ncp
module_defaults:
group/nutanix.ncp.ntnx:
nutanix_host: <ndb-era-server-ip>
nutanix_username: <username>
nutanix_password: <password>
validate_certs: false

tasks:

- name: Create single instance postgres database on registered db server vm
ntnx_ndb_databases:

name: POSTGRES_DATABASE_ANSIBLE

db_params_profile:
name: DEFAULT_POSTGRES_PARAMS

db_vm:
use_registered_server:
name: otiakmxh

postgres:
listener_port: "5432"
db_name: prad
db_password: db_password
db_size: 200

time_machine:
name: POSTGRES_DATABASE_ANSIBLE_TM
sla:
name: DEFAULT_OOB_GOLD_SLA
schedule:
daily: "11:00:00"
weekly: WEDNESDAY
monthly: 4
quaterly: JANUARY
yearly: FEBRUARY
log_catchup: 30
snapshots_per_day: 2

register: output

- debug:
msg: "{{output}}"
60 changes: 60 additions & 0 deletions examples/ndb/single_instance_postgress_database.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
- name: Single instance postgres database creation with new db server VM
hosts: localhost
gather_facts: false
collections:
- nutanix.ncp
module_defaults:
group/nutanix.ncp.ntnx:
nutanix_host: <ndb-era-server-ip>
nutanix_username: <username>
nutanix_password: <password>
validate_certs: false

tasks:

- name: Create single instance postgres database
ntnx_ndb_databases:

name: POSTGRES_DATABASE_ANSIBLE

db_params_profile:
name: DEFAULT_POSTGRES_PARAMS

db_vm:
create_new_server:
name: postgres_server_ansible
password: temp_password
cluster:
name: EraCluster
software_profile:
name: POSTGRES_10.4_OOB
network_profile:
name: DEFAULT_OOB_POSTGRESQL_NETWORK
compute_profile:
name: DEFAULT_OOB_SMALL_COMPUTE
pub_ssh_key: "<publickey-for-vm-access>"

postgres:
listener_port: "5432"
db_name: prad
db_password: db_password
db_size: 200

time_machine:
name: POSTGRES_DATABASE_ANSIBLE_TM
sla:
name: DEFAULT_OOB_GOLD_SLA
schedule:
daily: "11:00:00"
weekly: WEDNESDAY
monthly: 4
quaterly: JANUARY
yearly: FEBRUARY
log_catchup: 30
snapshots_per_day: 2

register: output

- debug:
msg: "{{output}}"
25 changes: 25 additions & 0 deletions examples/ndb/soft_delete_database_instance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
- name: Soft delete single instance database and time machine associated
hosts: localhost
gather_facts: false
collections:
- nutanix.ncp
module_defaults:
group/nutanix.ncp.ntnx:
nutanix_host: <ndb-era-ip>
nutanix_username: <username>
nutanix_password: <password>
validate_certs: false

tasks:

- name: Soft delete single instance database and time machine associated
ntnx_ndb_databases:
state: "absent"
db_uuid: c0a4433a-49f2-40f3-ae52-d88788d2824b
soft_delete: true
delete_time_machine: true
register: output

- debug:
msg: "{{output}}"
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace: "nutanix"
name: "ncp"
version: "1.7.0"
version: "1.8.0-beta.1"
readme: "README.md"
authors:
- "Abhishek Chaudhary (@abhimutant)"
Expand Down
8 changes: 8 additions & 0 deletions meta/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,11 @@ action_groups:
- ntnx_karbon_clusters_info
- ntnx_karbon_registries
- ntnx_karbon_registries_info
- ntnx_ndb_databases_info
- ntnx_ndb_clones_info
- ntnx_ndb_time_machines_info
- ntnx_ndb_profiles_info
- ntnx_ndb_db_servers_info
- ntnx_ndb_slas_info
- ntnx_ndb_databases
- ntnx_ndb_clusters_info
41 changes: 41 additions & 0 deletions plugins/doc_fragments/ntnx_ndb_base_module.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-

# Copyright: (c) 2017, Ansible Project
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)

from __future__ import absolute_import, division, print_function

__metaclass__ = type


class ModuleDocFragment(object):

# Plugin options for ntnx ndb
DOCUMENTATION = r"""
options:
nutanix_host:
description:
- ndb era server IP address
- C(nutanix_host). If not set then the value of the C(NUTANIX_HOST), environment variable is used.
type: str
required: true
nutanix_password:
description:
- ndb era server password
- C(nutanix_password). If not set then the value of the C(NUTANIX_PASSWORD), environment variable is used.
type: str
required: true
nutanix_username:
description:
- ndb era server username
- C(nutanix_username). If not set then the value of the C(NUTANIX_USERNAME), environment variable is used.
type: str
required: true
validate_certs:
description:
- Set value to C(False) to skip validation for self signed certificates
- This is not recommended for production setup
- C(validate_certs). If not set then the value of the C(VALIDATE_CERTS), environment variable is used.
type: bool
default: true
"""
12 changes: 12 additions & 0 deletions plugins/module_utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,3 +277,15 @@ class EntityFilterExpressionList:
"right_hand_side": {"collection": "SELF_OWNED"},
},
}


class NDB:

OPERATIONS_POLLING_DELAY = 30

class DatabaseTypes:
POSTGRES = "postgres_database"

class StatusCodes:
SUCCESS = "5"
FAILURE = "4"
Loading

0 comments on commit 99780cd

Please sign in to comment.