Commit graph

766 commits

Author SHA1 Message Date
Vi P
bf6d45eecd
Merge 307839b810 into 61bd3d1c13 2025-07-30 21:03:10 +00:00
Chris Hawk
02c4a83263 Fix an invalid format string on Python 2.7 2025-07-29 15:38:43 -07:00
Chris Hawk
2ed1936ad8
Merge pull request #693 from thekad/feature/bucket_policy
Some checks are pending
Run integration tests for the cloud.google collection / integration (stable-2.16) (push) Waiting to run
Run integration tests for the cloud.google collection / integration (stable-2.17) (push) Waiting to run
Run integration tests for the cloud.google collection / integration (stable-2.18) (push) Waiting to run
Add iamConfiguration support to gcp_storage_bucket
2025-07-29 15:25:49 -07:00
Chris Hawk
79504d54d6
Merge pull request #694 from thekad/feature/nested_bigquery_schema
Feature/nested bigquery schema
2025-07-29 15:17:43 -07:00
Chris Hawk
0bf24440d1
Merge pull request #684 from durgesh-ninave-crest/add-support-for-parameter-manager-module-lookup
Some checks failed
Run integration tests for the cloud.google collection / integration (stable-2.16) (push) Has been cancelled
Run integration tests for the cloud.google collection / integration (stable-2.17) (push) Has been cancelled
Run integration tests for the cloud.google collection / integration (stable-2.18) (push) Has been cancelled
feat(parametermanager): added support for parameter manager module and lookup
2025-07-16 12:29:03 -07:00
Jorge Gallegos
63d7025012
Let fields be sent raw in table schema definition
As per https://cloud.google.com/bigquery/docs/reference/rest/v2/tables#TableFieldSchema
the `fields` attribute can recursively define more fields if the `type`
attribute is RECORD. There is no way to define recursive argument spec
in ansible modules, but if sent as `raw`:

> The raw type, performs no type validation or type casting, and maintains the type of the passed value.

