Skip to content

Commit

Permalink
Merge branch 'client_sdk_with_inventory' into main
Browse files Browse the repository at this point in the history
# Conflicts:
#	.gitignore
#	README.md
#	galaxy.yml
#	plugins/module_utils/base_module.py
#	plugins/module_utils/entity.py
#	plugins/module_utils/prism/prism.py
#	plugins/module_utils/prism/vms.py
  • Loading branch information
Gevorg-Khachatryaan authored and Gevorg-Khachatryaan committed Jan 28, 2022
2 parents 3dbedde + 4e838de commit cdeceec
Show file tree
Hide file tree
Showing 21 changed files with 1,357 additions and 703 deletions.
46 changes: 45 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
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]
Expand Down Expand Up @@ -133,4 +164,17 @@ dmypy.json
*~

# vs code configs
.vscode
.vscode
© 2022 GitHub, Inc.
Terms
Privacy
Security
Status
Docs
Contact GitHub
Pricing
API
Training
Blog
About
Loading complete
163 changes: 14 additions & 149 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,169 +6,34 @@ Ansible collections to automate Nutanix Cloud Platform (ncp).
ansible-galaxy collection build
ansible-galaxy collection install nutanix-ncp-1.0.0.tar.gz
```

##or

### Installing the collection from GitHub repository
```
ansible-galaxy collection install git+https://github.com/nutanix/nutanix.ansible.git#nutanix,<branch>
```
_Add `--force` option for rebuilding or reinstalling to overwrite existing data_

# Included modules
```
nutanix_vms
ntnx_vms
```


# Inventory plugin
`ncp_prism_vm_inventory`

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

# Examples
Make sure to use the correct values that matches your environment for all the variables.

Create playbook.yml with the content as below, and run it using
```
ansible-playbook playbook.yml
## Playbook to print name of vms in PC
```
## Playbook to Create Different Vm's
```
---
- hosts: localhost
collections:
- nutanix.ncp
vars:
credentials:
username: UserName
password: Password
config:
ip_address: XXX.XXX.XXX.XXX
port: 9440
cluster:
uuid: "0005d578-2faf-9fb6-3c07-ac1f6b6f9780"
networks:
static:
name: "static_subnet"
uuid: "72c5057d-93f7-4389-a01a-2c2f42eae3ef"
ip: "10.30.30.72"
storage_config:
uuid: "4446ca0b-7846-4a6f-b00a-386736432121"
- nutanix.ncp
tasks:
- name: Create vm from image
nutanix.ncp.nutanix_vms:
state: present
name: image_vm
timezone: "UTC"
auth:
credentials: "{{credentials}}"
url: "{{config.ip_address}}:{{config.port}}"
cluster:
cluster_uuid: "{{cluster.uuid}}"
disks:
- type: "DISK"
clone_image: "CentOS-7-cloudinit"
bus: "SCSI"
register: result
#ignore_errors: True
- name: VM with Cluster , Network, UTC time zone, one Disk
nutanix_vms:
state: present
name: "Cluster Network and Disk"
timezone: "UTC"
auth:
credentials: "{{credentials}}"
url: "{{config.ip_address}}:{{config.port}}"
cluster:
cluster_uuid: "{{cluster.uuid}}"
networks:
- connected: True
subnet_name: "{{networks.static.name}}"
disks:
- type: "DISK"
size_gb: 5
bus: "PCI"
register: result
ignore_errors: True
- name: VM with Cluster, different Disks, memory size
nutanix_vms:
state: present
name: "Different disks"
auth:
credentials: "{{credentials}}"
url: "{{config.ip_address}}:{{config.port}}"
cluster:
cluster_uuid: "{{cluster.uuid}}"
disks:
- type: "DISK"
size_gb: 4
bus: "SATA"
- type: "DISK"
size_gb: 3
bus: "SCSI"
memory_gb: 20
register: result
ignore_errors: True
- name: VM with Cluster, different CDROMS
nutanix_vms:
state: present
name: "CDROM"
auth:
credentials: "{{credentials}}"
url: "{{config.ip_address}}:{{config.port}}"
cluster:
cluster_uuid: "{{cluster.uuid}}"
disks:
- type: "CDROM"
bus: "SATA"
- type: "CDROM"
bus: "IDE"
cores_per_vcpu: 1
register: result
ignore_errors: True
- name: delete recently created vm
nutanix_vms:
uuid: '{{ result["response"]["metadata"]["uuid"] }}'
state: absent
auth:
credentials: "{{credentials}}"
url: "{{config.ip_address}}:{{config.port}}"
register: result
- name: VM with all specification
nutanix_vms:
state: present
name: "All specification"
timezone: "GMT"
auth:
credentials: "{{credentials}}"
url: "{{config.ip_address}}:{{config.port}}"
cluster:
cluster_uuid: "{{cluster.uuid}}"
disks:
- type: "DISK"
size_gb: 1
bus: "SCSI"
- type: "DISK"
size_gb: 4
bus: "PCI"
- type: "DISK"
size_gb: 16
bus: "SATA"
- type: "DISK"
size_gb: 16
bus: "SCSI"
- type: "CDROM"
size_gb: 4
bus: "IDE"
boot_device_order_list:
- "DISK"
- "CDROM"
- "NETWORK"
vcpus: 20
cores_per_vcpu: 4
memory_gb: 6
register: result
ignore_errors: True
```
- 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
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).
Loading

0 comments on commit cdeceec

Please sign in to comment.