ansible-collections / google.cloud

GCP Ansible Collection https://galaxy.ansible.com/google/cloud
https://cloud.google.com
GNU General Public License v3.0
98 stars 124 forks source link

Apply Resource Policy to Compute Instance #323

Open ChrisCoe opened 3 years ago

ChrisCoe commented 3 years ago
SUMMARY

Hello, I hope you all are doing well.

Ansible collection does not allow creating an instance under a resource policy. I have to use the gcloud sdk to currently bring my VMs in a COLLOCATED placement policy which a resource policy provides. Ansible can create both resource policy and instance, but no way for them to play together which breaks my heart. I don't mind installing gcloud solely to connect these components together, but a better way is this feature. Have some way to apply a resource policy to a vm instance. For example, have a field in instance module to follow a resource policy during creation.

This PR tried to complete this feature but ran into quota errors (https://github.com/ansible-collections/google.cloud/pull/194). I'm able to apply resource policies to instances while consistently avoiding the quota errors I encountered with a work around I gathered through the documentation. Seems to me like quota errors should not stop this feature request.

Thank you.

ISSUE TYPE
COMPONENT NAME

gcp_compute_resource_policy field for google.cloud.gcp_compute_instance module.

ADDITIONAL INFORMATION

Forums about quota error mentioned above : https://groups.google.com/g/gce-discussion/c/asJA71NDkZM/m/2qon8TQZBQAJ https://groups.google.com/g/gce-discussion/c/Lfyk38giqK8

rambleraptor commented 3 years ago

Hi Christian!

Thanks so much for submitting this issue. I guess I'm a little confused about the problem. It sounds like the Ansible module supports this feature, but either a quota issue on your project or potentially a GCE-wide quota issue is stopping the issue from working properly?

I'm not aware of a situation where the Ansible module could fix either of these. Both of them require manual intervention. In the case of a personal quota issue, I believe you have to file a support ticket (or talk to your org administrator) to get your quota increased.

Do you have any more context about what you'd like the Ansible module to do in this situation?

ChrisCoe commented 3 years ago

Hi Alex!

Sure, I can explain better. Ansible supports creating an instance, and creating a resource policy in google cloud. Ansible does not support applying a resource policy to an instance which I find odd. That's the main problem I wish to address. My proposal for this is to create a new field when creating an instance to specify a resource policy; there are different ways to tackle the problem.

Context: I would like to have instances that are physically close to each other as mush as possible in the data center and compact placement provides this (https://cloud.google.com/compute/docs/instances/define-instance-placement). The only way to achieve this close placement is by defining a resource policy, and then having some instances follow that policy. I'm able to achieve this with some gcloud commands outside of Ansible without running into quota issues.

The talk about quotas was just me speculating why this may not have been done before.

sean-freeman commented 1 month ago

πŸ‘‹ Resurrecting this GH Issue, calling attention to active maintainers @toumorokoshi , @SirGitsalot , @alinabuzachis .

TL;DR:

Bluntly speaking, this is a 1 field (type: list) append to the Ansible Module's Python code. It's an easy fix that should have been delivered 4 years ago when it was initially raised.

Context:

To re-state the problem, the REST API allows insert of Resource Policy/ies and subsequent insert of GCP CE VM instance/s with 1..n Resource Policies assigned.

See REST API documentation for GCP CE VM Instance, with top-level field resourcePolicies[] to provide "Resource policies applied to this instance" : https://cloud.google.com/compute/docs/reference/rest/v1/instances/insert#body.request_body.FIELDS.resource_policy

Problem Summary:

The top-level field is missing from google.cloud.gcp_compute_instance, and therefore Ansible cannot create GCP CE VM with "Compact Placement Policy" or "Spread Placement Policy".

The latter impacts SAP on GCP deployments via the Ansible Collection community.sap_infrastructure from the SAP LinuxLab Open-Source Initiative, which provides equalised deployments of SAP Software Scenarios across multiple Infrastructure Platforms.

Ansible Collection functionality to "Provision VM with a Spread Placement" is provided by all other Cloud IaaS vendors.

toumorokoshi commented 1 month ago

πŸ‘‹ Resurrecting this GH Issue, calling attention to active maintainers @toumorokoshi

Unfortunately I'm no longer a maintainer - I left Google a little while back. But @SirGitsalot should be able to help!