(from https://docs.ansible.com/ansible/latest/dev_guide/developing_program_flow_modules.html#argument-spec)

Which works for what we're trying to accomplish here.

Also added integration test for this change
2025-06-27 12:15:39 -06:00
Jorge Gallegos
577debb433
According to docs, these fields are all mandatory
If you specify table_reference, you should specify all 3 fields as per
docs https://cloud.google.com/bigquery/docs/reference/rest/v2/TableReference
2025-06-27 12:10:15 -06:00
Jorge Gallegos
f9f0b33542
Add iamConfiguration support to gcp_storage_bucket
You can now set the iam configuration for a given bucket, you can set:
1. publicAccessPrevention and
2. uniformBucketLevelAccess

no support for bucketPolicyOnly because according to the storage docs:

Note: iamConfiguration also includes the bucketPolicyOnly field, which
uses a legacy name but has the same functionality as the
uniformBucketLevelAccess field. We recommend only using
uniformBucketLevelAccess, as specifying both fields may result in
unreliable behavior.

Also added integration tests for this feature

Signed-off-by: Jorge Gallegos <jgallego@redhat.com>
2025-06-26 12:04:25 -06:00
Chris Hawk
83c593d943
Merge pull request #685 from durgesh-ninave-crest/add-support-for-regional-secret-manager
Some checks failed
Run integration tests for the cloud.google collection / integration (stable-2.16) (push) Has been cancelled
Run integration tests for the cloud.google collection / integration (stable-2.17) (push) Has been cancelled
Run integration tests for the cloud.google collection / integration (stable-2.18) (push) Has been cancelled
feat(secretmanager): added support for regional secret manager
2025-06-20 13:47:49 -07:00
Chris Hawk
af3498daff
Merge pull request #691 from thekad/docs/serviceusage_service
Updated documentation for gcp_serviceusage_service
2025-06-20 13:20:56 -07:00
Chris Hawk
4eec57c4e1
Merge pull request #690 from thekad/feature/clearer_secret_manager_message
Clear up error responses from gcp_secret_manager lookup
2025-06-20 13:17:42 -07:00
Chris Hawk
43d8fd6960
Merge pull request #689 from thekad/feature/inventory_hostname
Adding hostname support to dynamic inventory
2025-06-20 13:16:35 -07:00
Jorge Gallegos
dfa3613d79
Updated documentation for gcp_serviceusage_service
You need the API enabled in order to use it first.

Signed-off-by: Jorge Gallegos <jgallego@redhat.com>
2025-06-11 14:50:55 -07:00
Jorge Gallegos
c9775be63e
Clear up error responses from gcp_secret_manager lookup
The wording of the raised exception wasn't great, adding a bit more
granularity to the type of error returned

Signed-off-by: Jorge Gallegos <jgallego@redhat.com>
2025-06-10 17:27:26 -07:00
Jorge Gallegos
3e3611fb23
Adding hostname support to dynamic inventory
Fixes #434

It is basically the same as #438 but with a few extra checks, don't want
to rebase the whole thing.

Signed-off-by: Jorge Gallegos <jgallego@redhat.com>
2025-06-09 13:32:14 -07:00
Jorge Gallegos
81fbe1debe
Add support for nicType
Fixes #645

You can now specify the type of NIC attached to your VM

Signed-off-by: Jorge Gallegos <jgallego@redhat.com>
2025-06-05 18:53:57 -07:00
durgesh-ninave-crest
ccdc27f22a fix sanity test issue 2025-06-05 17:27:52 +05:30
durgesh-ninave-crest
ac08c81321 fix sanity test issues 2025-06-05 12:00:49 +05:30
Jorge Gallegos
41f6d22780
Sanity fixes 2025-05-28 12:44:46 -07:00
Jorge Gallegos
6ee6b698ef
Add discard_local_ssd flag to compute instance
If you have an instance with a Local (scratch) SSD attached you need to
specify the behavior for this when changing the status to TERMINATED
i.e. stopping the instance. Without setting this flag you'll get an
error back from the API.
2025-05-28 12:33:59 -07:00
durgesh-ninave-crest
695fd4b355 update documentation of module and lookup 2025-05-19 18:15:57 +05:30
durgesh-ninave-crest
9101671c0e feat(secretmanager): added support for regional secret manager 2025-05-13 18:36:36 +05:30
durgesh-ninave-crest
342a0b2f95 feat(parametermanager): added support for parameter manager module and lookup 2025-05-13 17:58:24 +05:30
Bill Peck
fdcf1fa1fd
Fix get_project_disks to process all responses
The code to process the reponses was not indented correctly so it would
only process the last projects response.

Fixes #651
2025-04-02 12:39:00 -04:00
Vi P
307839b810
Remove plugin option from inventory config for compatibility with passthrough plugins
One niche but useful feature of Ansible inventory plugins is the ability to call one plugin from another. For example, you can write a custom plugin (`my.plugin.multi_cloud`) that acts as a sort of normalization interface between project inventories deployed on multiple cloud platforms. This makes it feasible to create a single set of Ansible Playbooks that can act on hosts across cloud platforms because they can expect managed node (inventory host) data to be consistent across those cloud platform vendors.

For example, `my.plugin.multi_cloud` inventory plugin might look something like the following code, which simply dynamically loads one or another underlying (upstream) vendor'ed inventory plugins based on the value of the shell environment variable called `CLOUD_PLATFORM`:

```python
#!/usr/bin/env python3

from ansible.errors import AnsibleError, AnsibleParserError
from ansible.plugins.inventory import BaseInventoryPlugin
from ansible.plugins.loader import inventory_loader
import os

class InventoryModule(BaseInventoryPlugin):

    def parse(self, inventory, loader, path, cache=True):
        super(InventoryModule, self).parse(inventory, loader, path)

        # Map the cloud platform to the appropriate vendor's inventory plugin.
        cloud_platform = os.environ.get('CLOUD_PLATFORM', '').lower()
        if cloud_platform == 'aws':
            plugin_fqcn = 'amazon.aws.aws_ec2'
        elif cloud_platform == 'gcp':
            plugin_fqcn = 'google.cloud.gcp_compute'
        else:
            raise AnsibleParserError(
                    f"Error: Unrecognized or unset cloud platform '{cloud_platform}'. "
                    f"Set ENTROPY_CLOUD_PLATFORM to 'aws' or 'gcp'.\n"
            )

        if not inventory_loader.has_plugin(plugin_fqcn):
            raise AnsibleParserError(f"Error: '{plugin_fqcn}' inventory plugin not found.\n")

        # Load the requested plugin.
        self.inventory_plugin = inventory_loader.get(plugin_fqcn)
```

In the above example, we see code loading either this `google.cloud.gcp_compute` inventory plugin or Amazon's `amazon.aws.aws_ec2` inventory plugin.

Later, we can invoke the underlying (upstream) plugin in a passthrough manner like this:

```python
        # Passthrough to the underlying plugin.
        if self.inventory_plugin.verify_file(path):
            self.inventory_plugin.parse(inventory, loader, path)
        else:
            raise AnsibleParserError(f"Error: Inventory configuration file '{path}' failed verification by plugin '{plugin_fqcn}'")
```

However, in order for this to work, we must supply the underlying plugin with knowledge of the fact that we are calling it from a different actual plugin. This is facilitated via Ansible's built in `_redirected_names` class property. Before calling the underlying plugin's `parse()` method, we must first do:

```python
        self.inventory_plugin._redirected_names.append(InventoryModule.NAME)
```

Now the underlying plugin will be permitted to run because the underlying plugin is informing Ansible that one of the names it is permitted to use is this "redirected" (aliased) name of the calling plugin. We have effectively monkey-patched the plugin during runtime, which is exactly what we want.

Unfortunately, for _this_ `google.cloud.gcp_compute` inventory plugin, that's not enough, because of the fact that the `plugin` option in its configuration file is also checked and compared against this same name. That's something that, for example, the `amazon.aws.aws_ec2` inventory plugin _doesn't_ do, and for good reason: enforcing this check with hardcoded options breaks the built-in functionality of the Ansible module loading alias features.

That's why I'm suggesting we remove this option. It isn't needed for the `auto` inventory plugin to load the plugin correctly, nor does it ever really need to be checked once this plugin is actually running; it's already running! But its presence _does_ break existing Ansible features, and makes the above use case of a pass-through plugin, for example, infeasible.

Thanks for considering this proposal.
2025-03-14 23:12:41 -04:00
Chris Hawk
5ebc615a48 Fix doc lint errors in gcp_pubsub_subscription 2025-01-10 14:52:33 -08:00
Chris Hawk
25d53ff320 Merge branch 'master' into issue-613 2025-01-10 13:59:02 -08:00
Chris Hawk
5a395e234f
Merge pull request #652 from gomesfernandes/fix/bigquery-clustering-fields
fix: google.cloud.gcp_bigquery_table clustering fields
2024-11-11 17:05:12 -08:00
Chris Hawk
d719b0efaa
Fix a YAML doc parsing error in gcp_pubsub_subscription.py 2024-11-11 16:49:34 -08:00
Chris Hawk
68c9af276c
Update gcp_pubsub_subscription.py
Fix lint errors
2024-11-11 16:40:47 -08:00
Sieradzki, Lukasz
e89571eb91 https://github.com/ansible-collections/google.cloud/issues/657 2024-11-08 23:03:14 +01:00
Sieradzki, Lukasz
2b35fbf404 https://github.com/ansible-collections/google.cloud/issues/657 2024-11-08 23:02:23 +01:00
Sieradzki, Lukasz
8b9a2c70dd https://github.com/ansible-collections/google.cloud/issues/657 2024-11-08 18:46:49 +01:00
Sieradzki, Lukasz
6794d18478 https://github.com/ansible-collections/google.cloud/issues/653 2024-11-07 11:02:53 +01:00
Chris Hawk
537707deef Fix a compute_backend_service permadiff 2024-11-06 16:16:00 -08:00
Chris Hawk
608a8486e3 Fix many documentation lint errors 2024-11-05 14:58:14 -08:00
Chris Hawk
1a7d4e3cda Add many no_log attributes 2024-11-05 14:06:56 -08:00
Sieradzki, Lukasz
0e9c32fcde https://github.com/ansible-collections/google.cloud/issues/653 2024-11-04 21:01:26 +01:00
Chris Hawk
78b36fe3b6 Fix lint errors in the gcp_secret_manager lookup plugin 2024-11-04 10:28:23 -08:00
Chris Hawk
22804f0cdc Fix lint errors in the gcp_compute lookup plugin 2024-11-04 10:18:57 -08:00
Caty Gomes Fernandes
30858618e5 fix: gcp_bigquery_table clustering payload 2024-10-31 18:20:15 +01:00
Chris Hawk
83e84e80d5 Add a basic DOCUMENTATION string for gcp_kms_filters.py 2024-08-22 16:04:26 -07:00
Chris Hawk
bc7313854d Remove an f-string usage for backward compatibility 2024-08-22 15:40:29 -07:00
Ivan Fernandez Calvo
f7140225a8
fix: support more than 10 secrets versions on gcp_secret_manager 2024-05-23 12:31:26 +02:00
Chris Hawk
a9c0624bbd
Merge pull request #578 from dcostakos/gcp_secret_manager
Adding support for Google Secret Manager for issue 543
2024-05-22 14:41:07 -07:00
Chris Hawk
811327bc09 chore: removed unused imports 2023-11-20 11:17:25 -08:00
Chris Hawk
661f114037 chore: fix a line length lint error 2023-11-17 16:47:05 -08:00
Chris Hawk
08ada5354d fix: upgrade ansible version, address test and lint errors 2023-11-17 16:39:42 -08:00
John Jarvis
3714be2936
fix: check for labels in json dict 2023-08-30 18:44:42 +02:00
Alina Buzachis
84503b7930
Fix doc_fragments/gcp.py (#587)
Signed-off-by: Alina Buzachis <abuzachis@redhat.com>
2023-07-22 00:31:54 +00:00