Skip to content

Commit

Permalink
Adding Azure stateful node support in Ansible (#8)
Browse files Browse the repository at this point in the history
* Draft

* Draft

* updated version

* Fixing documentation

* Documentation Fixes

* Fix type of preferred_zone parameter

* debugging

* reverting the MI changes made for debugging

* Minor changes

* Minor changes

* updated version

* Deletion Config Fixed

* Fixing Tests

* Fixing some of the lint Issues reported by sanity test run

* Updating broken links in the README.md

* Fixing module_utils location

* Documentation Fixes

* Updating python version in workflows

* Correcting Image field dicts

* Fixing the list parameters.

* Changing HAS_ANSIBLE_MODULE to use global scope

* Minor Fixes in data-types

* Static Analysis Fixes

* Update changelog.rst

* review comments fixed

* Resolved the module import error

---------

Co-authored-by: John Samuel <john.samuel@netapp.com>
  • Loading branch information
anuragsharma-123 and johnSamuelNetapp authored Mar 29, 2023
1 parent c0814c9 commit 6c28347
Show file tree
Hide file tree
Showing 17 changed files with 1,916 additions and 19 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ jobs:
with:
# it is just required to run that once as "ansible-test units" in the docker image
# will run on all python versions it supports.
python-version: 3.8
python-version: 3.9

- name: Install ansible-base (${{ matrix.ansible }})
run: pip install https://github.com/ansible/ansible/archive/${{ matrix.ansible }}.tar.gz --disable-pip-version-check
Expand Down
14 changes: 14 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,17 @@ New Modules
- spot.cloud_modules.aws_mrscaler - Create, update or delete Spot MRScaler
- spot.cloud_modules.aws_ocean_k8s - Create, update or delete Spot Ocean K8s
- spot.cloud_modules.event_subscription - Create event subscription for resource


v1.1.0
======

Release Summary
---------------

Adding support for Azure Stateful Nodes.

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

- spot.cloud_modules.azure_stateful_node - Manage (Create, Update, Delete) Azure Stateful Nodes
3 changes: 2 additions & 1 deletion CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
@SHxKM
@zivmessing
@zivmessing
@anuragsharma-123
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Version 2 of Spot's Python SDK does not support Python 2.7 so this collection re

## Spot Python SDK compatibility

Version `1.0.0` of this collection requires at least version `2.1.15` of Spot's Python SDK.
Version `1.1.0` of this collection requires at least version `2.1.29` of Spot's Python SDK.

## Included content

Expand All @@ -24,11 +24,12 @@ Version `1.0.0` of this collection requires at least version `2.1.15` of Spot's

Name | Description
--- | ---
[spot.cloud_modules.aws_elastigroup](docs/examples/elastigroup/README.md)|Manage Spot Elastigroups
[spot.cloud_modules.aws_managed_instance](docs/examples/managed_instance/README.md)|Manage Spot Managed Instances
[spot.cloud_modules.aws_ocean_k8s](docs/examples/ocean/README.md)|Manage Spot Ocean Kubernetes Clusters
[spot.cloud_modules.aws_mrscaler](docs/examples/emr/README.md)|Manage Spot MR Scalers
[spot.cloud_modules.event_subscription](docs/examples/events/README.md)|Manage Spot Event Subscriptions
[spot.cloud_modules.aws_elastigroup](https://github.com/spotinst/spot-ansible-cloud-modules/blob/main/docs/examples/elastigroup/README.md)|Manage Spot Elastigroups
[spot.cloud_modules.aws_managed_instance](https://github.com/spotinst/spot-ansible-cloud-modules/blob/main/docs/examples/managed_instance/README.md)|Manage Spot Managed Instances
[spot.cloud_modules.aws_ocean_k8s](https://github.com/spotinst/spot-ansible-cloud-modules/blob/main/docs/examples/ocean/README.md)|Manage Spot Ocean Kubernetes Clusters
[spot.cloud_modules.aws_mrscaler](https://github.com/spotinst/spot-ansible-cloud-modules/blob/main/docs/examples/emr/README.md)|Manage Spot MR Scalers
[spot.cloud_modules.event_subscription](https://github.com/spotinst/spot-ansible-cloud-modules/blob/main/docs/examples/events/README.md)|Manage Spot Event Subscriptions
[spot.cloud_modules.azure_stateful_node](https://github.com/spotinst/spot-ansible-cloud-modules/blob/main/docs/examples/stateful_node/README.md)|Manage Azure Stateful Nodes
<!--end collection content-->

## Installing this collection
Expand All @@ -51,7 +52,7 @@ be manually installed using pip and from the collection project's root, running:
pip install requirements.txt
or:

pip install spotinst_sdk2>=2.1.15
pip install spotinst_sdk2>=2.1.29

## Using this collection

Expand All @@ -78,7 +79,7 @@ You can either call modules by their Fully Qualified Collection Namespace (`FQCN

## Migrating from Spot's previous modules

*This section does **not** apply to you if you are upgrading from a previous version of **this** collection.*
*This section does **not** apply to you if you are upgrading from a previous version of **this** collection.*

If you are migrating either from `community.general` or from previously having our `spotinst_aws_elastigroup` installed manually, please take note of the following breaking changes:

Expand All @@ -92,7 +93,7 @@ If you are migrating either from `community.general` or from previously having o

- Python `>=3.6` required.
- `spotinst_sdk2` (v2) required (your version may have required `spotinst_sdk` (v1)).
- All references to modules should be changed to `spot.cloud_modules.module_name`, according to the module names in [the modules section](#modules).
- All references to modules should be changed to `spot.cloud_modules.module_name`, according to the module names in [the modules section](#modules).
- Note: all modules have been renamed.

## Contributing
Expand Down
10 changes: 10 additions & 0 deletions changelogs/changelog.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
ancestor: null
releases:
1.1.0:
changes:
release_summary: New collection - adding all existing modules.
fragments:
- 1-1-0-summary.yml
modules:
- description: Create, update or delete Spot Azure Stateful Nodes
name: azure_stateful_node
namespace: ''
release_date: '2023-03-20'
1.0.0:
changes:
release_summary: New collection - adding all existing modules.
Expand Down
6 changes: 6 additions & 0 deletions docs/examples/stateful_node/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
## Azure Stateful Node
<!--ts-->
* [Create a Stateful Node](azure-stateful-node-detailed.yaml)
* [Perform an action on a Stateful Node](azure-stateful-node-with-action.yaml)
* [Delete a Stateful Node](azure-stateful-node-delete.yaml)
<!--te-->
79 changes: 79 additions & 0 deletions docs/examples/stateful_node/azure-stateful-node-delete.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
- hosts: localhost
tasks:
- name: stateful_node
spot.cloud_modules.azure_stateful_node:
state: absent # absent = delete, present = create/update
uniqueness_by: "id"
id: "ssn-648a40b1"
do_not_update:
- region
- resource_group_name
stateful_node_config:
deletion_config:
deallocation_config:
disk_deallocation_config:
should_deallocate: true
ttl_in_hours: 0
network_deallocation_config:
should_deallocate: true
ttl_in_hours: 0
public_ip_deallocation_config:
should_deallocate: true
ttl_in_hours: 0
snapshot_deallocation_config:
should_deallocate: true
ttl_in_hours: 0
should_terminate_vm: true
stateful_node:
name: "ansible-stateful-node-example-with-action"
description: "a sample Stateful Node created via Ansible"
region: "eastus"
resource_group_name: "AutomationResourceGroup"
persistence:
data_disks_persistence_mode: "reattach"
os_disk_persistence_mode: "reattach"
should_persist_data_disks: true
should_persist_network: true
should_persist_os_disk: true
health:
health_check_types: ["vmState"]
auto_healing: true
grace_period: 300
unhealthy_duration: 120
scheduling:
tasks:
- is_enabled: false
cron_expression: "* * * 1 *"
type: "pause"
- is_enabled: true
cron_expression: "* * * 2 *"
type: "resume"
strategy:
draining_timeout: 300
fallback_to_od: true
preferred_lifecycle: "spot"
revert_to_spot:
perform_at: "always"
signals:
- timeout: 180
type: "vmReady"
- timeout: 210
type: "vmReadyToShutdown"
compute:
zones: ["1", "2"]
preferred_zone: "2"
vm_sizes:
od_sizes: ["standard_a1_v2", "standard_a2_v2"]
spot_sizes: ["standard_a1_v2", "standard_a2_v2"]
preferred_spot_sizes: ["standard_a1_v2"]
launch_specification:
boot_diagnostics:
is_enabled: true
type: "managed"
tags:
- tag_key: "Creator"
tag_value: "Ansible Test"
- tag_key: "Name"
tag_value: "Ansible Detailed Example With Action"
register: result
- debug: var=result
93 changes: 93 additions & 0 deletions docs/examples/stateful_node/azure-stateful-node-detailed.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
- hosts: localhost
tasks:
- name: stateful_node
spot.cloud_modules.azure_stateful_node:
state: present # absent = delete, present = create/update
uniqueness_by: "id"
do_not_update:
- region
- resource_group_name
stateful_node:
name: "ansible-stateful-node-example"
description: "a sample Stateful Node created via Ansible"
region: "eastus"
resource_group_name: "AutomationResourceGroup"
persistence:
data_disks_persistence_mode: "reattach"
os_disk_persistence_mode: "reattach"
should_persist_data_disks: true
should_persist_network: true
should_persist_os_disk: true
health:
health_check_types: ["vmState"]
auto_healing: true
grace_period: 300
unhealthy_duration: 120
scheduling:
tasks:
- is_enabled: true
cron_expression: "* * * 1 *"
type: "pause"
- is_enabled: false
cron_expression: "* * * 2 *"
type: "resume"
strategy:
draining_timeout: 300
fallback_to_od: true
preferred_lifecycle: "spot"
revert_to_spot:
perform_at: "always"
signals:
- timeout: 180
type: "vmReady"
- timeout: 210
type: "vmReadyToShutdown"
compute:
os: "Linux"
zones: ["1", "2"]
preferred_zone: "2"
vm_sizes:
od_sizes: ["standard_a1_v2", "standard_a2_v2"]
spot_sizes: ["standard_a1_v2", "standard_a2_v2"]
preferred_spot_sizes: ["standard_a1_v2"]
launch_specification:
boot_diagnostics:
is_enabled: true
type: "managed"
custom_data: "VGhpcyBpcyBjdXN0b20gZGF0YSBmaWVsZA=="
data_disks:
- lun: 0
size_g_b: 30
type: "Standard_LRS"
- lun: 1
size_g_b: 32
type: "StandardSSD_LRS"
image:
marketplace:
publisher: "Canonical"
version: "latest"
sku: "18.04-LTS"
offer: "UbuntuServer"
login:
user_name: "ubuntu"
ssh_public_key: <provide-your-ssh-key-here>
network:
resource_group_name: "AutomationResourceGroup"
virtual_network_name: "Automation-VirtualNetwork"
network_interfaces:
- is_primary: true
assign_public_ip: true
public_ip_sku: "Standard"
subnet_name: "Automation-PrivateSubnet"
enable_ip_forwarding: true
os_disk:
size_g_b: 30
type: "Standard_LRS"
shutdown_script: "VGhpcyBpcyBzaHV0ZG93biBzY3JpcHQ="
tags:
- tag_key: "Creator"
tag_value: "Ansible Test"
- tag_key: "Name"
tag_value: "Ansible Detailed Example"
register: result
- debug: var=result
64 changes: 64 additions & 0 deletions docs/examples/stateful_node/azure-stateful-node-with-action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
- hosts: localhost
tasks:
- name: stateful_node
spot.cloud_modules.azure_stateful_node:
state: present # absent = delete, present = create/update
uniqueness_by: "id"
id: "ssn-648a40b1"
do_not_update:
- region
- resource_group_name
action: "pause" # resume, recycle <------ if you would just like to perform an action, leave all other fields as is and include this line.
stateful_node:
name: "ansible-stateful-node-example-with-action"
description: "a sample Stateful Node created via Ansible"
region: "eastus"
resource_group_name: "AutomationResourceGroup"
persistence:
data_disks_persistence_mode: "reattach"
os_disk_persistence_mode: "reattach"
should_persist_data_disks: true
should_persist_network: true
should_persist_os_disk: true
health:
health_check_types: ["vmState"]
auto_healing: true
grace_period: 300
unhealthy_duration: 120
scheduling:
tasks:
- is_enabled: false
cron_expression: "* * * 1 *"
type: "pause"
- is_enabled: true
cron_expression: "* * * 2 *"
type: "resume"
strategy:
draining_timeout: 300
fallback_to_od: true
preferred_lifecycle: "spot"
revert_to_spot:
perform_at: "always"
signals:
- timeout: 180
type: "vmReady"
- timeout: 210
type: "vmReadyToShutdown"
compute:
zones: ["1", "2"]
preferred_zone: "2"
vm_sizes:
od_sizes: ["standard_a1_v2", "standard_a2_v2"]
spot_sizes: ["standard_a1_v2", "standard_a2_v2"]
preferred_spot_sizes: ["standard_a1_v2"]
launch_specification:
boot_diagnostics:
is_enabled: true
type: "managed"
tags:
- tag_key: "Creator"
tag_value: "Ansible Test"
- tag_key: "Name"
tag_value: "Ansible Detailed Example With Action"
register: result
- debug: var=result
6 changes: 3 additions & 3 deletions galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace: spot
name: cloud_modules

# The version of the collection. Must be compatible with semantic versioning
version: 1.0.0
version: 1.1.0

# The path to the Markdown (.md) readme file. This path is relative to the root of the collection
readme: README.md
Expand All @@ -19,7 +19,7 @@ authors:
- Shibel - Spot by NetApp <shibel@netapp.com>
- Noam - Spot by NetApp <noam.stern@netapp.com>
- Ziv - Spot by NetApp <ziv.messing@netapp.com>

- Anurag - Spot by NetApp <anurag.sharma@netapp.com>

# A short summary description of the collection
description: Manage your Spot resources with Ansible
Expand All @@ -29,7 +29,7 @@ license_file: LICENSE.txt

# A list of tags you want to associate with the collection for indexing/searching. A tag name has the same character
# requirements as 'namespace' and 'name'
tags: ["cloud", "netapp", "aws", "emr", "ec2", "infrastructure", "spot"]
tags: ["cloud", "netapp", "aws", "emr", "ec2", "infrastructure", "spot", "azure"]

# Collections that this collection requires to be installed for it to be usable. The key of the dict is the
# collection label 'namespace.name'. The value is a version range
Expand Down
Loading

0 comments on commit 6c28347

Please sign in to comment.