Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client sdk with inventory #45

Merged
merged 18 commits into from
Jan 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
180 changes: 180 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
Skip to content
Search or jump to…
Pull requests
Issues
Marketplace
Explore

@Gevorg-Khachatryan-97
nutanix
/
nutanix.ansible
Internal
Code
Issues
12
Pull requests
Actions
Projects
1
Wiki
Security
Insights
Settings
nutanix.ansible/.gitignore
@kumarsarath588
kumarsarath588 Add CICD github actions
Latest commit 0765ecc 6 days ago
History
1 contributor
136 lines (109 sloc) 1.8 KB

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/


# emacs stuff
*~

# vs code configs
.vscode
© 2022 GitHub, Inc.
Terms
Privacy
Security
Status
Docs
Contact GitHub
Pricing
API
Training
Blog
About
Loading complete
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Nutanix Ansible Collection - nutanix.ncp
Ansible collections to automate Nutanix Cloud Platform (ncp).

# Building and installing the collection locally
```
ansible-galaxy collection build
ansible-galaxy collection install nutanix-ncp-1.0.0.tar.gz
```
_Add `--force` option for rebuilding or reinstalling to overwrite existing data_

# Included modules
```
ntnx_vms
```

# Inventory plugin
`ncp_prism_vm_inventory`

# Module documentation and examples
```
ansible-doc nutanix.ncp.<module_name>
```

# Examples
## Playbook to print name of vms in PC
```
- hosts: localhost
collections:
- nutanix.ncp
tasks:
- ntnx_vms:
nutanix_host: '{{config.ip_address}}'
nutanix_username: '{{credentials.username}}'
nutanix_password: '{{credentials.password}}'
validate_certs: False
register: result
- debug:
msg: "{{ result.vms }}"
```
5 changes: 5 additions & 0 deletions examples/ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[defaults]
inventory = nutanix.yaml

[inventory]
enable_plugins = nutanix.ncp.ntnx_prism_vm_inventory
43 changes: 43 additions & 0 deletions examples/create_vm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
- name: VM Creation using all poissible options
hosts: localhost
gather_facts: false
collections:
- nutanix.ncp
tasks:
- name: create Vm
ntnx_vms:
state: present
nutanix_host: ''
nutanix_username: ''
nutanix_password: ''
name: "ansible_automation_demo"
desc: "ansible_vm_description"
categories:
AppType:
- "Apache_Spark"
cluster:
#uuid: "0005d578-2faf-9fb6-3c07-ac1f6b6f9780"
name: "auto_cluster_prod_1aa888141361"
networks:
- is_connected: True
subnet:
name: "vlan.800"
disks:
- type: "DISK"
size_gb: 30
bus: "SATA"
clone_image:
name: "CentOS-7-cloudinit"
vcpus: 1
cores_per_vcpu: 1
memory_gb: 1
guest_customization:
type: "cloud_init"
script_path: "test.json"
is_overridable: True
register: output

- name: output of list Subnets
debug:
msg: '{{ output }}'
23 changes: 23 additions & 0 deletions examples/delete_vm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
- name: Auto Generated Playbook
hosts: localhost
vars_files: credentials.yml
gather_facts: false
collections:
- nutanix.ncp
tasks:
- name: delete Vm
ntnx_vms:
state: absent
auth:
credentials: '{{credentials}}'
url: '{{config.ip_address}}:{{config.port}}'
nutanix_host: '{{config.ip_address}}'
nutanix_username: '{{credentials.username}}'
nutanix_password: '{{credentials.password}}'
uuid: "63f7115e-e071-4dc3-b417-69fe6d6ff37f"
register: output

- name: output of delete vm
debug:
msg: '{{ output }}'
6 changes: 6 additions & 0 deletions examples/nutanix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
plugin: nutanix.ncp.ntnx_prism_vm_inventory
validate_certs: False
data:
offset: 0
length: 100
16 changes: 16 additions & 0 deletions galaxy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace: "nutanix"
name: "ncp"
version: "1.0.0"
readme: "README.md"
authors:
- "Balu George (@balugeorge)"
- "Sarath Kumar K (@kumarsarath588)"
- "Prem Karat (@premkarat)"
description: Ansible collection for v3 Nutanix APIs https://www.nutanix.dev/api-reference-v3/
license_file: 'LICENSE'
tags: [nutanix, prism, ahv]
repository: https://github.com/nutanix/nutanix.ansible
documentation: https://github.com/nutanix/nutanix.ansible/nutanix/prism/docs
homepage: https://github.com/nutanix/nutanix.ansible/nutanix/prism
issues: https://github.com/nutanix/nutanix.ansible/issues
build_ignore: []
31 changes: 31 additions & 0 deletions plugins/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Collections Plugins Directory

This directory can be used to ship various plugins inside an Ansible collection. Each plugin is placed in a folder that
is named after the type of plugin it is in. It can also include the `module_utils` and `modules` directory that
would contain module utils and modules respectively.

Here is an example directory of the majority of plugins currently supported by Ansible:

```
└── plugins
├── action
├── become
├── cache
├── callback
├── cliconf
├── connection
├── filter
├── httpapi
├── inventory
├── lookup
├── module_utils
├── modules
├── netconf
├── shell
├── strategy
├── terminal
├── test
└── vars
```

A full list of plugin types can be found at [Working With Plugins](https://docs.ansible.com/ansible-core/devel/plugins/plugins.html).
Empty file added plugins/__init__.py
Empty file.
Loading