summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnsible Core Team <info@ansible.com>2020-03-09 09:40:37 +0000
committerAnsible Core Team <info@ansible.com>2020-03-09 09:40:37 +0000
commit174b9c0e4ce30e5c47b44318e35a782a7713c710 (patch)
tree75a9c4a34fbaded9ee9f760dc26c478d18e237c6
parent775a89254535f6698d191432b80caf8163321b6f (diff)
downloadansible-174b9c0e4ce30e5c47b44318e35a782a7713c710.tar.gz
Migrated to google.cloud
-rw-r--r--lib/ansible/module_utils/gcp_utils.py452
-rw-r--r--lib/ansible/modules/cloud/google/gcp_appengine_firewall_rule.py325
-rw-r--r--lib/ansible/modules/cloud/google/gcp_appengine_firewall_rule_info.py186
-rw-r--r--lib/ansible/modules/cloud/google/gcp_bigquery_dataset.py745
-rw-r--r--lib/ansible/modules/cloud/google/gcp_bigquery_dataset_info.py351
-rw-r--r--lib/ansible/modules/cloud/google/gcp_bigquery_table.py1703
-rw-r--r--lib/ansible/modules/cloud/google/gcp_bigquery_table_info.py626
-rw-r--r--lib/ansible/modules/cloud/google/gcp_cloudbuild_trigger.py961
-rw-r--r--lib/ansible/modules/cloud/google/gcp_cloudbuild_trigger_info.py411
-rw-r--r--lib/ansible/modules/cloud/google/gcp_cloudfunctions_cloud_function.py693
-rw-r--r--lib/ansible/modules/cloud/google/gcp_cloudfunctions_cloud_function_info.py309
-rw-r--r--lib/ansible/modules/cloud/google/gcp_cloudscheduler_job.py952
-rw-r--r--lib/ansible/modules/cloud/google/gcp_cloudscheduler_job_info.py396
-rw-r--r--lib/ansible/modules/cloud/google/gcp_cloudtasks_queue.py630
-rw-r--r--lib/ansible/modules/cloud/google/gcp_cloudtasks_queue_info.py301
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_address.py467
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_address_info.py265
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_autoscaler.py768
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_autoscaler_info.py327
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_backend_bucket.py437
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_backend_bucket_info.py240
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_backend_service.py1143
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_backend_service_info.py476
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_disk.py771
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_disk_info.py402
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_firewall.py810
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_firewall_info.py369
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_forwarding_rule.py707
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_forwarding_rule_info.py355
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_global_address.py466
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_global_address_info.py257
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_global_forwarding_rule.py764
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_global_forwarding_rule_info.py337
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_health_check.py1244
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_health_check_info.py525
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_http_health_check.py458
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_http_health_check_info.py257
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_https_health_check.py455
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_https_health_check_info.py257
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_image.py818
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_image_info.py388
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_instance.py1850
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_instance_group.py562
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_instance_group_info.py266
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_instance_group_manager.py621
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_instance_group_manager_info.py341
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_instance_info.py650
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_instance_template.py1661
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_instance_template_info.py608
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_interconnect_attachment.py584
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_interconnect_attachment_info.py337
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_network.py440
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_network_endpoint_group.py453
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_network_endpoint_group_info.py246
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_network_info.py249
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_node_group.py416
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_node_group_info.py223
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_node_template.py436
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_node_template_info.py247
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_region_backend_service.py778
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_region_backend_service_info.py375
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_region_disk.py672
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_region_disk_info.py346
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_reservation.py665
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_reservation_info.py312
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_route.py538
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_route_info.py271
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_router.py552
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_router_info.py276
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_snapshot.py569
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_snapshot_info.py294
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_ssl_certificate.py396
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_ssl_certificate_info.py224
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_ssl_policy.py458
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_ssl_policy_info.py262
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_subnetwork.py559
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_subnetwork_info.py274
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_target_http_proxy.py420
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_target_http_proxy_info.py218
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_target_https_proxy.py547
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_target_https_proxy_info.py241
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_target_instance.py419
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_target_instance_info.py231
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_target_pool.py521
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_target_pool_info.py277
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_target_ssl_proxy.py534
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_target_ssl_proxy_info.py237
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_target_tcp_proxy.py440
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_target_tcp_proxy_info.py223
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_target_vpn_gateway.py402
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_target_vpn_gateway_info.py239
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_url_map.py5077
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_url_map_info.py1659
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_vpn_tunnel.py516
-rw-r--r--lib/ansible/modules/cloud/google/gcp_compute_vpn_tunnel_info.py272
-rw-r--r--lib/ansible/modules/cloud/google/gcp_container_cluster.py2055
-rw-r--r--lib/ansible/modules/cloud/google/gcp_container_cluster_info.py767
-rw-r--r--lib/ansible/modules/cloud/google/gcp_container_node_pool.py1099
-rw-r--r--lib/ansible/modules/cloud/google/gcp_container_node_pool_info.py452
-rw-r--r--lib/ansible/modules/cloud/google/gcp_dns_managed_zone.py674
-rw-r--r--lib/ansible/modules/cloud/google/gcp_dns_managed_zone_info.py294
-rw-r--r--lib/ansible/modules/cloud/google/gcp_dns_resource_record_set.py497
-rw-r--r--lib/ansible/modules/cloud/google/gcp_dns_resource_record_set_info.py197
-rw-r--r--lib/ansible/modules/cloud/google/gcp_filestore_instance.py565
-rw-r--r--lib/ansible/modules/cloud/google/gcp_filestore_instance_info.py249
-rw-r--r--lib/ansible/modules/cloud/google/gcp_iam_role.py353
-rw-r--r--lib/ansible/modules/cloud/google/gcp_iam_role_info.py192
-rw-r--r--lib/ansible/modules/cloud/google/gcp_iam_service_account.py303
-rw-r--r--lib/ansible/modules/cloud/google/gcp_iam_service_account_info.py191
-rw-r--r--lib/ansible/modules/cloud/google/gcp_iam_service_account_key.py315
-rw-r--r--lib/ansible/modules/cloud/google/gcp_kms_crypto_key.py427
-rw-r--r--lib/ansible/modules/cloud/google/gcp_kms_crypto_key_info.py223
-rw-r--r--lib/ansible/modules/cloud/google/gcp_kms_key_ring.py295
-rw-r--r--lib/ansible/modules/cloud/google/gcp_kms_key_ring_info.py187
-rw-r--r--lib/ansible/modules/cloud/google/gcp_logging_metric.py805
-rw-r--r--lib/ansible/modules/cloud/google/gcp_logging_metric_info.py331
-rw-r--r--lib/ansible/modules/cloud/google/gcp_mlengine_model.py417
-rw-r--r--lib/ansible/modules/cloud/google/gcp_mlengine_model_info.py205
-rw-r--r--lib/ansible/modules/cloud/google/gcp_mlengine_version.py627
-rw-r--r--lib/ansible/modules/cloud/google/gcp_mlengine_version_info.py297
-rw-r--r--lib/ansible/modules/cloud/google/gcp_pubsub_subscription.py669
-rw-r--r--lib/ansible/modules/cloud/google/gcp_pubsub_subscription_info.py293
-rw-r--r--lib/ansible/modules/cloud/google/gcp_pubsub_topic.py377
-rw-r--r--lib/ansible/modules/cloud/google/gcp_pubsub_topic_info.py197
-rw-r--r--lib/ansible/modules/cloud/google/gcp_redis_instance.py543
-rw-r--r--lib/ansible/modules/cloud/google/gcp_redis_instance_info.py268
-rw-r--r--lib/ansible/modules/cloud/google/gcp_resourcemanager_project.py412
-rw-r--r--lib/ansible/modules/cloud/google/gcp_resourcemanager_project_info.py218
-rw-r--r--lib/ansible/modules/cloud/google/gcp_runtimeconfig_config.py273
-rw-r--r--lib/ansible/modules/cloud/google/gcp_runtimeconfig_config_info.py171
-rw-r--r--lib/ansible/modules/cloud/google/gcp_runtimeconfig_variable.py321
-rw-r--r--lib/ansible/modules/cloud/google/gcp_runtimeconfig_variable_info.py187
-rw-r--r--lib/ansible/modules/cloud/google/gcp_serviceusage_service.py440
-rw-r--r--lib/ansible/modules/cloud/google/gcp_serviceusage_service_info.py214
-rw-r--r--lib/ansible/modules/cloud/google/gcp_sourcerepo_repository.py292
-rw-r--r--lib/ansible/modules/cloud/google/gcp_sourcerepo_repository_info.py178
-rw-r--r--lib/ansible/modules/cloud/google/gcp_spanner_database.py377
-rw-r--r--lib/ansible/modules/cloud/google/gcp_spanner_database_info.py192
-rw-r--r--lib/ansible/modules/cloud/google/gcp_spanner_instance.py405
-rw-r--r--lib/ansible/modules/cloud/google/gcp_spanner_instance_info.py194
-rw-r--r--lib/ansible/modules/cloud/google/gcp_sql_database.py359
-rw-r--r--lib/ansible/modules/cloud/google/gcp_sql_database_info.py194
-rw-r--r--lib/ansible/modules/cloud/google/gcp_sql_instance.py1190
-rw-r--r--lib/ansible/modules/cloud/google/gcp_sql_instance_info.py471
-rw-r--r--lib/ansible/modules/cloud/google/gcp_sql_user.py392
-rw-r--r--lib/ansible/modules/cloud/google/gcp_sql_user_info.py195
-rw-r--r--lib/ansible/modules/cloud/google/gcp_storage_bucket.py1318
-rw-r--r--lib/ansible/modules/cloud/google/gcp_storage_bucket_access_control.py375
-rw-r--r--lib/ansible/modules/cloud/google/gcp_storage_object.py322
-rw-r--r--lib/ansible/modules/cloud/google/gcp_tpu_node.py524
-rw-r--r--lib/ansible/modules/cloud/google/gcp_tpu_node_info.py252
-rw-r--r--lib/ansible/plugins/inventory/gcp_compute.py616
-rw-r--r--test/integration/targets/gcp_appengine_firewall_rule/aliases2
-rw-r--r--test/integration/targets/gcp_appengine_firewall_rule/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_appengine_firewall_rule/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_appengine_firewall_rule/tasks/autogen.yml108
-rw-r--r--test/integration/targets/gcp_appengine_firewall_rule/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_bigquery_dataset/aliases2
-rw-r--r--test/integration/targets/gcp_bigquery_dataset/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_bigquery_dataset/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_bigquery_dataset/tasks/autogen.yml108
-rw-r--r--test/integration/targets/gcp_bigquery_dataset/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_bigquery_table/aliases2
-rw-r--r--test/integration/targets/gcp_bigquery_table/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_bigquery_table/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_bigquery_table/tasks/autogen.yml149
-rw-r--r--test/integration/targets/gcp_bigquery_table/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_cloudbuild_trigger/aliases2
-rw-r--r--test/integration/targets/gcp_cloudbuild_trigger/defaults/main.yml3
-rw-r--r--test/integration/targets/gcp_cloudbuild_trigger/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_cloudfunctions_cloud_function/aliases2
-rw-r--r--test/integration/targets/gcp_cloudfunctions_cloud_function/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_cloudfunctions_cloud_function/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_cloudfunctions_cloud_function/tasks/autogen.yml120
-rw-r--r--test/integration/targets/gcp_cloudfunctions_cloud_function/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_cloudscheduler_job/aliases2
-rw-r--r--test/integration/targets/gcp_cloudscheduler_job/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_cloudscheduler_job/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_cloudscheduler_job/tasks/autogen.yml155
-rw-r--r--test/integration/targets/gcp_cloudscheduler_job/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_cloudtasks_queue/aliases2
-rw-r--r--test/integration/targets/gcp_cloudtasks_queue/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_cloudtasks_queue/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_cloudtasks_queue/tasks/autogen.yml105
-rw-r--r--test/integration/targets/gcp_cloudtasks_queue/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_address/aliases2
-rw-r--r--test/integration/targets/gcp_compute_address/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_address/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_address/tasks/autogen.yml109
-rw-r--r--test/integration/targets/gcp_compute_address/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_autoscaler/aliases2
-rw-r--r--test/integration/targets/gcp_compute_autoscaler/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_autoscaler/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_autoscaler/tasks/autogen.yml251
-rw-r--r--test/integration/targets/gcp_compute_autoscaler/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_backend_bucket/aliases2
-rw-r--r--test/integration/targets/gcp_compute_backend_bucket/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_backend_bucket/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_backend_bucket/tasks/autogen.yml137
-rw-r--r--test/integration/targets/gcp_compute_backend_bucket/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_backend_service/aliases2
-rw-r--r--test/integration/targets/gcp_compute_backend_service/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_backend_service/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_backend_service/tasks/autogen.yml174
-rw-r--r--test/integration/targets/gcp_compute_backend_service/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_disk/aliases2
-rw-r--r--test/integration/targets/gcp_compute_disk/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_disk/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_disk/tasks/autogen.yml124
-rw-r--r--test/integration/targets/gcp_compute_disk/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_firewall/aliases2
-rw-r--r--test/integration/targets/gcp_compute_firewall/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_firewall/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_firewall/tasks/autogen.yml147
-rw-r--r--test/integration/targets/gcp_compute_firewall/tasks/main.yml3
-rw-r--r--test/integration/targets/gcp_compute_firewall/tasks/update.yml179
-rw-r--r--test/integration/targets/gcp_compute_forwarding_rule/aliases2
-rw-r--r--test/integration/targets/gcp_compute_forwarding_rule/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_forwarding_rule/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_forwarding_rule/tasks/autogen.yml170
-rw-r--r--test/integration/targets/gcp_compute_forwarding_rule/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_global_address/aliases2
-rw-r--r--test/integration/targets/gcp_compute_global_address/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_global_address/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_global_address/tasks/autogen.yml102
-rw-r--r--test/integration/targets/gcp_compute_global_address/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_global_forwarding_rule/aliases2
-rw-r--r--test/integration/targets/gcp_compute_global_forwarding_rule/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_global_forwarding_rule/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_global_forwarding_rule/tasks/autogen.yml251
-rw-r--r--test/integration/targets/gcp_compute_global_forwarding_rule/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_health_check/aliases2
-rw-r--r--test/integration/targets/gcp_compute_health_check/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_health_check/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_health_check/tasks/autogen.yml142
-rw-r--r--test/integration/targets/gcp_compute_health_check/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_http_health_check/aliases2
-rw-r--r--test/integration/targets/gcp_compute_http_health_check/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_http_health_check/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_http_health_check/tasks/autogen.yml122
-rw-r--r--test/integration/targets/gcp_compute_http_health_check/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_https_health_check/aliases2
-rw-r--r--test/integration/targets/gcp_compute_https_health_check/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_https_health_check/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_https_health_check/tasks/autogen.yml122
-rw-r--r--test/integration/targets/gcp_compute_https_health_check/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_image/aliases2
-rw-r--r--test/integration/targets/gcp_compute_image/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_image/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_image/tasks/autogen.yml129
-rw-r--r--test/integration/targets/gcp_compute_image/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_instance/aliases2
-rw-r--r--test/integration/targets/gcp_compute_instance/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_instance/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_instance/tasks/autogen.yml276
-rw-r--r--test/integration/targets/gcp_compute_instance/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_instance_group/aliases2
-rw-r--r--test/integration/targets/gcp_compute_instance_group/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_instance_group/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_instance_group/tasks/autogen.yml149
-rw-r--r--test/integration/targets/gcp_compute_instance_group/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_instance_group_manager/aliases2
-rw-r--r--test/integration/targets/gcp_compute_instance_group_manager/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_instance_group_manager/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_instance_group_manager/tasks/autogen.yml206
-rw-r--r--test/integration/targets/gcp_compute_instance_group_manager/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_instance_template/aliases2
-rw-r--r--test/integration/targets/gcp_compute_instance_template/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_instance_template/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_instance_template/tasks/autogen.yml206
-rw-r--r--test/integration/targets/gcp_compute_instance_template/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_interconnect_attachment/aliases2
-rw-r--r--test/integration/targets/gcp_compute_interconnect_attachment/defaults/main.yml3
-rw-r--r--test/integration/targets/gcp_compute_interconnect_attachment/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_network/aliases2
-rw-r--r--test/integration/targets/gcp_compute_network/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_network/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_network/tasks/autogen.yml107
-rw-r--r--test/integration/targets/gcp_compute_network/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_network_endpoint_group/aliases2
-rw-r--r--test/integration/targets/gcp_compute_network_endpoint_group/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_network_endpoint_group/tasks/autogen.yml169
-rw-r--r--test/integration/targets/gcp_compute_network_endpoint_group/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_node_group/aliases2
-rw-r--r--test/integration/targets/gcp_compute_node_group/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_node_group/tasks/autogen.yml148
-rw-r--r--test/integration/targets/gcp_compute_node_group/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_node_template/aliases2
-rw-r--r--test/integration/targets/gcp_compute_node_template/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_node_template/tasks/autogen.yml114
-rw-r--r--test/integration/targets/gcp_compute_node_template/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_region_backend_service/aliases2
-rw-r--r--test/integration/targets/gcp_compute_region_backend_service/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_region_backend_service/tasks/autogen.yml164
-rw-r--r--test/integration/targets/gcp_compute_region_backend_service/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_region_disk/aliases2
-rw-r--r--test/integration/targets/gcp_compute_region_disk/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_region_disk/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_region_disk/tasks/autogen.yml139
-rw-r--r--test/integration/targets/gcp_compute_region_disk/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_reservation/aliases2
-rw-r--r--test/integration/targets/gcp_compute_reservation/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_reservation/tasks/autogen.yml134
-rw-r--r--test/integration/targets/gcp_compute_reservation/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_route/aliases2
-rw-r--r--test/integration/targets/gcp_compute_route/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_route/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_route/tasks/autogen.yml152
-rw-r--r--test/integration/targets/gcp_compute_route/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_router/aliases2
-rw-r--r--test/integration/targets/gcp_compute_router/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_router/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_router/tasks/autogen.yml174
-rw-r--r--test/integration/targets/gcp_compute_router/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_snapshot/aliases2
-rw-r--r--test/integration/targets/gcp_compute_snapshot/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_snapshot/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_snapshot/tasks/autogen.yml144
-rw-r--r--test/integration/targets/gcp_compute_snapshot/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_ssl_certificate/aliases2
-rw-r--r--test/integration/targets/gcp_compute_ssl_certificate/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_ssl_certificate/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_ssl_certificate/tasks/autogen.yml227
-rw-r--r--test/integration/targets/gcp_compute_ssl_certificate/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_ssl_policy/aliases2
-rw-r--r--test/integration/targets/gcp_compute_ssl_policy/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_ssl_policy/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_ssl_policy/tasks/autogen.yml127
-rw-r--r--test/integration/targets/gcp_compute_ssl_policy/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_subnetwork/aliases2
-rw-r--r--test/integration/targets/gcp_compute_subnetwork/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_subnetwork/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_subnetwork/tasks/autogen.yml141
-rw-r--r--test/integration/targets/gcp_compute_subnetwork/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_target_http_proxy/aliases2
-rw-r--r--test/integration/targets/gcp_compute_target_http_proxy/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_target_http_proxy/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_target_http_proxy/tasks/autogen.yml200
-rw-r--r--test/integration/targets/gcp_compute_target_http_proxy/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_target_https_proxy/aliases2
-rw-r--r--test/integration/targets/gcp_compute_target_https_proxy/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_target_https_proxy/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_target_https_proxy/tasks/autogen.yml277
-rw-r--r--test/integration/targets/gcp_compute_target_https_proxy/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_target_instance/aliases2
-rw-r--r--test/integration/targets/gcp_compute_target_instance/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_target_instance/tasks/autogen.yml173
-rw-r--r--test/integration/targets/gcp_compute_target_instance/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_target_pool/aliases2
-rw-r--r--test/integration/targets/gcp_compute_target_pool/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_target_pool/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_target_pool/tasks/autogen.yml109
-rw-r--r--test/integration/targets/gcp_compute_target_pool/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_target_ssl_proxy/aliases2
-rw-r--r--test/integration/targets/gcp_compute_target_ssl_proxy/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_target_ssl_proxy/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_target_ssl_proxy/tasks/autogen.yml266
-rw-r--r--test/integration/targets/gcp_compute_target_ssl_proxy/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_target_tcp_proxy/aliases2
-rw-r--r--test/integration/targets/gcp_compute_target_tcp_proxy/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_target_tcp_proxy/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_target_tcp_proxy/tasks/autogen.yml194
-rw-r--r--test/integration/targets/gcp_compute_target_tcp_proxy/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_target_vpn_gateway/aliases2
-rw-r--r--test/integration/targets/gcp_compute_target_vpn_gateway/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_target_vpn_gateway/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_target_vpn_gateway/tasks/autogen.yml153
-rw-r--r--test/integration/targets/gcp_compute_target_vpn_gateway/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_url_map/aliases2
-rw-r--r--test/integration/targets/gcp_compute_url_map/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_url_map/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_url_map/tasks/autogen.yml181
-rw-r--r--test/integration/targets/gcp_compute_url_map/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_vpn_tunnel/aliases2
-rw-r--r--test/integration/targets/gcp_compute_vpn_tunnel/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_compute_vpn_tunnel/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_compute_vpn_tunnel/tasks/autogen.yml202
-rw-r--r--test/integration/targets/gcp_compute_vpn_tunnel/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_container_cluster/aliases2
-rw-r--r--test/integration/targets/gcp_container_cluster/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_container_cluster/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_container_cluster/tasks/autogen.yml140
-rw-r--r--test/integration/targets/gcp_container_cluster/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_container_node_pool/aliases2
-rw-r--r--test/integration/targets/gcp_container_node_pool/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_container_node_pool/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_container_node_pool/tasks/autogen.yml141
-rw-r--r--test/integration/targets/gcp_container_node_pool/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_dns_managed_zone/aliases2
-rw-r--r--test/integration/targets/gcp_dns_managed_zone/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_dns_managed_zone/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_dns_managed_zone/tasks/autogen.yml110
-rw-r--r--test/integration/targets/gcp_dns_managed_zone/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_dns_resource_record_set/aliases2
-rw-r--r--test/integration/targets/gcp_dns_resource_record_set/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_dns_resource_record_set/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_dns_resource_record_set/tasks/autogen.yml154
-rw-r--r--test/integration/targets/gcp_dns_resource_record_set/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_filestore_instance/aliases2
-rw-r--r--test/integration/targets/gcp_filestore_instance/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_filestore_instance/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_filestore_instance/tasks/autogen.yml145
-rw-r--r--test/integration/targets/gcp_filestore_instance/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_iam_role/aliases2
-rw-r--r--test/integration/targets/gcp_iam_role/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_iam_role/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_iam_role/tasks/autogen.yml128
-rw-r--r--test/integration/targets/gcp_iam_role/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_iam_service_account/aliases2
-rw-r--r--test/integration/targets/gcp_iam_service_account/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_iam_service_account/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_iam_service_account/tasks/autogen.yml103
-rw-r--r--test/integration/targets/gcp_iam_service_account/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_iam_service_account_key/aliases2
-rw-r--r--test/integration/targets/gcp_iam_service_account_key/defaults/main.yml3
-rw-r--r--test/integration/targets/gcp_iam_service_account_key/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_kms_crypto_key/aliases2
-rw-r--r--test/integration/targets/gcp_kms_crypto_key/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_kms_crypto_key/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_kms_crypto_key/tasks/autogen.yml73
-rw-r--r--test/integration/targets/gcp_kms_crypto_key/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_kms_key_ring/aliases2
-rw-r--r--test/integration/targets/gcp_kms_key_ring/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_kms_key_ring/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_kms_key_ring/tasks/autogen.yml63
-rw-r--r--test/integration/targets/gcp_kms_key_ring/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_logging_metric/aliases2
-rw-r--r--test/integration/targets/gcp_logging_metric/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_logging_metric/tasks/autogen.yml183
-rw-r--r--test/integration/targets/gcp_logging_metric/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_mlengine_model/aliases2
-rw-r--r--test/integration/targets/gcp_mlengine_model/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_mlengine_model/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_mlengine_model/tasks/autogen.yml113
-rw-r--r--test/integration/targets/gcp_mlengine_model/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_mlengine_version/aliases2
-rw-r--r--test/integration/targets/gcp_mlengine_version/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_mlengine_version/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_mlengine_version/tasks/autogen.yml155
-rw-r--r--test/integration/targets/gcp_mlengine_version/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_pubsub_subscription/aliases2
-rw-r--r--test/integration/targets/gcp_pubsub_subscription/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_pubsub_subscription/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_pubsub_subscription/tasks/autogen.yml128
-rw-r--r--test/integration/targets/gcp_pubsub_subscription/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_pubsub_topic/aliases2
-rw-r--r--test/integration/targets/gcp_pubsub_topic/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_pubsub_topic/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_pubsub_topic/tasks/autogen.yml98
-rw-r--r--test/integration/targets/gcp_pubsub_topic/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_redis_instance/aliases2
-rw-r--r--test/integration/targets/gcp_redis_instance/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_redis_instance/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_redis_instance/tasks/autogen.yml170
-rw-r--r--test/integration/targets/gcp_redis_instance/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_resourcemanager_project/aliases2
-rw-r--r--test/integration/targets/gcp_resourcemanager_project/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_resourcemanager_project/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_resourcemanager_project/tasks/autogen.yml113
-rw-r--r--test/integration/targets/gcp_resourcemanager_project/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_runtimeconfig_config/aliases2
-rw-r--r--test/integration/targets/gcp_runtimeconfig_config/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_runtimeconfig_config/tasks/autogen.yml103
-rw-r--r--test/integration/targets/gcp_runtimeconfig_config/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_runtimeconfig_variable/aliases2
-rw-r--r--test/integration/targets/gcp_runtimeconfig_variable/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_runtimeconfig_variable/tasks/autogen.yml132
-rw-r--r--test/integration/targets/gcp_runtimeconfig_variable/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_serviceusage_service/aliases2
-rw-r--r--test/integration/targets/gcp_serviceusage_service/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_serviceusage_service/tasks/autogen.yml98
-rw-r--r--test/integration/targets/gcp_serviceusage_service/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_sourcerepo_repository/aliases2
-rw-r--r--test/integration/targets/gcp_sourcerepo_repository/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_sourcerepo_repository/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_sourcerepo_repository/tasks/autogen.yml98
-rw-r--r--test/integration/targets/gcp_sourcerepo_repository/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_spanner_database/aliases2
-rw-r--r--test/integration/targets/gcp_spanner_database/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_spanner_database/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_spanner_database/tasks/autogen.yml135
-rw-r--r--test/integration/targets/gcp_spanner_database/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_spanner_instance/aliases2
-rw-r--r--test/integration/targets/gcp_spanner_instance/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_spanner_instance/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_spanner_instance/tasks/autogen.yml123
-rw-r--r--test/integration/targets/gcp_spanner_instance/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_sql_database/aliases2
-rw-r--r--test/integration/targets/gcp_sql_database/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_sql_database/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_sql_database/tasks/autogen.yml144
-rw-r--r--test/integration/targets/gcp_sql_database/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_sql_instance/aliases2
-rw-r--r--test/integration/targets/gcp_sql_instance/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_sql_instance/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_sql_instance/tasks/autogen.yml133
-rw-r--r--test/integration/targets/gcp_sql_instance/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_sql_user/aliases2
-rw-r--r--test/integration/targets/gcp_sql_user/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_sql_user/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_sql_user/tasks/autogen.yml149
-rw-r--r--test/integration/targets/gcp_sql_user/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_storage_bucket/aliases2
-rw-r--r--test/integration/targets/gcp_storage_bucket/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_storage_bucket/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_storage_bucket/tasks/autogen.yml74
-rw-r--r--test/integration/targets/gcp_storage_bucket/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_storage_bucket_access_control/aliases2
-rw-r--r--test/integration/targets/gcp_storage_bucket_access_control/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_storage_bucket_access_control/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_storage_bucket_access_control/tasks/autogen.yml104
-rw-r--r--test/integration/targets/gcp_storage_bucket_access_control/tasks/main.yml2
-rw-r--r--test/integration/targets/gcp_storage_object/aliases2
-rw-r--r--test/integration/targets/gcp_storage_object/defaults/main.yml3
-rw-r--r--test/integration/targets/gcp_storage_object/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_tpu_node/aliases2
-rw-r--r--test/integration/targets/gcp_tpu_node/defaults/main.yml2
-rw-r--r--test/integration/targets/gcp_tpu_node/meta/main.yml0
-rw-r--r--test/integration/targets/gcp_tpu_node/tasks/autogen.yml120
-rw-r--r--test/integration/targets/gcp_tpu_node/tasks/main.yml2
-rw-r--r--test/sanity/ignore.txt233
521 files changed, 0 insertions, 89272 deletions
diff --git a/lib/ansible/module_utils/gcp_utils.py b/lib/ansible/module_utils/gcp_utils.py
deleted file mode 100644
index 44cca3909a..0000000000
--- a/lib/ansible/module_utils/gcp_utils.py
+++ /dev/null
@@ -1,452 +0,0 @@
-# Copyright (c), Google Inc, 2017
-# Simplified BSD License (see licenses/simplified_bsd.txt or https://opensource.org/licenses/BSD-2-Clause)
-
-try:
- import requests
- HAS_REQUESTS = True
-except ImportError:
- HAS_REQUESTS = False
-
-try:
- import google.auth
- import google.auth.compute_engine
- from google.oauth2 import service_account
- from google.auth.transport.requests import AuthorizedSession
- HAS_GOOGLE_LIBRARIES = True
-except ImportError:
- HAS_GOOGLE_LIBRARIES = False
-
-from ansible.module_utils.basic import AnsibleModule, env_fallback
-from ansible.module_utils.six import string_types
-from ansible.module_utils._text import to_text, to_native
-import ast
-import os
-import json
-
-
-def navigate_hash(source, path, default=None):
- if not source:
- return None
-
- key = path[0]
- path = path[1:]
- if key not in source:
- return default
- result = source[key]
- if path:
- return navigate_hash(result, path, default)
- else:
- return result
-
-
-class GcpRequestException(Exception):
- pass
-
-
-def remove_nones_from_dict(obj):
- new_obj = {}
- for key in obj:
- value = obj[key]
- if value is not None and value != {} and value != []:
- new_obj[key] = value
-
- # Blank dictionaries should return None or GCP API may complain.
- if not new_obj:
- return None
- return new_obj
-
-
-# Handles the replacement of dicts with values -> the needed value for GCP API
-def replace_resource_dict(item, value):
- if isinstance(item, list):
- items = []
- for i in item:
- items.append(replace_resource_dict(i, value))
- return items
- else:
- if not item:
- return item
- else:
- return item.get(value)
-
-
-# Handles all authentication and HTTP sessions for GCP API calls.
-class GcpSession(object):
- def __init__(self, module, product):
- self.module = module
- self.product = product
- self._validate()
-
- def get(self, url, body=None, **kwargs):
- """
- This method should be avoided in favor of full_get
- """
- kwargs.update({'json': body})
- return self.full_get(url, **kwargs)
-
- def post(self, url, body=None, headers=None, **kwargs):
- """
- This method should be avoided in favor of full_post
- """
- kwargs.update({'json': body, 'headers': headers})
- return self.full_post(url, **kwargs)
-
- def post_contents(self, url, file_contents=None, headers=None, **kwargs):
- """
- This method should be avoided in favor of full_post
- """
- kwargs.update({'data': file_contents, 'headers': headers})
- return self.full_post(url, **kwargs)
-
- def delete(self, url, body=None):
- """
- This method should be avoided in favor of full_delete
- """
- kwargs = {'json': body}
- return self.full_delete(url, **kwargs)
-
- def put(self, url, body=None):
- """
- This method should be avoided in favor of full_put
- """
- kwargs = {'json': body}
- return self.full_put(url, **kwargs)
-
- def patch(self, url, body=None, **kwargs):
- """
- This method should be avoided in favor of full_patch
- """
- kwargs.update({'json': body})
- return self.full_patch(url, **kwargs)
-
- def list(self, url, callback, params=None, array_name='items',
- pageToken='nextPageToken', **kwargs):
- """
- This should be used for calling the GCP list APIs. It will return
- an array of items
-
- This takes a callback to a `return_if_object(module, response)`
- function that will decode the response + return a dictionary. Some
- modules handle the decode + error processing differently, so we should
- defer to the module to handle this.
- """
- resp = callback(self.module, self.full_get(url, params, **kwargs))
- items = resp.get(array_name) if resp.get(array_name) else []
- while resp.get(pageToken):
- if params:
- params['pageToken'] = resp.get(pageToken)
- else:
- params = {'pageToken': resp[pageToken]}
-
- resp = callback(self.module, self.full_get(url, params, **kwargs))
- if resp.get(array_name):
- items = items + resp.get(array_name)
- return items
-
- # The following methods fully mimic the requests API and should be used.
- def full_get(self, url, params=None, **kwargs):
- kwargs['headers'] = self._set_headers(kwargs.get('headers'))
- try:
- return self.session().get(url, params=params, **kwargs)
- except getattr(requests.exceptions, 'RequestException') as inst:
- # Only log the message to avoid logging any sensitive info.
- self.module.fail_json(msg=inst.message)
-
- def full_post(self, url, data=None, json=None, **kwargs):
- kwargs['headers'] = self._set_headers(kwargs.get('headers'))
-
- try:
- return self.session().post(url, data=data, json=json, **kwargs)
- except getattr(requests.exceptions, 'RequestException') as inst:
- self.module.fail_json(msg=inst.message)
-
- def full_put(self, url, data=None, **kwargs):
- kwargs['headers'] = self._set_headers(kwargs.get('headers'))
-
- try:
- return self.session().put(url, data=data, **kwargs)
- except getattr(requests.exceptions, 'RequestException') as inst:
- self.module.fail_json(msg=inst.message)
-
- def full_patch(self, url, data=None, **kwargs):
- kwargs['headers'] = self._set_headers(kwargs.get('headers'))
-
- try:
- return self.session().patch(url, data=data, **kwargs)
- except getattr(requests.exceptions, 'RequestException') as inst:
- self.module.fail_json(msg=inst.message)
-
- def full_delete(self, url, **kwargs):
- kwargs['headers'] = self._set_headers(kwargs.get('headers'))
-
- try:
- return self.session().delete(url, **kwargs)
- except getattr(requests.exceptions, 'RequestException') as inst:
- self.module.fail_json(msg=inst.message)
-
- def _set_headers(self, headers):
- if headers:
- return self._merge_dictionaries(headers, self._headers())
- else:
- return self._headers()
-
- def session(self):
- return AuthorizedSession(
- self._credentials())
-
- def _validate(self):
- if not HAS_REQUESTS:
- self.module.fail_json(msg="Please install the requests library")
-
- if not HAS_GOOGLE_LIBRARIES:
- self.module.fail_json(msg="Please install the google-auth library")
-
- if self.module.params.get('service_account_email') is not None and self.module.params['auth_kind'] != 'machineaccount':
- self.module.fail_json(
- msg="Service Account Email only works with Machine Account-based authentication"
- )
-
- if (self.module.params.get('service_account_file') is not None or
- self.module.params.get('service_account_contents') is not None) and self.module.params['auth_kind'] != 'serviceaccount':
- self.module.fail_json(
- msg="Service Account File only works with Service Account-based authentication"
- )
-
- def _credentials(self):
- cred_type = self.module.params['auth_kind']
- if cred_type == 'application':
- credentials, project_id = google.auth.default(scopes=self.module.params['scopes'])
- return credentials
- elif cred_type == 'serviceaccount' and self.module.params.get('service_account_file'):
- path = os.path.realpath(os.path.expanduser(self.module.params['service_account_file']))
- return service_account.Credentials.from_service_account_file(path).with_scopes(self.module.params['scopes'])
- elif cred_type == 'serviceaccount' and self.module.params.get('service_account_contents'):
- try:
- cred = json.loads(self.module.params.get('service_account_contents'))
- except json.decoder.JSONDecodeError as e:
- self.module.fail_json(
- msg="Unable to decode service_account_contents as JSON"
- )
- return service_account.Credentials.from_service_account_info(cred).with_scopes(self.module.params['scopes'])
- elif cred_type == 'machineaccount':
- return google.auth.compute_engine.Credentials(
- self.module.params['service_account_email'])
- else:
- self.module.fail_json(msg="Credential type '%s' not implemented" % cred_type)
-
- def _headers(self):
- if self.module.params.get('env_type'):
- return {
- 'User-Agent': "Google-Ansible-MM-{0}-{1}".format(self.product, self.module.params.get('env_type'))
- }
- else:
- return {
- 'User-Agent': "Google-Ansible-MM-{0}".format(self.product)
- }
-
- def _merge_dictionaries(self, a, b):
- new = a.copy()
- new.update(b)
- return new
-
-
-class GcpModule(AnsibleModule):
- def __init__(self, *args, **kwargs):
- arg_spec = {}
- if 'argument_spec' in kwargs:
- arg_spec = kwargs['argument_spec']
-
- kwargs['argument_spec'] = self._merge_dictionaries(
- arg_spec,
- dict(
- project=dict(
- required=False,
- type='str',
- fallback=(env_fallback, ['GCP_PROJECT'])),
- auth_kind=dict(
- required=True,
- fallback=(env_fallback, ['GCP_AUTH_KIND']),
- choices=['machineaccount', 'serviceaccount', 'application'],
- type='str'),
- service_account_email=dict(
- required=False,
- fallback=(env_fallback, ['GCP_SERVICE_ACCOUNT_EMAIL']),
- type='str'),
- service_account_file=dict(
- required=False,
- fallback=(env_fallback, ['GCP_SERVICE_ACCOUNT_FILE']),
- type='path'),
- service_account_contents=dict(
- required=False,
- fallback=(env_fallback, ['GCP_SERVICE_ACCOUNT_CONTENTS']),
- no_log=True,
- type='jsonarg'),
- scopes=dict(
- required=False,
- fallback=(env_fallback, ['GCP_SCOPES']),
- type='list'),
- env_type=dict(
- required=False,
- fallback=(env_fallback, ['GCP_ENV_TYPE']),
- type='str')
- )
- )
-
- mutual = []
- if 'mutually_exclusive' in kwargs:
- mutual = kwargs['mutually_exclusive']
-
- kwargs['mutually_exclusive'] = mutual.append(
- ['service_account_email', 'service_account_file', 'service_account_contents']
- )
-
- AnsibleModule.__init__(self, *args, **kwargs)
-
- def raise_for_status(self, response):
- try:
- response.raise_for_status()
- except getattr(requests.exceptions, 'RequestException') as inst:
- self.fail_json(msg="GCP returned error: %s" % response.json())
-
- def _merge_dictionaries(self, a, b):
- new = a.copy()
- new.update(b)
- return new
-
-
-# This class does difference checking according to a set of GCP-specific rules.
-# This will be primarily used for checking dictionaries.
-# In an equivalence check, the left-hand dictionary will be the request and
-# the right-hand side will be the response.
-
-# Rules:
-# Extra keys in response will be ignored.
-# Ordering of lists does not matter.
-# - exception: lists of dictionaries are
-# assumed to be in sorted order.
-class GcpRequest(object):
- def __init__(self, request):
- self.request = request
-
- def __eq__(self, other):
- return not self.difference(other)
-
- def __ne__(self, other):
- return not self.__eq__(other)
-
- # Returns the difference between a request + response.
- # While this is used under the hood for __eq__ and __ne__,
- # it is useful for debugging.
- def difference(self, response):
- return self._compare_value(self.request, response.request)
-
- def _compare_dicts(self, req_dict, resp_dict):
- difference = {}
- for key in req_dict:
- if resp_dict.get(key):
- difference[key] = self._compare_value(req_dict.get(key), resp_dict.get(key))
-
- # Remove all empty values from difference.
- sanitized_difference = {}
- for key in difference:
- if difference[key]:
- sanitized_difference[key] = difference[key]
-
- return sanitized_difference
-
- # Takes in two lists and compares them.
- # All things in the list should be identical (even if a dictionary)
- def _compare_lists(self, req_list, resp_list):
- # Have to convert each thing over to unicode.
- # Python doesn't handle equality checks between unicode + non-unicode well.
- difference = []
- new_req_list = self._convert_value(req_list)
- new_resp_list = self._convert_value(resp_list)
-
- # We have to compare each thing in the request to every other thing
- # in the response.
- # This is because the request value will be a subset of the response value.
- # The assumption is that these lists will be small enough that it won't
- # be a performance burden.
- for req_item in new_req_list:
- found_item = False
- for resp_item in new_resp_list:
- # Looking for a None value here.
- if not self._compare_value(req_item, resp_item):
- found_item = True
- if not found_item:
- difference.append(req_item)
-
- difference2 = []
- for value in difference:
- if value:
- difference2.append(value)
-
- return difference2
-
- # Compare two values of arbitrary types.
- def _compare_value(self, req_value, resp_value):
- diff = None
- # If a None is found, a difference does not exist.
- # Only differing values matter.
- if not resp_value:
- return None
-
- # Can assume non-None types at this point.
- try:
- if isinstance(req_value, list):
- diff = self._compare_lists(req_value, resp_value)
- elif isinstance(req_value, dict):
- diff = self._compare_dicts(req_value, resp_value)
- elif isinstance(req_value, bool):
- diff = self._compare_boolean(req_value, resp_value)
- # Always use to_text values to avoid unicode issues.
- elif to_text(req_value) != to_text(resp_value):
- diff = req_value
- # to_text may throw UnicodeErrors.
- # These errors shouldn't crash Ansible and should be hidden.
- except UnicodeError:
- pass
-
- return diff
-
- # Compare two boolean values.
- def _compare_boolean(self, req_value, resp_value):
- try:
- # Both True
- if req_value and isinstance(resp_value, bool) and resp_value:
- return None
- # Value1 True, resp_value 'true'
- elif req_value and to_text(resp_value) == 'true':
- return None
- # Both False
- elif not req_value and isinstance(resp_value, bool) and not resp_value:
- return None
- # Value1 False, resp_value 'false'
- elif not req_value and to_text(resp_value) == 'false':
- return None
- else:
- return resp_value
-
- # to_text may throw UnicodeErrors.
- # These errors shouldn't crash Ansible and should be hidden.
- except UnicodeError:
- return None
-
- # Python (2 esp.) doesn't do comparisons between unicode + non-unicode well.
- # This leads to a lot of false positives when diffing values.
- # The Ansible to_text() function is meant to get all strings
- # into a standard format.
- def _convert_value(self, value):
- if isinstance(value, list):
- new_list = []
- for item in value:
- new_list.append(self._convert_value(item))
- return new_list
- elif isinstance(value, dict):
- new_dict = {}
- for key in value:
- new_dict[key] = self._convert_value(value[key])
- return new_dict
- else:
- return to_text(value)
diff --git a/lib/ansible/modules/cloud/google/gcp_appengine_firewall_rule.py b/lib/ansible/modules/cloud/google/gcp_appengine_firewall_rule.py
deleted file mode 100644
index 5ed58b97a3..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_appengine_firewall_rule.py
+++ /dev/null
@@ -1,325 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_appengine_firewall_rule
-description:
-- A single firewall rule that is evaluated against incoming traffic and provides an
- action to take on matched requests.
-short_description: Creates a GCP FirewallRule
-version_added: '2.9'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- description:
- description:
- - An optional string description of this rule.
- required: false
- type: str
- source_range:
- description:
- - IP address or range, defined using CIDR notation, of requests that this rule
- applies to.
- required: true
- type: str
- action:
- description:
- - The action to take if this rule matches.
- - 'Some valid choices include: "UNSPECIFIED_ACTION", "ALLOW", "DENY"'
- required: true
- type: str
- priority:
- description:
- - A positive integer that defines the order of rule evaluation.
- - Rules with the lowest priority are evaluated first.
- - A default rule at priority Int32.MaxValue matches all IPv4 and IPv6 traffic
- when no previous rule matches. Only the action of this rule can be modified
- by the user.
- required: false
- type: int
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/appengine/docs/admin-api/reference/rest/v1/apps.firewall.ingressRules)'
-- 'Official Documentation: U(https://cloud.google.com/appengine/docs/standard/python/creating-firewalls#creating_firewall_rules)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a firewall rule
- gcp_appengine_firewall_rule:
- priority: 1000
- source_range: 10.0.0.0
- action: ALLOW
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-description:
- description:
- - An optional string description of this rule.
- returned: success
- type: str
-sourceRange:
- description:
- - IP address or range, defined using CIDR notation, of requests that this rule applies
- to.
- returned: success
- type: str
-action:
- description:
- - The action to take if this rule matches.
- returned: success
- type: str
-priority:
- description:
- - A positive integer that defines the order of rule evaluation.
- - Rules with the lowest priority are evaluated first.
- - A default rule at priority Int32.MaxValue matches all IPv4 and IPv6 traffic when
- no previous rule matches. Only the action of this rule can be modified by the
- user.
- returned: success
- type: int
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- description=dict(type='str'),
- source_range=dict(required=True, type='str'),
- action=dict(required=True, type='str'),
- priority=dict(type='int'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
-
- state = module.params['state']
-
- fetch = fetch_resource(module, self_link(module))
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), fetch)
- fetch = fetch_resource(module, self_link(module))
- changed = True
- else:
- delete(module, self_link(module))
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module))
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link):
- auth = GcpSession(module, 'appengine')
- return return_if_object(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, fetch):
- auth = GcpSession(module, 'appengine')
- params = {'updateMask': updateMask(resource_to_request(module), response_to_hash(module, fetch))}
- request = resource_to_request(module)
- del request['name']
- return return_if_object(module, auth.patch(link, request, params=params))
-
-
-def updateMask(request, response):
- update_mask = []
- if request.get('description') != response.get('description'):
- update_mask.append('description')
- if request.get('sourceRange') != response.get('sourceRange'):
- update_mask.append('sourceRange')
- if request.get('action') != response.get('action'):
- update_mask.append('action')
- if request.get('priority') != response.get('priority'):
- update_mask.append('priority')
- return ','.join(update_mask)
-
-
-def delete(module, link):
- auth = GcpSession(module, 'appengine')
- return return_if_object(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {u'description': module.params.get('description'), u'sourceRange': module.params.get('source_range'), u'action': module.params.get('action')}
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, allow_not_found=True):
- auth = GcpSession(module, 'appengine')
- return return_if_object(module, auth.get(link), allow_not_found)
-
-
-def self_link(module):
- return "https://appengine.googleapis.com/v1/apps/{project}/firewall/ingressRules/{priority}".format(**module.params)
-
-
-def collection(module):
- return "https://appengine.googleapis.com/v1/apps/{project}/firewall/ingressRules".format(**module.params)
-
-
-def return_if_object(module, response, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {u'description': response.get(u'description'), u'sourceRange': response.get(u'sourceRange'), u'action': response.get(u'action')}
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_appengine_firewall_rule_info.py b/lib/ansible/modules/cloud/google/gcp_appengine_firewall_rule_info.py
deleted file mode 100644
index ef62652dbd..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_appengine_firewall_rule_info.py
+++ /dev/null
@@ -1,186 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_appengine_firewall_rule_info
-description:
-- Gather info for GCP FirewallRule
-short_description: Gather info for GCP FirewallRule
-version_added: '2.9'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a firewall rule
- gcp_appengine_firewall_rule_info:
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- description:
- description:
- - An optional string description of this rule.
- returned: success
- type: str
- sourceRange:
- description:
- - IP address or range, defined using CIDR notation, of requests that this rule
- applies to.
- returned: success
- type: str
- action:
- description:
- - The action to take if this rule matches.
- returned: success
- type: str
- priority:
- description:
- - A positive integer that defines the order of rule evaluation.
- - Rules with the lowest priority are evaluated first.
- - A default rule at priority Int32.MaxValue matches all IPv4 and IPv6 traffic
- when no previous rule matches. Only the action of this rule can be modified
- by the user.
- returned: success
- type: int
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict())
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
-
- return_value = {'resources': fetch_list(module, collection(module))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://appengine.googleapis.com/v1/apps/{project}/firewall/ingressRules".format(**module.params)
-
-
-def fetch_list(module, link):
- auth = GcpSession(module, 'appengine')
- return auth.list(link, return_if_object, array_name='ingressRules')
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_bigquery_dataset.py b/lib/ansible/modules/cloud/google/gcp_bigquery_dataset.py
deleted file mode 100644
index db27ce2b42..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_bigquery_dataset.py
+++ /dev/null
@@ -1,745 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_bigquery_dataset
-description:
-- Datasets allow you to organize and control access to your tables.
-short_description: Creates a GCP Dataset
-version_added: '2.8'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- name:
- description:
- - Dataset name.
- required: false
- type: str
- access:
- description:
- - An array of objects that define dataset access for one or more entities.
- required: false
- type: list
- suboptions:
- domain:
- description:
- - A domain to grant access to. Any users signed in with the domain specified
- will be granted the specified access .
- required: false
- type: str
- group_by_email:
- description:
- - An email address of a Google Group to grant access to.
- required: false
- type: str
- role:
- description:
- - Describes the rights granted to the user specified by the other member of
- the access object. Primitive, Predefined and custom roles are supported.
- Predefined roles that have equivalent primitive roles are swapped by the
- API to their Primitive counterparts, and will show a diff post-create. See
- [official docs](U(https://cloud.google.com/bigquery/docs/access-control)).
- required: false
- type: str
- special_group:
- description:
- - A special group to grant access to.
- - 'Possible values include: * `projectOwners`: Owners of the enclosing project.'
- - "* `projectReaders`: Readers of the enclosing project."
- - "* `projectWriters`: Writers of the enclosing project."
- - "* `allAuthenticatedUsers`: All authenticated BigQuery users. ."
- required: false
- type: str
- user_by_email:
- description:
- - 'An email address of a user to grant access to. For example: fred@example.com
- .'
- required: false
- type: str
- view:
- description:
- - A view from a different dataset to grant access to. Queries executed against
- that view will have read access to tables in this dataset. The role field
- is not required when this field is set. If that view is updated by any user,
- access to the view needs to be granted again via an update operation.
- required: false
- type: dict
- suboptions:
- dataset_id:
- description:
- - The ID of the dataset containing this table.
- required: true
- type: str
- project_id:
- description:
- - The ID of the project containing this table.
- required: true
- type: str
- table_id:
- description:
- - The ID of the table. The ID must contain only letters (a-z, A-Z), numbers
- (0-9), or underscores. The maximum length is 1,024 characters.
- required: true
- type: str
- dataset_reference:
- description:
- - A reference that identifies the dataset.
- required: true
- type: dict
- suboptions:
- dataset_id:
- description:
- - A unique ID for this dataset, without the project name. The ID must contain
- only letters (a-z, A-Z), numbers (0-9), or underscores. The maximum length
- is 1,024 characters.
- required: true
- type: str
- project_id:
- description:
- - The ID of the project containing this dataset.
- required: false
- type: str
- default_table_expiration_ms:
- description:
- - The default lifetime of all tables in the dataset, in milliseconds.
- - The minimum value is 3600000 milliseconds (one hour).
- - Once this property is set, all newly-created tables in the dataset will have
- an `expirationTime` property set to the creation time plus the value in this
- property, and changing the value will only affect new tables, not existing ones.
- When the `expirationTime` for a given table is reached, that table will be deleted
- automatically.
- - If a table's `expirationTime` is modified or removed before the table expires,
- or if you provide an explicit `expirationTime` when creating a table, that value
- takes precedence over the default expiration time indicated by this property.
- required: false
- type: int
- default_partition_expiration_ms:
- description:
- - The default partition expiration for all partitioned tables in the dataset,
- in milliseconds.
- - Once this property is set, all newly-created partitioned tables in the dataset
- will have an `expirationMs` property in the `timePartitioning` settings set
- to this value, and changing the value will only affect new tables, not existing
- ones. The storage in a partition will have an expiration time of its partition
- time plus this value.
- - 'Setting this property overrides the use of `defaultTableExpirationMs` for partitioned
- tables: only one of `defaultTableExpirationMs` and `defaultPartitionExpirationMs`
- will be used for any new partitioned table. If you provide an explicit `timePartitioning.expirationMs`
- when creating or updating a partitioned table, that value takes precedence over
- the default partition expiration time indicated by this property.'
- required: false
- type: int
- version_added: '2.9'
- description:
- description:
- - A user-friendly description of the dataset.
- required: false
- type: str
- friendly_name:
- description:
- - A descriptive name for the dataset.
- required: false
- type: str
- labels:
- description:
- - The labels associated with this dataset. You can use these to organize and group
- your datasets .
- required: false
- type: dict
- location:
- description:
- - The geographic location where the dataset should reside.
- - See [official docs](U(https://cloud.google.com/bigquery/docs/dataset-locations)).
- - There are two types of locations, regional or multi-regional. A regional location
- is a specific geographic place, such as Tokyo, and a multi-regional location
- is a large geographic area, such as the United States, that contains at least
- two geographic places.
- - 'Possible regional values include: `asia-east1`, `asia-northeast1`, `asia-southeast1`,
- `australia-southeast1`, `europe-north1`, `europe-west2` and `us-east4`.'
- - 'Possible multi-regional values: `EU` and `US`.'
- - The default value is multi-regional location `US`.
- - Changing this forces a new resource to be created.
- required: false
- default: US
- type: str
- default_encryption_configuration:
- description:
- - The default encryption key for all tables in the dataset. Once this property
- is set, all newly-created partitioned tables in the dataset will have encryption
- key set to this value, unless table creation request (or query) overrides the
- key.
- required: false
- type: dict
- version_added: '2.10'
- suboptions:
- kms_key_name:
- description:
- - Describes the Cloud KMS encryption key that will be used to protect destination
- BigQuery table. The BigQuery Service Account associated with your project
- requires access to this encryption key.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-'''
-
-EXAMPLES = '''
-- name: create a dataset
- gcp_bigquery_dataset:
- name: my_example_dataset
- dataset_reference:
- dataset_id: my_example_dataset
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-name:
- description:
- - Dataset name.
- returned: success
- type: str
-access:
- description:
- - An array of objects that define dataset access for one or more entities.
- returned: success
- type: complex
- contains:
- domain:
- description:
- - A domain to grant access to. Any users signed in with the domain specified
- will be granted the specified access .
- returned: success
- type: str
- groupByEmail:
- description:
- - An email address of a Google Group to grant access to.
- returned: success
- type: str
- role:
- description:
- - Describes the rights granted to the user specified by the other member of
- the access object. Primitive, Predefined and custom roles are supported. Predefined
- roles that have equivalent primitive roles are swapped by the API to their
- Primitive counterparts, and will show a diff post-create. See [official docs](U(https://cloud.google.com/bigquery/docs/access-control)).
- returned: success
- type: str
- specialGroup:
- description:
- - A special group to grant access to.
- - 'Possible values include: * `projectOwners`: Owners of the enclosing project.'
- - "* `projectReaders`: Readers of the enclosing project."
- - "* `projectWriters`: Writers of the enclosing project."
- - "* `allAuthenticatedUsers`: All authenticated BigQuery users. ."
- returned: success
- type: str
- userByEmail:
- description:
- - 'An email address of a user to grant access to. For example: fred@example.com
- .'
- returned: success
- type: str
- view:
- description:
- - A view from a different dataset to grant access to. Queries executed against
- that view will have read access to tables in this dataset. The role field
- is not required when this field is set. If that view is updated by any user,
- access to the view needs to be granted again via an update operation.
- returned: success
- type: complex
- contains:
- datasetId:
- description:
- - The ID of the dataset containing this table.
- returned: success
- type: str
- projectId:
- description:
- - The ID of the project containing this table.
- returned: success
- type: str
- tableId:
- description:
- - The ID of the table. The ID must contain only letters (a-z, A-Z), numbers
- (0-9), or underscores. The maximum length is 1,024 characters.
- returned: success
- type: str
-creationTime:
- description:
- - The time when this dataset was created, in milliseconds since the epoch.
- returned: success
- type: int
-datasetReference:
- description:
- - A reference that identifies the dataset.
- returned: success
- type: complex
- contains:
- datasetId:
- description:
- - A unique ID for this dataset, without the project name. The ID must contain
- only letters (a-z, A-Z), numbers (0-9), or underscores. The maximum length
- is 1,024 characters.
- returned: success
- type: str
- projectId:
- description:
- - The ID of the project containing this dataset.
- returned: success
- type: str
-defaultTableExpirationMs:
- description:
- - The default lifetime of all tables in the dataset, in milliseconds.
- - The minimum value is 3600000 milliseconds (one hour).
- - Once this property is set, all newly-created tables in the dataset will have an
- `expirationTime` property set to the creation time plus the value in this property,
- and changing the value will only affect new tables, not existing ones. When the
- `expirationTime` for a given table is reached, that table will be deleted automatically.
- - If a table's `expirationTime` is modified or removed before the table expires,
- or if you provide an explicit `expirationTime` when creating a table, that value
- takes precedence over the default expiration time indicated by this property.
- returned: success
- type: int
-defaultPartitionExpirationMs:
- description:
- - The default partition expiration for all partitioned tables in the dataset, in
- milliseconds.
- - Once this property is set, all newly-created partitioned tables in the dataset
- will have an `expirationMs` property in the `timePartitioning` settings set to
- this value, and changing the value will only affect new tables, not existing ones.
- The storage in a partition will have an expiration time of its partition time
- plus this value.
- - 'Setting this property overrides the use of `defaultTableExpirationMs` for partitioned
- tables: only one of `defaultTableExpirationMs` and `defaultPartitionExpirationMs`
- will be used for any new partitioned table. If you provide an explicit `timePartitioning.expirationMs`
- when creating or updating a partitioned table, that value takes precedence over
- the default partition expiration time indicated by this property.'
- returned: success
- type: int
-description:
- description:
- - A user-friendly description of the dataset.
- returned: success
- type: str
-etag:
- description:
- - A hash of the resource.
- returned: success
- type: str
-friendlyName:
- description:
- - A descriptive name for the dataset.
- returned: success
- type: str
-id:
- description:
- - The fully-qualified unique name of the dataset in the format projectId:datasetId.
- The dataset name without the project name is given in the datasetId field .
- returned: success
- type: str
-labels:
- description:
- - The labels associated with this dataset. You can use these to organize and group
- your datasets .
- returned: success
- type: dict
-lastModifiedTime:
- description:
- - The date when this dataset or any of its tables was last modified, in milliseconds
- since the epoch.
- returned: success
- type: int
-location:
- description:
- - The geographic location where the dataset should reside.
- - See [official docs](U(https://cloud.google.com/bigquery/docs/dataset-locations)).
- - There are two types of locations, regional or multi-regional. A regional location
- is a specific geographic place, such as Tokyo, and a multi-regional location is
- a large geographic area, such as the United States, that contains at least two
- geographic places.
- - 'Possible regional values include: `asia-east1`, `asia-northeast1`, `asia-southeast1`,
- `australia-southeast1`, `europe-north1`, `europe-west2` and `us-east4`.'
- - 'Possible multi-regional values: `EU` and `US`.'
- - The default value is multi-regional location `US`.
- - Changing this forces a new resource to be created.
- returned: success
- type: str
-defaultEncryptionConfiguration:
- description:
- - The default encryption key for all tables in the dataset. Once this property is
- set, all newly-created partitioned tables in the dataset will have encryption
- key set to this value, unless table creation request (or query) overrides the
- key.
- returned: success
- type: complex
- contains:
- kmsKeyName:
- description:
- - Describes the Cloud KMS encryption key that will be used to protect destination
- BigQuery table. The BigQuery Service Account associated with your project
- requires access to this encryption key.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- name=dict(type='str'),
- access=dict(
- type='list',
- elements='dict',
- options=dict(
- domain=dict(type='str'),
- group_by_email=dict(type='str'),
- role=dict(type='str'),
- special_group=dict(type='str'),
- user_by_email=dict(type='str'),
- view=dict(
- type='dict',
- options=dict(
- dataset_id=dict(required=True, type='str'), project_id=dict(required=True, type='str'), table_id=dict(required=True, type='str')
- ),
- ),
- ),
- ),
- dataset_reference=dict(required=True, type='dict', options=dict(dataset_id=dict(required=True, type='str'), project_id=dict(type='str'))),
- default_table_expiration_ms=dict(type='int'),
- default_partition_expiration_ms=dict(type='int'),
- description=dict(type='str'),
- friendly_name=dict(type='str'),
- labels=dict(type='dict'),
- location=dict(default='US', type='str'),
- default_encryption_configuration=dict(type='dict', options=dict(kms_key_name=dict(required=True, type='str'))),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/bigquery']
-
- state = module.params['state']
- kind = 'bigquery#dataset'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'bigquery')
- return return_if_object(module, auth.post(link, resource_to_request(module)), kind)
-
-
-def update(module, link, kind):
- auth = GcpSession(module, 'bigquery')
- return return_if_object(module, auth.put(link, resource_to_request(module)), kind)
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'bigquery')
- return return_if_object(module, auth.delete(link), kind)
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'bigquery#dataset',
- u'name': module.params.get('name'),
- u'access': DatasetAccessArray(module.params.get('access', []), module).to_request(),
- u'datasetReference': DatasetDatasetreference(module.params.get('dataset_reference', {}), module).to_request(),
- u'defaultTableExpirationMs': module.params.get('default_table_expiration_ms'),
- u'defaultPartitionExpirationMs': module.params.get('default_partition_expiration_ms'),
- u'description': module.params.get('description'),
- u'friendlyName': module.params.get('friendly_name'),
- u'labels': module.params.get('labels'),
- u'location': module.params.get('location'),
- u'defaultEncryptionConfiguration': DatasetDefaultencryptionconfiguration(
- module.params.get('default_encryption_configuration', {}), module
- ).to_request(),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'bigquery')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/bigquery/v2/projects/{project}/datasets/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/bigquery/v2/projects/{project}/datasets".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'name': response.get(u'name'),
- u'access': DatasetAccessArray(response.get(u'access', []), module).from_response(),
- u'creationTime': response.get(u'creationTime'),
- u'datasetReference': DatasetDatasetreference(response.get(u'datasetReference', {}), module).from_response(),
- u'defaultTableExpirationMs': response.get(u'defaultTableExpirationMs'),
- u'defaultPartitionExpirationMs': response.get(u'defaultPartitionExpirationMs'),
- u'description': response.get(u'description'),
- u'etag': response.get(u'etag'),
- u'friendlyName': response.get(u'friendlyName'),
- u'id': response.get(u'id'),
- u'labels': response.get(u'labels'),
- u'lastModifiedTime': response.get(u'lastModifiedTime'),
- u'location': response.get(u'location'),
- u'defaultEncryptionConfiguration': DatasetDefaultencryptionconfiguration(response.get(u'defaultEncryptionConfiguration', {}), module).from_response(),
- }
-
-
-class DatasetAccessArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict(
- {
- u'domain': item.get('domain'),
- u'groupByEmail': item.get('group_by_email'),
- u'role': item.get('role'),
- u'specialGroup': item.get('special_group'),
- u'userByEmail': item.get('user_by_email'),
- u'view': DatasetView(item.get('view', {}), self.module).to_request(),
- }
- )
-
- def _response_from_item(self, item):
- return remove_nones_from_dict(
- {
- u'domain': item.get(u'domain'),
- u'groupByEmail': item.get(u'groupByEmail'),
- u'role': item.get(u'role'),
- u'specialGroup': item.get(u'specialGroup'),
- u'userByEmail': item.get(u'userByEmail'),
- u'view': DatasetView(item.get(u'view', {}), self.module).from_response(),
- }
- )
-
-
-class DatasetView(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {u'datasetId': self.request.get('dataset_id'), u'projectId': self.request.get('project_id'), u'tableId': self.request.get('table_id')}
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {u'datasetId': self.request.get(u'datasetId'), u'projectId': self.request.get(u'projectId'), u'tableId': self.request.get(u'tableId')}
- )
-
-
-class DatasetDatasetreference(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'datasetId': self.request.get('dataset_id'), u'projectId': self.request.get('project_id')})
-
- def from_response(self):
- return remove_nones_from_dict({u'datasetId': self.request.get(u'datasetId'), u'projectId': self.request.get(u'projectId')})
-
-
-class DatasetDefaultencryptionconfiguration(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'kmsKeyName': self.request.get('kms_key_name')})
-
- def from_response(self):
- return remove_nones_from_dict({u'kmsKeyName': self.request.get(u'kmsKeyName')})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_bigquery_dataset_info.py b/lib/ansible/modules/cloud/google/gcp_bigquery_dataset_info.py
deleted file mode 100644
index bfb18f970e..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_bigquery_dataset_info.py
+++ /dev/null
@@ -1,351 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_bigquery_dataset_info
-description:
-- Gather info for GCP Dataset
-short_description: Gather info for GCP Dataset
-version_added: '2.8'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a dataset
- gcp_bigquery_dataset_info:
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- name:
- description:
- - Dataset name.
- returned: success
- type: str
- access:
- description:
- - An array of objects that define dataset access for one or more entities.
- returned: success
- type: complex
- contains:
- domain:
- description:
- - A domain to grant access to. Any users signed in with the domain specified
- will be granted the specified access .
- returned: success
- type: str
- groupByEmail:
- description:
- - An email address of a Google Group to grant access to.
- returned: success
- type: str
- role:
- description:
- - Describes the rights granted to the user specified by the other member
- of the access object. Primitive, Predefined and custom roles are supported.
- Predefined roles that have equivalent primitive roles are swapped by the
- API to their Primitive counterparts, and will show a diff post-create.
- See [official docs](U(https://cloud.google.com/bigquery/docs/access-control)).
- returned: success
- type: str
- specialGroup:
- description:
- - A special group to grant access to.
- - 'Possible values include: * `projectOwners`: Owners of the enclosing project.'
- - "* `projectReaders`: Readers of the enclosing project."
- - "* `projectWriters`: Writers of the enclosing project."
- - "* `allAuthenticatedUsers`: All authenticated BigQuery users. ."
- returned: success
- type: str
- userByEmail:
- description:
- - 'An email address of a user to grant access to. For example: fred@example.com
- .'
- returned: success
- type: str
- view:
- description:
- - A view from a different dataset to grant access to. Queries executed against
- that view will have read access to tables in this dataset. The role field
- is not required when this field is set. If that view is updated by any
- user, access to the view needs to be granted again via an update operation.
- returned: success
- type: complex
- contains:
- datasetId:
- description:
- - The ID of the dataset containing this table.
- returned: success
- type: str
- projectId:
- description:
- - The ID of the project containing this table.
- returned: success
- type: str
- tableId:
- description:
- - The ID of the table. The ID must contain only letters (a-z, A-Z),
- numbers (0-9), or underscores. The maximum length is 1,024 characters.
- returned: success
- type: str
- creationTime:
- description:
- - The time when this dataset was created, in milliseconds since the epoch.
- returned: success
- type: int
- datasetReference:
- description:
- - A reference that identifies the dataset.
- returned: success
- type: complex
- contains:
- datasetId:
- description:
- - A unique ID for this dataset, without the project name. The ID must contain
- only letters (a-z, A-Z), numbers (0-9), or underscores. The maximum length
- is 1,024 characters.
- returned: success
- type: str
- projectId:
- description:
- - The ID of the project containing this dataset.
- returned: success
- type: str
- defaultTableExpirationMs:
- description:
- - The default lifetime of all tables in the dataset, in milliseconds.
- - The minimum value is 3600000 milliseconds (one hour).
- - Once this property is set, all newly-created tables in the dataset will have
- an `expirationTime` property set to the creation time plus the value in this
- property, and changing the value will only affect new tables, not existing
- ones. When the `expirationTime` for a given table is reached, that table will
- be deleted automatically.
- - If a table's `expirationTime` is modified or removed before the table expires,
- or if you provide an explicit `expirationTime` when creating a table, that
- value takes precedence over the default expiration time indicated by this
- property.
- returned: success
- type: int
- defaultPartitionExpirationMs:
- description:
- - The default partition expiration for all partitioned tables in the dataset,
- in milliseconds.
- - Once this property is set, all newly-created partitioned tables in the dataset
- will have an `expirationMs` property in the `timePartitioning` settings set
- to this value, and changing the value will only affect new tables, not existing
- ones. The storage in a partition will have an expiration time of its partition
- time plus this value.
- - 'Setting this property overrides the use of `defaultTableExpirationMs` for
- partitioned tables: only one of `defaultTableExpirationMs` and `defaultPartitionExpirationMs`
- will be used for any new partitioned table. If you provide an explicit `timePartitioning.expirationMs`
- when creating or updating a partitioned table, that value takes precedence
- over the default partition expiration time indicated by this property.'
- returned: success
- type: int
- description:
- description:
- - A user-friendly description of the dataset.
- returned: success
- type: str
- etag:
- description:
- - A hash of the resource.
- returned: success
- type: str
- friendlyName:
- description:
- - A descriptive name for the dataset.
- returned: success
- type: str
- id:
- description:
- - The fully-qualified unique name of the dataset in the format projectId:datasetId.
- The dataset name without the project name is given in the datasetId field
- .
- returned: success
- type: str
- labels:
- description:
- - The labels associated with this dataset. You can use these to organize and
- group your datasets .
- returned: success
- type: dict
- lastModifiedTime:
- description:
- - The date when this dataset or any of its tables was last modified, in milliseconds
- since the epoch.
- returned: success
- type: int
- location:
- description:
- - The geographic location where the dataset should reside.
- - See [official docs](U(https://cloud.google.com/bigquery/docs/dataset-locations)).
- - There are two types of locations, regional or multi-regional. A regional location
- is a specific geographic place, such as Tokyo, and a multi-regional location
- is a large geographic area, such as the United States, that contains at least
- two geographic places.
- - 'Possible regional values include: `asia-east1`, `asia-northeast1`, `asia-southeast1`,
- `australia-southeast1`, `europe-north1`, `europe-west2` and `us-east4`.'
- - 'Possible multi-regional values: `EU` and `US`.'
- - The default value is multi-regional location `US`.
- - Changing this forces a new resource to be created.
- returned: success
- type: str
- defaultEncryptionConfiguration:
- description:
- - The default encryption key for all tables in the dataset. Once this property
- is set, all newly-created partitioned tables in the dataset will have encryption
- key set to this value, unless table creation request (or query) overrides
- the key.
- returned: success
- type: complex
- contains:
- kmsKeyName:
- description:
- - Describes the Cloud KMS encryption key that will be used to protect destination
- BigQuery table. The BigQuery Service Account associated with your project
- requires access to this encryption key.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict())
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/bigquery']
-
- return_value = {'resources': fetch_list(module, collection(module))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/bigquery/v2/projects/{project}/datasets".format(**module.params)
-
-
-def fetch_list(module, link):
- auth = GcpSession(module, 'bigquery')
- return auth.list(link, return_if_object, array_name='datasets')
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_bigquery_table.py b/lib/ansible/modules/cloud/google/gcp_bigquery_table.py
deleted file mode 100644
index 4a4f8804e6..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_bigquery_table.py
+++ /dev/null
@@ -1,1703 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_bigquery_table
-description:
-- A Table that belongs to a Dataset .
-short_description: Creates a GCP Table
-version_added: '2.8'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- table_reference:
- description:
- - Reference describing the ID of this table.
- required: false
- type: dict
- suboptions:
- dataset_id:
- description:
- - The ID of the dataset containing this table.
- required: false
- type: str
- project_id:
- description:
- - The ID of the project containing this table.
- required: false
- type: str
- table_id:
- description:
- - The ID of the table.
- required: false
- type: str
- clustering:
- description:
- - One or more fields on which data should be clustered. Only top-level, non-repeated,
- simple-type fields are supported. When you cluster a table using multiple columns,
- the order of columns you specify is important. The order of the specified columns
- determines the sort order of the data.
- required: false
- type: list
- version_added: '2.9'
- description:
- description:
- - A user-friendly description of the dataset.
- required: false
- type: str
- friendly_name:
- description:
- - A descriptive name for this table.
- required: false
- type: str
- labels:
- description:
- - The labels associated with this dataset. You can use these to organize and group
- your datasets .
- required: false
- type: dict
- name:
- description:
- - Name of the table.
- required: false
- type: str
- num_rows:
- description:
- - The number of rows of data in this table, excluding any data in the streaming
- buffer.
- required: false
- type: int
- version_added: '2.9'
- view:
- description:
- - The view definition.
- required: false
- type: dict
- suboptions:
- use_legacy_sql:
- description:
- - Specifies whether to use BigQuery's legacy SQL for this view .
- required: false
- type: bool
- user_defined_function_resources:
- description:
- - Describes user-defined function resources used in the query.
- required: false
- type: list
- suboptions:
- inline_code:
- description:
- - An inline resource that contains code for a user-defined function (UDF).
- Providing a inline code resource is equivalent to providing a URI for
- a file containing the same code.
- required: false
- type: str
- resource_uri:
- description:
- - A code resource to load from a Google Cloud Storage URI (gs://bucket/path).
- required: false
- type: str
- time_partitioning:
- description:
- - If specified, configures time-based partitioning for this table.
- required: false
- type: dict
- suboptions:
- expiration_ms:
- description:
- - Number of milliseconds for which to keep the storage for a partition.
- required: false
- type: int
- field:
- description:
- - If not set, the table is partitioned by pseudo column, referenced via either
- '_PARTITIONTIME' as TIMESTAMP type, or '_PARTITIONDATE' as DATE type. If
- field is specified, the table is instead partitioned by this field. The
- field must be a top-level TIMESTAMP or DATE field. Its mode must be NULLABLE
- or REQUIRED.
- required: false
- type: str
- version_added: '2.9'
- type:
- description:
- - The only type supported is DAY, which will generate one partition per day.
- - 'Some valid choices include: "DAY"'
- required: false
- type: str
- schema:
- description:
- - Describes the schema of this table.
- required: false
- type: dict
- suboptions:
- fields:
- description:
- - Describes the fields in a table.
- required: false
- type: list
- suboptions:
- description:
- description:
- - The field description. The maximum length is 1,024 characters.
- required: false
- type: str
- fields:
- description:
- - Describes the nested schema fields if the type property is set to RECORD.
- required: false
- type: list
- mode:
- description:
- - The field mode.
- - 'Some valid choices include: "NULLABLE", "REQUIRED", "REPEATED"'
- required: false
- type: str
- name:
- description:
- - The field name.
- required: false
- type: str
- type:
- description:
- - The field data type.
- - 'Some valid choices include: "STRING", "BYTES", "INTEGER", "FLOAT",
- "TIMESTAMP", "DATE", "TIME", "DATETIME", "RECORD"'
- required: false
- type: str
- encryption_configuration:
- description:
- - Custom encryption configuration.
- required: false
- type: dict
- suboptions:
- kms_key_name:
- description:
- - Describes the Cloud KMS encryption key that will be used to protect destination
- BigQuery table. The BigQuery Service Account associated with your project
- requires access to this encryption key.
- required: false
- type: str
- expiration_time:
- description:
- - The time when this table expires, in milliseconds since the epoch. If not present,
- the table will persist indefinitely.
- required: false
- type: int
- external_data_configuration:
- description:
- - Describes the data format, location, and other properties of a table stored
- outside of BigQuery. By defining these properties, the data source can then
- be queried as if it were a standard BigQuery table.
- required: false
- type: dict
- suboptions:
- autodetect:
- description:
- - Try to detect schema and format options automatically. Any option specified
- explicitly will be honored.
- required: false
- type: bool
- compression:
- description:
- - The compression type of the data source.
- - 'Some valid choices include: "GZIP", "NONE"'
- required: false
- type: str
- ignore_unknown_values:
- description:
- - Indicates if BigQuery should allow extra values that are not represented
- in the table schema .
- required: false
- type: bool
- max_bad_records:
- description:
- - The maximum number of bad records that BigQuery can ignore when reading
- data .
- required: false
- default: '0'
- type: int
- source_format:
- description:
- - The data format.
- - 'Some valid choices include: "CSV", "GOOGLE_SHEETS", "NEWLINE_DELIMITED_JSON",
- "AVRO", "DATASTORE_BACKUP", "BIGTABLE"'
- required: false
- type: str
- source_uris:
- description:
- - The fully-qualified URIs that point to your data in Google Cloud.
- - 'For Google Cloud Storage URIs: Each URI can contain one ''*'' wildcard
- character and it must come after the ''bucket'' name. Size limits related
- to load jobs apply to external data sources. For Google Cloud Bigtable URIs:
- Exactly one URI can be specified and it has be a fully specified and valid
- HTTPS URL for a Google Cloud Bigtable table. For Google Cloud Datastore
- backups, exactly one URI can be specified. Also, the ''*'' wildcard character
- is not allowed.'
- required: false
- type: list
- schema:
- description:
- - The schema for the data. Schema is required for CSV and JSON formats.
- required: false
- type: dict
- suboptions:
- fields:
- description:
- - Describes the fields in a table.
- required: false
- type: list
- suboptions:
- description:
- description:
- - The field description.
- required: false
- type: str
- fields:
- description:
- - Describes the nested schema fields if the type property is set to
- RECORD .
- required: false
- type: list
- mode:
- description:
- - Field mode.
- - 'Some valid choices include: "NULLABLE", "REQUIRED", "REPEATED"'
- required: false
- type: str
- name:
- description:
- - Field name.
- required: false
- type: str
- type:
- description:
- - Field data type.
- - 'Some valid choices include: "STRING", "BYTES", "INTEGER", "FLOAT",
- "TIMESTAMP", "DATE", "TIME", "DATETIME", "RECORD"'
- required: false
- type: str
- google_sheets_options:
- description:
- - Additional options if sourceFormat is set to GOOGLE_SHEETS.
- required: false
- type: dict
- suboptions:
- skip_leading_rows:
- description:
- - The number of rows at the top of a Google Sheet that BigQuery will skip
- when reading the data.
- required: false
- default: '0'
- type: int
- csv_options:
- description:
- - Additional properties to set if sourceFormat is set to CSV.
- required: false
- type: dict
- suboptions:
- allow_jagged_rows:
- description:
- - Indicates if BigQuery should accept rows that are missing trailing optional
- columns .
- required: false
- type: bool
- allow_quoted_newlines:
- description:
- - Indicates if BigQuery should allow quoted data sections that contain
- newline characters in a CSV file .
- required: false
- type: bool
- encoding:
- description:
- - The character encoding of the data.
- - 'Some valid choices include: "UTF-8", "ISO-8859-1"'
- required: false
- type: str
- field_delimiter:
- description:
- - The separator for fields in a CSV file.
- required: false
- type: str
- quote:
- description:
- - The value that is used to quote data sections in a CSV file.
- required: false
- type: str
- skip_leading_rows:
- description:
- - The number of rows at the top of a CSV file that BigQuery will skip
- when reading the data.
- required: false
- default: '0'
- type: int
- bigtable_options:
- description:
- - Additional options if sourceFormat is set to BIGTABLE.
- required: false
- type: dict
- suboptions:
- ignore_unspecified_column_families:
- description:
- - If field is true, then the column families that are not specified in
- columnFamilies list are not exposed in the table schema .
- required: false
- type: bool
- read_rowkey_as_string:
- description:
- - If field is true, then the rowkey column families will be read and converted
- to string.
- required: false
- type: bool
- column_families:
- description:
- - List of column families to expose in the table schema along with their
- types.
- required: false
- type: list
- suboptions:
- columns:
- description:
- - Lists of columns that should be exposed as individual fields as
- opposed to a list of (column name, value) pairs.
- required: false
- type: list
- suboptions:
- encoding:
- description:
- - The encoding of the values when the type is not STRING.
- - 'Some valid choices include: "TEXT", "BINARY"'
- required: false
- type: str
- field_name:
- description:
- - If the qualifier is not a valid BigQuery field identifier, a
- valid identifier must be provided as the column field name and
- is used as field name in queries.
- required: false
- type: str
- only_read_latest:
- description:
- - If this is set, only the latest version of value in this column
- are exposed .
- required: false
- type: bool
- qualifier_string:
- description:
- - Qualifier of the column.
- required: true
- type: str
- type:
- description:
- - The type to convert the value in cells of this column.
- - 'Some valid choices include: "BYTES", "STRING", "INTEGER", "FLOAT",
- "BOOLEAN"'
- required: false
- type: str
- encoding:
- description:
- - The encoding of the values when the type is not STRING.
- - 'Some valid choices include: "TEXT", "BINARY"'
- required: false
- type: str
- family_id:
- description:
- - Identifier of the column family.
- required: false
- type: str
- only_read_latest:
- description:
- - If this is set only the latest version of value are exposed for
- all columns in this column family .
- required: false
- type: bool
- type:
- description:
- - The type to convert the value in cells of this column family.
- - 'Some valid choices include: "BYTES", "STRING", "INTEGER", "FLOAT",
- "BOOLEAN"'
- required: false
- type: str
- dataset:
- description:
- - Name of the dataset.
- required: false
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-'''
-
-EXAMPLES = '''
-- name: create a dataset
- gcp_bigquery_dataset:
- name: example_dataset
- dataset_reference:
- dataset_id: example_dataset
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: dataset
-
-- name: create a table
- gcp_bigquery_table:
- name: example_table
- dataset: example_dataset
- table_reference:
- dataset_id: example_dataset
- project_id: test_project
- table_id: example_table
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-tableReference:
- description:
- - Reference describing the ID of this table.
- returned: success
- type: complex
- contains:
- datasetId:
- description:
- - The ID of the dataset containing this table.
- returned: success
- type: str
- projectId:
- description:
- - The ID of the project containing this table.
- returned: success
- type: str
- tableId:
- description:
- - The ID of the table.
- returned: success
- type: str
-clustering:
- description:
- - One or more fields on which data should be clustered. Only top-level, non-repeated,
- simple-type fields are supported. When you cluster a table using multiple columns,
- the order of columns you specify is important. The order of the specified columns
- determines the sort order of the data.
- returned: success
- type: list
-creationTime:
- description:
- - The time when this dataset was created, in milliseconds since the epoch.
- returned: success
- type: int
-description:
- description:
- - A user-friendly description of the dataset.
- returned: success
- type: str
-friendlyName:
- description:
- - A descriptive name for this table.
- returned: success
- type: str
-id:
- description:
- - An opaque ID uniquely identifying the table.
- returned: success
- type: str
-labels:
- description:
- - The labels associated with this dataset. You can use these to organize and group
- your datasets .
- returned: success
- type: dict
-lastModifiedTime:
- description:
- - The time when this table was last modified, in milliseconds since the epoch.
- returned: success
- type: int
-location:
- description:
- - The geographic location where the table resides. This value is inherited from
- the dataset.
- returned: success
- type: str
-name:
- description:
- - Name of the table.
- returned: success
- type: str
-numBytes:
- description:
- - The size of this table in bytes, excluding any data in the streaming buffer.
- returned: success
- type: int
-numLongTermBytes:
- description:
- - The number of bytes in the table that are considered "long-term storage".
- returned: success
- type: int
-numRows:
- description:
- - The number of rows of data in this table, excluding any data in the streaming
- buffer.
- returned: success
- type: int
-requirePartitionFilter:
- description:
- - If set to true, queries over this table require a partition filter that can be
- used for partition elimination to be specified.
- returned: success
- type: bool
-type:
- description:
- - Describes the table type.
- returned: success
- type: str
-view:
- description:
- - The view definition.
- returned: success
- type: complex
- contains:
- useLegacySql:
- description:
- - Specifies whether to use BigQuery's legacy SQL for this view .
- returned: success
- type: bool
- userDefinedFunctionResources:
- description:
- - Describes user-defined function resources used in the query.
- returned: success
- type: complex
- contains:
- inlineCode:
- description:
- - An inline resource that contains code for a user-defined function (UDF).
- Providing a inline code resource is equivalent to providing a URI for
- a file containing the same code.
- returned: success
- type: str
- resourceUri:
- description:
- - A code resource to load from a Google Cloud Storage URI (gs://bucket/path).
- returned: success
- type: str
-timePartitioning:
- description:
- - If specified, configures time-based partitioning for this table.
- returned: success
- type: complex
- contains:
- expirationMs:
- description:
- - Number of milliseconds for which to keep the storage for a partition.
- returned: success
- type: int
- field:
- description:
- - If not set, the table is partitioned by pseudo column, referenced via either
- '_PARTITIONTIME' as TIMESTAMP type, or '_PARTITIONDATE' as DATE type. If field
- is specified, the table is instead partitioned by this field. The field must
- be a top-level TIMESTAMP or DATE field. Its mode must be NULLABLE or REQUIRED.
- returned: success
- type: str
- type:
- description:
- - The only type supported is DAY, which will generate one partition per day.
- returned: success
- type: str
-streamingBuffer:
- description:
- - Contains information regarding this table's streaming buffer, if one is present.
- This field will be absent if the table is not being streamed to or if there is
- no data in the streaming buffer.
- returned: success
- type: complex
- contains:
- estimatedBytes:
- description:
- - A lower-bound estimate of the number of bytes currently in the streaming buffer.
- returned: success
- type: int
- estimatedRows:
- description:
- - A lower-bound estimate of the number of rows currently in the streaming buffer.
- returned: success
- type: int
- oldestEntryTime:
- description:
- - Contains the timestamp of the oldest entry in the streaming buffer, in milliseconds
- since the epoch, if the streaming buffer is available.
- returned: success
- type: int
-schema:
- description:
- - Describes the schema of this table.
- returned: success
- type: complex
- contains:
- fields:
- description:
- - Describes the fields in a table.
- returned: success
- type: complex
- contains:
- description:
- description:
- - The field description. The maximum length is 1,024 characters.
- returned: success
- type: str
- fields:
- description:
- - Describes the nested schema fields if the type property is set to RECORD.
- returned: success
- type: list
- mode:
- description:
- - The field mode.
- returned: success
- type: str
- name:
- description:
- - The field name.
- returned: success
- type: str
- type:
- description:
- - The field data type.
- returned: success
- type: str
-encryptionConfiguration:
- description:
- - Custom encryption configuration.
- returned: success
- type: complex
- contains:
- kmsKeyName:
- description:
- - Describes the Cloud KMS encryption key that will be used to protect destination
- BigQuery table. The BigQuery Service Account associated with your project
- requires access to this encryption key.
- returned: success
- type: str
-expirationTime:
- description:
- - The time when this table expires, in milliseconds since the epoch. If not present,
- the table will persist indefinitely.
- returned: success
- type: int
-externalDataConfiguration:
- description:
- - Describes the data format, location, and other properties of a table stored outside
- of BigQuery. By defining these properties, the data source can then be queried
- as if it were a standard BigQuery table.
- returned: success
- type: complex
- contains:
- autodetect:
- description:
- - Try to detect schema and format options automatically. Any option specified
- explicitly will be honored.
- returned: success
- type: bool
- compression:
- description:
- - The compression type of the data source.
- returned: success
- type: str
- ignoreUnknownValues:
- description:
- - Indicates if BigQuery should allow extra values that are not represented in
- the table schema .
- returned: success
- type: bool
- maxBadRecords:
- description:
- - The maximum number of bad records that BigQuery can ignore when reading data
- .
- returned: success
- type: int
- sourceFormat:
- description:
- - The data format.
- returned: success
- type: str
- sourceUris:
- description:
- - The fully-qualified URIs that point to your data in Google Cloud.
- - 'For Google Cloud Storage URIs: Each URI can contain one ''*'' wildcard character
- and it must come after the ''bucket'' name. Size limits related to load jobs
- apply to external data sources. For Google Cloud Bigtable URIs: Exactly one
- URI can be specified and it has be a fully specified and valid HTTPS URL for
- a Google Cloud Bigtable table. For Google Cloud Datastore backups, exactly
- one URI can be specified. Also, the ''*'' wildcard character is not allowed.'
- returned: success
- type: list
- schema:
- description:
- - The schema for the data. Schema is required for CSV and JSON formats.
- returned: success
- type: complex
- contains:
- fields:
- description:
- - Describes the fields in a table.
- returned: success
- type: complex
- contains:
- description:
- description:
- - The field description.
- returned: success
- type: str
- fields:
- description:
- - Describes the nested schema fields if the type property is set to
- RECORD .
- returned: success
- type: list
- mode:
- description:
- - Field mode.
- returned: success
- type: str
- name:
- description:
- - Field name.
- returned: success
- type: str
- type:
- description:
- - Field data type.
- returned: success
- type: str
- googleSheetsOptions:
- description:
- - Additional options if sourceFormat is set to GOOGLE_SHEETS.
- returned: success
- type: complex
- contains:
- skipLeadingRows:
- description:
- - The number of rows at the top of a Google Sheet that BigQuery will skip
- when reading the data.
- returned: success
- type: int
- csvOptions:
- description:
- - Additional properties to set if sourceFormat is set to CSV.
- returned: success
- type: complex
- contains:
- allowJaggedRows:
- description:
- - Indicates if BigQuery should accept rows that are missing trailing optional
- columns .
- returned: success
- type: bool
- allowQuotedNewlines:
- description:
- - Indicates if BigQuery should allow quoted data sections that contain newline
- characters in a CSV file .
- returned: success
- type: bool
- encoding:
- description:
- - The character encoding of the data.
- returned: success
- type: str
- fieldDelimiter:
- description:
- - The separator for fields in a CSV file.
- returned: success
- type: str
- quote:
- description:
- - The value that is used to quote data sections in a CSV file.
- returned: success
- type: str
- skipLeadingRows:
- description:
- - The number of rows at the top of a CSV file that BigQuery will skip when
- reading the data.
- returned: success
- type: int
- bigtableOptions:
- description:
- - Additional options if sourceFormat is set to BIGTABLE.
- returned: success
- type: complex
- contains:
- ignoreUnspecifiedColumnFamilies:
- description:
- - If field is true, then the column families that are not specified in columnFamilies
- list are not exposed in the table schema .
- returned: success
- type: bool
- readRowkeyAsString:
- description:
- - If field is true, then the rowkey column families will be read and converted
- to string.
- returned: success
- type: bool
- columnFamilies:
- description:
- - List of column families to expose in the table schema along with their
- types.
- returned: success
- type: complex
- contains:
- columns:
- description:
- - Lists of columns that should be exposed as individual fields as opposed
- to a list of (column name, value) pairs.
- returned: success
- type: complex
- contains:
- encoding:
- description:
- - The encoding of the values when the type is not STRING.
- returned: success
- type: str
- fieldName:
- description:
- - If the qualifier is not a valid BigQuery field identifier, a valid
- identifier must be provided as the column field name and is used
- as field name in queries.
- returned: success
- type: str
- onlyReadLatest:
- description:
- - If this is set, only the latest version of value in this column
- are exposed .
- returned: success
- type: bool
- qualifierString:
- description:
- - Qualifier of the column.
- returned: success
- type: str
- type:
- description:
- - The type to convert the value in cells of this column.
- returned: success
- type: str
- encoding:
- description:
- - The encoding of the values when the type is not STRING.
- returned: success
- type: str
- familyId:
- description:
- - Identifier of the column family.
- returned: success
- type: str
- onlyReadLatest:
- description:
- - If this is set only the latest version of value are exposed for all
- columns in this column family .
- returned: success
- type: bool
- type:
- description:
- - The type to convert the value in cells of this column family.
- returned: success
- type: str
-dataset:
- description:
- - Name of the dataset.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- table_reference=dict(type='dict', options=dict(dataset_id=dict(type='str'), project_id=dict(type='str'), table_id=dict(type='str'))),
- clustering=dict(type='list', elements='str'),
- description=dict(type='str'),
- friendly_name=dict(type='str'),
- labels=dict(type='dict'),
- name=dict(type='str'),
- num_rows=dict(type='int'),
- view=dict(
- type='dict',
- options=dict(
- use_legacy_sql=dict(type='bool'),
- user_defined_function_resources=dict(
- type='list', elements='dict', options=dict(inline_code=dict(type='str'), resource_uri=dict(type='str'))
- ),
- ),
- ),
- time_partitioning=dict(type='dict', options=dict(expiration_ms=dict(type='int'), field=dict(type='str'), type=dict(type='str'))),
- schema=dict(
- type='dict',
- options=dict(
- fields=dict(
- type='list',
- elements='dict',
- options=dict(
- description=dict(type='str'),
- fields=dict(type='list', elements='str'),
- mode=dict(type='str'),
- name=dict(type='str'),
- type=dict(type='str'),
- ),
- )
- ),
- ),
- encryption_configuration=dict(type='dict', options=dict(kms_key_name=dict(type='str'))),
- expiration_time=dict(type='int'),
- external_data_configuration=dict(
- type='dict',
- options=dict(
- autodetect=dict(type='bool'),
- compression=dict(type='str'),
- ignore_unknown_values=dict(type='bool'),
- max_bad_records=dict(default=0, type='int'),
- source_format=dict(type='str'),
- source_uris=dict(type='list', elements='str'),
- schema=dict(
- type='dict',
- options=dict(
- fields=dict(
- type='list',
- elements='dict',
- options=dict(
- description=dict(type='str'),
- fields=dict(type='list', elements='str'),
- mode=dict(type='str'),
- name=dict(type='str'),
- type=dict(type='str'),
- ),
- )
- ),
- ),
- google_sheets_options=dict(type='dict', options=dict(skip_leading_rows=dict(default=0, type='int'))),
- csv_options=dict(
- type='dict',
- options=dict(
- allow_jagged_rows=dict(type='bool'),
- allow_quoted_newlines=dict(type='bool'),
- encoding=dict(type='str'),
- field_delimiter=dict(type='str'),
- quote=dict(type='str'),
- skip_leading_rows=dict(default=0, type='int'),
- ),
- ),
- bigtable_options=dict(
- type='dict',
- options=dict(
- ignore_unspecified_column_families=dict(type='bool'),
- read_rowkey_as_string=dict(type='bool'),
- column_families=dict(
- type='list',
- elements='dict',
- options=dict(
- columns=dict(
- type='list',
- elements='dict',
- options=dict(
- encoding=dict(type='str'),
- field_name=dict(type='str'),
- only_read_latest=dict(type='bool'),
- qualifier_string=dict(required=True, type='str'),
- type=dict(type='str'),
- ),
- ),
- encoding=dict(type='str'),
- family_id=dict(type='str'),
- only_read_latest=dict(type='bool'),
- type=dict(type='str'),
- ),
- ),
- ),
- ),
- ),
- ),
- dataset=dict(type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/bigquery']
-
- state = module.params['state']
- kind = 'bigquery#table'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'bigquery')
- return return_if_object(module, auth.post(link, resource_to_request(module)), kind)
-
-
-def update(module, link, kind):
- auth = GcpSession(module, 'bigquery')
- return return_if_object(module, auth.put(link, resource_to_request(module)), kind)
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'bigquery')
- return return_if_object(module, auth.delete(link), kind)
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'bigquery#table',
- u'tableReference': TableTablereference(module.params.get('table_reference', {}), module).to_request(),
- u'clustering': module.params.get('clustering'),
- u'description': module.params.get('description'),
- u'friendlyName': module.params.get('friendly_name'),
- u'labels': module.params.get('labels'),
- u'name': module.params.get('name'),
- u'numRows': module.params.get('num_rows'),
- u'view': TableView(module.params.get('view', {}), module).to_request(),
- u'timePartitioning': TableTimepartitioning(module.params.get('time_partitioning', {}), module).to_request(),
- u'schema': TableSchema(module.params.get('schema', {}), module).to_request(),
- u'encryptionConfiguration': TableEncryptionconfiguration(module.params.get('encryption_configuration', {}), module).to_request(),
- u'expirationTime': module.params.get('expiration_time'),
- u'externalDataConfiguration': TableExternaldataconfiguration(module.params.get('external_data_configuration', {}), module).to_request(),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'bigquery')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/bigquery/v2/projects/{project}/datasets/{dataset}/tables/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/bigquery/v2/projects/{project}/datasets/{dataset}/tables".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'tableReference': TableTablereference(response.get(u'tableReference', {}), module).from_response(),
- u'clustering': response.get(u'clustering'),
- u'creationTime': response.get(u'creationTime'),
- u'description': response.get(u'description'),
- u'friendlyName': response.get(u'friendlyName'),
- u'id': response.get(u'id'),
- u'labels': response.get(u'labels'),
- u'lastModifiedTime': response.get(u'lastModifiedTime'),
- u'location': response.get(u'location'),
- u'name': response.get(u'name'),
- u'numBytes': response.get(u'numBytes'),
- u'numLongTermBytes': response.get(u'numLongTermBytes'),
- u'numRows': response.get(u'numRows'),
- u'requirePartitionFilter': response.get(u'requirePartitionFilter'),
- u'type': response.get(u'type'),
- u'view': TableView(response.get(u'view', {}), module).from_response(),
- u'timePartitioning': TableTimepartitioning(response.get(u'timePartitioning', {}), module).from_response(),
- u'streamingBuffer': TableStreamingbuffer(response.get(u'streamingBuffer', {}), module).from_response(),
- u'schema': TableSchema(response.get(u'schema', {}), module).from_response(),
- u'encryptionConfiguration': TableEncryptionconfiguration(response.get(u'encryptionConfiguration', {}), module).from_response(),
- u'expirationTime': response.get(u'expirationTime'),
- u'externalDataConfiguration': TableExternaldataconfiguration(response.get(u'externalDataConfiguration', {}), module).from_response(),
- }
-
-
-class TableTablereference(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {u'datasetId': self.request.get('dataset_id'), u'projectId': self.request.get('project_id'), u'tableId': self.request.get('table_id')}
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {u'datasetId': self.request.get(u'datasetId'), u'projectId': self.request.get(u'projectId'), u'tableId': self.request.get(u'tableId')}
- )
-
-
-class TableView(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'useLegacySql': self.request.get('use_legacy_sql'),
- u'userDefinedFunctionResources': TableUserdefinedfunctionresourcesArray(
- self.request.get('user_defined_function_resources', []), self.module
- ).to_request(),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'useLegacySql': self.request.get(u'useLegacySql'),
- u'userDefinedFunctionResources': TableUserdefinedfunctionresourcesArray(
- self.request.get(u'userDefinedFunctionResources', []), self.module
- ).from_response(),
- }
- )
-
-
-class TableUserdefinedfunctionresourcesArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'inlineCode': item.get('inline_code'), u'resourceUri': item.get('resource_uri')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'inlineCode': item.get(u'inlineCode'), u'resourceUri': item.get(u'resourceUri')})
-
-
-class TableTimepartitioning(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {u'expirationMs': self.request.get('expiration_ms'), u'field': self.request.get('field'), u'type': self.request.get('type')}
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {u'expirationMs': self.request.get(u'expirationMs'), u'field': self.request.get(u'field'), u'type': self.request.get(u'type')}
- )
-
-
-class TableStreamingbuffer(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({})
-
- def from_response(self):
- return remove_nones_from_dict({})
-
-
-class TableSchema(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'fields': TableFieldsArray(self.request.get('fields', []), self.module).to_request()})
-
- def from_response(self):
- return remove_nones_from_dict({u'fields': TableFieldsArray(self.request.get(u'fields', []), self.module).from_response()})
-
-
-class TableFieldsArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict(
- {
- u'description': item.get('description'),
- u'fields': item.get('fields'),
- u'mode': item.get('mode'),
- u'name': item.get('name'),
- u'type': item.get('type'),
- }
- )
-
- def _response_from_item(self, item):
- return remove_nones_from_dict(
- {
- u'description': item.get(u'description'),
- u'fields': item.get(u'fields'),
- u'mode': item.get(u'mode'),
- u'name': item.get(u'name'),
- u'type': item.get(u'type'),
- }
- )
-
-
-class TableEncryptionconfiguration(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'kmsKeyName': self.request.get('kms_key_name')})
-
- def from_response(self):
- return remove_nones_from_dict({u'kmsKeyName': self.request.get(u'kmsKeyName')})
-
-
-class TableExternaldataconfiguration(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'autodetect': self.request.get('autodetect'),
- u'compression': self.request.get('compression'),
- u'ignoreUnknownValues': self.request.get('ignore_unknown_values'),
- u'maxBadRecords': self.request.get('max_bad_records'),
- u'sourceFormat': self.request.get('source_format'),
- u'sourceUris': self.request.get('source_uris'),
- u'schema': TableSchema(self.request.get('schema', {}), self.module).to_request(),
- u'googleSheetsOptions': TableGooglesheetsoptions(self.request.get('google_sheets_options', {}), self.module).to_request(),
- u'csvOptions': TableCsvoptions(self.request.get('csv_options', {}), self.module).to_request(),
- u'bigtableOptions': TableBigtableoptions(self.request.get('bigtable_options', {}), self.module).to_request(),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'autodetect': self.request.get(u'autodetect'),
- u'compression': self.request.get(u'compression'),
- u'ignoreUnknownValues': self.request.get(u'ignoreUnknownValues'),
- u'maxBadRecords': self.request.get(u'maxBadRecords'),
- u'sourceFormat': self.request.get(u'sourceFormat'),
- u'sourceUris': self.request.get(u'sourceUris'),
- u'schema': TableSchema(self.request.get(u'schema', {}), self.module).from_response(),
- u'googleSheetsOptions': TableGooglesheetsoptions(self.request.get(u'googleSheetsOptions', {}), self.module).from_response(),
- u'csvOptions': TableCsvoptions(self.request.get(u'csvOptions', {}), self.module).from_response(),
- u'bigtableOptions': TableBigtableoptions(self.request.get(u'bigtableOptions', {}), self.module).from_response(),
- }
- )
-
-
-class TableSchema(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'fields': TableFieldsArray(self.request.get('fields', []), self.module).to_request()})
-
- def from_response(self):
- return remove_nones_from_dict({u'fields': TableFieldsArray(self.request.get(u'fields', []), self.module).from_response()})
-
-
-class TableFieldsArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict(
- {
- u'description': item.get('description'),
- u'fields': item.get('fields'),
- u'mode': item.get('mode'),
- u'name': item.get('name'),
- u'type': item.get('type'),
- }
- )
-
- def _response_from_item(self, item):
- return remove_nones_from_dict(
- {
- u'description': item.get(u'description'),
- u'fields': item.get(u'fields'),
- u'mode': item.get(u'mode'),
- u'name': item.get(u'name'),
- u'type': item.get(u'type'),
- }
- )
-
-
-class TableGooglesheetsoptions(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'skipLeadingRows': self.request.get('skip_leading_rows')})
-
- def from_response(self):
- return remove_nones_from_dict({u'skipLeadingRows': self.request.get(u'skipLeadingRows')})
-
-
-class TableCsvoptions(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'allowJaggedRows': self.request.get('allow_jagged_rows'),
- u'allowQuotedNewlines': self.request.get('allow_quoted_newlines'),
- u'encoding': self.request.get('encoding'),
- u'fieldDelimiter': self.request.get('field_delimiter'),
- u'quote': self.request.get('quote'),
- u'skipLeadingRows': self.request.get('skip_leading_rows'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'allowJaggedRows': self.request.get(u'allowJaggedRows'),
- u'allowQuotedNewlines': self.request.get(u'allowQuotedNewlines'),
- u'encoding': self.request.get(u'encoding'),
- u'fieldDelimiter': self.request.get(u'fieldDelimiter'),
- u'quote': self.request.get(u'quote'),
- u'skipLeadingRows': self.request.get(u'skipLeadingRows'),
- }
- )
-
-
-class TableBigtableoptions(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'ignoreUnspecifiedColumnFamilies': self.request.get('ignore_unspecified_column_families'),
- u'readRowkeyAsString': self.request.get('read_rowkey_as_string'),
- u'columnFamilies': TableColumnfamiliesArray(self.request.get('column_families', []), self.module).to_request(),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'ignoreUnspecifiedColumnFamilies': self.request.get(u'ignoreUnspecifiedColumnFamilies'),
- u'readRowkeyAsString': self.request.get(u'readRowkeyAsString'),
- u'columnFamilies': TableColumnfamiliesArray(self.request.get(u'columnFamilies', []), self.module).from_response(),
- }
- )
-
-
-class TableColumnfamiliesArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict(
- {
- u'columns': TableColumnsArray(item.get('columns', []), self.module).to_request(),
- u'encoding': item.get('encoding'),
- u'familyId': item.get('family_id'),
- u'onlyReadLatest': item.get('only_read_latest'),
- u'type': item.get('type'),
- }
- )
-
- def _response_from_item(self, item):
- return remove_nones_from_dict(
- {
- u'columns': TableColumnsArray(item.get(u'columns', []), self.module).from_response(),
- u'encoding': item.get(u'encoding'),
- u'familyId': item.get(u'familyId'),
- u'onlyReadLatest': item.get(u'onlyReadLatest'),
- u'type': item.get(u'type'),
- }
- )
-
-
-class TableColumnsArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict(
- {
- u'encoding': item.get('encoding'),
- u'fieldName': item.get('field_name'),
- u'onlyReadLatest': item.get('only_read_latest'),
- u'qualifierString': item.get('qualifier_string'),
- u'type': item.get('type'),
- }
- )
-
- def _response_from_item(self, item):
- return remove_nones_from_dict(
- {
- u'encoding': item.get(u'encoding'),
- u'fieldName': item.get(u'fieldName'),
- u'onlyReadLatest': item.get(u'onlyReadLatest'),
- u'qualifierString': item.get(u'qualifierString'),
- u'type': item.get(u'type'),
- }
- )
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_bigquery_table_info.py b/lib/ansible/modules/cloud/google/gcp_bigquery_table_info.py
deleted file mode 100644
index e72d8326ed..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_bigquery_table_info.py
+++ /dev/null
@@ -1,626 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_bigquery_table_info
-description:
-- Gather info for GCP Table
-short_description: Gather info for GCP Table
-version_added: '2.8'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- dataset:
- description:
- - Name of the dataset.
- required: false
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a table
- gcp_bigquery_table_info:
- dataset: example_dataset
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- tableReference:
- description:
- - Reference describing the ID of this table.
- returned: success
- type: complex
- contains:
- datasetId:
- description:
- - The ID of the dataset containing this table.
- returned: success
- type: str
- projectId:
- description:
- - The ID of the project containing this table.
- returned: success
- type: str
- tableId:
- description:
- - The ID of the table.
- returned: success
- type: str
- clustering:
- description:
- - One or more fields on which data should be clustered. Only top-level, non-repeated,
- simple-type fields are supported. When you cluster a table using multiple
- columns, the order of columns you specify is important. The order of the specified
- columns determines the sort order of the data.
- returned: success
- type: list
- creationTime:
- description:
- - The time when this dataset was created, in milliseconds since the epoch.
- returned: success
- type: int
- description:
- description:
- - A user-friendly description of the dataset.
- returned: success
- type: str
- friendlyName:
- description:
- - A descriptive name for this table.
- returned: success
- type: str
- id:
- description:
- - An opaque ID uniquely identifying the table.
- returned: success
- type: str
- labels:
- description:
- - The labels associated with this dataset. You can use these to organize and
- group your datasets .
- returned: success
- type: dict
- lastModifiedTime:
- description:
- - The time when this table was last modified, in milliseconds since the epoch.
- returned: success
- type: int
- location:
- description:
- - The geographic location where the table resides. This value is inherited from
- the dataset.
- returned: success
- type: str
- name:
- description:
- - Name of the table.
- returned: success
- type: str
- numBytes:
- description:
- - The size of this table in bytes, excluding any data in the streaming buffer.
- returned: success
- type: int
- numLongTermBytes:
- description:
- - The number of bytes in the table that are considered "long-term storage".
- returned: success
- type: int
- numRows:
- description:
- - The number of rows of data in this table, excluding any data in the streaming
- buffer.
- returned: success
- type: int
- requirePartitionFilter:
- description:
- - If set to true, queries over this table require a partition filter that can
- be used for partition elimination to be specified.
- returned: success
- type: bool
- type:
- description:
- - Describes the table type.
- returned: success
- type: str
- view:
- description:
- - The view definition.
- returned: success
- type: complex
- contains:
- useLegacySql:
- description:
- - Specifies whether to use BigQuery's legacy SQL for this view .
- returned: success
- type: bool
- userDefinedFunctionResources:
- description:
- - Describes user-defined function resources used in the query.
- returned: success
- type: complex
- contains:
- inlineCode:
- description:
- - An inline resource that contains code for a user-defined function
- (UDF). Providing a inline code resource is equivalent to providing
- a URI for a file containing the same code.
- returned: success
- type: str
- resourceUri:
- description:
- - A code resource to load from a Google Cloud Storage URI (gs://bucket/path).
- returned: success
- type: str
- timePartitioning:
- description:
- - If specified, configures time-based partitioning for this table.
- returned: success
- type: complex
- contains:
- expirationMs:
- description:
- - Number of milliseconds for which to keep the storage for a partition.
- returned: success
- type: int
- field:
- description:
- - If not set, the table is partitioned by pseudo column, referenced via
- either '_PARTITIONTIME' as TIMESTAMP type, or '_PARTITIONDATE' as DATE
- type. If field is specified, the table is instead partitioned by this
- field. The field must be a top-level TIMESTAMP or DATE field. Its mode
- must be NULLABLE or REQUIRED.
- returned: success
- type: str
- type:
- description:
- - The only type supported is DAY, which will generate one partition per
- day.
- returned: success
- type: str
- streamingBuffer:
- description:
- - Contains information regarding this table's streaming buffer, if one is present.
- This field will be absent if the table is not being streamed to or if there
- is no data in the streaming buffer.
- returned: success
- type: complex
- contains:
- estimatedBytes:
- description:
- - A lower-bound estimate of the number of bytes currently in the streaming
- buffer.
- returned: success
- type: int
- estimatedRows:
- description:
- - A lower-bound estimate of the number of rows currently in the streaming
- buffer.
- returned: success
- type: int
- oldestEntryTime:
- description:
- - Contains the timestamp of the oldest entry in the streaming buffer, in
- milliseconds since the epoch, if the streaming buffer is available.
- returned: success
- type: int
- schema:
- description:
- - Describes the schema of this table.
- returned: success
- type: complex
- contains:
- fields:
- description:
- - Describes the fields in a table.
- returned: success
- type: complex
- contains:
- description:
- description:
- - The field description. The maximum length is 1,024 characters.
- returned: success
- type: str
- fields:
- description:
- - Describes the nested schema fields if the type property is set to
- RECORD.
- returned: success
- type: list
- mode:
- description:
- - The field mode.
- returned: success
- type: str
- name:
- description:
- - The field name.
- returned: success
- type: str
- type:
- description:
- - The field data type.
- returned: success
- type: str
- encryptionConfiguration:
- description:
- - Custom encryption configuration.
- returned: success
- type: complex
- contains:
- kmsKeyName:
- description:
- - Describes the Cloud KMS encryption key that will be used to protect destination
- BigQuery table. The BigQuery Service Account associated with your project
- requires access to this encryption key.
- returned: success
- type: str
- expirationTime:
- description:
- - The time when this table expires, in milliseconds since the epoch. If not
- present, the table will persist indefinitely.
- returned: success
- type: int
- externalDataConfiguration:
- description:
- - Describes the data format, location, and other properties of a table stored
- outside of BigQuery. By defining these properties, the data source can then
- be queried as if it were a standard BigQuery table.
- returned: success
- type: complex
- contains:
- autodetect:
- description:
- - Try to detect schema and format options automatically. Any option specified
- explicitly will be honored.
- returned: success
- type: bool
- compression:
- description:
- - The compression type of the data source.
- returned: success
- type: str
- ignoreUnknownValues:
- description:
- - Indicates if BigQuery should allow extra values that are not represented
- in the table schema .
- returned: success
- type: bool
- maxBadRecords:
- description:
- - The maximum number of bad records that BigQuery can ignore when reading
- data .
- returned: success
- type: int
- sourceFormat:
- description:
- - The data format.
- returned: success
- type: str
- sourceUris:
- description:
- - The fully-qualified URIs that point to your data in Google Cloud.
- - 'For Google Cloud Storage URIs: Each URI can contain one ''*'' wildcard
- character and it must come after the ''bucket'' name. Size limits related
- to load jobs apply to external data sources. For Google Cloud Bigtable
- URIs: Exactly one URI can be specified and it has be a fully specified
- and valid HTTPS URL for a Google Cloud Bigtable table. For Google Cloud
- Datastore backups, exactly one URI can be specified. Also, the ''*'' wildcard
- character is not allowed.'
- returned: success
- type: list
- schema:
- description:
- - The schema for the data. Schema is required for CSV and JSON formats.
- returned: success
- type: complex
- contains:
- fields:
- description:
- - Describes the fields in a table.
- returned: success
- type: complex
- contains:
- description:
- description:
- - The field description.
- returned: success
- type: str
- fields:
- description:
- - Describes the nested schema fields if the type property is set
- to RECORD .
- returned: success
- type: list
- mode:
- description:
- - Field mode.
- returned: success
- type: str
- name:
- description:
- - Field name.
- returned: success
- type: str
- type:
- description:
- - Field data type.
- returned: success
- type: str
- googleSheetsOptions:
- description:
- - Additional options if sourceFormat is set to GOOGLE_SHEETS.
- returned: success
- type: complex
- contains:
- skipLeadingRows:
- description:
- - The number of rows at the top of a Google Sheet that BigQuery will
- skip when reading the data.
- returned: success
- type: int
- csvOptions:
- description:
- - Additional properties to set if sourceFormat is set to CSV.
- returned: success
- type: complex
- contains:
- allowJaggedRows:
- description:
- - Indicates if BigQuery should accept rows that are missing trailing
- optional columns .
- returned: success
- type: bool
- allowQuotedNewlines:
- description:
- - Indicates if BigQuery should allow quoted data sections that contain
- newline characters in a CSV file .
- returned: success
- type: bool
- encoding:
- description:
- - The character encoding of the data.
- returned: success
- type: str
- fieldDelimiter:
- description:
- - The separator for fields in a CSV file.
- returned: success
- type: str
- quote:
- description:
- - The value that is used to quote data sections in a CSV file.
- returned: success
- type: str
- skipLeadingRows:
- description:
- - The number of rows at the top of a CSV file that BigQuery will skip
- when reading the data.
- returned: success
- type: int
- bigtableOptions:
- description:
- - Additional options if sourceFormat is set to BIGTABLE.
- returned: success
- type: complex
- contains:
- ignoreUnspecifiedColumnFamilies:
- description:
- - If field is true, then the column families that are not specified
- in columnFamilies list are not exposed in the table schema .
- returned: success
- type: bool
- readRowkeyAsString:
- description:
- - If field is true, then the rowkey column families will be read and
- converted to string.
- returned: success
- type: bool
- columnFamilies:
- description:
- - List of column families to expose in the table schema along with their
- types.
- returned: success
- type: complex
- contains:
- columns:
- description:
- - Lists of columns that should be exposed as individual fields as
- opposed to a list of (column name, value) pairs.
- returned: success
- type: complex
- contains:
- encoding:
- description:
- - The encoding of the values when the type is not STRING.
- returned: success
- type: str
- fieldName:
- description:
- - If the qualifier is not a valid BigQuery field identifier,
- a valid identifier must be provided as the column field name
- and is used as field name in queries.
- returned: success
- type: str
- onlyReadLatest:
- description:
- - If this is set, only the latest version of value in this column
- are exposed .
- returned: success
- type: bool
- qualifierString:
- description:
- - Qualifier of the column.
- returned: success
- type: str
- type:
- description:
- - The type to convert the value in cells of this column.
- returned: success
- type: str
- encoding:
- description:
- - The encoding of the values when the type is not STRING.
- returned: success
- type: str
- familyId:
- description:
- - Identifier of the column family.
- returned: success
- type: str
- onlyReadLatest:
- description:
- - If this is set only the latest version of value are exposed for
- all columns in this column family .
- returned: success
- type: bool
- type:
- description:
- - The type to convert the value in cells of this column family.
- returned: success
- type: str
- dataset:
- description:
- - Name of the dataset.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(dataset=dict(type='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/bigquery']
-
- return_value = {'resources': fetch_list(module, collection(module))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/bigquery/v2/projects/{project}/datasets/{dataset}/tables".format(**module.params)
-
-
-def fetch_list(module, link):
- auth = GcpSession(module, 'bigquery')
- return auth.list(link, return_if_object, array_name='tables')
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_cloudbuild_trigger.py b/lib/ansible/modules/cloud/google/gcp_cloudbuild_trigger.py
deleted file mode 100644
index 3cd2c9f2b9..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_cloudbuild_trigger.py
+++ /dev/null
@@ -1,961 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_cloudbuild_trigger
-description:
-- Configuration for an automated build in response to source repository changes.
-short_description: Creates a GCP Trigger
-version_added: '2.8'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- id:
- description:
- - The unique identifier for the trigger.
- required: false
- type: str
- name:
- description:
- - Name of the trigger. Must be unique within the project.
- required: false
- type: str
- version_added: '2.10'
- description:
- description:
- - Human-readable description of the trigger.
- required: false
- type: str
- disabled:
- description:
- - Whether the trigger is disabled or not. If true, the trigger will never result
- in a build.
- required: false
- type: bool
- substitutions:
- description:
- - Substitutions data for Build resource.
- required: false
- type: dict
- filename:
- description:
- - Path, from the source root, to a file whose contents is used for the template.
- Either a filename or build template must be provided.
- required: false
- type: str
- ignored_files:
- description:
- - ignoredFiles and includedFiles are file glob matches using http://godoc/pkg/path/filepath#Match
- extended with support for `**`.
- - If ignoredFiles and changed files are both empty, then they are not used to
- determine whether or not to trigger a build.
- - If ignoredFiles is not empty, then we ignore any files that match any of the
- ignored_file globs. If the change has no files that are outside of the ignoredFiles
- globs, then we do not trigger a build.
- required: false
- type: list
- included_files:
- description:
- - ignoredFiles and includedFiles are file glob matches using http://godoc/pkg/path/filepath#Match
- extended with support for `**`.
- - If any of the files altered in the commit pass the ignoredFiles filter and includedFiles
- is empty, then as far as this filter is concerned, we should trigger the build.
- - If any of the files altered in the commit pass the ignoredFiles filter and includedFiles
- is not empty, then we make sure that at least one of those files matches a includedFiles
- glob. If not, then we do not trigger a build.
- required: false
- type: list
- trigger_template:
- description:
- - Template describing the types of source changes to trigger a build.
- - Branch and tag names in trigger templates are interpreted as regular expressions.
- Any branch or tag change that matches that regular expression will trigger a
- build.
- required: false
- type: dict
- suboptions:
- project_id:
- description:
- - ID of the project that owns the Cloud Source Repository. If omitted, the
- project ID requesting the build is assumed.
- required: false
- type: str
- repo_name:
- description:
- - Name of the Cloud Source Repository. If omitted, the name "default" is assumed.
- required: false
- default: default
- type: str
- dir:
- description:
- - Directory, relative to the source root, in which to run the build.
- - This must be a relative path. If a step's dir is specified and is an absolute
- path, this value is ignored for that step's execution.
- required: false
- type: str
- branch_name:
- description:
- - Name of the branch to build. Exactly one a of branch name, tag, or commit
- SHA must be provided.
- - This field is a regular expression.
- required: false
- type: str
- tag_name:
- description:
- - Name of the tag to build. Exactly one of a branch name, tag, or commit SHA
- must be provided.
- - This field is a regular expression.
- required: false
- type: str
- commit_sha:
- description:
- - Explicit commit SHA to build. Exactly one of a branch name, tag, or commit
- SHA must be provided.
- required: false
- type: str
- build:
- description:
- - Contents of the build template. Either a filename or build template must be
- provided.
- required: false
- type: dict
- suboptions:
- tags:
- description:
- - Tags for annotation of a Build. These are not docker tags.
- required: false
- type: list
- images:
- description:
- - A list of images to be pushed upon the successful completion of all build
- steps.
- - The images are pushed using the builder service account's credentials.
- - The digests of the pushed images will be stored in the Build resource's
- results field.
- - If any of the images fail to be pushed, the build status is marked FAILURE.
- required: false
- type: list
- steps:
- description:
- - The operations to be performed on the workspace.
- required: false
- type: list
- suboptions:
- name:
- description:
- - The name of the container image that will run this particular build
- step.
- - If the image is available in the host's Docker daemon's cache, it will
- be run directly. If not, the host will attempt to pull the image first,
- using the builder service account's credentials if necessary.
- - The Docker daemon's cache will already have the latest versions of all
- of the officially supported build steps (U(https://github.com/GoogleCloudPlatform/cloud-builders)).
- - The Docker daemon will also have cached many of the layers for some
- popular images, like "ubuntu", "debian", but they will be refreshed
- at the time you attempt to use them.
- - If you built an image in a previous build step, it will be stored in
- the host's Docker daemon's cache and is available to use as the name
- for a later build step.
- required: false
- type: str
- args:
- description:
- - A list of arguments that will be presented to the step when it is started.
- - If the image used to run the step's container has an entrypoint, the
- args are used as arguments to that entrypoint. If the image does not
- define an entrypoint, the first element in args is used as the entrypoint,
- and the remainder will be used as arguments.
- required: false
- type: list
- env:
- description:
- - A list of environment variable definitions to be used when running a
- step.
- - The elements are of the form "KEY=VALUE" for the environment variable
- "KEY" being given the value "VALUE".
- required: false
- type: list
- id:
- description:
- - Unique identifier for this build step, used in `wait_for` to reference
- this build step as a dependency.
- required: false
- type: str
- entrypoint:
- description:
- - Entrypoint to be used instead of the build step image's default entrypoint.
- - If unset, the image's default entrypoint is used .
- required: false
- type: str
- dir:
- description:
- - Working directory to use when running this step's container.
- - If this value is a relative path, it is relative to the build's working
- directory. If this value is absolute, it may be outside the build's
- working directory, in which case the contents of the path may not be
- persisted across build step executions, unless a `volume` for that path
- is specified.
- - If the build specifies a `RepoSource` with `dir` and a step with a `dir`,
- which specifies an absolute path, the `RepoSource` `dir` is ignored
- for the step's execution.
- required: false
- type: str
- secret_env:
- description:
- - A list of environment variables which are encrypted using a Cloud Key
- Management Service crypto key. These values must be specified in the
- build's `Secret`.
- required: false
- type: list
- timeout:
- description:
- - Time limit for executing this build step. If not defined, the step has
- no time limit and will be allowed to continue to run until either it
- completes or the build itself times out.
- required: false
- type: str
- timing:
- description:
- - Output only. Stores timing information for executing this build step.
- required: false
- type: str
- volumes:
- description:
- - List of volumes to mount into the build step.
- - Each volume is created as an empty volume prior to execution of the
- build step. Upon completion of the build, volumes and their contents
- are discarded.
- - Using a named volume in only one step is not valid as it is indicative
- of a build request with an incorrect configuration.
- required: false
- type: list
- suboptions:
- name:
- description:
- - Name of the volume to mount.
- - Volume names must be unique per build step and must be valid names
- for Docker volumes. Each named volume must be used by at least two
- build steps.
- required: false
- type: str
- path:
- description:
- - Path at which to mount the volume.
- - Paths must be absolute and cannot conflict with other volume paths
- on the same build step or with certain reserved volume paths.
- required: false
- type: str
- wait_for:
- description:
- - The ID(s) of the step(s) that this build step depends on.
- - This build step will not start until all the build steps in `wait_for`
- have completed successfully. If `wait_for` is empty, this build step
- will start when all previous build steps in the `Build.Steps` list have
- completed successfully.
- required: false
- type: list
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/cloud-build/docs/api/reference/rest/)'
-- 'Automating builds using build triggers: U(https://cloud.google.com/cloud-build/docs/running-builds/automate-builds)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-- The id for this resource is created by the API after you create the resource the
- first time. If you want to manage this resource after creation, you'll have to copy
- the generated id into the playbook. If you do not, new triggers will be created
- on subsequent runs.
-'''
-
-EXAMPLES = '''
-- name: create a repository
- gcp_sourcerepo_repository:
- name: projects/{{ gcp_project }}/repos/{{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
-
-- name: create a trigger
- gcp_cloudbuild_trigger:
- trigger_template:
- branch_name: master
- project_id: test_project
- repo_name: test_object
- filename: cloudbuild.yaml
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-id:
- description:
- - The unique identifier for the trigger.
- returned: success
- type: str
-name:
- description:
- - Name of the trigger. Must be unique within the project.
- returned: success
- type: str
-description:
- description:
- - Human-readable description of the trigger.
- returned: success
- type: str
-disabled:
- description:
- - Whether the trigger is disabled or not. If true, the trigger will never result
- in a build.
- returned: success
- type: bool
-createTime:
- description:
- - Time when the trigger was created.
- returned: success
- type: str
-substitutions:
- description:
- - Substitutions data for Build resource.
- returned: success
- type: dict
-filename:
- description:
- - Path, from the source root, to a file whose contents is used for the template.
- Either a filename or build template must be provided.
- returned: success
- type: str
-ignoredFiles:
- description:
- - ignoredFiles and includedFiles are file glob matches using http://godoc/pkg/path/filepath#Match
- extended with support for `**`.
- - If ignoredFiles and changed files are both empty, then they are not used to determine
- whether or not to trigger a build.
- - If ignoredFiles is not empty, then we ignore any files that match any of the ignored_file
- globs. If the change has no files that are outside of the ignoredFiles globs,
- then we do not trigger a build.
- returned: success
- type: list
-includedFiles:
- description:
- - ignoredFiles and includedFiles are file glob matches using http://godoc/pkg/path/filepath#Match
- extended with support for `**`.
- - If any of the files altered in the commit pass the ignoredFiles filter and includedFiles
- is empty, then as far as this filter is concerned, we should trigger the build.
- - If any of the files altered in the commit pass the ignoredFiles filter and includedFiles
- is not empty, then we make sure that at least one of those files matches a includedFiles
- glob. If not, then we do not trigger a build.
- returned: success
- type: list
-triggerTemplate:
- description:
- - Template describing the types of source changes to trigger a build.
- - Branch and tag names in trigger templates are interpreted as regular expressions.
- Any branch or tag change that matches that regular expression will trigger a build.
- returned: success
- type: complex
- contains:
- projectId:
- description:
- - ID of the project that owns the Cloud Source Repository. If omitted, the project
- ID requesting the build is assumed.
- returned: success
- type: str
- repoName:
- description:
- - Name of the Cloud Source Repository. If omitted, the name "default" is assumed.
- returned: success
- type: str
- dir:
- description:
- - Directory, relative to the source root, in which to run the build.
- - This must be a relative path. If a step's dir is specified and is an absolute
- path, this value is ignored for that step's execution.
- returned: success
- type: str
- branchName:
- description:
- - Name of the branch to build. Exactly one a of branch name, tag, or commit
- SHA must be provided.
- - This field is a regular expression.
- returned: success
- type: str
- tagName:
- description:
- - Name of the tag to build. Exactly one of a branch name, tag, or commit SHA
- must be provided.
- - This field is a regular expression.
- returned: success
- type: str
- commitSha:
- description:
- - Explicit commit SHA to build. Exactly one of a branch name, tag, or commit
- SHA must be provided.
- returned: success
- type: str
-build:
- description:
- - Contents of the build template. Either a filename or build template must be provided.
- returned: success
- type: complex
- contains:
- tags:
- description:
- - Tags for annotation of a Build. These are not docker tags.
- returned: success
- type: list
- images:
- description:
- - A list of images to be pushed upon the successful completion of all build
- steps.
- - The images are pushed using the builder service account's credentials.
- - The digests of the pushed images will be stored in the Build resource's results
- field.
- - If any of the images fail to be pushed, the build status is marked FAILURE.
- returned: success
- type: list
- steps:
- description:
- - The operations to be performed on the workspace.
- returned: success
- type: complex
- contains:
- name:
- description:
- - The name of the container image that will run this particular build step.
- - If the image is available in the host's Docker daemon's cache, it will
- be run directly. If not, the host will attempt to pull the image first,
- using the builder service account's credentials if necessary.
- - The Docker daemon's cache will already have the latest versions of all
- of the officially supported build steps (U(https://github.com/GoogleCloudPlatform/cloud-builders)).
- - The Docker daemon will also have cached many of the layers for some popular
- images, like "ubuntu", "debian", but they will be refreshed at the time
- you attempt to use them.
- - If you built an image in a previous build step, it will be stored in the
- host's Docker daemon's cache and is available to use as the name for a
- later build step.
- returned: success
- type: str
- args:
- description:
- - A list of arguments that will be presented to the step when it is started.
- - If the image used to run the step's container has an entrypoint, the args
- are used as arguments to that entrypoint. If the image does not define
- an entrypoint, the first element in args is used as the entrypoint, and
- the remainder will be used as arguments.
- returned: success
- type: list
- env:
- description:
- - A list of environment variable definitions to be used when running a step.
- - The elements are of the form "KEY=VALUE" for the environment variable
- "KEY" being given the value "VALUE".
- returned: success
- type: list
- id:
- description:
- - Unique identifier for this build step, used in `wait_for` to reference
- this build step as a dependency.
- returned: success
- type: str
- entrypoint:
- description:
- - Entrypoint to be used instead of the build step image's default entrypoint.
- - If unset, the image's default entrypoint is used .
- returned: success
- type: str
- dir:
- description:
- - Working directory to use when running this step's container.
- - If this value is a relative path, it is relative to the build's working
- directory. If this value is absolute, it may be outside the build's working
- directory, in which case the contents of the path may not be persisted
- across build step executions, unless a `volume` for that path is specified.
- - If the build specifies a `RepoSource` with `dir` and a step with a `dir`,
- which specifies an absolute path, the `RepoSource` `dir` is ignored for
- the step's execution.
- returned: success
- type: str
- secretEnv:
- description:
- - A list of environment variables which are encrypted using a Cloud Key
- Management Service crypto key. These values must be specified in the build's
- `Secret`.
- returned: success
- type: list
- timeout:
- description:
- - Time limit for executing this build step. If not defined, the step has
- no time limit and will be allowed to continue to run until either it completes
- or the build itself times out.
- returned: success
- type: str
- timing:
- description:
- - Output only. Stores timing information for executing this build step.
- returned: success
- type: str
- volumes:
- description:
- - List of volumes to mount into the build step.
- - Each volume is created as an empty volume prior to execution of the build
- step. Upon completion of the build, volumes and their contents are discarded.
- - Using a named volume in only one step is not valid as it is indicative
- of a build request with an incorrect configuration.
- returned: success
- type: complex
- contains:
- name:
- description:
- - Name of the volume to mount.
- - Volume names must be unique per build step and must be valid names
- for Docker volumes. Each named volume must be used by at least two
- build steps.
- returned: success
- type: str
- path:
- description:
- - Path at which to mount the volume.
- - Paths must be absolute and cannot conflict with other volume paths
- on the same build step or with certain reserved volume paths.
- returned: success
- type: str
- waitFor:
- description:
- - The ID(s) of the step(s) that this build step depends on.
- - This build step will not start until all the build steps in `wait_for`
- have completed successfully. If `wait_for` is empty, this build step will
- start when all previous build steps in the `Build.Steps` list have completed
- successfully.
- returned: success
- type: list
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- id=dict(type='str'),
- name=dict(type='str'),
- description=dict(type='str'),
- disabled=dict(type='bool'),
- substitutions=dict(type='dict'),
- filename=dict(type='str'),
- ignored_files=dict(type='list', elements='str'),
- included_files=dict(type='list', elements='str'),
- trigger_template=dict(
- type='dict',
- options=dict(
- project_id=dict(type='str'),
- repo_name=dict(default='default', type='str'),
- dir=dict(type='str'),
- branch_name=dict(type='str'),
- tag_name=dict(type='str'),
- commit_sha=dict(type='str'),
- ),
- ),
- build=dict(
- type='dict',
- options=dict(
- tags=dict(type='list', elements='str'),
- images=dict(type='list', elements='str'),
- steps=dict(
- type='list',
- elements='dict',
- options=dict(
- name=dict(type='str'),
- args=dict(type='list', elements='str'),
- env=dict(type='list', elements='str'),
- id=dict(type='str'),
- entrypoint=dict(type='str'),
- dir=dict(type='str'),
- secret_env=dict(type='list', elements='str'),
- timeout=dict(type='str'),
- timing=dict(type='str'),
- volumes=dict(type='list', elements='dict', options=dict(name=dict(type='str'), path=dict(type='str'))),
- wait_for=dict(type='list', elements='str'),
- ),
- ),
- ),
- ),
- ),
- mutually_exclusive=[['build', 'filename']],
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
-
- state = module.params['state']
-
- fetch = fetch_resource(module, self_link(module))
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module))
- fetch = fetch_resource(module, self_link(module))
- changed = True
- else:
- delete(module, self_link(module))
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module))
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link):
- auth = GcpSession(module, 'cloudbuild')
- return return_if_object(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link):
- auth = GcpSession(module, 'cloudbuild')
- return return_if_object(module, auth.patch(link, resource_to_request(module)))
-
-
-def delete(module, link):
- auth = GcpSession(module, 'cloudbuild')
- return return_if_object(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'id': module.params.get('id'),
- u'name': module.params.get('name'),
- u'description': module.params.get('description'),
- u'disabled': module.params.get('disabled'),
- u'substitutions': module.params.get('substitutions'),
- u'filename': module.params.get('filename'),
- u'ignoredFiles': module.params.get('ignored_files'),
- u'includedFiles': module.params.get('included_files'),
- u'triggerTemplate': TriggerTriggertemplate(module.params.get('trigger_template', {}), module).to_request(),
- u'build': TriggerBuild(module.params.get('build', {}), module).to_request(),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, allow_not_found=True):
- auth = GcpSession(module, 'cloudbuild')
- return return_if_object(module, auth.get(link), allow_not_found)
-
-
-def self_link(module):
- return "https://cloudbuild.googleapis.com/v1/projects/{project}/triggers/{id}".format(**module.params)
-
-
-def collection(module):
- return "https://cloudbuild.googleapis.com/v1/projects/{project}/triggers".format(**module.params)
-
-
-def return_if_object(module, response, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'id': response.get(u'id'),
- u'name': response.get(u'name'),
- u'description': response.get(u'description'),
- u'disabled': response.get(u'disabled'),
- u'createTime': response.get(u'createTime'),
- u'substitutions': response.get(u'substitutions'),
- u'filename': response.get(u'filename'),
- u'ignoredFiles': response.get(u'ignoredFiles'),
- u'includedFiles': response.get(u'includedFiles'),
- u'triggerTemplate': TriggerTriggertemplate(response.get(u'triggerTemplate', {}), module).from_response(),
- u'build': TriggerBuild(response.get(u'build', {}), module).from_response(),
- }
-
-
-class TriggerTriggertemplate(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'projectId': self.request.get('project_id'),
- u'repoName': self.request.get('repo_name'),
- u'dir': self.request.get('dir'),
- u'branchName': self.request.get('branch_name'),
- u'tagName': self.request.get('tag_name'),
- u'commitSha': self.request.get('commit_sha'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'projectId': self.request.get(u'projectId'),
- u'repoName': self.request.get(u'repoName'),
- u'dir': self.request.get(u'dir'),
- u'branchName': self.request.get(u'branchName'),
- u'tagName': self.request.get(u'tagName'),
- u'commitSha': self.request.get(u'commitSha'),
- }
- )
-
-
-class TriggerBuild(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'tags': self.request.get('tags'),
- u'images': self.request.get('images'),
- u'steps': TriggerStepsArray(self.request.get('steps', []), self.module).to_request(),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'tags': self.request.get(u'tags'),
- u'images': self.request.get(u'images'),
- u'steps': TriggerStepsArray(self.request.get(u'steps', []), self.module).from_response(),
- }
- )
-
-
-class TriggerStepsArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict(
- {
- u'name': item.get('name'),
- u'args': item.get('args'),
- u'env': item.get('env'),
- u'id': item.get('id'),
- u'entrypoint': item.get('entrypoint'),
- u'dir': item.get('dir'),
- u'secretEnv': item.get('secret_env'),
- u'timeout': item.get('timeout'),
- u'timing': item.get('timing'),
- u'volumes': TriggerVolumesArray(item.get('volumes', []), self.module).to_request(),
- u'waitFor': item.get('wait_for'),
- }
- )
-
- def _response_from_item(self, item):
- return remove_nones_from_dict(
- {
- u'name': item.get(u'name'),
- u'args': item.get(u'args'),
- u'env': item.get(u'env'),
- u'id': item.get(u'id'),
- u'entrypoint': item.get(u'entrypoint'),
- u'dir': item.get(u'dir'),
- u'secretEnv': item.get(u'secretEnv'),
- u'timeout': item.get(u'timeout'),
- u'timing': item.get(u'timing'),
- u'volumes': TriggerVolumesArray(item.get(u'volumes', []), self.module).from_response(),
- u'waitFor': item.get(u'waitFor'),
- }
- )
-
-
-class TriggerVolumesArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'name': item.get('name'), u'path': item.get('path')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'name': item.get(u'name'), u'path': item.get(u'path')})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_cloudbuild_trigger_info.py b/lib/ansible/modules/cloud/google/gcp_cloudbuild_trigger_info.py
deleted file mode 100644
index 10764dab92..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_cloudbuild_trigger_info.py
+++ /dev/null
@@ -1,411 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_cloudbuild_trigger_info
-description:
-- Gather info for GCP Trigger
-short_description: Gather info for GCP Trigger
-version_added: '2.8'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a trigger
- gcp_cloudbuild_trigger_info:
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- id:
- description:
- - The unique identifier for the trigger.
- returned: success
- type: str
- name:
- description:
- - Name of the trigger. Must be unique within the project.
- returned: success
- type: str
- description:
- description:
- - Human-readable description of the trigger.
- returned: success
- type: str
- disabled:
- description:
- - Whether the trigger is disabled or not. If true, the trigger will never result
- in a build.
- returned: success
- type: bool
- createTime:
- description:
- - Time when the trigger was created.
- returned: success
- type: str
- substitutions:
- description:
- - Substitutions data for Build resource.
- returned: success
- type: dict
- filename:
- description:
- - Path, from the source root, to a file whose contents is used for the template.
- Either a filename or build template must be provided.
- returned: success
- type: str
- ignoredFiles:
- description:
- - ignoredFiles and includedFiles are file glob matches using http://godoc/pkg/path/filepath#Match
- extended with support for `**`.
- - If ignoredFiles and changed files are both empty, then they are not used to
- determine whether or not to trigger a build.
- - If ignoredFiles is not empty, then we ignore any files that match any of the
- ignored_file globs. If the change has no files that are outside of the ignoredFiles
- globs, then we do not trigger a build.
- returned: success
- type: list
- includedFiles:
- description:
- - ignoredFiles and includedFiles are file glob matches using http://godoc/pkg/path/filepath#Match
- extended with support for `**`.
- - If any of the files altered in the commit pass the ignoredFiles filter and
- includedFiles is empty, then as far as this filter is concerned, we should
- trigger the build.
- - If any of the files altered in the commit pass the ignoredFiles filter and
- includedFiles is not empty, then we make sure that at least one of those files
- matches a includedFiles glob. If not, then we do not trigger a build.
- returned: success
- type: list
- triggerTemplate:
- description:
- - Template describing the types of source changes to trigger a build.
- - Branch and tag names in trigger templates are interpreted as regular expressions.
- Any branch or tag change that matches that regular expression will trigger
- a build.
- returned: success
- type: complex
- contains:
- projectId:
- description:
- - ID of the project that owns the Cloud Source Repository. If omitted, the
- project ID requesting the build is assumed.
- returned: success
- type: str
- repoName:
- description:
- - Name of the Cloud Source Repository. If omitted, the name "default" is
- assumed.
- returned: success
- type: str
- dir:
- description:
- - Directory, relative to the source root, in which to run the build.
- - This must be a relative path. If a step's dir is specified and is an absolute
- path, this value is ignored for that step's execution.
- returned: success
- type: str
- branchName:
- description:
- - Name of the branch to build. Exactly one a of branch name, tag, or commit
- SHA must be provided.
- - This field is a regular expression.
- returned: success
- type: str
- tagName:
- description:
- - Name of the tag to build. Exactly one of a branch name, tag, or commit
- SHA must be provided.
- - This field is a regular expression.
- returned: success
- type: str
- commitSha:
- description:
- - Explicit commit SHA to build. Exactly one of a branch name, tag, or commit
- SHA must be provided.
- returned: success
- type: str
- build:
- description:
- - Contents of the build template. Either a filename or build template must be
- provided.
- returned: success
- type: complex
- contains:
- tags:
- description:
- - Tags for annotation of a Build. These are not docker tags.
- returned: success
- type: list
- images:
- description:
- - A list of images to be pushed upon the successful completion of all build
- steps.
- - The images are pushed using the builder service account's credentials.
- - The digests of the pushed images will be stored in the Build resource's
- results field.
- - If any of the images fail to be pushed, the build status is marked FAILURE.
- returned: success
- type: list
- steps:
- description:
- - The operations to be performed on the workspace.
- returned: success
- type: complex
- contains:
- name:
- description:
- - The name of the container image that will run this particular build
- step.
- - If the image is available in the host's Docker daemon's cache, it
- will be run directly. If not, the host will attempt to pull the image
- first, using the builder service account's credentials if necessary.
- - The Docker daemon's cache will already have the latest versions of
- all of the officially supported build steps (U(https://github.com/GoogleCloudPlatform/cloud-builders)).
- - The Docker daemon will also have cached many of the layers for some
- popular images, like "ubuntu", "debian", but they will be refreshed
- at the time you attempt to use them.
- - If you built an image in a previous build step, it will be stored
- in the host's Docker daemon's cache and is available to use as the
- name for a later build step.
- returned: success
- type: str
- args:
- description:
- - A list of arguments that will be presented to the step when it is
- started.
- - If the image used to run the step's container has an entrypoint, the
- args are used as arguments to that entrypoint. If the image does not
- define an entrypoint, the first element in args is used as the entrypoint,
- and the remainder will be used as arguments.
- returned: success
- type: list
- env:
- description:
- - A list of environment variable definitions to be used when running
- a step.
- - The elements are of the form "KEY=VALUE" for the environment variable
- "KEY" being given the value "VALUE".
- returned: success
- type: list
- id:
- description:
- - Unique identifier for this build step, used in `wait_for` to reference
- this build step as a dependency.
- returned: success
- type: str
- entrypoint:
- description:
- - Entrypoint to be used instead of the build step image's default entrypoint.
- - If unset, the image's default entrypoint is used .
- returned: success
- type: str
- dir:
- description:
- - Working directory to use when running this step's container.
- - If this value is a relative path, it is relative to the build's working
- directory. If this value is absolute, it may be outside the build's
- working directory, in which case the contents of the path may not
- be persisted across build step executions, unless a `volume` for that
- path is specified.
- - If the build specifies a `RepoSource` with `dir` and a step with a
- `dir`, which specifies an absolute path, the `RepoSource` `dir` is
- ignored for the step's execution.
- returned: success
- type: str
- secretEnv:
- description:
- - A list of environment variables which are encrypted using a Cloud
- Key Management Service crypto key. These values must be specified
- in the build's `Secret`.
- returned: success
- type: list
- timeout:
- description:
- - Time limit for executing this build step. If not defined, the step
- has no time limit and will be allowed to continue to run until either
- it completes or the build itself times out.
- returned: success
- type: str
- timing:
- description:
- - Output only. Stores timing information for executing this build step.
- returned: success
- type: str
- volumes:
- description:
- - List of volumes to mount into the build step.
- - Each volume is created as an empty volume prior to execution of the
- build step. Upon completion of the build, volumes and their contents
- are discarded.
- - Using a named volume in only one step is not valid as it is indicative
- of a build request with an incorrect configuration.
- returned: success
- type: complex
- contains:
- name:
- description:
- - Name of the volume to mount.
- - Volume names must be unique per build step and must be valid names
- for Docker volumes. Each named volume must be used by at least
- two build steps.
- returned: success
- type: str
- path:
- description:
- - Path at which to mount the volume.
- - Paths must be absolute and cannot conflict with other volume paths
- on the same build step or with certain reserved volume paths.
- returned: success
- type: str
- waitFor:
- description:
- - The ID(s) of the step(s) that this build step depends on.
- - This build step will not start until all the build steps in `wait_for`
- have completed successfully. If `wait_for` is empty, this build step
- will start when all previous build steps in the `Build.Steps` list
- have completed successfully.
- returned: success
- type: list
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict())
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
-
- return_value = {'resources': fetch_list(module, collection(module))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://cloudbuild.googleapis.com/v1/projects/{project}/triggers".format(**module.params)
-
-
-def fetch_list(module, link):
- auth = GcpSession(module, 'cloudbuild')
- return auth.list(link, return_if_object, array_name='triggers')
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_cloudfunctions_cloud_function.py b/lib/ansible/modules/cloud/google/gcp_cloudfunctions_cloud_function.py
deleted file mode 100644
index 7a0c4dea04..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_cloudfunctions_cloud_function.py
+++ /dev/null
@@ -1,693 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_cloudfunctions_cloud_function
-description:
-- A Cloud Function that contains user computation executed in response to an event.
-short_description: Creates a GCP CloudFunction
-version_added: '2.9'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- name:
- description:
- - A user-defined name of the function. Function names must be unique globally
- and match pattern `projects/*/locations/*/functions/*`.
- required: true
- type: str
- description:
- description:
- - User-provided description of a function.
- required: false
- type: str
- entry_point:
- description:
- - The name of the function (as defined in source code) that will be executed.
- - Defaults to the resource name suffix, if not specified. For backward compatibility,
- if function with given name is not found, then the system will try to use function
- named "function". For Node.js this is name of a function exported by the module
- specified in source_location.
- required: false
- type: str
- runtime:
- description:
- - The runtime in which the function is going to run. If empty, defaults to Node.js
- 6.
- required: false
- type: str
- timeout:
- description:
- - The function execution timeout. Execution is considered failed and can be terminated
- if the function is not completed at the end of the timeout period. Defaults
- to 60 seconds.
- required: false
- type: str
- available_memory_mb:
- description:
- - The amount of memory in MB available for a function.
- required: false
- type: int
- labels:
- description:
- - A set of key/value label pairs associated with this Cloud Function.
- required: false
- type: dict
- environment_variables:
- description:
- - Environment variables that shall be available during function execution.
- required: false
- type: dict
- source_archive_url:
- description:
- - The Google Cloud Storage URL, starting with gs://, pointing to the zip archive
- which contains the function.
- required: false
- type: str
- source_upload_url:
- description:
- - The Google Cloud Storage signed URL used for source uploading.
- required: false
- type: str
- source_repository:
- description:
- - The source repository where a function is hosted.
- required: false
- type: dict
- suboptions:
- url:
- description:
- - The URL pointing to the hosted repository where the function is defined
- .
- required: false
- type: str
- https_trigger:
- description:
- - An HTTPS endpoint type of source that can be triggered via URL.
- required: false
- type: dict
- suboptions: {}
- event_trigger:
- description:
- - An HTTPS endpoint type of source that can be triggered via URL.
- required: false
- type: dict
- suboptions:
- event_type:
- description:
- - 'The type of event to observe. For example: `providers/cloud.storage/eventTypes/object.change`
- and `providers/cloud.pubsub/eventTypes/topic.publish`.'
- required: true
- type: str
- resource:
- description:
- - The resource(s) from which to observe events, for example, `projects/_/buckets/myBucket.`
- .
- required: true
- type: str
- service:
- description:
- - The hostname of the service that should be observed.
- required: false
- type: str
- location:
- description:
- - The location of this cloud function.
- required: true
- type: str
- trigger_http:
- description:
- - Use HTTP to trigger this function.
- required: false
- type: bool
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-'''
-
-EXAMPLES = '''
-- name: create a cloud function
- gcp_cloudfunctions_cloud_function:
- name: test_object
- location: us-central1
- entry_point: helloGET
- source_archive_url: gs://ansible-cloudfunctions-bucket/function.zip
- trigger_http: 'true'
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-name:
- description:
- - A user-defined name of the function. Function names must be unique globally and
- match pattern `projects/*/locations/*/functions/*`.
- returned: success
- type: str
-description:
- description:
- - User-provided description of a function.
- returned: success
- type: str
-status:
- description:
- - Status of the function deployment.
- returned: success
- type: str
-entryPoint:
- description:
- - The name of the function (as defined in source code) that will be executed.
- - Defaults to the resource name suffix, if not specified. For backward compatibility,
- if function with given name is not found, then the system will try to use function
- named "function". For Node.js this is name of a function exported by the module
- specified in source_location.
- returned: success
- type: str
-runtime:
- description:
- - The runtime in which the function is going to run. If empty, defaults to Node.js
- 6.
- returned: success
- type: str
-timeout:
- description:
- - The function execution timeout. Execution is considered failed and can be terminated
- if the function is not completed at the end of the timeout period. Defaults to
- 60 seconds.
- returned: success
- type: str
-availableMemoryMb:
- description:
- - The amount of memory in MB available for a function.
- returned: success
- type: int
-serviceAccountEmail:
- description:
- - The email of the service account for this function.
- returned: success
- type: str
-updateTime:
- description:
- - The last update timestamp of a Cloud Function.
- returned: success
- type: str
-versionId:
- description:
- - The version identifier of the Cloud Function. Each deployment attempt results
- in a new version of a function being created.
- returned: success
- type: str
-labels:
- description:
- - A set of key/value label pairs associated with this Cloud Function.
- returned: success
- type: dict
-environmentVariables:
- description:
- - Environment variables that shall be available during function execution.
- returned: success
- type: dict
-sourceArchiveUrl:
- description:
- - The Google Cloud Storage URL, starting with gs://, pointing to the zip archive
- which contains the function.
- returned: success
- type: str
-sourceUploadUrl:
- description:
- - The Google Cloud Storage signed URL used for source uploading.
- returned: success
- type: str
-sourceRepository:
- description:
- - The source repository where a function is hosted.
- returned: success
- type: complex
- contains:
- url:
- description:
- - The URL pointing to the hosted repository where the function is defined .
- returned: success
- type: str
- deployedUrl:
- description:
- - The URL pointing to the hosted repository where the function were defined
- at the time of deployment.
- returned: success
- type: str
-httpsTrigger:
- description:
- - An HTTPS endpoint type of source that can be triggered via URL.
- returned: success
- type: complex
- contains:
- url:
- description:
- - The deployed url for the function.
- returned: success
- type: str
-eventTrigger:
- description:
- - An HTTPS endpoint type of source that can be triggered via URL.
- returned: success
- type: complex
- contains:
- eventType:
- description:
- - 'The type of event to observe. For example: `providers/cloud.storage/eventTypes/object.change`
- and `providers/cloud.pubsub/eventTypes/topic.publish`.'
- returned: success
- type: str
- resource:
- description:
- - The resource(s) from which to observe events, for example, `projects/_/buckets/myBucket.`
- .
- returned: success
- type: str
- service:
- description:
- - The hostname of the service that should be observed.
- returned: success
- type: str
-location:
- description:
- - The location of this cloud function.
- returned: success
- type: str
-trigger_http:
- description:
- - Use HTTP to trigger this function.
- returned: success
- type: bool
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import re
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- name=dict(required=True, type='str'),
- description=dict(type='str'),
- entry_point=dict(type='str'),
- runtime=dict(type='str'),
- timeout=dict(type='str'),
- available_memory_mb=dict(type='int'),
- labels=dict(type='dict'),
- environment_variables=dict(type='dict'),
- source_archive_url=dict(type='str'),
- source_upload_url=dict(type='str'),
- source_repository=dict(type='dict', options=dict(url=dict(type='str'))),
- https_trigger=dict(type='dict', options=dict()),
- event_trigger=dict(
- type='dict', options=dict(event_type=dict(required=True, type='str'), resource=dict(required=True, type='str'), service=dict(type='str'))
- ),
- location=dict(required=True, type='str'),
- trigger_http=dict(type='bool'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
-
- state = module.params['state']
-
- fetch = fetch_resource(module, self_link(module))
- changed = False
-
- # Need to set triggerHttps to {} if boolean true.
- if fetch and fetch.get('httpsTrigger') and module.params['trigger_http']:
- module.params['https_trigger'] = fetch.get('httpsTrigger')
- elif module.params['trigger_http']:
- module.params['https_trigger'] = {}
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), fetch)
- fetch = fetch_resource(module, self_link(module))
- changed = True
- else:
- delete(module, self_link(module))
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module))
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link):
- auth = GcpSession(module, 'cloudfunctions')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, fetch):
- auth = GcpSession(module, 'cloudfunctions')
- params = {'updateMask': updateMask(resource_to_request(module), response_to_hash(module, fetch))}
- request = resource_to_request(module)
- del request['name']
- return wait_for_operation(module, auth.put(link, request, params=params))
-
-
-def updateMask(request, response):
- update_mask = []
- if request.get('name') != response.get('name'):
- update_mask.append('name')
- if request.get('description') != response.get('description'):
- update_mask.append('description')
- if request.get('entryPoint') != response.get('entryPoint'):
- update_mask.append('entryPoint')
- if request.get('runtime') != response.get('runtime'):
- update_mask.append('runtime')
- if request.get('timeout') != response.get('timeout'):
- update_mask.append('timeout')
- if request.get('availableMemoryMb') != response.get('availableMemoryMb'):
- update_mask.append('availableMemoryMb')
- if request.get('labels') != response.get('labels'):
- update_mask.append('labels')
- if request.get('environmentVariables') != response.get('environmentVariables'):
- update_mask.append('environmentVariables')
- if request.get('sourceArchiveUrl') != response.get('sourceArchiveUrl'):
- update_mask.append('sourceArchiveUrl')
- if request.get('sourceUploadUrl') != response.get('sourceUploadUrl'):
- update_mask.append('sourceUploadUrl')
- if request.get('sourceRepository') != response.get('sourceRepository'):
- update_mask.append('sourceRepository')
- if request.get('httpsTrigger') != response.get('httpsTrigger'):
- update_mask.append('httpsTrigger')
- if request.get('eventTrigger') != response.get('eventTrigger'):
- update_mask.append('eventTrigger')
- if request.get('location') != response.get('location'):
- update_mask.append('location')
- if request.get('trigger_http') != response.get('trigger_http'):
- update_mask.append('trigger_http')
- return ','.join(update_mask)
-
-
-def delete(module, link):
- auth = GcpSession(module, 'cloudfunctions')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'name': name_pattern(module.params.get('name'), module),
- u'description': module.params.get('description'),
- u'entryPoint': module.params.get('entry_point'),
- u'runtime': module.params.get('runtime'),
- u'timeout': module.params.get('timeout'),
- u'availableMemoryMb': module.params.get('available_memory_mb'),
- u'labels': module.params.get('labels'),
- u'environmentVariables': module.params.get('environment_variables'),
- u'sourceArchiveUrl': module.params.get('source_archive_url'),
- u'sourceUploadUrl': module.params.get('source_upload_url'),
- u'sourceRepository': CloudFunctionSourcerepository(module.params.get('source_repository', {}), module).to_request(),
- u'httpsTrigger': CloudFunctionHttpstrigger(module.params.get('https_trigger', {}), module).to_request(),
- u'eventTrigger': CloudFunctionEventtrigger(module.params.get('event_trigger', {}), module).to_request(),
- }
- request = encode_request(request, module)
- return request
-
-
-def fetch_resource(module, link, allow_not_found=True):
- auth = GcpSession(module, 'cloudfunctions')
- return return_if_object(module, auth.get(link), allow_not_found)
-
-
-def self_link(module):
- return "https://cloudfunctions.googleapis.com/v1/projects/{project}/locations/{location}/functions/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://cloudfunctions.googleapis.com/v1/projects/{project}/locations/{location}/functions".format(**module.params)
-
-
-def return_if_object(module, response, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'name': response.get(u'name'),
- u'description': response.get(u'description'),
- u'status': response.get(u'status'),
- u'entryPoint': response.get(u'entryPoint'),
- u'runtime': response.get(u'runtime'),
- u'timeout': response.get(u'timeout'),
- u'availableMemoryMb': response.get(u'availableMemoryMb'),
- u'serviceAccountEmail': response.get(u'serviceAccountEmail'),
- u'updateTime': response.get(u'updateTime'),
- u'versionId': response.get(u'versionId'),
- u'labels': response.get(u'labels'),
- u'environmentVariables': response.get(u'environmentVariables'),
- u'sourceArchiveUrl': response.get(u'sourceArchiveUrl'),
- u'sourceUploadUrl': response.get(u'sourceUploadUrl'),
- u'sourceRepository': CloudFunctionSourcerepository(response.get(u'sourceRepository', {}), module).from_response(),
- u'httpsTrigger': CloudFunctionHttpstrigger(response.get(u'httpsTrigger', {}), module).from_response(),
- u'eventTrigger': CloudFunctionEventtrigger(response.get(u'eventTrigger', {}), module).from_response(),
- }
-
-
-def name_pattern(name, module):
- if name is None:
- return
-
- regex = r"projects/.*/locations/.*/functions/.*"
-
- if not re.match(regex, name):
- name = "projects/{project}/locations/{location}/functions/{name}".format(**module.params)
-
- return name
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://cloudfunctions.googleapis.com/v1/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response)
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['done'])
- wait_done = wait_for_completion(status, op_result, module)
- raise_if_errors(wait_done, ['error'], module)
- return navigate_hash(wait_done, ['response'])
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while not status:
- raise_if_errors(op_result, ['error'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, False)
- status = navigate_hash(op_result, ['done'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-def encode_request(request, module):
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- if module.params['trigger_http'] and not return_vals.get('httpsTrigger'):
- return_vals['httpsTrigger'] = {}
-
- return return_vals
-
-
-class CloudFunctionSourcerepository(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'url': self.request.get('url')})
-
- def from_response(self):
- return remove_nones_from_dict({u'url': self.request.get(u'url')})
-
-
-class CloudFunctionHttpstrigger(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({})
-
- def from_response(self):
- return remove_nones_from_dict({})
-
-
-class CloudFunctionEventtrigger(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {u'eventType': self.request.get('event_type'), u'resource': self.request.get('resource'), u'service': self.request.get('service')}
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {u'eventType': self.request.get(u'eventType'), u'resource': self.request.get(u'resource'), u'service': self.request.get(u'service')}
- )
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_cloudfunctions_cloud_function_info.py b/lib/ansible/modules/cloud/google/gcp_cloudfunctions_cloud_function_info.py
deleted file mode 100644
index e9d2839aa0..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_cloudfunctions_cloud_function_info.py
+++ /dev/null
@@ -1,309 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_cloudfunctions_cloud_function_info
-description:
-- Gather info for GCP CloudFunction
-short_description: Gather info for GCP CloudFunction
-version_added: '2.9'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- location:
- description:
- - The location of this cloud function.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a cloud function
- gcp_cloudfunctions_cloud_function_info:
- location: us-central1
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- name:
- description:
- - A user-defined name of the function. Function names must be unique globally
- and match pattern `projects/*/locations/*/functions/*`.
- returned: success
- type: str
- description:
- description:
- - User-provided description of a function.
- returned: success
- type: str
- status:
- description:
- - Status of the function deployment.
- returned: success
- type: str
- entryPoint:
- description:
- - The name of the function (as defined in source code) that will be executed.
- - Defaults to the resource name suffix, if not specified. For backward compatibility,
- if function with given name is not found, then the system will try to use
- function named "function". For Node.js this is name of a function exported
- by the module specified in source_location.
- returned: success
- type: str
- runtime:
- description:
- - The runtime in which the function is going to run. If empty, defaults to Node.js
- 6.
- returned: success
- type: str
- timeout:
- description:
- - The function execution timeout. Execution is considered failed and can be
- terminated if the function is not completed at the end of the timeout period.
- Defaults to 60 seconds.
- returned: success
- type: str
- availableMemoryMb:
- description:
- - The amount of memory in MB available for a function.
- returned: success
- type: int
- serviceAccountEmail:
- description:
- - The email of the service account for this function.
- returned: success
- type: str
- updateTime:
- description:
- - The last update timestamp of a Cloud Function.
- returned: success
- type: str
- versionId:
- description:
- - The version identifier of the Cloud Function. Each deployment attempt results
- in a new version of a function being created.
- returned: success
- type: str
- labels:
- description:
- - A set of key/value label pairs associated with this Cloud Function.
- returned: success
- type: dict
- environmentVariables:
- description:
- - Environment variables that shall be available during function execution.
- returned: success
- type: dict
- sourceArchiveUrl:
- description:
- - The Google Cloud Storage URL, starting with gs://, pointing to the zip archive
- which contains the function.
- returned: success
- type: str
- sourceUploadUrl:
- description:
- - The Google Cloud Storage signed URL used for source uploading.
- returned: success
- type: str
- sourceRepository:
- description:
- - The source repository where a function is hosted.
- returned: success
- type: complex
- contains:
- url:
- description:
- - The URL pointing to the hosted repository where the function is defined
- .
- returned: success
- type: str
- deployedUrl:
- description:
- - The URL pointing to the hosted repository where the function were defined
- at the time of deployment.
- returned: success
- type: str
- httpsTrigger:
- description:
- - An HTTPS endpoint type of source that can be triggered via URL.
- returned: success
- type: complex
- contains:
- url:
- description:
- - The deployed url for the function.
- returned: success
- type: str
- eventTrigger:
- description:
- - An HTTPS endpoint type of source that can be triggered via URL.
- returned: success
- type: complex
- contains:
- eventType:
- description:
- - 'The type of event to observe. For example: `providers/cloud.storage/eventTypes/object.change`
- and `providers/cloud.pubsub/eventTypes/topic.publish`.'
- returned: success
- type: str
- resource:
- description:
- - The resource(s) from which to observe events, for example, `projects/_/buckets/myBucket.`
- .
- returned: success
- type: str
- service:
- description:
- - The hostname of the service that should be observed.
- returned: success
- type: str
- location:
- description:
- - The location of this cloud function.
- returned: success
- type: str
- trigger_http:
- description:
- - Use HTTP to trigger this function.
- returned: success
- type: bool
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(location=dict(required=True, type='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
-
- return_value = {'resources': fetch_list(module, collection(module))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://cloudfunctions.googleapis.com/v1/projects/{project}/locations/{location}/functions".format(**module.params)
-
-
-def fetch_list(module, link):
- auth = GcpSession(module, 'cloudfunctions')
- return auth.list(link, return_if_object, array_name='functions')
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_cloudscheduler_job.py b/lib/ansible/modules/cloud/google/gcp_cloudscheduler_job.py
deleted file mode 100644
index ea303e8e33..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_cloudscheduler_job.py
+++ /dev/null
@@ -1,952 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_cloudscheduler_job
-description:
-- A scheduled job that can publish a pubsub message or a http request every X interval
- of time, using crontab format string.
-- To use Cloud Scheduler your project must contain an App Engine app that is located
- in one of the supported regions. If your project does not have an App Engine app,
- you must create one.
-short_description: Creates a GCP Job
-version_added: '2.9'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- name:
- description:
- - The name of the job.
- required: true
- type: str
- description:
- description:
- - A human-readable description for the job. This string must not contain more
- than 500 characters.
- required: false
- type: str
- schedule:
- description:
- - Describes the schedule on which the job will be executed.
- required: false
- type: str
- time_zone:
- description:
- - Specifies the time zone to be used in interpreting schedule.
- - The value of this field must be a time zone name from the tz database.
- required: false
- default: Etc/UTC
- type: str
- retry_config:
- description:
- - By default, if a job does not complete successfully, meaning that an acknowledgement
- is not received from the handler, then it will be retried with exponential backoff
- according to the settings .
- required: false
- type: dict
- suboptions:
- retry_count:
- description:
- - The number of attempts that the system will make to run a job using the
- exponential backoff procedure described by maxDoublings.
- - Values greater than 5 and negative values are not allowed.
- required: false
- type: int
- max_retry_duration:
- description:
- - The time limit for retrying a failed job, measured from time when an execution
- was first attempted. If specified with retryCount, the job will be retried
- until both limits are reached.
- - A duration in seconds with up to nine fractional digits, terminated by 's'.
- required: false
- type: str
- min_backoff_duration:
- description:
- - The minimum amount of time to wait before retrying a job after it fails.
- - A duration in seconds with up to nine fractional digits, terminated by 's'.
- required: false
- type: str
- max_backoff_duration:
- description:
- - The maximum amount of time to wait before retrying a job after it fails.
- - A duration in seconds with up to nine fractional digits, terminated by 's'.
- required: false
- type: str
- max_doublings:
- description:
- - The time between retries will double maxDoublings times.
- - A job's retry interval starts at minBackoffDuration, then doubles maxDoublings
- times, then increases linearly, and finally retries retries at intervals
- of maxBackoffDuration up to retryCount times.
- required: false
- type: int
- pubsub_target:
- description:
- - Pub/Sub target If the job providers a Pub/Sub target the cron will publish a
- message to the provided topic .
- required: false
- type: dict
- suboptions:
- topic_name:
- description:
- - The name of the Cloud Pub/Sub topic to which messages will be published
- when a job is delivered. The topic name must be in the same format as required
- by PubSub's PublishRequest.name, for example projects/PROJECT_ID/topics/TOPIC_ID.
- required: true
- type: str
- data:
- description:
- - The message payload for PubsubMessage.
- - Pubsub message must contain either non-empty data, or at least one attribute.
- required: false
- type: str
- attributes:
- description:
- - Attributes for PubsubMessage.
- - Pubsub message must contain either non-empty data, or at least one attribute.
- required: false
- type: dict
- app_engine_http_target:
- description:
- - App Engine HTTP target.
- - If the job providers a App Engine HTTP target the cron will send a request to
- the service instance .
- required: false
- type: dict
- suboptions:
- http_method:
- description:
- - Which HTTP method to use for the request.
- required: false
- type: str
- app_engine_routing:
- description:
- - App Engine Routing setting for the job.
- required: false
- type: dict
- suboptions:
- service:
- description:
- - App service.
- - By default, the job is sent to the service which is the default service
- when the job is attempted.
- required: false
- type: str
- version:
- description:
- - App version.
- - By default, the job is sent to the version which is the default version
- when the job is attempted.
- required: false
- type: str
- instance:
- description:
- - App instance.
- - By default, the job is sent to an instance which is available when the
- job is attempted.
- required: false
- type: str
- relative_uri:
- description:
- - The relative URI.
- required: true
- type: str
- body:
- description:
- - HTTP request body. A request body is allowed only if the HTTP method is
- POST or PUT. It will result in invalid argument error to set a body on a
- job with an incompatible HttpMethod.
- required: false
- type: str
- headers:
- description:
- - HTTP request headers.
- - This map contains the header field names and values. Headers can be set
- when the job is created.
- required: false
- type: dict
- http_target:
- description:
- - HTTP target.
- - If the job providers a http_target the cron will send a request to the targeted
- url .
- required: false
- type: dict
- suboptions:
- uri:
- description:
- - The full URI path that the request will be sent to.
- required: true
- type: str
- http_method:
- description:
- - Which HTTP method to use for the request.
- required: false
- type: str
- body:
- description:
- - HTTP request body. A request body is allowed only if the HTTP method is
- POST, PUT, or PATCH. It is an error to set body on a job with an incompatible
- HttpMethod.
- required: false
- type: str
- headers:
- description:
- - This map contains the header field names and values. Repeated headers are
- not supported, but a header value can contain commas.
- required: false
- type: dict
- oauth_token:
- description:
- - Contains information needed for generating an OAuth token.
- - This type of authorization should be used when sending requests to a GCP
- endpoint.
- required: false
- type: dict
- suboptions:
- service_account_email:
- description:
- - Service account email to be used for generating OAuth token.
- - The service account must be within the same project as the job.
- required: false
- type: str
- scope:
- description:
- - OAuth scope to be used for generating OAuth access token. If not specified,
- "U(https://www.googleapis.com/auth/cloud-platform") will be used.
- required: false
- type: str
- oidc_token:
- description:
- - Contains information needed for generating an OpenID Connect token.
- - This type of authorization should be used when sending requests to third
- party endpoints or Cloud Run.
- required: false
- type: dict
- suboptions:
- service_account_email:
- description:
- - Service account email to be used for generating OAuth token.
- - The service account must be within the same project as the job.
- required: false
- type: str
- audience:
- description:
- - Audience to be used when generating OIDC token. If not specified, the
- URI specified in target will be used.
- required: false
- type: str
- region:
- description:
- - Region where the scheduler job resides .
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/scheduler/docs/reference/rest/)'
-- 'Official Documentation: U(https://cloud.google.com/scheduler/)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a job
- gcp_cloudscheduler_job:
- name: job
- region: us-central1
- schedule: "*/4 * * * *"
- description: test app engine job
- time_zone: Europe/London
- app_engine_http_target:
- http_method: POST
- app_engine_routing:
- service: web
- version: prod
- instance: my-instance-001
- relative_uri: "/ping"
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-name:
- description:
- - The name of the job.
- returned: success
- type: str
-description:
- description:
- - A human-readable description for the job. This string must not contain more than
- 500 characters.
- returned: success
- type: str
-schedule:
- description:
- - Describes the schedule on which the job will be executed.
- returned: success
- type: str
-timeZone:
- description:
- - Specifies the time zone to be used in interpreting schedule.
- - The value of this field must be a time zone name from the tz database.
- returned: success
- type: str
-retryConfig:
- description:
- - By default, if a job does not complete successfully, meaning that an acknowledgement
- is not received from the handler, then it will be retried with exponential backoff
- according to the settings .
- returned: success
- type: complex
- contains:
- retryCount:
- description:
- - The number of attempts that the system will make to run a job using the exponential
- backoff procedure described by maxDoublings.
- - Values greater than 5 and negative values are not allowed.
- returned: success
- type: int
- maxRetryDuration:
- description:
- - The time limit for retrying a failed job, measured from time when an execution
- was first attempted. If specified with retryCount, the job will be retried
- until both limits are reached.
- - A duration in seconds with up to nine fractional digits, terminated by 's'.
- returned: success
- type: str
- minBackoffDuration:
- description:
- - The minimum amount of time to wait before retrying a job after it fails.
- - A duration in seconds with up to nine fractional digits, terminated by 's'.
- returned: success
- type: str
- maxBackoffDuration:
- description:
- - The maximum amount of time to wait before retrying a job after it fails.
- - A duration in seconds with up to nine fractional digits, terminated by 's'.
- returned: success
- type: str
- maxDoublings:
- description:
- - The time between retries will double maxDoublings times.
- - A job's retry interval starts at minBackoffDuration, then doubles maxDoublings
- times, then increases linearly, and finally retries retries at intervals of
- maxBackoffDuration up to retryCount times.
- returned: success
- type: int
-pubsubTarget:
- description:
- - Pub/Sub target If the job providers a Pub/Sub target the cron will publish a message
- to the provided topic .
- returned: success
- type: complex
- contains:
- topicName:
- description:
- - The name of the Cloud Pub/Sub topic to which messages will be published when
- a job is delivered. The topic name must be in the same format as required
- by PubSub's PublishRequest.name, for example projects/PROJECT_ID/topics/TOPIC_ID.
- returned: success
- type: str
- data:
- description:
- - The message payload for PubsubMessage.
- - Pubsub message must contain either non-empty data, or at least one attribute.
- returned: success
- type: str
- attributes:
- description:
- - Attributes for PubsubMessage.
- - Pubsub message must contain either non-empty data, or at least one attribute.
- returned: success
- type: dict
-appEngineHttpTarget:
- description:
- - App Engine HTTP target.
- - If the job providers a App Engine HTTP target the cron will send a request to
- the service instance .
- returned: success
- type: complex
- contains:
- httpMethod:
- description:
- - Which HTTP method to use for the request.
- returned: success
- type: str
- appEngineRouting:
- description:
- - App Engine Routing setting for the job.
- returned: success
- type: complex
- contains:
- service:
- description:
- - App service.
- - By default, the job is sent to the service which is the default service
- when the job is attempted.
- returned: success
- type: str
- version:
- description:
- - App version.
- - By default, the job is sent to the version which is the default version
- when the job is attempted.
- returned: success
- type: str
- instance:
- description:
- - App instance.
- - By default, the job is sent to an instance which is available when the
- job is attempted.
- returned: success
- type: str
- relativeUri:
- description:
- - The relative URI.
- returned: success
- type: str
- body:
- description:
- - HTTP request body. A request body is allowed only if the HTTP method is POST
- or PUT. It will result in invalid argument error to set a body on a job with
- an incompatible HttpMethod.
- returned: success
- type: str
- headers:
- description:
- - HTTP request headers.
- - This map contains the header field names and values. Headers can be set when
- the job is created.
- returned: success
- type: dict
-httpTarget:
- description:
- - HTTP target.
- - If the job providers a http_target the cron will send a request to the targeted
- url .
- returned: success
- type: complex
- contains:
- uri:
- description:
- - The full URI path that the request will be sent to.
- returned: success
- type: str
- httpMethod:
- description:
- - Which HTTP method to use for the request.
- returned: success
- type: str
- body:
- description:
- - HTTP request body. A request body is allowed only if the HTTP method is POST,
- PUT, or PATCH. It is an error to set body on a job with an incompatible HttpMethod.
- returned: success
- type: str
- headers:
- description:
- - This map contains the header field names and values. Repeated headers are
- not supported, but a header value can contain commas.
- returned: success
- type: dict
- oauthToken:
- description:
- - Contains information needed for generating an OAuth token.
- - This type of authorization should be used when sending requests to a GCP endpoint.
- returned: success
- type: complex
- contains:
- serviceAccountEmail:
- description:
- - Service account email to be used for generating OAuth token.
- - The service account must be within the same project as the job.
- returned: success
- type: str
- scope:
- description:
- - OAuth scope to be used for generating OAuth access token. If not specified,
- "U(https://www.googleapis.com/auth/cloud-platform") will be used.
- returned: success
- type: str
- oidcToken:
- description:
- - Contains information needed for generating an OpenID Connect token.
- - This type of authorization should be used when sending requests to third party
- endpoints or Cloud Run.
- returned: success
- type: complex
- contains:
- serviceAccountEmail:
- description:
- - Service account email to be used for generating OAuth token.
- - The service account must be within the same project as the job.
- returned: success
- type: str
- audience:
- description:
- - Audience to be used when generating OIDC token. If not specified, the
- URI specified in target will be used.
- returned: success
- type: str
-region:
- description:
- - Region where the scheduler job resides .
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- name=dict(required=True, type='str'),
- description=dict(type='str'),
- schedule=dict(type='str'),
- time_zone=dict(default='Etc/UTC', type='str'),
- retry_config=dict(
- type='dict',
- options=dict(
- retry_count=dict(type='int'),
- max_retry_duration=dict(type='str'),
- min_backoff_duration=dict(type='str'),
- max_backoff_duration=dict(type='str'),
- max_doublings=dict(type='int'),
- ),
- ),
- pubsub_target=dict(type='dict', options=dict(topic_name=dict(required=True, type='str'), data=dict(type='str'), attributes=dict(type='dict'))),
- app_engine_http_target=dict(
- type='dict',
- options=dict(
- http_method=dict(type='str'),
- app_engine_routing=dict(type='dict', options=dict(service=dict(type='str'), version=dict(type='str'), instance=dict(type='str'))),
- relative_uri=dict(required=True, type='str'),
- body=dict(type='str'),
- headers=dict(type='dict'),
- ),
- ),
- http_target=dict(
- type='dict',
- options=dict(
- uri=dict(required=True, type='str'),
- http_method=dict(type='str'),
- body=dict(type='str'),
- headers=dict(type='dict'),
- oauth_token=dict(type='dict', options=dict(service_account_email=dict(type='str'), scope=dict(type='str'))),
- oidc_token=dict(type='dict', options=dict(service_account_email=dict(type='str'), audience=dict(type='str'))),
- ),
- ),
- region=dict(required=True, type='str'),
- ),
- mutually_exclusive=[['app_engine_http_target', 'http_target', 'pubsub_target']],
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
-
- state = module.params['state']
-
- fetch = fetch_resource(module, self_link(module))
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module))
- fetch = fetch_resource(module, self_link(module))
- changed = True
- else:
- delete(module, self_link(module))
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module))
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link):
- auth = GcpSession(module, 'cloudscheduler')
- return return_if_object(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link):
- delete(module, self_link(module))
- create(module, collection(module))
-
-
-def delete(module, link):
- auth = GcpSession(module, 'cloudscheduler')
- return return_if_object(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'name': module.params.get('name'),
- u'description': module.params.get('description'),
- u'schedule': module.params.get('schedule'),
- u'timeZone': module.params.get('time_zone'),
- u'retryConfig': JobRetryconfig(module.params.get('retry_config', {}), module).to_request(),
- u'pubsubTarget': JobPubsubtarget(module.params.get('pubsub_target', {}), module).to_request(),
- u'appEngineHttpTarget': JobAppenginehttptarget(module.params.get('app_engine_http_target', {}), module).to_request(),
- u'httpTarget': JobHttptarget(module.params.get('http_target', {}), module).to_request(),
- }
- request = encode_request(request, module)
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, allow_not_found=True):
- auth = GcpSession(module, 'cloudscheduler')
- return return_if_object(module, auth.get(link), allow_not_found)
-
-
-def self_link(module):
- return "https://cloudscheduler.googleapis.com/v1/projects/{project}/locations/{region}/jobs/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://cloudscheduler.googleapis.com/v1/projects/{project}/locations/{region}/jobs".format(**module.params)
-
-
-def return_if_object(module, response, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- result = decode_request(result, module)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
- request = decode_request(request, module)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'name': module.params.get('name'),
- u'description': module.params.get('description'),
- u'schedule': module.params.get('schedule'),
- u'timeZone': module.params.get('time_zone'),
- u'retryConfig': JobRetryconfig(module.params.get('retry_config', {}), module).to_request(),
- u'pubsubTarget': JobPubsubtarget(module.params.get('pubsub_target', {}), module).to_request(),
- u'appEngineHttpTarget': JobAppenginehttptarget(module.params.get('app_engine_http_target', {}), module).to_request(),
- u'httpTarget': JobHttptarget(module.params.get('http_target', {}), module).to_request(),
- }
-
-
-def encode_request(request, module):
- request['name'] = "projects/%s/locations/%s/jobs/%s" % (module.params['project'], module.params['region'], module.params['name'])
- return request
-
-
-def decode_request(response, module):
- if 'name' in response:
- response['name'] = response['name'].split('/')[-1]
-
- return response
-
-
-class JobRetryconfig(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'retryCount': self.request.get('retry_count'),
- u'maxRetryDuration': self.request.get('max_retry_duration'),
- u'minBackoffDuration': self.request.get('min_backoff_duration'),
- u'maxBackoffDuration': self.request.get('max_backoff_duration'),
- u'maxDoublings': self.request.get('max_doublings'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'retryCount': self.module.params.get('retry_count'),
- u'maxRetryDuration': self.module.params.get('max_retry_duration'),
- u'minBackoffDuration': self.module.params.get('min_backoff_duration'),
- u'maxBackoffDuration': self.module.params.get('max_backoff_duration'),
- u'maxDoublings': self.module.params.get('max_doublings'),
- }
- )
-
-
-class JobPubsubtarget(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {u'topicName': self.request.get('topic_name'), u'data': self.request.get('data'), u'attributes': self.request.get('attributes')}
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {u'topicName': self.module.params.get('topic_name'), u'data': self.module.params.get('data'), u'attributes': self.module.params.get('attributes')}
- )
-
-
-class JobAppenginehttptarget(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'httpMethod': self.request.get('http_method'),
- u'appEngineRouting': JobAppenginerouting(self.request.get('app_engine_routing', {}), self.module).to_request(),
- u'relativeUri': self.request.get('relative_uri'),
- u'body': self.request.get('body'),
- u'headers': self.request.get('headers'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'httpMethod': self.module.params.get('http_method'),
- u'appEngineRouting': JobAppenginerouting(self.module.params.get('app_engine_routing', {}), self.module).to_request(),
- u'relativeUri': self.request.get(u'relativeUri'),
- u'body': self.module.params.get('body'),
- u'headers': self.module.params.get('headers'),
- }
- )
-
-
-class JobAppenginerouting(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {u'service': self.request.get('service'), u'version': self.request.get('version'), u'instance': self.request.get('instance')}
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {u'service': self.module.params.get('service'), u'version': self.module.params.get('version'), u'instance': self.module.params.get('instance')}
- )
-
-
-class JobHttptarget(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'uri': self.request.get('uri'),
- u'httpMethod': self.request.get('http_method'),
- u'body': self.request.get('body'),
- u'headers': self.request.get('headers'),
- u'oauthToken': JobOauthtoken(self.request.get('oauth_token', {}), self.module).to_request(),
- u'oidcToken': JobOidctoken(self.request.get('oidc_token', {}), self.module).to_request(),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'uri': self.request.get(u'uri'),
- u'httpMethod': self.request.get(u'httpMethod'),
- u'body': self.request.get(u'body'),
- u'headers': self.request.get(u'headers'),
- u'oauthToken': JobOauthtoken(self.module.params.get('oauth_token', {}), self.module).to_request(),
- u'oidcToken': JobOidctoken(self.module.params.get('oidc_token', {}), self.module).to_request(),
- }
- )
-
-
-class JobOauthtoken(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'serviceAccountEmail': self.request.get('service_account_email'), u'scope': self.request.get('scope')})
-
- def from_response(self):
- return remove_nones_from_dict({u'serviceAccountEmail': self.request.get(u'serviceAccountEmail'), u'scope': self.request.get(u'scope')})
-
-
-class JobOidctoken(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'serviceAccountEmail': self.request.get('service_account_email'), u'audience': self.request.get('audience')})
-
- def from_response(self):
- return remove_nones_from_dict({u'serviceAccountEmail': self.request.get(u'serviceAccountEmail'), u'audience': self.request.get(u'audience')})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_cloudscheduler_job_info.py b/lib/ansible/modules/cloud/google/gcp_cloudscheduler_job_info.py
deleted file mode 100644
index 2a280c9847..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_cloudscheduler_job_info.py
+++ /dev/null
@@ -1,396 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_cloudscheduler_job_info
-description:
-- Gather info for GCP Job
-short_description: Gather info for GCP Job
-version_added: '2.9'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- region:
- description:
- - Region where the scheduler job resides .
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a job
- gcp_cloudscheduler_job_info:
- region: us-central1
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- name:
- description:
- - The name of the job.
- returned: success
- type: str
- description:
- description:
- - A human-readable description for the job. This string must not contain more
- than 500 characters.
- returned: success
- type: str
- schedule:
- description:
- - Describes the schedule on which the job will be executed.
- returned: success
- type: str
- timeZone:
- description:
- - Specifies the time zone to be used in interpreting schedule.
- - The value of this field must be a time zone name from the tz database.
- returned: success
- type: str
- retryConfig:
- description:
- - By default, if a job does not complete successfully, meaning that an acknowledgement
- is not received from the handler, then it will be retried with exponential
- backoff according to the settings .
- returned: success
- type: complex
- contains:
- retryCount:
- description:
- - The number of attempts that the system will make to run a job using the
- exponential backoff procedure described by maxDoublings.
- - Values greater than 5 and negative values are not allowed.
- returned: success
- type: int
- maxRetryDuration:
- description:
- - The time limit for retrying a failed job, measured from time when an execution
- was first attempted. If specified with retryCount, the job will be retried
- until both limits are reached.
- - A duration in seconds with up to nine fractional digits, terminated by
- 's'.
- returned: success
- type: str
- minBackoffDuration:
- description:
- - The minimum amount of time to wait before retrying a job after it fails.
- - A duration in seconds with up to nine fractional digits, terminated by
- 's'.
- returned: success
- type: str
- maxBackoffDuration:
- description:
- - The maximum amount of time to wait before retrying a job after it fails.
- - A duration in seconds with up to nine fractional digits, terminated by
- 's'.
- returned: success
- type: str
- maxDoublings:
- description:
- - The time between retries will double maxDoublings times.
- - A job's retry interval starts at minBackoffDuration, then doubles maxDoublings
- times, then increases linearly, and finally retries retries at intervals
- of maxBackoffDuration up to retryCount times.
- returned: success
- type: int
- pubsubTarget:
- description:
- - Pub/Sub target If the job providers a Pub/Sub target the cron will publish
- a message to the provided topic .
- returned: success
- type: complex
- contains:
- topicName:
- description:
- - The name of the Cloud Pub/Sub topic to which messages will be published
- when a job is delivered. The topic name must be in the same format as
- required by PubSub's PublishRequest.name, for example projects/PROJECT_ID/topics/TOPIC_ID.
- returned: success
- type: str
- data:
- description:
- - The message payload for PubsubMessage.
- - Pubsub message must contain either non-empty data, or at least one attribute.
- returned: success
- type: str
- attributes:
- description:
- - Attributes for PubsubMessage.
- - Pubsub message must contain either non-empty data, or at least one attribute.
- returned: success
- type: dict
- appEngineHttpTarget:
- description:
- - App Engine HTTP target.
- - If the job providers a App Engine HTTP target the cron will send a request
- to the service instance .
- returned: success
- type: complex
- contains:
- httpMethod:
- description:
- - Which HTTP method to use for the request.
- returned: success
- type: str
- appEngineRouting:
- description:
- - App Engine Routing setting for the job.
- returned: success
- type: complex
- contains:
- service:
- description:
- - App service.
- - By default, the job is sent to the service which is the default service
- when the job is attempted.
- returned: success
- type: str
- version:
- description:
- - App version.
- - By default, the job is sent to the version which is the default version
- when the job is attempted.
- returned: success
- type: str
- instance:
- description:
- - App instance.
- - By default, the job is sent to an instance which is available when
- the job is attempted.
- returned: success
- type: str
- relativeUri:
- description:
- - The relative URI.
- returned: success
- type: str
- body:
- description:
- - HTTP request body. A request body is allowed only if the HTTP method is
- POST or PUT. It will result in invalid argument error to set a body on
- a job with an incompatible HttpMethod.
- returned: success
- type: str
- headers:
- description:
- - HTTP request headers.
- - This map contains the header field names and values. Headers can be set
- when the job is created.
- returned: success
- type: dict
- httpTarget:
- description:
- - HTTP target.
- - If the job providers a http_target the cron will send a request to the targeted
- url .
- returned: success
- type: complex
- contains:
- uri:
- description:
- - The full URI path that the request will be sent to.
- returned: success
- type: str
- httpMethod:
- description:
- - Which HTTP method to use for the request.
- returned: success
- type: str
- body:
- description:
- - HTTP request body. A request body is allowed only if the HTTP method is
- POST, PUT, or PATCH. It is an error to set body on a job with an incompatible
- HttpMethod.
- returned: success
- type: str
- headers:
- description:
- - This map contains the header field names and values. Repeated headers
- are not supported, but a header value can contain commas.
- returned: success
- type: dict
- oauthToken:
- description:
- - Contains information needed for generating an OAuth token.
- - This type of authorization should be used when sending requests to a GCP
- endpoint.
- returned: success
- type: complex
- contains:
- serviceAccountEmail:
- description:
- - Service account email to be used for generating OAuth token.
- - The service account must be within the same project as the job.
- returned: success
- type: str
- scope:
- description:
- - OAuth scope to be used for generating OAuth access token. If not specified,
- "U(https://www.googleapis.com/auth/cloud-platform") will be used.
- returned: success
- type: str
- oidcToken:
- description:
- - Contains information needed for generating an OpenID Connect token.
- - This type of authorization should be used when sending requests to third
- party endpoints or Cloud Run.
- returned: success
- type: complex
- contains:
- serviceAccountEmail:
- description:
- - Service account email to be used for generating OAuth token.
- - The service account must be within the same project as the job.
- returned: success
- type: str
- audience:
- description:
- - Audience to be used when generating OIDC token. If not specified,
- the URI specified in target will be used.
- returned: success
- type: str
- region:
- description:
- - Region where the scheduler job resides .
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(region=dict(required=True, type='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
-
- return_value = {'resources': fetch_list(module, collection(module))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://cloudscheduler.googleapis.com/v1/projects/{project}/locations/{region}/jobs".format(**module.params)
-
-
-def fetch_list(module, link):
- auth = GcpSession(module, 'cloudscheduler')
- return auth.list(link, return_if_object, array_name='jobs')
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_cloudtasks_queue.py b/lib/ansible/modules/cloud/google/gcp_cloudtasks_queue.py
deleted file mode 100644
index 3b394551d7..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_cloudtasks_queue.py
+++ /dev/null
@@ -1,630 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_cloudtasks_queue
-description:
-- A named resource to which messages are sent by publishers.
-short_description: Creates a GCP Queue
-version_added: '2.9'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- name:
- description:
- - The queue name.
- required: false
- type: str
- app_engine_routing_override:
- description:
- - Overrides for task-level appEngineRouting. These settings apply only to App
- Engine tasks in this queue .
- required: false
- type: dict
- suboptions:
- service:
- description:
- - App service.
- - By default, the task is sent to the service which is the default service
- when the task is attempted.
- required: false
- type: str
- version:
- description:
- - App version.
- - By default, the task is sent to the version which is the default version
- when the task is attempted.
- required: false
- type: str
- instance:
- description:
- - App instance.
- - By default, the task is sent to an instance which is available when the
- task is attempted.
- required: false
- type: str
- rate_limits:
- description:
- - 'Rate limits for task dispatches. The queue''s actual dispatch rate is the result
- of: * Number of tasks in the queue * User-specified throttling: rateLimits,
- retryConfig, and the queue''s state.'
- - "* System throttling due to 429 (Too Many Requests) or 503 (Service Unavailable)
- responses from the worker, high error rates, or to smooth sudden large traffic
- spikes."
- required: false
- type: dict
- suboptions:
- max_dispatches_per_second:
- description:
- - The maximum rate at which tasks are dispatched from this queue.
- - If unspecified when the queue is created, Cloud Tasks will pick the default.
- required: false
- type: int
- max_concurrent_dispatches:
- description:
- - The maximum number of concurrent tasks that Cloud Tasks allows to be dispatched
- for this queue. After this threshold has been reached, Cloud Tasks stops
- dispatching tasks until the number of concurrent requests decreases.
- required: false
- type: int
- retry_config:
- description:
- - Settings that determine the retry behavior.
- required: false
- type: dict
- suboptions:
- max_attempts:
- description:
- - Number of attempts per task.
- - Cloud Tasks will attempt the task maxAttempts times (that is, if the first
- attempt fails, then there will be maxAttempts - 1 retries). Must be >= -1.
- - If unspecified when the queue is created, Cloud Tasks will pick the default.
- - "-1 indicates unlimited attempts."
- required: false
- type: int
- max_retry_duration:
- description:
- - If positive, maxRetryDuration specifies the time limit for retrying a failed
- task, measured from when the task was first attempted. Once maxRetryDuration
- time has passed and the task has been attempted maxAttempts times, no further
- attempts will be made and the task will be deleted.
- - If zero, then the task age is unlimited.
- required: false
- type: str
- min_backoff:
- description:
- - A task will be scheduled for retry between minBackoff and maxBackoff duration
- after it fails, if the queue's RetryConfig specifies that the task should
- be retried.
- required: false
- type: str
- max_backoff:
- description:
- - A task will be scheduled for retry between minBackoff and maxBackoff duration
- after it fails, if the queue's RetryConfig specifies that the task should
- be retried.
- required: false
- type: str
- max_doublings:
- description:
- - The time between retries will double maxDoublings times.
- - A task's retry interval starts at minBackoff, then doubles maxDoublings
- times, then increases linearly, and finally retries retries at intervals
- of maxBackoff up to maxAttempts times.
- required: false
- type: int
- status:
- description:
- - The current state of the queue.
- - 'Some valid choices include: "RUNNING", "PAUSED", "DISABLED"'
- required: false
- type: str
- location:
- description:
- - The location of the queue.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-'''
-
-EXAMPLES = '''
-- name: create a queue
- gcp_cloudtasks_queue:
- name: test_object
- location: us-central1
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-name:
- description:
- - The queue name.
- returned: success
- type: str
-appEngineRoutingOverride:
- description:
- - Overrides for task-level appEngineRouting. These settings apply only to App Engine
- tasks in this queue .
- returned: success
- type: complex
- contains:
- service:
- description:
- - App service.
- - By default, the task is sent to the service which is the default service when
- the task is attempted.
- returned: success
- type: str
- version:
- description:
- - App version.
- - By default, the task is sent to the version which is the default version when
- the task is attempted.
- returned: success
- type: str
- instance:
- description:
- - App instance.
- - By default, the task is sent to an instance which is available when the task
- is attempted.
- returned: success
- type: str
- host:
- description:
- - The host that the task is sent to.
- returned: success
- type: str
-rateLimits:
- description:
- - 'Rate limits for task dispatches. The queue''s actual dispatch rate is the result
- of: * Number of tasks in the queue * User-specified throttling: rateLimits, retryConfig,
- and the queue''s state.'
- - "* System throttling due to 429 (Too Many Requests) or 503 (Service Unavailable)
- responses from the worker, high error rates, or to smooth sudden large traffic
- spikes."
- returned: success
- type: complex
- contains:
- maxDispatchesPerSecond:
- description:
- - The maximum rate at which tasks are dispatched from this queue.
- - If unspecified when the queue is created, Cloud Tasks will pick the default.
- returned: success
- type: int
- maxConcurrentDispatches:
- description:
- - The maximum number of concurrent tasks that Cloud Tasks allows to be dispatched
- for this queue. After this threshold has been reached, Cloud Tasks stops dispatching
- tasks until the number of concurrent requests decreases.
- returned: success
- type: int
- maxBurstSize:
- description:
- - The max burst size.
- - Max burst size limits how fast tasks in queue are processed when many tasks
- are in the queue and the rate is high. This field allows the queue to have
- a high rate so processing starts shortly after a task is enqueued, but still
- limits resource usage when many tasks are enqueued in a short period of time.
- returned: success
- type: int
-retryConfig:
- description:
- - Settings that determine the retry behavior.
- returned: success
- type: complex
- contains:
- maxAttempts:
- description:
- - Number of attempts per task.
- - Cloud Tasks will attempt the task maxAttempts times (that is, if the first
- attempt fails, then there will be maxAttempts - 1 retries). Must be >= -1.
- - If unspecified when the queue is created, Cloud Tasks will pick the default.
- - "-1 indicates unlimited attempts."
- returned: success
- type: int
- maxRetryDuration:
- description:
- - If positive, maxRetryDuration specifies the time limit for retrying a failed
- task, measured from when the task was first attempted. Once maxRetryDuration
- time has passed and the task has been attempted maxAttempts times, no further
- attempts will be made and the task will be deleted.
- - If zero, then the task age is unlimited.
- returned: success
- type: str
- minBackoff:
- description:
- - A task will be scheduled for retry between minBackoff and maxBackoff duration
- after it fails, if the queue's RetryConfig specifies that the task should
- be retried.
- returned: success
- type: str
- maxBackoff:
- description:
- - A task will be scheduled for retry between minBackoff and maxBackoff duration
- after it fails, if the queue's RetryConfig specifies that the task should
- be retried.
- returned: success
- type: str
- maxDoublings:
- description:
- - The time between retries will double maxDoublings times.
- - A task's retry interval starts at minBackoff, then doubles maxDoublings times,
- then increases linearly, and finally retries retries at intervals of maxBackoff
- up to maxAttempts times.
- returned: success
- type: int
- purgeTime:
- description:
- - The last time this queue was purged.
- returned: success
- type: str
-status:
- description:
- - The current state of the queue.
- returned: success
- type: str
-location:
- description:
- - The location of the queue.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import re
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- name=dict(type='str'),
- app_engine_routing_override=dict(type='dict', options=dict(service=dict(type='str'), version=dict(type='str'), instance=dict(type='str'))),
- rate_limits=dict(type='dict', options=dict(max_dispatches_per_second=dict(type='int'), max_concurrent_dispatches=dict(type='int'))),
- retry_config=dict(
- type='dict',
- options=dict(
- max_attempts=dict(type='int'),
- max_retry_duration=dict(type='str'),
- min_backoff=dict(type='str'),
- max_backoff=dict(type='str'),
- max_doublings=dict(type='int'),
- ),
- ),
- status=dict(type='str'),
- location=dict(required=True, type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
-
- state = module.params['state']
-
- fetch = fetch_resource(module, self_link(module))
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module))
- fetch = fetch_resource(module, self_link(module))
- changed = True
- else:
- delete(module, self_link(module))
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module))
- changed = True
- else:
- fetch = {}
-
- if fetch:
- instance = QueueStatus(module, fetch.get('state'))
- instance.run()
- if module.params.get('status'):
- fetch.update({'status': module.params['status']})
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link):
- auth = GcpSession(module, 'cloudtasks')
- return return_if_object(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link):
- auth = GcpSession(module, 'cloudtasks')
- return return_if_object(module, auth.put(link, resource_to_request(module)))
-
-
-def delete(module, link):
- auth = GcpSession(module, 'cloudtasks')
- return return_if_object(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'name': name_pattern(module.params.get('name'), module),
- u'appEngineRoutingOverride': QueueAppengineroutingoverride(module.params.get('app_engine_routing_override', {}), module).to_request(),
- u'rateLimits': QueueRatelimits(module.params.get('rate_limits', {}), module).to_request(),
- u'retryConfig': QueueRetryconfig(module.params.get('retry_config', {}), module).to_request(),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, allow_not_found=True):
- auth = GcpSession(module, 'cloudtasks')
- return return_if_object(module, auth.get(link), allow_not_found)
-
-
-def self_link(module):
- return "https://cloudtasks.googleapis.com/v2/projects/{project}/locations/{location}/queues/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://cloudtasks.googleapis.com/v2/projects/{project}/locations/{location}/queues".format(**module.params)
-
-
-def return_if_object(module, response, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'name': response.get(u'name'),
- u'appEngineRoutingOverride': QueueAppengineroutingoverride(response.get(u'appEngineRoutingOverride', {}), module).from_response(),
- u'rateLimits': QueueRatelimits(response.get(u'rateLimits', {}), module).from_response(),
- u'retryConfig': QueueRetryconfig(response.get(u'retryConfig', {}), module).from_response(),
- }
-
-
-def name_pattern(name, module):
- if name is None:
- return
-
- regex = r"projects/.*/locations/.*/queues/.*"
-
- if not re.match(regex, name):
- name = "projects/{project}/locations/{location}/queues/{name}".format(**module.params)
-
- return name
-
-
-class QueueStatus(object):
- def __init__(self, module, current_status):
- self.module = module
- self.current_status = current_status
- self.desired_status = self.module.params.get('status')
-
- def run(self):
- # GcpRequest handles unicode text handling
- if GcpRequest({'status': self.current_status}) == GcpRequest({'status': self.desired_status}):
- return
- elif self.desired_status == 'PAUSED':
- self.stop()
- elif self.desired_status == 'RUNNING':
- self.start()
-
- def start(self):
- auth = GcpSession(self.module, 'cloudtasks')
- return_if_object(self.module, auth.post(self._start_url()))
-
- def stop(self):
- auth = GcpSession(self.module, 'cloudtasks')
- return_if_object(self.module, auth.post(self._stop_url()))
-
- def _start_url(self):
- return "https://cloudtasks.googleapis.com/v2/projects/{project}/locations/{location}/queues/{name}:resume".format(**self.module.params)
-
- def _stop_url(self):
- return "https://cloudtasks.googleapis.com/v2/projects/{project}/locations/{location}/queues/{name}:pause".format(**self.module.params)
-
-
-class QueueAppengineroutingoverride(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {u'service': self.request.get('service'), u'version': self.request.get('version'), u'instance': self.request.get('instance')}
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {u'service': self.request.get(u'service'), u'version': self.request.get(u'version'), u'instance': self.request.get(u'instance')}
- )
-
-
-class QueueRatelimits(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'maxDispatchesPerSecond': self.request.get('max_dispatches_per_second'),
- u'maxConcurrentDispatches': self.request.get('max_concurrent_dispatches'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {u'maxDispatchesPerSecond': self.request.get(u'maxDispatchesPerSecond'), u'maxConcurrentDispatches': self.request.get(u'maxConcurrentDispatches')}
- )
-
-
-class QueueRetryconfig(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'maxAttempts': self.request.get('max_attempts'),
- u'maxRetryDuration': self.request.get('max_retry_duration'),
- u'minBackoff': self.request.get('min_backoff'),
- u'maxBackoff': self.request.get('max_backoff'),
- u'maxDoublings': self.request.get('max_doublings'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'maxAttempts': self.request.get(u'maxAttempts'),
- u'maxRetryDuration': self.request.get(u'maxRetryDuration'),
- u'minBackoff': self.request.get(u'minBackoff'),
- u'maxBackoff': self.request.get(u'maxBackoff'),
- u'maxDoublings': self.request.get(u'maxDoublings'),
- }
- )
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_cloudtasks_queue_info.py b/lib/ansible/modules/cloud/google/gcp_cloudtasks_queue_info.py
deleted file mode 100644
index c5f49552ac..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_cloudtasks_queue_info.py
+++ /dev/null
@@ -1,301 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_cloudtasks_queue_info
-description:
-- Gather info for GCP Queue
-short_description: Gather info for GCP Queue
-version_added: '2.9'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- location:
- description:
- - The location of the queue.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a queue
- gcp_cloudtasks_queue_info:
- location: us-central1
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- name:
- description:
- - The queue name.
- returned: success
- type: str
- appEngineRoutingOverride:
- description:
- - Overrides for task-level appEngineRouting. These settings apply only to App
- Engine tasks in this queue .
- returned: success
- type: complex
- contains:
- service:
- description:
- - App service.
- - By default, the task is sent to the service which is the default service
- when the task is attempted.
- returned: success
- type: str
- version:
- description:
- - App version.
- - By default, the task is sent to the version which is the default version
- when the task is attempted.
- returned: success
- type: str
- instance:
- description:
- - App instance.
- - By default, the task is sent to an instance which is available when the
- task is attempted.
- returned: success
- type: str
- host:
- description:
- - The host that the task is sent to.
- returned: success
- type: str
- rateLimits:
- description:
- - 'Rate limits for task dispatches. The queue''s actual dispatch rate is the
- result of: * Number of tasks in the queue * User-specified throttling: rateLimits,
- retryConfig, and the queue''s state.'
- - "* System throttling due to 429 (Too Many Requests) or 503 (Service Unavailable)
- responses from the worker, high error rates, or to smooth sudden large traffic
- spikes."
- returned: success
- type: complex
- contains:
- maxDispatchesPerSecond:
- description:
- - The maximum rate at which tasks are dispatched from this queue.
- - If unspecified when the queue is created, Cloud Tasks will pick the default.
- returned: success
- type: int
- maxConcurrentDispatches:
- description:
- - The maximum number of concurrent tasks that Cloud Tasks allows to be dispatched
- for this queue. After this threshold has been reached, Cloud Tasks stops
- dispatching tasks until the number of concurrent requests decreases.
- returned: success
- type: int
- maxBurstSize:
- description:
- - The max burst size.
- - Max burst size limits how fast tasks in queue are processed when many
- tasks are in the queue and the rate is high. This field allows the queue
- to have a high rate so processing starts shortly after a task is enqueued,
- but still limits resource usage when many tasks are enqueued in a short
- period of time.
- returned: success
- type: int
- retryConfig:
- description:
- - Settings that determine the retry behavior.
- returned: success
- type: complex
- contains:
- maxAttempts:
- description:
- - Number of attempts per task.
- - Cloud Tasks will attempt the task maxAttempts times (that is, if the first
- attempt fails, then there will be maxAttempts - 1 retries). Must be >=
- -1.
- - If unspecified when the queue is created, Cloud Tasks will pick the default.
- - "-1 indicates unlimited attempts."
- returned: success
- type: int
- maxRetryDuration:
- description:
- - If positive, maxRetryDuration specifies the time limit for retrying a
- failed task, measured from when the task was first attempted. Once maxRetryDuration
- time has passed and the task has been attempted maxAttempts times, no
- further attempts will be made and the task will be deleted.
- - If zero, then the task age is unlimited.
- returned: success
- type: str
- minBackoff:
- description:
- - A task will be scheduled for retry between minBackoff and maxBackoff duration
- after it fails, if the queue's RetryConfig specifies that the task should
- be retried.
- returned: success
- type: str
- maxBackoff:
- description:
- - A task will be scheduled for retry between minBackoff and maxBackoff duration
- after it fails, if the queue's RetryConfig specifies that the task should
- be retried.
- returned: success
- type: str
- maxDoublings:
- description:
- - The time between retries will double maxDoublings times.
- - A task's retry interval starts at minBackoff, then doubles maxDoublings
- times, then increases linearly, and finally retries retries at intervals
- of maxBackoff up to maxAttempts times.
- returned: success
- type: int
- purgeTime:
- description:
- - The last time this queue was purged.
- returned: success
- type: str
- status:
- description:
- - The current state of the queue.
- returned: success
- type: str
- location:
- description:
- - The location of the queue.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(location=dict(required=True, type='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
-
- return_value = {'resources': fetch_list(module, collection(module))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://cloudtasks.googleapis.com/v2/projects/{project}/locations/{location}/queues".format(**module.params)
-
-
-def fetch_list(module, link):
- auth = GcpSession(module, 'cloudtasks')
- return auth.list(link, return_if_object, array_name='queues')
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_address.py b/lib/ansible/modules/cloud/google/gcp_compute_address.py
deleted file mode 100644
index 2b2e775536..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_address.py
+++ /dev/null
@@ -1,467 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_address
-description:
-- Represents an Address resource.
-- Each virtual machine instance has an ephemeral internal IP address and, optionally,
- an external IP address. To communicate between instances on the same network, you
- can use an instance's internal IP address. To communicate with the Internet and
- instances outside of the same network, you must specify the instance's external
- IP address.
-- Internal IP addresses are ephemeral and only belong to an instance for the lifetime
- of the instance; if the instance is deleted and recreated, the instance is assigned
- a new internal IP address, either by Compute Engine or by you. External IP addresses
- can be either ephemeral or static.
-short_description: Creates a GCP Address
-version_added: '2.6'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- address:
- description:
- - The static external IP address represented by this resource. Only IPv4 is supported.
- An address may only be specified for INTERNAL address types. The IP address
- must be inside the specified subnetwork, if any.
- required: false
- type: str
- address_type:
- description:
- - The type of address to reserve, either INTERNAL or EXTERNAL.
- - If unspecified, defaults to EXTERNAL.
- - 'Some valid choices include: "INTERNAL", "EXTERNAL"'
- required: false
- default: EXTERNAL
- type: str
- version_added: '2.7'
- description:
- description:
- - An optional description of this resource.
- required: false
- type: str
- name:
- description:
- - Name of the resource. The name must be 1-63 characters long, and comply with
- RFC1035. Specifically, the name must be 1-63 characters long and match the regular
- expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must
- be a lowercase letter, and all following characters must be a dash, lowercase
- letter, or digit, except the last character, which cannot be a dash.
- required: true
- type: str
- purpose:
- description:
- - 'The purpose of this resource, which can be one of the following values: - GCE_ENDPOINT
- for addresses that are used by VM instances, alias IP ranges, internal load
- balancers, and similar resources.'
- - This should only be set when using an Internal address.
- - 'Some valid choices include: "GCE_ENDPOINT"'
- required: false
- type: str
- version_added: '2.10'
- network_tier:
- description:
- - 'The networking tier used for configuring this address. This field can take
- the following values: PREMIUM or STANDARD. If this field is not specified, it
- is assumed to be PREMIUM.'
- - 'Some valid choices include: "PREMIUM", "STANDARD"'
- required: false
- type: str
- version_added: '2.8'
- subnetwork:
- description:
- - The URL of the subnetwork in which to reserve the address. If an IP address
- is specified, it must be within the subnetwork's IP range.
- - This field can only be used with INTERNAL type with GCE_ENDPOINT/DNS_RESOLVER
- purposes.
- - 'This field represents a link to a Subnetwork resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''selfLink'' and value
- of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
- to a gcp_compute_subnetwork task and then set this subnetwork field to "{{ name-of-resource
- }}"'
- required: false
- type: dict
- version_added: '2.7'
- region:
- description:
- - URL of the region where the regional address resides.
- - This field is not applicable to global addresses.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/compute/docs/reference/beta/addresses)'
-- 'Reserving a Static External IP Address: U(https://cloud.google.com/compute/docs/instances-and-network)'
-- 'Reserving a Static Internal IP Address: U(https://cloud.google.com/compute/docs/ip-addresses/reserve-static-internal-ip-address)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a address
- gcp_compute_address:
- name: test-address1
- region: us-west1
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-address:
- description:
- - The static external IP address represented by this resource. Only IPv4 is supported.
- An address may only be specified for INTERNAL address types. The IP address must
- be inside the specified subnetwork, if any.
- returned: success
- type: str
-addressType:
- description:
- - The type of address to reserve, either INTERNAL or EXTERNAL.
- - If unspecified, defaults to EXTERNAL.
- returned: success
- type: str
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
-id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
-name:
- description:
- - Name of the resource. The name must be 1-63 characters long, and comply with RFC1035.
- Specifically, the name must be 1-63 characters long and match the regular expression
- `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase
- letter, and all following characters must be a dash, lowercase letter, or digit,
- except the last character, which cannot be a dash.
- returned: success
- type: str
-purpose:
- description:
- - 'The purpose of this resource, which can be one of the following values: - GCE_ENDPOINT
- for addresses that are used by VM instances, alias IP ranges, internal load balancers,
- and similar resources.'
- - This should only be set when using an Internal address.
- returned: success
- type: str
-networkTier:
- description:
- - 'The networking tier used for configuring this address. This field can take the
- following values: PREMIUM or STANDARD. If this field is not specified, it is assumed
- to be PREMIUM.'
- returned: success
- type: str
-subnetwork:
- description:
- - The URL of the subnetwork in which to reserve the address. If an IP address is
- specified, it must be within the subnetwork's IP range.
- - This field can only be used with INTERNAL type with GCE_ENDPOINT/DNS_RESOLVER
- purposes.
- returned: success
- type: dict
-users:
- description:
- - The URLs of the resources that are using this address.
- returned: success
- type: list
-region:
- description:
- - URL of the region where the regional address resides.
- - This field is not applicable to global addresses.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- address=dict(type='str'),
- address_type=dict(default='EXTERNAL', type='str'),
- description=dict(type='str'),
- name=dict(required=True, type='str'),
- purpose=dict(type='str'),
- network_tier=dict(type='str'),
- subnetwork=dict(type='dict'),
- region=dict(required=True, type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#address'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind):
- delete(module, self_link(module), kind)
- create(module, collection(module), kind)
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#address',
- u'address': module.params.get('address'),
- u'addressType': module.params.get('address_type'),
- u'description': module.params.get('description'),
- u'name': module.params.get('name'),
- u'purpose': module.params.get('purpose'),
- u'networkTier': module.params.get('network_tier'),
- u'subnetwork': replace_resource_dict(module.params.get(u'subnetwork', {}), 'selfLink'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/addresses/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/addresses".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'address': response.get(u'address'),
- u'addressType': response.get(u'addressType'),
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'description': response.get(u'description'),
- u'id': response.get(u'id'),
- u'name': response.get(u'name'),
- u'purpose': response.get(u'purpose'),
- u'networkTier': response.get(u'networkTier'),
- u'subnetwork': response.get(u'subnetwork'),
- u'users': response.get(u'users'),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#address')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_address_info.py b/lib/ansible/modules/cloud/google/gcp_compute_address_info.py
deleted file mode 100644
index ceff444680..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_address_info.py
+++ /dev/null
@@ -1,265 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_address_info
-description:
-- Gather info for GCP Address
-short_description: Gather info for GCP Address
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- region:
- description:
- - URL of the region where the regional address resides.
- - This field is not applicable to global addresses.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on an address
- gcp_compute_address_info:
- region: us-west1
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- address:
- description:
- - The static external IP address represented by this resource. Only IPv4 is
- supported. An address may only be specified for INTERNAL address types. The
- IP address must be inside the specified subnetwork, if any.
- returned: success
- type: str
- addressType:
- description:
- - The type of address to reserve, either INTERNAL or EXTERNAL.
- - If unspecified, defaults to EXTERNAL.
- returned: success
- type: str
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
- id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
- name:
- description:
- - Name of the resource. The name must be 1-63 characters long, and comply with
- RFC1035. Specifically, the name must be 1-63 characters long and match the
- regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character
- must be a lowercase letter, and all following characters must be a dash, lowercase
- letter, or digit, except the last character, which cannot be a dash.
- returned: success
- type: str
- purpose:
- description:
- - 'The purpose of this resource, which can be one of the following values: -
- GCE_ENDPOINT for addresses that are used by VM instances, alias IP ranges,
- internal load balancers, and similar resources.'
- - This should only be set when using an Internal address.
- returned: success
- type: str
- networkTier:
- description:
- - 'The networking tier used for configuring this address. This field can take
- the following values: PREMIUM or STANDARD. If this field is not specified,
- it is assumed to be PREMIUM.'
- returned: success
- type: str
- subnetwork:
- description:
- - The URL of the subnetwork in which to reserve the address. If an IP address
- is specified, it must be within the subnetwork's IP range.
- - This field can only be used with INTERNAL type with GCE_ENDPOINT/DNS_RESOLVER
- purposes.
- returned: success
- type: dict
- users:
- description:
- - The URLs of the resources that are using this address.
- returned: success
- type: list
- region:
- description:
- - URL of the region where the regional address resides.
- - This field is not applicable to global addresses.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str'), region=dict(required=True, type='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/addresses".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_autoscaler.py b/lib/ansible/modules/cloud/google/gcp_compute_autoscaler.py
deleted file mode 100644
index df890f0c96..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_autoscaler.py
+++ /dev/null
@@ -1,768 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_autoscaler
-description:
-- Represents an Autoscaler resource.
-- Autoscalers allow you to automatically scale virtual machine instances in managed
- instance groups according to an autoscaling policy that you define.
-short_description: Creates a GCP Autoscaler
-version_added: '2.9'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- name:
- description:
- - Name of the resource. The name must be 1-63 characters long and match the regular
- expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must
- be a lowercase letter, and all following characters must be a dash, lowercase
- letter, or digit, except the last character, which cannot be a dash.
- required: true
- type: str
- description:
- description:
- - An optional description of this resource.
- required: false
- type: str
- autoscaling_policy:
- description:
- - 'The configuration parameters for the autoscaling algorithm. You can define
- one or more of the policies for an autoscaler: cpuUtilization, customMetricUtilizations,
- and loadBalancingUtilization.'
- - If none of these are specified, the default will be to autoscale based on cpuUtilization
- to 0.6 or 60%.
- required: true
- type: dict
- suboptions:
- min_num_replicas:
- description:
- - The minimum number of replicas that the autoscaler can scale down to. This
- cannot be less than 0. If not provided, autoscaler will choose a default
- value depending on maximum number of instances allowed.
- required: false
- type: int
- aliases:
- - minReplicas
- max_num_replicas:
- description:
- - The maximum number of instances that the autoscaler can scale up to. This
- is required when creating or updating an autoscaler. The maximum number
- of replicas should not be lower than minimal number of replicas.
- required: true
- type: int
- aliases:
- - maxReplicas
- cool_down_period_sec:
- description:
- - The number of seconds that the autoscaler should wait before it starts collecting
- information from a new instance. This prevents the autoscaler from collecting
- information when the instance is initializing, during which the collected
- usage would not be reliable. The default time autoscaler waits is 60 seconds.
- - Virtual machine initialization times might vary because of numerous factors.
- We recommend that you test how long an instance may take to initialize.
- To do this, create an instance and time the startup process.
- required: false
- default: '60'
- type: int
- aliases:
- - cooldownPeriod
- cpu_utilization:
- description:
- - Defines the CPU utilization policy that allows the autoscaler to scale based
- on the average CPU utilization of a managed instance group.
- required: false
- type: dict
- suboptions:
- utilization_target:
- description:
- - The target CPU utilization that the autoscaler should maintain.
- - Must be a float value in the range (0, 1]. If not specified, the default
- is 0.6.
- - If the CPU level is below the target utilization, the autoscaler scales
- down the number of instances until it reaches the minimum number of
- instances you specified or until the average CPU of your instances reaches
- the target utilization.
- - If the average CPU is above the target utilization, the autoscaler scales
- up until it reaches the maximum number of instances you specified or
- until the average utilization reaches the target utilization.
- required: false
- type: str
- aliases:
- - target
- custom_metric_utilizations:
- description:
- - Defines the CPU utilization policy that allows the autoscaler to scale based
- on the average CPU utilization of a managed instance group.
- required: false
- type: list
- aliases:
- - metric
- suboptions:
- metric:
- description:
- - The identifier (type) of the Stackdriver Monitoring metric.
- - The metric cannot have negative values.
- - The metric must have a value type of INT64 or DOUBLE.
- required: true
- type: str
- aliases:
- - name
- utilization_target:
- description:
- - The target value of the metric that autoscaler should maintain. This
- must be a positive value. A utilization metric scales number of virtual
- machines handling requests to increase or decrease proportionally to
- the metric.
- - For example, a good metric to use as a utilizationTarget is U(www.googleapis.com/compute/instance/network/received_bytes_count).
- - The autoscaler will work to keep this value constant for each of the
- instances.
- required: false
- type: str
- aliases:
- - target
- utilization_target_type:
- description:
- - Defines how target utilization value is expressed for a Stackdriver
- Monitoring metric. Either GAUGE, DELTA_PER_SECOND, or DELTA_PER_MINUTE.
- - 'Some valid choices include: "GAUGE", "DELTA_PER_SECOND", "DELTA_PER_MINUTE"'
- required: false
- type: str
- aliases:
- - type
- load_balancing_utilization:
- description:
- - Configuration parameters of autoscaling based on a load balancer.
- required: false
- type: dict
- suboptions:
- utilization_target:
- description:
- - Fraction of backend capacity utilization (set in HTTP(s) load balancing
- configuration) that autoscaler should maintain. Must be a positive float
- value. If not defined, the default is 0.8.
- required: false
- type: str
- aliases:
- - target
- target:
- description:
- - URL of the managed instance group that this autoscaler will scale.
- - 'This field represents a link to a InstanceGroupManager resource in GCP. It
- can be specified in two ways. First, you can place a dictionary with key ''selfLink''
- and value of your resource''s selfLink Alternatively, you can add `register:
- name-of-resource` to a gcp_compute_instance_group_manager task and then set
- this target field to "{{ name-of-resource }}"'
- required: true
- type: dict
- zone:
- description:
- - URL of the zone where the instance group resides.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/v1/autoscalers)'
-- 'Autoscaling Groups of Instances: U(https://cloud.google.com/compute/docs/autoscaler/)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a network
- gcp_compute_network:
- name: network-instancetemplate
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: network
-
-- name: create a address
- gcp_compute_address:
- name: address-instancetemplate
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: address
-
-- name: create a instance template
- gcp_compute_instance_template:
- name: "{{ resource_name }}"
- properties:
- disks:
- - auto_delete: 'true'
- boot: 'true'
- initialize_params:
- source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
- machine_type: n1-standard-1
- network_interfaces:
- - network: "{{ network }}"
- access_configs:
- - name: test-config
- type: ONE_TO_ONE_NAT
- nat_ip: "{{ address }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: instancetemplate
-
-- name: create a instance group manager
- gcp_compute_instance_group_manager:
- name: "{{ resource_name }}"
- base_instance_name: test1-child
- instance_template: "{{ instancetemplate }}"
- target_size: 3
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: igm
-
-- name: create a autoscaler
- gcp_compute_autoscaler:
- name: test_object
- zone: us-central1-a
- target: "{{ igm }}"
- autoscaling_policy:
- max_num_replicas: 5
- min_num_replicas: 1
- cool_down_period_sec: 60
- cpu_utilization:
- utilization_target: 0.5
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-id:
- description:
- - Unique identifier for the resource.
- returned: success
- type: int
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-name:
- description:
- - Name of the resource. The name must be 1-63 characters long and match the regular
- expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be
- a lowercase letter, and all following characters must be a dash, lowercase letter,
- or digit, except the last character, which cannot be a dash.
- returned: success
- type: str
-description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
-autoscalingPolicy:
- description:
- - 'The configuration parameters for the autoscaling algorithm. You can define one
- or more of the policies for an autoscaler: cpuUtilization, customMetricUtilizations,
- and loadBalancingUtilization.'
- - If none of these are specified, the default will be to autoscale based on cpuUtilization
- to 0.6 or 60%.
- returned: success
- type: complex
- contains:
- minNumReplicas:
- description:
- - The minimum number of replicas that the autoscaler can scale down to. This
- cannot be less than 0. If not provided, autoscaler will choose a default value
- depending on maximum number of instances allowed.
- returned: success
- type: int
- maxNumReplicas:
- description:
- - The maximum number of instances that the autoscaler can scale up to. This
- is required when creating or updating an autoscaler. The maximum number of
- replicas should not be lower than minimal number of replicas.
- returned: success
- type: int
- coolDownPeriodSec:
- description:
- - The number of seconds that the autoscaler should wait before it starts collecting
- information from a new instance. This prevents the autoscaler from collecting
- information when the instance is initializing, during which the collected
- usage would not be reliable. The default time autoscaler waits is 60 seconds.
- - Virtual machine initialization times might vary because of numerous factors.
- We recommend that you test how long an instance may take to initialize. To
- do this, create an instance and time the startup process.
- returned: success
- type: int
- cpuUtilization:
- description:
- - Defines the CPU utilization policy that allows the autoscaler to scale based
- on the average CPU utilization of a managed instance group.
- returned: success
- type: complex
- contains:
- utilizationTarget:
- description:
- - The target CPU utilization that the autoscaler should maintain.
- - Must be a float value in the range (0, 1]. If not specified, the default
- is 0.6.
- - If the CPU level is below the target utilization, the autoscaler scales
- down the number of instances until it reaches the minimum number of instances
- you specified or until the average CPU of your instances reaches the target
- utilization.
- - If the average CPU is above the target utilization, the autoscaler scales
- up until it reaches the maximum number of instances you specified or until
- the average utilization reaches the target utilization.
- returned: success
- type: str
- customMetricUtilizations:
- description:
- - Defines the CPU utilization policy that allows the autoscaler to scale based
- on the average CPU utilization of a managed instance group.
- returned: success
- type: complex
- contains:
- metric:
- description:
- - The identifier (type) of the Stackdriver Monitoring metric.
- - The metric cannot have negative values.
- - The metric must have a value type of INT64 or DOUBLE.
- returned: success
- type: str
- utilizationTarget:
- description:
- - The target value of the metric that autoscaler should maintain. This must
- be a positive value. A utilization metric scales number of virtual machines
- handling requests to increase or decrease proportionally to the metric.
- - For example, a good metric to use as a utilizationTarget is U(www.googleapis.com/compute/instance/network/received_bytes_count).
- - The autoscaler will work to keep this value constant for each of the instances.
- returned: success
- type: str
- utilizationTargetType:
- description:
- - Defines how target utilization value is expressed for a Stackdriver Monitoring
- metric. Either GAUGE, DELTA_PER_SECOND, or DELTA_PER_MINUTE.
- returned: success
- type: str
- loadBalancingUtilization:
- description:
- - Configuration parameters of autoscaling based on a load balancer.
- returned: success
- type: complex
- contains:
- utilizationTarget:
- description:
- - Fraction of backend capacity utilization (set in HTTP(s) load balancing
- configuration) that autoscaler should maintain. Must be a positive float
- value. If not defined, the default is 0.8.
- returned: success
- type: str
-target:
- description:
- - URL of the managed instance group that this autoscaler will scale.
- returned: success
- type: dict
-zone:
- description:
- - URL of the zone where the instance group resides.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- name=dict(required=True, type='str'),
- description=dict(type='str'),
- autoscaling_policy=dict(
- required=True,
- type='dict',
- options=dict(
- min_num_replicas=dict(type='int', aliases=['minReplicas']),
- max_num_replicas=dict(required=True, type='int', aliases=['maxReplicas']),
- cool_down_period_sec=dict(default=60, type='int', aliases=['cooldownPeriod']),
- cpu_utilization=dict(type='dict', options=dict(utilization_target=dict(type='str', aliases=['target']))),
- custom_metric_utilizations=dict(
- type='list',
- elements='dict',
- aliases=['metric'],
- options=dict(
- metric=dict(required=True, type='str', aliases=['name']),
- utilization_target=dict(type='str', aliases=['target']),
- utilization_target_type=dict(type='str', aliases=['type']),
- ),
- ),
- load_balancing_utilization=dict(type='dict', options=dict(utilization_target=dict(type='str', aliases=['target']))),
- ),
- ),
- target=dict(required=True, type='dict'),
- zone=dict(required=True, type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#autoscaler'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.put(link, resource_to_request(module)))
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#autoscaler',
- u'zone': module.params.get('zone'),
- u'name': module.params.get('name'),
- u'description': module.params.get('description'),
- u'autoscalingPolicy': AutoscalerAutoscalingpolicy(module.params.get('autoscaling_policy', {}), module).to_request(),
- u'target': replace_resource_dict(module.params.get(u'target', {}), 'selfLink'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/autoscalers/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/autoscalers".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'id': response.get(u'id'),
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'name': module.params.get('name'),
- u'description': response.get(u'description'),
- u'autoscalingPolicy': AutoscalerAutoscalingpolicy(response.get(u'autoscalingPolicy', {}), module).from_response(),
- u'target': response.get(u'target'),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#autoscaler')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-class AutoscalerAutoscalingpolicy(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'minNumReplicas': self.request.get('min_num_replicas'),
- u'maxNumReplicas': self.request.get('max_num_replicas'),
- u'coolDownPeriodSec': self.request.get('cool_down_period_sec'),
- u'cpuUtilization': AutoscalerCpuutilization(self.request.get('cpu_utilization', {}), self.module).to_request(),
- u'customMetricUtilizations': AutoscalerCustommetricutilizationsArray(
- self.request.get('custom_metric_utilizations', []), self.module
- ).to_request(),
- u'loadBalancingUtilization': AutoscalerLoadbalancingutilization(self.request.get('load_balancing_utilization', {}), self.module).to_request(),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'minNumReplicas': self.request.get(u'minNumReplicas'),
- u'maxNumReplicas': self.request.get(u'maxNumReplicas'),
- u'coolDownPeriodSec': self.request.get(u'coolDownPeriodSec'),
- u'cpuUtilization': AutoscalerCpuutilization(self.request.get(u'cpuUtilization', {}), self.module).from_response(),
- u'customMetricUtilizations': AutoscalerCustommetricutilizationsArray(
- self.request.get(u'customMetricUtilizations', []), self.module
- ).from_response(),
- u'loadBalancingUtilization': AutoscalerLoadbalancingutilization(self.request.get(u'loadBalancingUtilization', {}), self.module).from_response(),
- }
- )
-
-
-class AutoscalerCpuutilization(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'utilizationTarget': self.request.get('utilization_target')})
-
- def from_response(self):
- return remove_nones_from_dict({u'utilizationTarget': self.request.get(u'utilizationTarget')})
-
-
-class AutoscalerCustommetricutilizationsArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict(
- {u'metric': item.get('metric'), u'utilizationTarget': item.get('utilization_target'), u'utilizationTargetType': item.get('utilization_target_type')}
- )
-
- def _response_from_item(self, item):
- return remove_nones_from_dict(
- {u'metric': item.get(u'metric'), u'utilizationTarget': item.get(u'utilizationTarget'), u'utilizationTargetType': item.get(u'utilizationTargetType')}
- )
-
-
-class AutoscalerLoadbalancingutilization(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'utilizationTarget': self.request.get('utilization_target')})
-
- def from_response(self):
- return remove_nones_from_dict({u'utilizationTarget': self.request.get(u'utilizationTarget')})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_autoscaler_info.py b/lib/ansible/modules/cloud/google/gcp_compute_autoscaler_info.py
deleted file mode 100644
index 7bfac26f39..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_autoscaler_info.py
+++ /dev/null
@@ -1,327 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_autoscaler_info
-description:
-- Gather info for GCP Autoscaler
-short_description: Gather info for GCP Autoscaler
-version_added: '2.9'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- zone:
- description:
- - URL of the zone where the instance group resides.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on an autoscaler
- gcp_compute_autoscaler_info:
- zone: us-central1-a
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- id:
- description:
- - Unique identifier for the resource.
- returned: success
- type: int
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- name:
- description:
- - Name of the resource. The name must be 1-63 characters long and match the
- regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character
- must be a lowercase letter, and all following characters must be a dash, lowercase
- letter, or digit, except the last character, which cannot be a dash.
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
- autoscalingPolicy:
- description:
- - 'The configuration parameters for the autoscaling algorithm. You can define
- one or more of the policies for an autoscaler: cpuUtilization, customMetricUtilizations,
- and loadBalancingUtilization.'
- - If none of these are specified, the default will be to autoscale based on
- cpuUtilization to 0.6 or 60%.
- returned: success
- type: complex
- contains:
- minNumReplicas:
- description:
- - The minimum number of replicas that the autoscaler can scale down to.
- This cannot be less than 0. If not provided, autoscaler will choose a
- default value depending on maximum number of instances allowed.
- returned: success
- type: int
- maxNumReplicas:
- description:
- - The maximum number of instances that the autoscaler can scale up to. This
- is required when creating or updating an autoscaler. The maximum number
- of replicas should not be lower than minimal number of replicas.
- returned: success
- type: int
- coolDownPeriodSec:
- description:
- - The number of seconds that the autoscaler should wait before it starts
- collecting information from a new instance. This prevents the autoscaler
- from collecting information when the instance is initializing, during
- which the collected usage would not be reliable. The default time autoscaler
- waits is 60 seconds.
- - Virtual machine initialization times might vary because of numerous factors.
- We recommend that you test how long an instance may take to initialize.
- To do this, create an instance and time the startup process.
- returned: success
- type: int
- cpuUtilization:
- description:
- - Defines the CPU utilization policy that allows the autoscaler to scale
- based on the average CPU utilization of a managed instance group.
- returned: success
- type: complex
- contains:
- utilizationTarget:
- description:
- - The target CPU utilization that the autoscaler should maintain.
- - Must be a float value in the range (0, 1]. If not specified, the default
- is 0.6.
- - If the CPU level is below the target utilization, the autoscaler scales
- down the number of instances until it reaches the minimum number of
- instances you specified or until the average CPU of your instances
- reaches the target utilization.
- - If the average CPU is above the target utilization, the autoscaler
- scales up until it reaches the maximum number of instances you specified
- or until the average utilization reaches the target utilization.
- returned: success
- type: str
- customMetricUtilizations:
- description:
- - Defines the CPU utilization policy that allows the autoscaler to scale
- based on the average CPU utilization of a managed instance group.
- returned: success
- type: complex
- contains:
- metric:
- description:
- - The identifier (type) of the Stackdriver Monitoring metric.
- - The metric cannot have negative values.
- - The metric must have a value type of INT64 or DOUBLE.
- returned: success
- type: str
- utilizationTarget:
- description:
- - The target value of the metric that autoscaler should maintain. This
- must be a positive value. A utilization metric scales number of virtual
- machines handling requests to increase or decrease proportionally
- to the metric.
- - For example, a good metric to use as a utilizationTarget is U(www.googleapis.com/compute/instance/network/received_bytes_count).
- - The autoscaler will work to keep this value constant for each of the
- instances.
- returned: success
- type: str
- utilizationTargetType:
- description:
- - Defines how target utilization value is expressed for a Stackdriver
- Monitoring metric. Either GAUGE, DELTA_PER_SECOND, or DELTA_PER_MINUTE.
- returned: success
- type: str
- loadBalancingUtilization:
- description:
- - Configuration parameters of autoscaling based on a load balancer.
- returned: success
- type: complex
- contains:
- utilizationTarget:
- description:
- - Fraction of backend capacity utilization (set in HTTP(s) load balancing
- configuration) that autoscaler should maintain. Must be a positive
- float value. If not defined, the default is 0.8.
- returned: success
- type: str
- target:
- description:
- - URL of the managed instance group that this autoscaler will scale.
- returned: success
- type: dict
- zone:
- description:
- - URL of the zone where the instance group resides.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str'), zone=dict(required=True, type='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/autoscalers".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_backend_bucket.py b/lib/ansible/modules/cloud/google/gcp_compute_backend_bucket.py
deleted file mode 100644
index 8defeaf729..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_backend_bucket.py
+++ /dev/null
@@ -1,437 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_backend_bucket
-description:
-- Backend buckets allow you to use Google Cloud Storage buckets with HTTP(S) load
- balancing.
-- An HTTP(S) load balancer can direct traffic to specified URLs to a backend bucket
- rather than a backend service. It can send requests for static content to a Cloud
- Storage bucket and requests for dynamic content to a virtual machine instance.
-short_description: Creates a GCP BackendBucket
-version_added: '2.6'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- bucket_name:
- description:
- - Cloud Storage bucket name.
- required: true
- type: str
- cdn_policy:
- description:
- - Cloud CDN configuration for this Backend Bucket.
- required: false
- type: dict
- version_added: '2.8'
- suboptions:
- signed_url_cache_max_age_sec:
- description:
- - Maximum number of seconds the response to a signed URL request will be considered
- fresh. Defaults to 1hr (3600s). After this time period, the response will
- be revalidated before being served.
- - 'When serving responses to signed URL requests, Cloud CDN will internally
- behave as though all responses from this backend had a "Cache-Control: public,
- max-age=[TTL]" header, regardless of any existing Cache-Control header.
- The actual headers served in responses will not be altered.'
- required: false
- default: '3600'
- type: int
- description:
- description:
- - An optional textual description of the resource; provided by the client when
- the resource is created.
- required: false
- type: str
- enable_cdn:
- description:
- - If true, enable Cloud CDN for this BackendBucket.
- required: false
- type: bool
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/compute/docs/reference/v1/backendBuckets)'
-- 'Using a Cloud Storage bucket as a load balancer backend: U(https://cloud.google.com/compute/docs/load-balancing/http/backend-bucket)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a bucket
- gcp_storage_bucket:
- name: bucket-backendbucket
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: bucket
-
-- name: create a backend bucket
- gcp_compute_backend_bucket:
- name: test_object
- bucket_name: "{{ bucket.name }}"
- description: A BackendBucket to connect LNB w/ Storage Bucket
- enable_cdn: 'true'
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-bucketName:
- description:
- - Cloud Storage bucket name.
- returned: success
- type: str
-cdnPolicy:
- description:
- - Cloud CDN configuration for this Backend Bucket.
- returned: success
- type: complex
- contains:
- signedUrlCacheMaxAgeSec:
- description:
- - Maximum number of seconds the response to a signed URL request will be considered
- fresh. Defaults to 1hr (3600s). After this time period, the response will
- be revalidated before being served.
- - 'When serving responses to signed URL requests, Cloud CDN will internally
- behave as though all responses from this backend had a "Cache-Control: public,
- max-age=[TTL]" header, regardless of any existing Cache-Control header. The
- actual headers served in responses will not be altered.'
- returned: success
- type: int
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-description:
- description:
- - An optional textual description of the resource; provided by the client when the
- resource is created.
- returned: success
- type: str
-enableCdn:
- description:
- - If true, enable Cloud CDN for this BackendBucket.
- returned: success
- type: bool
-id:
- description:
- - Unique identifier for the resource.
- returned: success
- type: int
-name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- bucket_name=dict(required=True, type='str'),
- cdn_policy=dict(type='dict', options=dict(signed_url_cache_max_age_sec=dict(default=3600, type='int'))),
- description=dict(type='str'),
- enable_cdn=dict(type='bool'),
- name=dict(required=True, type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#backendBucket'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.put(link, resource_to_request(module)))
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#backendBucket',
- u'bucketName': module.params.get('bucket_name'),
- u'cdnPolicy': BackendBucketCdnpolicy(module.params.get('cdn_policy', {}), module).to_request(),
- u'description': module.params.get('description'),
- u'enableCdn': module.params.get('enable_cdn'),
- u'name': module.params.get('name'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/backendBuckets/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/backendBuckets".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'bucketName': response.get(u'bucketName'),
- u'cdnPolicy': BackendBucketCdnpolicy(response.get(u'cdnPolicy', {}), module).from_response(),
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'description': response.get(u'description'),
- u'enableCdn': response.get(u'enableCdn'),
- u'id': response.get(u'id'),
- u'name': module.params.get('name'),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/global/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#backendBucket')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-class BackendBucketCdnpolicy(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'signedUrlCacheMaxAgeSec': self.request.get('signed_url_cache_max_age_sec')})
-
- def from_response(self):
- return remove_nones_from_dict({u'signedUrlCacheMaxAgeSec': self.request.get(u'signedUrlCacheMaxAgeSec')})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_backend_bucket_info.py b/lib/ansible/modules/cloud/google/gcp_compute_backend_bucket_info.py
deleted file mode 100644
index 7b1e2fa406..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_backend_bucket_info.py
+++ /dev/null
@@ -1,240 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_backend_bucket_info
-description:
-- Gather info for GCP BackendBucket
-short_description: Gather info for GCP BackendBucket
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a backend bucket
- gcp_compute_backend_bucket_info:
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- bucketName:
- description:
- - Cloud Storage bucket name.
- returned: success
- type: str
- cdnPolicy:
- description:
- - Cloud CDN configuration for this Backend Bucket.
- returned: success
- type: complex
- contains:
- signedUrlCacheMaxAgeSec:
- description:
- - Maximum number of seconds the response to a signed URL request will be
- considered fresh. Defaults to 1hr (3600s). After this time period, the
- response will be revalidated before being served.
- - 'When serving responses to signed URL requests, Cloud CDN will internally
- behave as though all responses from this backend had a "Cache-Control:
- public, max-age=[TTL]" header, regardless of any existing Cache-Control
- header. The actual headers served in responses will not be altered.'
- returned: success
- type: int
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- description:
- description:
- - An optional textual description of the resource; provided by the client when
- the resource is created.
- returned: success
- type: str
- enableCdn:
- description:
- - If true, enable Cloud CDN for this BackendBucket.
- returned: success
- type: bool
- id:
- description:
- - Unique identifier for the resource.
- returned: success
- type: int
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created.
- The name must be 1-63 characters long, and comply with RFC1035. Specifically,
- the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/backendBuckets".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_backend_service.py b/lib/ansible/modules/cloud/google/gcp_compute_backend_service.py
deleted file mode 100644
index 020785d1e5..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_backend_service.py
+++ /dev/null
@@ -1,1143 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_backend_service
-description:
-- A Backend Service defines a group of virtual machines that will serve traffic for
- load balancing. This resource is a global backend service, appropriate for external
- load balancing or self-managed internal load balancing.
-- For managed internal load balancing, use a regional backend service instead.
-- Currently self-managed internal load balancing is only available in beta.
-short_description: Creates a GCP BackendService
-version_added: '2.6'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- affinity_cookie_ttl_sec:
- description:
- - Lifetime of cookies in seconds if session_affinity is GENERATED_COOKIE. If set
- to 0, the cookie is non-persistent and lasts only until the end of the browser
- session (or equivalent). The maximum allowed value for TTL is one day.
- - When the load balancing scheme is INTERNAL, this field is not used.
- required: false
- type: int
- backends:
- description:
- - The set of backends that serve this BackendService.
- required: false
- type: list
- suboptions:
- balancing_mode:
- description:
- - Specifies the balancing mode for this backend.
- - For global HTTP(S) or TCP/SSL load balancing, the default is UTILIZATION.
- Valid values are UTILIZATION, RATE (for HTTP(S)) and CONNECTION (for TCP/SSL).
- - 'Some valid choices include: "UTILIZATION", "RATE", "CONNECTION"'
- required: false
- default: UTILIZATION
- type: str
- capacity_scaler:
- description:
- - A multiplier applied to the group's maximum servicing capacity (based on
- UTILIZATION, RATE or CONNECTION).
- - Default value is 1, which means the group will serve up to 100% of its configured
- capacity (depending on balancingMode). A setting of 0 means the group is
- completely drained, offering 0% of its available Capacity. Valid range is
- [0.0,1.0].
- required: false
- default: '1.0'
- type: str
- description:
- description:
- - An optional description of this resource.
- - Provide this property when you create the resource.
- required: false
- type: str
- group:
- description:
- - The fully-qualified URL of an Instance Group or Network Endpoint Group resource.
- In case of instance group this defines the list of instances that serve
- traffic. Member virtual machine instances from each instance group must
- live in the same zone as the instance group itself. No two backends in a
- backend service are allowed to use same Instance Group resource.
- - For Network Endpoint Groups this defines list of endpoints. All endpoints
- of Network Endpoint Group must be hosted on instances located in the same
- zone as the Network Endpoint Group.
- - Backend services cannot mix Instance Group and Network Endpoint Group backends.
- - Note that you must specify an Instance Group or Network Endpoint Group resource
- using the fully-qualified URL, rather than a partial URL.
- required: false
- type: str
- max_connections:
- description:
- - The max number of simultaneous connections for the group. Can be used with
- either CONNECTION or UTILIZATION balancing modes.
- - For CONNECTION mode, either maxConnections or one of maxConnectionsPerInstance
- or maxConnectionsPerEndpoint, as appropriate for group type, must be set.
- required: false
- type: int
- max_connections_per_instance:
- description:
- - The max number of simultaneous connections that a single backend instance
- can handle. This is used to calculate the capacity of the group. Can be
- used in either CONNECTION or UTILIZATION balancing modes.
- - For CONNECTION mode, either maxConnections or maxConnectionsPerInstance
- must be set.
- required: false
- type: int
- max_connections_per_endpoint:
- description:
- - The max number of simultaneous connections that a single backend network
- endpoint can handle. This is used to calculate the capacity of the group.
- Can be used in either CONNECTION or UTILIZATION balancing modes.
- - For CONNECTION mode, either maxConnections or maxConnectionsPerEndpoint
- must be set.
- required: false
- type: int
- version_added: '2.9'
- max_rate:
- description:
- - The max requests per second (RPS) of the group.
- - Can be used with either RATE or UTILIZATION balancing modes, but required
- if RATE mode. For RATE mode, either maxRate or one of maxRatePerInstance
- or maxRatePerEndpoint, as appropriate for group type, must be set.
- required: false
- type: int
- max_rate_per_instance:
- description:
- - The max requests per second (RPS) that a single backend instance can handle.
- This is used to calculate the capacity of the group. Can be used in either
- balancing mode. For RATE mode, either maxRate or maxRatePerInstance must
- be set.
- required: false
- type: str
- max_rate_per_endpoint:
- description:
- - The max requests per second (RPS) that a single backend network endpoint
- can handle. This is used to calculate the capacity of the group. Can be
- used in either balancing mode. For RATE mode, either maxRate or maxRatePerEndpoint
- must be set.
- required: false
- type: str
- version_added: '2.9'
- max_utilization:
- description:
- - Used when balancingMode is UTILIZATION. This ratio defines the CPU utilization
- target for the group. The default is 0.8. Valid range is [0.0, 1.0].
- required: false
- default: '0.8'
- type: str
- cdn_policy:
- description:
- - Cloud CDN configuration for this BackendService.
- required: false
- type: dict
- suboptions:
- cache_key_policy:
- description:
- - The CacheKeyPolicy for this CdnPolicy.
- required: false
- type: dict
- suboptions:
- include_host:
- description:
- - If true requests to different hosts will be cached separately.
- required: false
- type: bool
- include_protocol:
- description:
- - If true, http and https requests will be cached separately.
- required: false
- type: bool
- include_query_string:
- description:
- - If true, include query string parameters in the cache key according
- to query_string_whitelist and query_string_blacklist. If neither is
- set, the entire query string will be included.
- - If false, the query string will be excluded from the cache key entirely.
- required: false
- type: bool
- query_string_blacklist:
- description:
- - Names of query string parameters to exclude in cache keys.
- - All other parameters will be included. Either specify query_string_whitelist
- or query_string_blacklist, not both.
- - "'&' and '=' will be percent encoded and not treated as delimiters."
- required: false
- type: list
- query_string_whitelist:
- description:
- - Names of query string parameters to include in cache keys.
- - All other parameters will be excluded. Either specify query_string_whitelist
- or query_string_blacklist, not both.
- - "'&' and '=' will be percent encoded and not treated as delimiters."
- required: false
- type: list
- signed_url_cache_max_age_sec:
- description:
- - Maximum number of seconds the response to a signed URL request will be considered
- fresh, defaults to 1hr (3600s). After this time period, the response will
- be revalidated before being served.
- - 'When serving responses to signed URL requests, Cloud CDN will internally
- behave as though all responses from this backend had a "Cache-Control: public,
- max-age=[TTL]" header, regardless of any existing Cache-Control header.
- The actual headers served in responses will not be altered.'
- required: false
- default: '3600'
- type: int
- version_added: '2.8'
- connection_draining:
- description:
- - Settings for connection draining .
- required: false
- type: dict
- suboptions:
- draining_timeout_sec:
- description:
- - Time for which instance will be drained (not accept new connections, but
- still work to finish started).
- required: false
- default: '300'
- type: int
- description:
- description:
- - An optional description of this resource.
- required: false
- type: str
- enable_cdn:
- description:
- - If true, enable Cloud CDN for this BackendService.
- required: false
- type: bool
- health_checks:
- description:
- - The set of URLs to the HttpHealthCheck or HttpsHealthCheck resource for health
- checking this BackendService. Currently at most one health check can be specified,
- and a health check is required.
- - For internal load balancing, a URL to a HealthCheck resource must be specified
- instead.
- required: true
- type: list
- iap:
- description:
- - Settings for enabling Cloud Identity Aware Proxy.
- required: false
- type: dict
- version_added: '2.7'
- suboptions:
- enabled:
- description:
- - Enables IAP.
- required: false
- type: bool
- oauth2_client_id:
- description:
- - OAuth2 Client ID for IAP .
- required: true
- type: str
- oauth2_client_secret:
- description:
- - OAuth2 Client Secret for IAP .
- required: true
- type: str
- load_balancing_scheme:
- description:
- - Indicates whether the backend service will be used with internal or external
- load balancing. A backend service created for one type of load balancing cannot
- be used with the other. Must be `EXTERNAL` or `INTERNAL_SELF_MANAGED` for a
- global backend service. Defaults to `EXTERNAL`.
- - 'Some valid choices include: "EXTERNAL", "INTERNAL_SELF_MANAGED"'
- required: false
- default: EXTERNAL
- type: str
- version_added: '2.7'
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- required: true
- type: str
- port_name:
- description:
- - Name of backend port. The same name should appear in the instance groups referenced
- by this service. Required when the load balancing scheme is EXTERNAL.
- required: false
- type: str
- protocol:
- description:
- - The protocol this BackendService uses to communicate with backends.
- - 'Possible values are HTTP, HTTPS, HTTP2, TCP, and SSL. The default is HTTP.
- **NOTE**: HTTP2 is only valid for beta HTTP/2 load balancer types and may result
- in errors if used with the GA API.'
- - 'Some valid choices include: "HTTP", "HTTPS", "HTTP2", "TCP", "SSL"'
- required: false
- type: str
- security_policy:
- description:
- - The security policy associated with this backend service.
- required: false
- type: str
- version_added: '2.8'
- session_affinity:
- description:
- - Type of session affinity to use. The default is NONE. Session affinity is not
- applicable if the protocol is UDP.
- - 'Some valid choices include: "NONE", "CLIENT_IP", "CLIENT_IP_PORT_PROTO", "CLIENT_IP_PROTO",
- "GENERATED_COOKIE", "HEADER_FIELD", "HTTP_COOKIE"'
- required: false
- type: str
- timeout_sec:
- description:
- - How many seconds to wait for the backend before considering it a failed request.
- Default is 30 seconds. Valid range is [1, 86400].
- required: false
- type: int
- aliases:
- - timeout_seconds
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/compute/docs/reference/v1/backendServices)'
-- 'Official Documentation: U(https://cloud.google.com/compute/docs/load-balancing/http/backend-service)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a instance group
- gcp_compute_instance_group:
- name: instancegroup-backendservice
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: instancegroup
-
-- name: create a HTTP health check
- gcp_compute_http_health_check:
- name: httphealthcheck-backendservice
- healthy_threshold: 10
- port: 8080
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: healthcheck
-
-- name: create a backend service
- gcp_compute_backend_service:
- name: test_object
- backends:
- - group: "{{ instancegroup.selfLink }}"
- health_checks:
- - "{{ healthcheck.selfLink }}"
- enable_cdn: 'true'
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-affinityCookieTtlSec:
- description:
- - Lifetime of cookies in seconds if session_affinity is GENERATED_COOKIE. If set
- to 0, the cookie is non-persistent and lasts only until the end of the browser
- session (or equivalent). The maximum allowed value for TTL is one day.
- - When the load balancing scheme is INTERNAL, this field is not used.
- returned: success
- type: int
-backends:
- description:
- - The set of backends that serve this BackendService.
- returned: success
- type: complex
- contains:
- balancingMode:
- description:
- - Specifies the balancing mode for this backend.
- - For global HTTP(S) or TCP/SSL load balancing, the default is UTILIZATION.
- Valid values are UTILIZATION, RATE (for HTTP(S)) and CONNECTION (for TCP/SSL).
- returned: success
- type: str
- capacityScaler:
- description:
- - A multiplier applied to the group's maximum servicing capacity (based on UTILIZATION,
- RATE or CONNECTION).
- - Default value is 1, which means the group will serve up to 100% of its configured
- capacity (depending on balancingMode). A setting of 0 means the group is completely
- drained, offering 0% of its available Capacity. Valid range is [0.0,1.0].
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource.
- - Provide this property when you create the resource.
- returned: success
- type: str
- group:
- description:
- - The fully-qualified URL of an Instance Group or Network Endpoint Group resource.
- In case of instance group this defines the list of instances that serve traffic.
- Member virtual machine instances from each instance group must live in the
- same zone as the instance group itself. No two backends in a backend service
- are allowed to use same Instance Group resource.
- - For Network Endpoint Groups this defines list of endpoints. All endpoints
- of Network Endpoint Group must be hosted on instances located in the same
- zone as the Network Endpoint Group.
- - Backend services cannot mix Instance Group and Network Endpoint Group backends.
- - Note that you must specify an Instance Group or Network Endpoint Group resource
- using the fully-qualified URL, rather than a partial URL.
- returned: success
- type: str
- maxConnections:
- description:
- - The max number of simultaneous connections for the group. Can be used with
- either CONNECTION or UTILIZATION balancing modes.
- - For CONNECTION mode, either maxConnections or one of maxConnectionsPerInstance
- or maxConnectionsPerEndpoint, as appropriate for group type, must be set.
- returned: success
- type: int
- maxConnectionsPerInstance:
- description:
- - The max number of simultaneous connections that a single backend instance
- can handle. This is used to calculate the capacity of the group. Can be used
- in either CONNECTION or UTILIZATION balancing modes.
- - For CONNECTION mode, either maxConnections or maxConnectionsPerInstance must
- be set.
- returned: success
- type: int
- maxConnectionsPerEndpoint:
- description:
- - The max number of simultaneous connections that a single backend network endpoint
- can handle. This is used to calculate the capacity of the group. Can be used
- in either CONNECTION or UTILIZATION balancing modes.
- - For CONNECTION mode, either maxConnections or maxConnectionsPerEndpoint must
- be set.
- returned: success
- type: int
- maxRate:
- description:
- - The max requests per second (RPS) of the group.
- - Can be used with either RATE or UTILIZATION balancing modes, but required
- if RATE mode. For RATE mode, either maxRate or one of maxRatePerInstance or
- maxRatePerEndpoint, as appropriate for group type, must be set.
- returned: success
- type: int
- maxRatePerInstance:
- description:
- - The max requests per second (RPS) that a single backend instance can handle.
- This is used to calculate the capacity of the group. Can be used in either
- balancing mode. For RATE mode, either maxRate or maxRatePerInstance must be
- set.
- returned: success
- type: str
- maxRatePerEndpoint:
- description:
- - The max requests per second (RPS) that a single backend network endpoint can
- handle. This is used to calculate the capacity of the group. Can be used in
- either balancing mode. For RATE mode, either maxRate or maxRatePerEndpoint
- must be set.
- returned: success
- type: str
- maxUtilization:
- description:
- - Used when balancingMode is UTILIZATION. This ratio defines the CPU utilization
- target for the group. The default is 0.8. Valid range is [0.0, 1.0].
- returned: success
- type: str
-cdnPolicy:
- description:
- - Cloud CDN configuration for this BackendService.
- returned: success
- type: complex
- contains:
- cacheKeyPolicy:
- description:
- - The CacheKeyPolicy for this CdnPolicy.
- returned: success
- type: complex
- contains:
- includeHost:
- description:
- - If true requests to different hosts will be cached separately.
- returned: success
- type: bool
- includeProtocol:
- description:
- - If true, http and https requests will be cached separately.
- returned: success
- type: bool
- includeQueryString:
- description:
- - If true, include query string parameters in the cache key according to
- query_string_whitelist and query_string_blacklist. If neither is set,
- the entire query string will be included.
- - If false, the query string will be excluded from the cache key entirely.
- returned: success
- type: bool
- queryStringBlacklist:
- description:
- - Names of query string parameters to exclude in cache keys.
- - All other parameters will be included. Either specify query_string_whitelist
- or query_string_blacklist, not both.
- - "'&' and '=' will be percent encoded and not treated as delimiters."
- returned: success
- type: list
- queryStringWhitelist:
- description:
- - Names of query string parameters to include in cache keys.
- - All other parameters will be excluded. Either specify query_string_whitelist
- or query_string_blacklist, not both.
- - "'&' and '=' will be percent encoded and not treated as delimiters."
- returned: success
- type: list
- signedUrlCacheMaxAgeSec:
- description:
- - Maximum number of seconds the response to a signed URL request will be considered
- fresh, defaults to 1hr (3600s). After this time period, the response will
- be revalidated before being served.
- - 'When serving responses to signed URL requests, Cloud CDN will internally
- behave as though all responses from this backend had a "Cache-Control: public,
- max-age=[TTL]" header, regardless of any existing Cache-Control header. The
- actual headers served in responses will not be altered.'
- returned: success
- type: int
-connectionDraining:
- description:
- - Settings for connection draining .
- returned: success
- type: complex
- contains:
- drainingTimeoutSec:
- description:
- - Time for which instance will be drained (not accept new connections, but still
- work to finish started).
- returned: success
- type: int
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-fingerprint:
- description:
- - Fingerprint of this resource. A hash of the contents stored in this object. This
- field is used in optimistic locking.
- returned: success
- type: str
-description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
-enableCDN:
- description:
- - If true, enable Cloud CDN for this BackendService.
- returned: success
- type: bool
-healthChecks:
- description:
- - The set of URLs to the HttpHealthCheck or HttpsHealthCheck resource for health
- checking this BackendService. Currently at most one health check can be specified,
- and a health check is required.
- - For internal load balancing, a URL to a HealthCheck resource must be specified
- instead.
- returned: success
- type: list
-id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
-iap:
- description:
- - Settings for enabling Cloud Identity Aware Proxy.
- returned: success
- type: complex
- contains:
- enabled:
- description:
- - Enables IAP.
- returned: success
- type: bool
- oauth2ClientId:
- description:
- - OAuth2 Client ID for IAP .
- returned: success
- type: str
- oauth2ClientSecret:
- description:
- - OAuth2 Client Secret for IAP .
- returned: success
- type: str
- oauth2ClientSecretSha256:
- description:
- - OAuth2 Client Secret SHA-256 for IAP .
- returned: success
- type: str
-loadBalancingScheme:
- description:
- - Indicates whether the backend service will be used with internal or external load
- balancing. A backend service created for one type of load balancing cannot be
- used with the other. Must be `EXTERNAL` or `INTERNAL_SELF_MANAGED` for a global
- backend service. Defaults to `EXTERNAL`.
- returned: success
- type: str
-name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
-portName:
- description:
- - Name of backend port. The same name should appear in the instance groups referenced
- by this service. Required when the load balancing scheme is EXTERNAL.
- returned: success
- type: str
-protocol:
- description:
- - The protocol this BackendService uses to communicate with backends.
- - 'Possible values are HTTP, HTTPS, HTTP2, TCP, and SSL. The default is HTTP. **NOTE**:
- HTTP2 is only valid for beta HTTP/2 load balancer types and may result in errors
- if used with the GA API.'
- returned: success
- type: str
-securityPolicy:
- description:
- - The security policy associated with this backend service.
- returned: success
- type: str
-sessionAffinity:
- description:
- - Type of session affinity to use. The default is NONE. Session affinity is not
- applicable if the protocol is UDP.
- returned: success
- type: str
-timeoutSec:
- description:
- - How many seconds to wait for the backend before considering it a failed request.
- Default is 30 seconds. Valid range is [1, 86400].
- returned: success
- type: int
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- affinity_cookie_ttl_sec=dict(type='int'),
- backends=dict(
- type='list',
- elements='dict',
- options=dict(
- balancing_mode=dict(default='UTILIZATION', type='str'),
- capacity_scaler=dict(default=1.0, type='str'),
- description=dict(type='str'),
- group=dict(type='str'),
- max_connections=dict(type='int'),
- max_connections_per_instance=dict(type='int'),
- max_connections_per_endpoint=dict(type='int'),
- max_rate=dict(type='int'),
- max_rate_per_instance=dict(type='str'),
- max_rate_per_endpoint=dict(type='str'),
- max_utilization=dict(default=0.8, type='str'),
- ),
- ),
- cdn_policy=dict(
- type='dict',
- options=dict(
- cache_key_policy=dict(
- type='dict',
- options=dict(
- include_host=dict(type='bool'),
- include_protocol=dict(type='bool'),
- include_query_string=dict(type='bool'),
- query_string_blacklist=dict(type='list', elements='str'),
- query_string_whitelist=dict(type='list', elements='str'),
- ),
- ),
- signed_url_cache_max_age_sec=dict(default=3600, type='int'),
- ),
- ),
- connection_draining=dict(type='dict', options=dict(draining_timeout_sec=dict(default=300, type='int'))),
- description=dict(type='str'),
- enable_cdn=dict(type='bool'),
- health_checks=dict(required=True, type='list', elements='str'),
- iap=dict(
- type='dict',
- options=dict(enabled=dict(type='bool'), oauth2_client_id=dict(required=True, type='str'), oauth2_client_secret=dict(required=True, type='str')),
- ),
- load_balancing_scheme=dict(default='EXTERNAL', type='str'),
- name=dict(required=True, type='str'),
- port_name=dict(type='str'),
- protocol=dict(type='str'),
- security_policy=dict(type='str'),
- session_affinity=dict(type='str'),
- timeout_sec=dict(type='int', aliases=['timeout_seconds']),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#backendService'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind, fetch)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind, fetch):
- update_fields(module, resource_to_request(module), response_to_hash(module, fetch))
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.put(link, resource_to_request(module)))
-
-
-def update_fields(module, request, response):
- if response.get('securityPolicy') != request.get('securityPolicy'):
- security_policy_update(module, request, response)
-
-
-def security_policy_update(module, request, response):
- auth = GcpSession(module, 'compute')
- auth.post(
- ''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/global/backendServices/{name}/setSecurityPolicy"]).format(**module.params),
- {u'securityPolicy': module.params.get('security_policy')},
- )
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#backendService',
- u'affinityCookieTtlSec': module.params.get('affinity_cookie_ttl_sec'),
- u'backends': BackendServiceBackendsArray(module.params.get('backends', []), module).to_request(),
- u'cdnPolicy': BackendServiceCdnpolicy(module.params.get('cdn_policy', {}), module).to_request(),
- u'connectionDraining': BackendServiceConnectiondraining(module.params.get('connection_draining', {}), module).to_request(),
- u'description': module.params.get('description'),
- u'enableCDN': module.params.get('enable_cdn'),
- u'healthChecks': module.params.get('health_checks'),
- u'iap': BackendServiceIap(module.params.get('iap', {}), module).to_request(),
- u'loadBalancingScheme': module.params.get('load_balancing_scheme'),
- u'name': module.params.get('name'),
- u'portName': module.params.get('port_name'),
- u'protocol': module.params.get('protocol'),
- u'securityPolicy': module.params.get('security_policy'),
- u'sessionAffinity': module.params.get('session_affinity'),
- u'timeoutSec': module.params.get('timeout_sec'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/backendServices/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/backendServices".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'affinityCookieTtlSec': response.get(u'affinityCookieTtlSec'),
- u'backends': BackendServiceBackendsArray(response.get(u'backends', []), module).from_response(),
- u'cdnPolicy': BackendServiceCdnpolicy(response.get(u'cdnPolicy', {}), module).from_response(),
- u'connectionDraining': BackendServiceConnectiondraining(response.get(u'connectionDraining', {}), module).from_response(),
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'fingerprint': response.get(u'fingerprint'),
- u'description': response.get(u'description'),
- u'enableCDN': response.get(u'enableCDN'),
- u'healthChecks': response.get(u'healthChecks'),
- u'id': response.get(u'id'),
- u'iap': BackendServiceIap(response.get(u'iap', {}), module).from_response(),
- u'loadBalancingScheme': module.params.get('load_balancing_scheme'),
- u'name': module.params.get('name'),
- u'portName': response.get(u'portName'),
- u'protocol': response.get(u'protocol'),
- u'securityPolicy': response.get(u'securityPolicy'),
- u'sessionAffinity': response.get(u'sessionAffinity'),
- u'timeoutSec': response.get(u'timeoutSec'),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/global/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#backendService')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-class BackendServiceBackendsArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict(
- {
- u'balancingMode': item.get('balancing_mode'),
- u'capacityScaler': item.get('capacity_scaler'),
- u'description': item.get('description'),
- u'group': item.get('group'),
- u'maxConnections': item.get('max_connections'),
- u'maxConnectionsPerInstance': item.get('max_connections_per_instance'),
- u'maxConnectionsPerEndpoint': item.get('max_connections_per_endpoint'),
- u'maxRate': item.get('max_rate'),
- u'maxRatePerInstance': item.get('max_rate_per_instance'),
- u'maxRatePerEndpoint': item.get('max_rate_per_endpoint'),
- u'maxUtilization': item.get('max_utilization'),
- }
- )
-
- def _response_from_item(self, item):
- return remove_nones_from_dict(
- {
- u'balancingMode': item.get(u'balancingMode'),
- u'capacityScaler': item.get(u'capacityScaler'),
- u'description': item.get(u'description'),
- u'group': item.get(u'group'),
- u'maxConnections': item.get(u'maxConnections'),
- u'maxConnectionsPerInstance': item.get(u'maxConnectionsPerInstance'),
- u'maxConnectionsPerEndpoint': item.get(u'maxConnectionsPerEndpoint'),
- u'maxRate': item.get(u'maxRate'),
- u'maxRatePerInstance': item.get(u'maxRatePerInstance'),
- u'maxRatePerEndpoint': item.get(u'maxRatePerEndpoint'),
- u'maxUtilization': item.get(u'maxUtilization'),
- }
- )
-
-
-class BackendServiceCdnpolicy(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'cacheKeyPolicy': BackendServiceCachekeypolicy(self.request.get('cache_key_policy', {}), self.module).to_request(),
- u'signedUrlCacheMaxAgeSec': self.request.get('signed_url_cache_max_age_sec'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'cacheKeyPolicy': BackendServiceCachekeypolicy(self.request.get(u'cacheKeyPolicy', {}), self.module).from_response(),
- u'signedUrlCacheMaxAgeSec': self.request.get(u'signedUrlCacheMaxAgeSec'),
- }
- )
-
-
-class BackendServiceCachekeypolicy(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'includeHost': self.request.get('include_host'),
- u'includeProtocol': self.request.get('include_protocol'),
- u'includeQueryString': self.request.get('include_query_string'),
- u'queryStringBlacklist': self.request.get('query_string_blacklist'),
- u'queryStringWhitelist': self.request.get('query_string_whitelist'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'includeHost': self.request.get(u'includeHost'),
- u'includeProtocol': self.request.get(u'includeProtocol'),
- u'includeQueryString': self.request.get(u'includeQueryString'),
- u'queryStringBlacklist': self.request.get(u'queryStringBlacklist'),
- u'queryStringWhitelist': self.request.get(u'queryStringWhitelist'),
- }
- )
-
-
-class BackendServiceConnectiondraining(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'drainingTimeoutSec': self.request.get('draining_timeout_sec')})
-
- def from_response(self):
- return remove_nones_from_dict({u'drainingTimeoutSec': self.request.get(u'drainingTimeoutSec')})
-
-
-class BackendServiceIap(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'enabled': self.request.get('enabled'),
- u'oauth2ClientId': self.request.get('oauth2_client_id'),
- u'oauth2ClientSecret': self.request.get('oauth2_client_secret'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'enabled': self.request.get(u'enabled'),
- u'oauth2ClientId': self.request.get(u'oauth2ClientId'),
- u'oauth2ClientSecret': self.request.get(u'oauth2ClientSecret'),
- }
- )
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_backend_service_info.py b/lib/ansible/modules/cloud/google/gcp_compute_backend_service_info.py
deleted file mode 100644
index 382719499d..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_backend_service_info.py
+++ /dev/null
@@ -1,476 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_backend_service_info
-description:
-- Gather info for GCP BackendService
-short_description: Gather info for GCP BackendService
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a backend service
- gcp_compute_backend_service_info:
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- affinityCookieTtlSec:
- description:
- - Lifetime of cookies in seconds if session_affinity is GENERATED_COOKIE. If
- set to 0, the cookie is non-persistent and lasts only until the end of the
- browser session (or equivalent). The maximum allowed value for TTL is one
- day.
- - When the load balancing scheme is INTERNAL, this field is not used.
- returned: success
- type: int
- backends:
- description:
- - The set of backends that serve this BackendService.
- returned: success
- type: complex
- contains:
- balancingMode:
- description:
- - Specifies the balancing mode for this backend.
- - For global HTTP(S) or TCP/SSL load balancing, the default is UTILIZATION.
- Valid values are UTILIZATION, RATE (for HTTP(S)) and CONNECTION (for TCP/SSL).
- returned: success
- type: str
- capacityScaler:
- description:
- - A multiplier applied to the group's maximum servicing capacity (based
- on UTILIZATION, RATE or CONNECTION).
- - Default value is 1, which means the group will serve up to 100% of its
- configured capacity (depending on balancingMode). A setting of 0 means
- the group is completely drained, offering 0% of its available Capacity.
- Valid range is [0.0,1.0].
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource.
- - Provide this property when you create the resource.
- returned: success
- type: str
- group:
- description:
- - The fully-qualified URL of an Instance Group or Network Endpoint Group
- resource. In case of instance group this defines the list of instances
- that serve traffic. Member virtual machine instances from each instance
- group must live in the same zone as the instance group itself. No two
- backends in a backend service are allowed to use same Instance Group resource.
- - For Network Endpoint Groups this defines list of endpoints. All endpoints
- of Network Endpoint Group must be hosted on instances located in the same
- zone as the Network Endpoint Group.
- - Backend services cannot mix Instance Group and Network Endpoint Group
- backends.
- - Note that you must specify an Instance Group or Network Endpoint Group
- resource using the fully-qualified URL, rather than a partial URL.
- returned: success
- type: str
- maxConnections:
- description:
- - The max number of simultaneous connections for the group. Can be used
- with either CONNECTION or UTILIZATION balancing modes.
- - For CONNECTION mode, either maxConnections or one of maxConnectionsPerInstance
- or maxConnectionsPerEndpoint, as appropriate for group type, must be set.
- returned: success
- type: int
- maxConnectionsPerInstance:
- description:
- - The max number of simultaneous connections that a single backend instance
- can handle. This is used to calculate the capacity of the group. Can be
- used in either CONNECTION or UTILIZATION balancing modes.
- - For CONNECTION mode, either maxConnections or maxConnectionsPerInstance
- must be set.
- returned: success
- type: int
- maxConnectionsPerEndpoint:
- description:
- - The max number of simultaneous connections that a single backend network
- endpoint can handle. This is used to calculate the capacity of the group.
- Can be used in either CONNECTION or UTILIZATION balancing modes.
- - For CONNECTION mode, either maxConnections or maxConnectionsPerEndpoint
- must be set.
- returned: success
- type: int
- maxRate:
- description:
- - The max requests per second (RPS) of the group.
- - Can be used with either RATE or UTILIZATION balancing modes, but required
- if RATE mode. For RATE mode, either maxRate or one of maxRatePerInstance
- or maxRatePerEndpoint, as appropriate for group type, must be set.
- returned: success
- type: int
- maxRatePerInstance:
- description:
- - The max requests per second (RPS) that a single backend instance can handle.
- This is used to calculate the capacity of the group. Can be used in either
- balancing mode. For RATE mode, either maxRate or maxRatePerInstance must
- be set.
- returned: success
- type: str
- maxRatePerEndpoint:
- description:
- - The max requests per second (RPS) that a single backend network endpoint
- can handle. This is used to calculate the capacity of the group. Can be
- used in either balancing mode. For RATE mode, either maxRate or maxRatePerEndpoint
- must be set.
- returned: success
- type: str
- maxUtilization:
- description:
- - Used when balancingMode is UTILIZATION. This ratio defines the CPU utilization
- target for the group. The default is 0.8. Valid range is [0.0, 1.0].
- returned: success
- type: str
- cdnPolicy:
- description:
- - Cloud CDN configuration for this BackendService.
- returned: success
- type: complex
- contains:
- cacheKeyPolicy:
- description:
- - The CacheKeyPolicy for this CdnPolicy.
- returned: success
- type: complex
- contains:
- includeHost:
- description:
- - If true requests to different hosts will be cached separately.
- returned: success
- type: bool
- includeProtocol:
- description:
- - If true, http and https requests will be cached separately.
- returned: success
- type: bool
- includeQueryString:
- description:
- - If true, include query string parameters in the cache key according
- to query_string_whitelist and query_string_blacklist. If neither is
- set, the entire query string will be included.
- - If false, the query string will be excluded from the cache key entirely.
- returned: success
- type: bool
- queryStringBlacklist:
- description:
- - Names of query string parameters to exclude in cache keys.
- - All other parameters will be included. Either specify query_string_whitelist
- or query_string_blacklist, not both.
- - "'&' and '=' will be percent encoded and not treated as delimiters."
- returned: success
- type: list
- queryStringWhitelist:
- description:
- - Names of query string parameters to include in cache keys.
- - All other parameters will be excluded. Either specify query_string_whitelist
- or query_string_blacklist, not both.
- - "'&' and '=' will be percent encoded and not treated as delimiters."
- returned: success
- type: list
- signedUrlCacheMaxAgeSec:
- description:
- - Maximum number of seconds the response to a signed URL request will be
- considered fresh, defaults to 1hr (3600s). After this time period, the
- response will be revalidated before being served.
- - 'When serving responses to signed URL requests, Cloud CDN will internally
- behave as though all responses from this backend had a "Cache-Control:
- public, max-age=[TTL]" header, regardless of any existing Cache-Control
- header. The actual headers served in responses will not be altered.'
- returned: success
- type: int
- connectionDraining:
- description:
- - Settings for connection draining .
- returned: success
- type: complex
- contains:
- drainingTimeoutSec:
- description:
- - Time for which instance will be drained (not accept new connections, but
- still work to finish started).
- returned: success
- type: int
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- fingerprint:
- description:
- - Fingerprint of this resource. A hash of the contents stored in this object.
- This field is used in optimistic locking.
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
- enableCDN:
- description:
- - If true, enable Cloud CDN for this BackendService.
- returned: success
- type: bool
- healthChecks:
- description:
- - The set of URLs to the HttpHealthCheck or HttpsHealthCheck resource for health
- checking this BackendService. Currently at most one health check can be specified,
- and a health check is required.
- - For internal load balancing, a URL to a HealthCheck resource must be specified
- instead.
- returned: success
- type: list
- id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
- iap:
- description:
- - Settings for enabling Cloud Identity Aware Proxy.
- returned: success
- type: complex
- contains:
- enabled:
- description:
- - Enables IAP.
- returned: success
- type: bool
- oauth2ClientId:
- description:
- - OAuth2 Client ID for IAP .
- returned: success
- type: str
- oauth2ClientSecret:
- description:
- - OAuth2 Client Secret for IAP .
- returned: success
- type: str
- oauth2ClientSecretSha256:
- description:
- - OAuth2 Client Secret SHA-256 for IAP .
- returned: success
- type: str
- loadBalancingScheme:
- description:
- - Indicates whether the backend service will be used with internal or external
- load balancing. A backend service created for one type of load balancing cannot
- be used with the other. Must be `EXTERNAL` or `INTERNAL_SELF_MANAGED` for
- a global backend service. Defaults to `EXTERNAL`.
- returned: success
- type: str
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created.
- The name must be 1-63 characters long, and comply with RFC1035. Specifically,
- the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
- portName:
- description:
- - Name of backend port. The same name should appear in the instance groups referenced
- by this service. Required when the load balancing scheme is EXTERNAL.
- returned: success
- type: str
- protocol:
- description:
- - The protocol this BackendService uses to communicate with backends.
- - 'Possible values are HTTP, HTTPS, HTTP2, TCP, and SSL. The default is HTTP.
- **NOTE**: HTTP2 is only valid for beta HTTP/2 load balancer types and may
- result in errors if used with the GA API.'
- returned: success
- type: str
- securityPolicy:
- description:
- - The security policy associated with this backend service.
- returned: success
- type: str
- sessionAffinity:
- description:
- - Type of session affinity to use. The default is NONE. Session affinity is
- not applicable if the protocol is UDP.
- returned: success
- type: str
- timeoutSec:
- description:
- - How many seconds to wait for the backend before considering it a failed request.
- Default is 30 seconds. Valid range is [1, 86400].
- returned: success
- type: int
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/backendServices".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_disk.py b/lib/ansible/modules/cloud/google/gcp_compute_disk.py
deleted file mode 100644
index 7e7bab8361..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_disk.py
+++ /dev/null
@@ -1,771 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_disk
-description:
-- Persistent disks are durable storage devices that function similarly to the physical
- disks in a desktop or a server. Compute Engine manages the hardware behind these
- devices to ensure data redundancy and optimize performance for you. Persistent disks
- are available as either standard hard disk drives (HDD) or solid-state drives (SSD).
-- Persistent disks are located independently from your virtual machine instances,
- so you can detach or move persistent disks to keep your data even after you delete
- your instances. Persistent disk performance scales automatically with size, so you
- can resize your existing persistent disks or add more persistent disks to an instance
- to meet your performance and storage space requirements.
-- Add a persistent disk to your instance when you need reliable and affordable storage
- with consistent performance characteristics.
-short_description: Creates a GCP Disk
-version_added: '2.6'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- required: false
- type: str
- labels:
- description:
- - Labels to apply to this disk. A list of key->value pairs.
- required: false
- type: dict
- version_added: '2.7'
- licenses:
- description:
- - Any applicable publicly visible licenses.
- required: false
- type: list
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- required: true
- type: str
- size_gb:
- description:
- - Size of the persistent disk, specified in GB. You can specify this field when
- creating a persistent disk using the sourceImage or sourceSnapshot parameter,
- or specify it alone to create an empty persistent disk.
- - If you specify this field along with sourceImage or sourceSnapshot, the value
- of sizeGb must not be less than the size of the sourceImage or the size of the
- snapshot.
- required: false
- type: int
- physical_block_size_bytes:
- description:
- - Physical block size of the persistent disk, in bytes. If not present in a request,
- a default value is used. Currently supported sizes are 4096 and 16384, other
- sizes may be added in the future.
- - If an unsupported value is requested, the error message will list the supported
- values for the caller's project.
- required: false
- type: int
- version_added: '2.8'
- type:
- description:
- - URL of the disk type resource describing which disk type to use to create the
- disk. Provide this when creating the disk.
- required: false
- type: str
- version_added: '2.7'
- source_image:
- description:
- - The source image used to create this disk. If the source image is deleted, this
- field will not be set.
- - 'To create a disk with one of the public operating system images, specify the
- image by its family name. For example, specify family/debian-8 to use the latest
- Debian 8 image: projects/debian-cloud/global/images/family/debian-8 Alternatively,
- use a specific version of a public operating system image: projects/debian-cloud/global/images/debian-8-jessie-vYYYYMMDD
- To create a disk with a private image that you created, specify the image name
- in the following format: global/images/my-private-image You can also specify
- a private image by its image family, which returns the latest version of the
- image in that family. Replace the image name with family/family-name: global/images/family/my-private-family
- .'
- required: false
- type: str
- zone:
- description:
- - A reference to the zone where the disk resides.
- required: true
- type: str
- source_image_encryption_key:
- description:
- - The customer-supplied encryption key of the source image. Required if the source
- image is protected by a customer-supplied encryption key.
- required: false
- type: dict
- suboptions:
- raw_key:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
- base64 to either encrypt or decrypt this resource.
- required: false
- type: str
- kms_key_name:
- description:
- - The name of the encryption key that is stored in Google Cloud KMS.
- required: false
- type: str
- disk_encryption_key:
- description:
- - Encrypts the disk using a customer-supplied encryption key.
- - After you encrypt a disk with a customer-supplied key, you must provide the
- same key if you use the disk later (e.g. to create a disk snapshot or an image,
- or to attach the disk to a virtual machine).
- - Customer-supplied encryption keys do not protect access to metadata of the disk.
- - If you do not provide an encryption key when creating the disk, then the disk
- will be encrypted using an automatically generated key and you do not need to
- provide a key to use the disk later.
- required: false
- type: dict
- suboptions:
- raw_key:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
- base64 to either encrypt or decrypt this resource.
- required: false
- type: str
- kms_key_name:
- description:
- - The name of the encryption key that is stored in Google Cloud KMS.
- required: false
- type: str
- source_snapshot:
- description:
- - The source snapshot used to create this disk. You can provide this as a partial
- or full URL to the resource.
- - 'This field represents a link to a Snapshot resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''selfLink'' and value
- of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
- to a gcp_compute_snapshot task and then set this source_snapshot field to "{{
- name-of-resource }}"'
- required: false
- type: dict
- source_snapshot_encryption_key:
- description:
- - The customer-supplied encryption key of the source snapshot. Required if the
- source snapshot is protected by a customer-supplied encryption key.
- required: false
- type: dict
- suboptions:
- raw_key:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
- base64 to either encrypt or decrypt this resource.
- required: false
- type: str
- kms_key_name:
- description:
- - The name of the encryption key that is stored in Google Cloud KMS.
- required: false
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/compute/docs/reference/v1/disks)'
-- 'Adding a persistent disk: U(https://cloud.google.com/compute/docs/disks/add-persistent-disk)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a disk
- gcp_compute_disk:
- name: test_object
- size_gb: 50
- disk_encryption_key:
- raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0=
- zone: us-central1-a
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-labelFingerprint:
- description:
- - The fingerprint used for optimistic locking of this resource. Used internally
- during updates.
- returned: success
- type: str
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- returned: success
- type: str
-id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
-lastAttachTimestamp:
- description:
- - Last attach timestamp in RFC3339 text format.
- returned: success
- type: str
-lastDetachTimestamp:
- description:
- - Last detach timestamp in RFC3339 text format.
- returned: success
- type: str
-labels:
- description:
- - Labels to apply to this disk. A list of key->value pairs.
- returned: success
- type: dict
-licenses:
- description:
- - Any applicable publicly visible licenses.
- returned: success
- type: list
-name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
-sizeGb:
- description:
- - Size of the persistent disk, specified in GB. You can specify this field when
- creating a persistent disk using the sourceImage or sourceSnapshot parameter,
- or specify it alone to create an empty persistent disk.
- - If you specify this field along with sourceImage or sourceSnapshot, the value
- of sizeGb must not be less than the size of the sourceImage or the size of the
- snapshot.
- returned: success
- type: int
-users:
- description:
- - 'Links to the users of the disk (attached instances) in form: project/zones/zone/instances/instance
- .'
- returned: success
- type: list
-physicalBlockSizeBytes:
- description:
- - Physical block size of the persistent disk, in bytes. If not present in a request,
- a default value is used. Currently supported sizes are 4096 and 16384, other sizes
- may be added in the future.
- - If an unsupported value is requested, the error message will list the supported
- values for the caller's project.
- returned: success
- type: int
-type:
- description:
- - URL of the disk type resource describing which disk type to use to create the
- disk. Provide this when creating the disk.
- returned: success
- type: str
-sourceImage:
- description:
- - The source image used to create this disk. If the source image is deleted, this
- field will not be set.
- - 'To create a disk with one of the public operating system images, specify the
- image by its family name. For example, specify family/debian-8 to use the latest
- Debian 8 image: projects/debian-cloud/global/images/family/debian-8 Alternatively,
- use a specific version of a public operating system image: projects/debian-cloud/global/images/debian-8-jessie-vYYYYMMDD
- To create a disk with a private image that you created, specify the image name
- in the following format: global/images/my-private-image You can also specify a
- private image by its image family, which returns the latest version of the image
- in that family. Replace the image name with family/family-name: global/images/family/my-private-family
- .'
- returned: success
- type: str
-zone:
- description:
- - A reference to the zone where the disk resides.
- returned: success
- type: str
-sourceImageEncryptionKey:
- description:
- - The customer-supplied encryption key of the source image. Required if the source
- image is protected by a customer-supplied encryption key.
- returned: success
- type: complex
- contains:
- rawKey:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
- base64 to either encrypt or decrypt this resource.
- returned: success
- type: str
- sha256:
- description:
- - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
- key that protects this resource.
- returned: success
- type: str
- kmsKeyName:
- description:
- - The name of the encryption key that is stored in Google Cloud KMS.
- returned: success
- type: str
-sourceImageId:
- description:
- - The ID value of the image used to create this disk. This value identifies the
- exact image that was used to create this persistent disk. For example, if you
- created the persistent disk from an image that was later deleted and recreated
- under the same name, the source image ID would identify the exact version of the
- image that was used.
- returned: success
- type: str
-diskEncryptionKey:
- description:
- - Encrypts the disk using a customer-supplied encryption key.
- - After you encrypt a disk with a customer-supplied key, you must provide the same
- key if you use the disk later (e.g. to create a disk snapshot or an image, or
- to attach the disk to a virtual machine).
- - Customer-supplied encryption keys do not protect access to metadata of the disk.
- - If you do not provide an encryption key when creating the disk, then the disk
- will be encrypted using an automatically generated key and you do not need to
- provide a key to use the disk later.
- returned: success
- type: complex
- contains:
- rawKey:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
- base64 to either encrypt or decrypt this resource.
- returned: success
- type: str
- sha256:
- description:
- - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
- key that protects this resource.
- returned: success
- type: str
- kmsKeyName:
- description:
- - The name of the encryption key that is stored in Google Cloud KMS.
- returned: success
- type: str
-sourceSnapshot:
- description:
- - The source snapshot used to create this disk. You can provide this as a partial
- or full URL to the resource.
- returned: success
- type: dict
-sourceSnapshotEncryptionKey:
- description:
- - The customer-supplied encryption key of the source snapshot. Required if the source
- snapshot is protected by a customer-supplied encryption key.
- returned: success
- type: complex
- contains:
- rawKey:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
- base64 to either encrypt or decrypt this resource.
- returned: success
- type: str
- kmsKeyName:
- description:
- - The name of the encryption key that is stored in Google Cloud KMS.
- returned: success
- type: str
- sha256:
- description:
- - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
- key that protects this resource.
- returned: success
- type: str
-sourceSnapshotId:
- description:
- - The unique ID of the snapshot used to create this disk. This value identifies
- the exact snapshot that was used to create this persistent disk. For example,
- if you created the persistent disk from a snapshot that was later deleted and
- recreated under the same name, the source snapshot ID would identify the exact
- version of the snapshot that was used.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import re
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- description=dict(type='str'),
- labels=dict(type='dict'),
- licenses=dict(type='list', elements='str'),
- name=dict(required=True, type='str'),
- size_gb=dict(type='int'),
- physical_block_size_bytes=dict(type='int'),
- type=dict(type='str'),
- source_image=dict(type='str'),
- zone=dict(required=True, type='str'),
- source_image_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), kms_key_name=dict(type='str'))),
- disk_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), kms_key_name=dict(type='str'))),
- source_snapshot=dict(type='dict'),
- source_snapshot_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), kms_key_name=dict(type='str'))),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#disk'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind, fetch)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind, fetch):
- update_fields(module, resource_to_request(module), response_to_hash(module, fetch))
- return fetch_resource(module, self_link(module), kind)
-
-
-def update_fields(module, request, response):
- if response.get('labels') != request.get('labels'):
- label_fingerprint_update(module, request, response)
- if response.get('sizeGb') != request.get('sizeGb'):
- size_gb_update(module, request, response)
-
-
-def label_fingerprint_update(module, request, response):
- auth = GcpSession(module, 'compute')
- auth.post(
- ''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/zones/{zone}/disks/{name}/setLabels"]).format(**module.params),
- {u'labelFingerprint': response.get('labelFingerprint'), u'labels': module.params.get('labels')},
- )
-
-
-def size_gb_update(module, request, response):
- auth = GcpSession(module, 'compute')
- auth.post(
- ''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/zones/{zone}/disks/{name}/resize"]).format(**module.params),
- {u'sizeGb': module.params.get('size_gb')},
- )
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#disk',
- u'sourceImageEncryptionKey': DiskSourceimageencryptionkey(module.params.get('source_image_encryption_key', {}), module).to_request(),
- u'diskEncryptionKey': DiskDiskencryptionkey(module.params.get('disk_encryption_key', {}), module).to_request(),
- u'sourceSnapshotEncryptionKey': DiskSourcesnapshotencryptionkey(module.params.get('source_snapshot_encryption_key', {}), module).to_request(),
- u'description': module.params.get('description'),
- u'labels': module.params.get('labels'),
- u'licenses': module.params.get('licenses'),
- u'name': module.params.get('name'),
- u'sizeGb': module.params.get('size_gb'),
- u'physicalBlockSizeBytes': module.params.get('physical_block_size_bytes'),
- u'type': disk_type_selflink(module.params.get('type'), module.params),
- u'sourceImage': module.params.get('source_image'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/disks/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/disks".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'labelFingerprint': response.get(u'labelFingerprint'),
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'description': response.get(u'description'),
- u'id': response.get(u'id'),
- u'lastAttachTimestamp': response.get(u'lastAttachTimestamp'),
- u'lastDetachTimestamp': response.get(u'lastDetachTimestamp'),
- u'labels': response.get(u'labels'),
- u'licenses': response.get(u'licenses'),
- u'name': module.params.get('name'),
- u'sizeGb': response.get(u'sizeGb'),
- u'users': response.get(u'users'),
- u'physicalBlockSizeBytes': response.get(u'physicalBlockSizeBytes'),
- u'type': response.get(u'type'),
- u'sourceImage': module.params.get('source_image'),
- }
-
-
-def disk_type_selflink(name, params):
- if name is None:
- return
- url = r"https://www.googleapis.com/compute/v1/projects/.*/zones/.*/diskTypes/.*"
- if not re.match(url, name):
- name = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/diskTypes/%s".format(**params) % name
- return name
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#disk')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-class DiskSourceimageencryptionkey(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'rawKey': self.request.get('raw_key'), u'kmsKeyName': self.request.get('kms_key_name')})
-
- def from_response(self):
- return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey'), u'kmsKeyName': self.request.get(u'kmsKeyName')})
-
-
-class DiskDiskencryptionkey(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'rawKey': self.request.get('raw_key'), u'kmsKeyName': self.request.get('kms_key_name')})
-
- def from_response(self):
- return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey'), u'kmsKeyName': self.request.get(u'kmsKeyName')})
-
-
-class DiskSourcesnapshotencryptionkey(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'rawKey': self.request.get('raw_key'), u'kmsKeyName': self.request.get('kms_key_name')})
-
- def from_response(self):
- return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey'), u'kmsKeyName': self.request.get(u'kmsKeyName')})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_disk_info.py b/lib/ansible/modules/cloud/google/gcp_compute_disk_info.py
deleted file mode 100644
index 07add3b2c8..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_disk_info.py
+++ /dev/null
@@ -1,402 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_disk_info
-description:
-- Gather info for GCP Disk
-short_description: Gather info for GCP Disk
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- zone:
- description:
- - A reference to the zone where the disk resides.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a disk
- gcp_compute_disk_info:
- zone: us-central1-a
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- labelFingerprint:
- description:
- - The fingerprint used for optimistic locking of this resource. Used internally
- during updates.
- returned: success
- type: str
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- returned: success
- type: str
- id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
- lastAttachTimestamp:
- description:
- - Last attach timestamp in RFC3339 text format.
- returned: success
- type: str
- lastDetachTimestamp:
- description:
- - Last detach timestamp in RFC3339 text format.
- returned: success
- type: str
- labels:
- description:
- - Labels to apply to this disk. A list of key->value pairs.
- returned: success
- type: dict
- licenses:
- description:
- - Any applicable publicly visible licenses.
- returned: success
- type: list
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created.
- The name must be 1-63 characters long, and comply with RFC1035. Specifically,
- the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
- sizeGb:
- description:
- - Size of the persistent disk, specified in GB. You can specify this field when
- creating a persistent disk using the sourceImage or sourceSnapshot parameter,
- or specify it alone to create an empty persistent disk.
- - If you specify this field along with sourceImage or sourceSnapshot, the value
- of sizeGb must not be less than the size of the sourceImage or the size of
- the snapshot.
- returned: success
- type: int
- users:
- description:
- - 'Links to the users of the disk (attached instances) in form: project/zones/zone/instances/instance
- .'
- returned: success
- type: list
- physicalBlockSizeBytes:
- description:
- - Physical block size of the persistent disk, in bytes. If not present in a
- request, a default value is used. Currently supported sizes are 4096 and 16384,
- other sizes may be added in the future.
- - If an unsupported value is requested, the error message will list the supported
- values for the caller's project.
- returned: success
- type: int
- type:
- description:
- - URL of the disk type resource describing which disk type to use to create
- the disk. Provide this when creating the disk.
- returned: success
- type: str
- sourceImage:
- description:
- - The source image used to create this disk. If the source image is deleted,
- this field will not be set.
- - 'To create a disk with one of the public operating system images, specify
- the image by its family name. For example, specify family/debian-8 to use
- the latest Debian 8 image: projects/debian-cloud/global/images/family/debian-8
- Alternatively, use a specific version of a public operating system image:
- projects/debian-cloud/global/images/debian-8-jessie-vYYYYMMDD To create a
- disk with a private image that you created, specify the image name in the
- following format: global/images/my-private-image You can also specify a private
- image by its image family, which returns the latest version of the image in
- that family. Replace the image name with family/family-name: global/images/family/my-private-family
- .'
- returned: success
- type: str
- zone:
- description:
- - A reference to the zone where the disk resides.
- returned: success
- type: str
- sourceImageEncryptionKey:
- description:
- - The customer-supplied encryption key of the source image. Required if the
- source image is protected by a customer-supplied encryption key.
- returned: success
- type: complex
- contains:
- rawKey:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
- base64 to either encrypt or decrypt this resource.
- returned: success
- type: str
- sha256:
- description:
- - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
- key that protects this resource.
- returned: success
- type: str
- kmsKeyName:
- description:
- - The name of the encryption key that is stored in Google Cloud KMS.
- returned: success
- type: str
- sourceImageId:
- description:
- - The ID value of the image used to create this disk. This value identifies
- the exact image that was used to create this persistent disk. For example,
- if you created the persistent disk from an image that was later deleted and
- recreated under the same name, the source image ID would identify the exact
- version of the image that was used.
- returned: success
- type: str
- diskEncryptionKey:
- description:
- - Encrypts the disk using a customer-supplied encryption key.
- - After you encrypt a disk with a customer-supplied key, you must provide the
- same key if you use the disk later (e.g. to create a disk snapshot or an image,
- or to attach the disk to a virtual machine).
- - Customer-supplied encryption keys do not protect access to metadata of the
- disk.
- - If you do not provide an encryption key when creating the disk, then the disk
- will be encrypted using an automatically generated key and you do not need
- to provide a key to use the disk later.
- returned: success
- type: complex
- contains:
- rawKey:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
- base64 to either encrypt or decrypt this resource.
- returned: success
- type: str
- sha256:
- description:
- - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
- key that protects this resource.
- returned: success
- type: str
- kmsKeyName:
- description:
- - The name of the encryption key that is stored in Google Cloud KMS.
- - Your project's Compute Engine System service account (`service-{{PROJECT_NUMBER}}@compute-system.iam.gserviceaccount.com`)
- must have `roles/cloudkms.cryptoKeyEncrypterDecrypter` to use this feature.
- returned: success
- type: str
- sourceSnapshot:
- description:
- - The source snapshot used to create this disk. You can provide this as a partial
- or full URL to the resource.
- returned: success
- type: dict
- sourceSnapshotEncryptionKey:
- description:
- - The customer-supplied encryption key of the source snapshot. Required if the
- source snapshot is protected by a customer-supplied encryption key.
- returned: success
- type: complex
- contains:
- rawKey:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
- base64 to either encrypt or decrypt this resource.
- returned: success
- type: str
- kmsKeyName:
- description:
- - The name of the encryption key that is stored in Google Cloud KMS.
- returned: success
- type: str
- sha256:
- description:
- - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
- key that protects this resource.
- returned: success
- type: str
- sourceSnapshotId:
- description:
- - The unique ID of the snapshot used to create this disk. This value identifies
- the exact snapshot that was used to create this persistent disk. For example,
- if you created the persistent disk from a snapshot that was later deleted
- and recreated under the same name, the source snapshot ID would identify the
- exact version of the snapshot that was used.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str'), zone=dict(required=True, type='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/disks".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_firewall.py b/lib/ansible/modules/cloud/google/gcp_compute_firewall.py
deleted file mode 100644
index bbd6cdd156..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_firewall.py
+++ /dev/null
@@ -1,810 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_firewall
-description:
-- Each network has its own firewall controlling access to and from the instances.
-- All traffic to instances, even from other instances, is blocked by the firewall
- unless firewall rules are created to allow it.
-- The default network has automatically created firewall rules that are shown in default
- firewall rules. No manually created network has automatically created firewall rules
- except for a default "allow" rule for outgoing traffic and a default "deny" for
- incoming traffic. For all networks except the default network, you must create any
- firewall rules you need.
-short_description: Creates a GCP Firewall
-version_added: '2.6'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- allowed:
- description:
- - The list of ALLOW rules specified by this firewall. Each rule specifies a protocol
- and port-range tuple that describes a permitted connection.
- required: false
- type: list
- suboptions:
- ip_protocol:
- description:
- - The IP protocol to which this rule applies. The protocol type is required
- when creating a firewall rule. This value can either be one of the following
- well known protocol strings (tcp, udp, icmp, esp, ah, sctp), or the IP protocol
- number.
- required: true
- type: str
- ports:
- description:
- - An optional list of ports to which this rule applies. This field is only
- applicable for UDP or TCP protocol. Each entry must be either an integer
- or a range. If not specified, this rule applies to connections through any
- port.
- - 'Example inputs include: ["22"], ["80","443"], and ["12345-12349"].'
- required: false
- type: list
- denied:
- description:
- - The list of DENY rules specified by this firewall. Each rule specifies a protocol
- and port-range tuple that describes a denied connection.
- required: false
- type: list
- version_added: '2.8'
- suboptions:
- ip_protocol:
- description:
- - The IP protocol to which this rule applies. The protocol type is required
- when creating a firewall rule. This value can either be one of the following
- well known protocol strings (tcp, udp, icmp, esp, ah, sctp), or the IP protocol
- number.
- required: true
- type: str
- ports:
- description:
- - An optional list of ports to which this rule applies. This field is only
- applicable for UDP or TCP protocol. Each entry must be either an integer
- or a range. If not specified, this rule applies to connections through any
- port.
- - 'Example inputs include: ["22"], ["80","443"], and ["12345-12349"].'
- required: false
- type: list
- description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- required: false
- type: str
- destination_ranges:
- description:
- - If destination ranges are specified, the firewall will apply only to traffic
- that has destination IP address in these ranges. These ranges must be expressed
- in CIDR format. Only IPv4 is supported.
- required: false
- type: list
- version_added: '2.8'
- direction:
- description:
- - 'Direction of traffic to which this firewall applies; default is INGRESS. Note:
- For INGRESS traffic, it is NOT supported to specify destinationRanges; For EGRESS
- traffic, it is NOT supported to specify sourceRanges OR sourceTags.'
- - 'Some valid choices include: "INGRESS", "EGRESS"'
- required: false
- type: str
- version_added: '2.8'
- disabled:
- description:
- - Denotes whether the firewall rule is disabled, i.e not applied to the network
- it is associated with. When set to true, the firewall rule is not enforced and
- the network behaves as if it did not exist. If this is unspecified, the firewall
- rule will be enabled.
- required: false
- type: bool
- version_added: '2.8'
- log_config:
- description:
- - This field denotes whether to enable logging for a particular firewall rule.
- If logging is enabled, logs will be exported to Stackdriver.
- required: false
- type: dict
- version_added: '2.10'
- suboptions:
- enable_logging:
- description:
- - This field denotes whether to enable logging for a particular firewall rule.
- If logging is enabled, logs will be exported to Stackdriver.
- required: false
- type: bool
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- required: true
- type: str
- network:
- description:
- - 'URL of the network resource for this firewall rule. If not specified when creating
- a firewall rule, the default network is used: global/networks/default If you
- choose to specify this property, you can specify the network as a full or partial
- URL. For example, the following are all valid URLs: U(https://www.googleapis.com/compute/v1/projects/myproject/global/)
- networks/my-network projects/myproject/global/networks/my-network global/networks/default
- .'
- - 'This field represents a link to a Network resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''selfLink'' and value
- of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
- to a gcp_compute_network task and then set this network field to "{{ name-of-resource
- }}"'
- required: false
- default:
- selfLink: global/networks/default
- type: dict
- priority:
- description:
- - Priority for this rule. This is an integer between 0 and 65535, both inclusive.
- When not specified, the value assumed is 1000. Relative priorities determine
- precedence of conflicting rules. Lower value of priority implies higher precedence
- (eg, a rule with priority 0 has higher precedence than a rule with priority
- 1). DENY rules take precedence over ALLOW rules having equal priority.
- required: false
- default: '1000'
- type: int
- version_added: '2.8'
- source_ranges:
- description:
- - If source ranges are specified, the firewall will apply only to traffic that
- has source IP address in these ranges. These ranges must be expressed in CIDR
- format. One or both of sourceRanges and sourceTags may be set. If both properties
- are set, the firewall will apply to traffic that has source IP address within
- sourceRanges OR the source IP that belongs to a tag listed in the sourceTags
- property. The connection does not need to match both properties for the firewall
- to apply. Only IPv4 is supported.
- required: false
- type: list
- source_service_accounts:
- description:
- - If source service accounts are specified, the firewall will apply only to traffic
- originating from an instance with a service account in this list. Source service
- accounts cannot be used to control traffic to an instance's external IP address
- because service accounts are associated with an instance, not an IP address.
- sourceRanges can be set at the same time as sourceServiceAccounts. If both are
- set, the firewall will apply to traffic that has source IP address within sourceRanges
- OR the source IP belongs to an instance with service account listed in sourceServiceAccount.
- The connection does not need to match both properties for the firewall to apply.
- sourceServiceAccounts cannot be used at the same time as sourceTags or targetTags.
- required: false
- type: list
- version_added: '2.8'
- source_tags:
- description:
- - If source tags are specified, the firewall will apply only to traffic with source
- IP that belongs to a tag listed in source tags. Source tags cannot be used to
- control traffic to an instance's external IP address. Because tags are associated
- with an instance, not an IP address. One or both of sourceRanges and sourceTags
- may be set. If both properties are set, the firewall will apply to traffic that
- has source IP address within sourceRanges OR the source IP that belongs to a
- tag listed in the sourceTags property. The connection does not need to match
- both properties for the firewall to apply.
- required: false
- type: list
- target_service_accounts:
- description:
- - A list of service accounts indicating sets of instances located in the network
- that may make network connections as specified in allowed[].
- - targetServiceAccounts cannot be used at the same time as targetTags or sourceTags.
- If neither targetServiceAccounts nor targetTags are specified, the firewall
- rule applies to all instances on the specified network.
- required: false
- type: list
- version_added: '2.8'
- target_tags:
- description:
- - A list of instance tags indicating sets of instances located in the network
- that may make network connections as specified in allowed[].
- - If no targetTags are specified, the firewall rule applies to all instances on
- the specified network.
- required: false
- type: list
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/compute/docs/reference/v1/firewalls)'
-- 'Official Documentation: U(https://cloud.google.com/vpc/docs/firewalls)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a firewall
- gcp_compute_firewall:
- name: test_object
- allowed:
- - ip_protocol: tcp
- ports:
- - '22'
- target_tags:
- - test-ssh-server
- - staging-ssh-server
- source_tags:
- - test-ssh-clients
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-allowed:
- description:
- - The list of ALLOW rules specified by this firewall. Each rule specifies a protocol
- and port-range tuple that describes a permitted connection.
- returned: success
- type: complex
- contains:
- ip_protocol:
- description:
- - The IP protocol to which this rule applies. The protocol type is required
- when creating a firewall rule. This value can either be one of the following
- well known protocol strings (tcp, udp, icmp, esp, ah, sctp), or the IP protocol
- number.
- returned: success
- type: str
- ports:
- description:
- - An optional list of ports to which this rule applies. This field is only applicable
- for UDP or TCP protocol. Each entry must be either an integer or a range.
- If not specified, this rule applies to connections through any port.
- - 'Example inputs include: ["22"], ["80","443"], and ["12345-12349"].'
- returned: success
- type: list
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-denied:
- description:
- - The list of DENY rules specified by this firewall. Each rule specifies a protocol
- and port-range tuple that describes a denied connection.
- returned: success
- type: complex
- contains:
- ip_protocol:
- description:
- - The IP protocol to which this rule applies. The protocol type is required
- when creating a firewall rule. This value can either be one of the following
- well known protocol strings (tcp, udp, icmp, esp, ah, sctp), or the IP protocol
- number.
- returned: success
- type: str
- ports:
- description:
- - An optional list of ports to which this rule applies. This field is only applicable
- for UDP or TCP protocol. Each entry must be either an integer or a range.
- If not specified, this rule applies to connections through any port.
- - 'Example inputs include: ["22"], ["80","443"], and ["12345-12349"].'
- returned: success
- type: list
-description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- returned: success
- type: str
-destinationRanges:
- description:
- - If destination ranges are specified, the firewall will apply only to traffic that
- has destination IP address in these ranges. These ranges must be expressed in
- CIDR format. Only IPv4 is supported.
- returned: success
- type: list
-direction:
- description:
- - 'Direction of traffic to which this firewall applies; default is INGRESS. Note:
- For INGRESS traffic, it is NOT supported to specify destinationRanges; For EGRESS
- traffic, it is NOT supported to specify sourceRanges OR sourceTags.'
- returned: success
- type: str
-disabled:
- description:
- - Denotes whether the firewall rule is disabled, i.e not applied to the network
- it is associated with. When set to true, the firewall rule is not enforced and
- the network behaves as if it did not exist. If this is unspecified, the firewall
- rule will be enabled.
- returned: success
- type: bool
-logConfig:
- description:
- - This field denotes whether to enable logging for a particular firewall rule. If
- logging is enabled, logs will be exported to Stackdriver.
- returned: success
- type: complex
- contains:
- enableLogging:
- description:
- - This field denotes whether to enable logging for a particular firewall rule.
- If logging is enabled, logs will be exported to Stackdriver.
- returned: success
- type: bool
-id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
-name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
-network:
- description:
- - 'URL of the network resource for this firewall rule. If not specified when creating
- a firewall rule, the default network is used: global/networks/default If you choose
- to specify this property, you can specify the network as a full or partial URL.
- For example, the following are all valid URLs: U(https://www.googleapis.com/compute/v1/projects/myproject/global/)
- networks/my-network projects/myproject/global/networks/my-network global/networks/default
- .'
- returned: success
- type: dict
-priority:
- description:
- - Priority for this rule. This is an integer between 0 and 65535, both inclusive.
- When not specified, the value assumed is 1000. Relative priorities determine precedence
- of conflicting rules. Lower value of priority implies higher precedence (eg, a
- rule with priority 0 has higher precedence than a rule with priority 1). DENY
- rules take precedence over ALLOW rules having equal priority.
- returned: success
- type: int
-sourceRanges:
- description:
- - If source ranges are specified, the firewall will apply only to traffic that has
- source IP address in these ranges. These ranges must be expressed in CIDR format.
- One or both of sourceRanges and sourceTags may be set. If both properties are
- set, the firewall will apply to traffic that has source IP address within sourceRanges
- OR the source IP that belongs to a tag listed in the sourceTags property. The
- connection does not need to match both properties for the firewall to apply. Only
- IPv4 is supported.
- returned: success
- type: list
-sourceServiceAccounts:
- description:
- - If source service accounts are specified, the firewall will apply only to traffic
- originating from an instance with a service account in this list. Source service
- accounts cannot be used to control traffic to an instance's external IP address
- because service accounts are associated with an instance, not an IP address. sourceRanges
- can be set at the same time as sourceServiceAccounts. If both are set, the firewall
- will apply to traffic that has source IP address within sourceRanges OR the source
- IP belongs to an instance with service account listed in sourceServiceAccount.
- The connection does not need to match both properties for the firewall to apply.
- sourceServiceAccounts cannot be used at the same time as sourceTags or targetTags.
- returned: success
- type: list
-sourceTags:
- description:
- - If source tags are specified, the firewall will apply only to traffic with source
- IP that belongs to a tag listed in source tags. Source tags cannot be used to
- control traffic to an instance's external IP address. Because tags are associated
- with an instance, not an IP address. One or both of sourceRanges and sourceTags
- may be set. If both properties are set, the firewall will apply to traffic that
- has source IP address within sourceRanges OR the source IP that belongs to a tag
- listed in the sourceTags property. The connection does not need to match both
- properties for the firewall to apply.
- returned: success
- type: list
-targetServiceAccounts:
- description:
- - A list of service accounts indicating sets of instances located in the network
- that may make network connections as specified in allowed[].
- - targetServiceAccounts cannot be used at the same time as targetTags or sourceTags.
- If neither targetServiceAccounts nor targetTags are specified, the firewall rule
- applies to all instances on the specified network.
- returned: success
- type: list
-targetTags:
- description:
- - A list of instance tags indicating sets of instances located in the network that
- may make network connections as specified in allowed[].
- - If no targetTags are specified, the firewall rule applies to all instances on
- the specified network.
- returned: success
- type: list
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import re
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- allowed=dict(type='list', elements='dict', options=dict(ip_protocol=dict(required=True, type='str'), ports=dict(type='list', elements='str'))),
- denied=dict(type='list', elements='dict', options=dict(ip_protocol=dict(required=True, type='str'), ports=dict(type='list', elements='str'))),
- description=dict(type='str'),
- destination_ranges=dict(type='list', elements='str'),
- direction=dict(type='str'),
- disabled=dict(type='bool'),
- log_config=dict(type='dict', options=dict(enable_logging=dict(type='bool'))),
- name=dict(required=True, type='str'),
- network=dict(default=dict(selfLink='global/networks/default'), type='dict'),
- priority=dict(default=1000, type='int'),
- source_ranges=dict(type='list', elements='str'),
- source_service_accounts=dict(type='list', elements='str'),
- source_tags=dict(type='list', elements='str'),
- target_service_accounts=dict(type='list', elements='str'),
- target_tags=dict(type='list', elements='str'),
- ),
- mutually_exclusive=[
- ['destination_ranges', 'source_ranges', 'source_tags'],
- ['destination_ranges', 'source_ranges'],
- ['source_service_accounts', 'source_tags', 'target_tags'],
- ['destination_ranges', 'source_service_accounts', 'source_tags', 'target_service_accounts'],
- ['source_tags', 'target_service_accounts', 'target_tags'],
- ['source_service_accounts', 'target_service_accounts', 'target_tags'],
- ],
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#firewall'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.patch(link, resource_to_request(module)))
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#firewall',
- u'allowed': FirewallAllowedArray(module.params.get('allowed', []), module).to_request(),
- u'denied': FirewallDeniedArray(module.params.get('denied', []), module).to_request(),
- u'description': module.params.get('description'),
- u'destinationRanges': module.params.get('destination_ranges'),
- u'direction': module.params.get('direction'),
- u'disabled': module.params.get('disabled'),
- u'logConfig': FirewallLogconfig(module.params.get('log_config', {}), module).to_request(),
- u'name': module.params.get('name'),
- u'network': replace_resource_dict(module.params.get(u'network', {}), 'selfLink'),
- u'priority': module.params.get('priority'),
- u'sourceRanges': module.params.get('source_ranges'),
- u'sourceServiceAccounts': module.params.get('source_service_accounts'),
- u'sourceTags': module.params.get('source_tags'),
- u'targetServiceAccounts': module.params.get('target_service_accounts'),
- u'targetTags': module.params.get('target_tags'),
- }
- request = encode_request(request, module)
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/firewalls/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/firewalls".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'allowed': FirewallAllowedArray(response.get(u'allowed', []), module).from_response(),
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'denied': FirewallDeniedArray(response.get(u'denied', []), module).from_response(),
- u'description': response.get(u'description'),
- u'destinationRanges': response.get(u'destinationRanges'),
- u'direction': response.get(u'direction'),
- u'disabled': response.get(u'disabled'),
- u'logConfig': FirewallLogconfig(response.get(u'logConfig', {}), module).from_response(),
- u'id': response.get(u'id'),
- u'name': module.params.get('name'),
- u'network': response.get(u'network'),
- u'priority': response.get(u'priority'),
- u'sourceRanges': response.get(u'sourceRanges'),
- u'sourceServiceAccounts': response.get(u'sourceServiceAccounts'),
- u'sourceTags': response.get(u'sourceTags'),
- u'targetServiceAccounts': response.get(u'targetServiceAccounts'),
- u'targetTags': response.get(u'targetTags'),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/global/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#firewall')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-def encode_request(request, module):
- if 'network' in request and request['network'] is not None:
- if not re.match(r'https://www.googleapis.com/compute/v1/projects/.*', request['network']):
- request['network'] = 'https://www.googleapis.com/compute/v1/projects/{project}/{network}'.format(
- project=module.params['project'], network=request['network']
- )
-
- return request
-
-
-class FirewallAllowedArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'IPProtocol': item.get('ip_protocol'), u'ports': item.get('ports')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'IPProtocol': item.get(u'IPProtocol'), u'ports': item.get(u'ports')})
-
-
-class FirewallDeniedArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'IPProtocol': item.get('ip_protocol'), u'ports': item.get('ports')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'IPProtocol': item.get(u'IPProtocol'), u'ports': item.get(u'ports')})
-
-
-class FirewallLogconfig(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'enableLogging': self.request.get('enable_logging')})
-
- def from_response(self):
- return remove_nones_from_dict({u'enableLogging': self.request.get(u'enableLogging')})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_firewall_info.py b/lib/ansible/modules/cloud/google/gcp_compute_firewall_info.py
deleted file mode 100644
index a12ad9b485..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_firewall_info.py
+++ /dev/null
@@ -1,369 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_firewall_info
-description:
-- Gather info for GCP Firewall
-short_description: Gather info for GCP Firewall
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a firewall
- gcp_compute_firewall_info:
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- allowed:
- description:
- - The list of ALLOW rules specified by this firewall. Each rule specifies a
- protocol and port-range tuple that describes a permitted connection.
- returned: success
- type: complex
- contains:
- ip_protocol:
- description:
- - The IP protocol to which this rule applies. The protocol type is required
- when creating a firewall rule. This value can either be one of the following
- well known protocol strings (tcp, udp, icmp, esp, ah, sctp), or the IP
- protocol number.
- returned: success
- type: str
- ports:
- description:
- - An optional list of ports to which this rule applies. This field is only
- applicable for UDP or TCP protocol. Each entry must be either an integer
- or a range. If not specified, this rule applies to connections through
- any port.
- - 'Example inputs include: ["22"], ["80","443"], and ["12345-12349"].'
- returned: success
- type: list
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- denied:
- description:
- - The list of DENY rules specified by this firewall. Each rule specifies a protocol
- and port-range tuple that describes a denied connection.
- returned: success
- type: complex
- contains:
- ip_protocol:
- description:
- - The IP protocol to which this rule applies. The protocol type is required
- when creating a firewall rule. This value can either be one of the following
- well known protocol strings (tcp, udp, icmp, esp, ah, sctp), or the IP
- protocol number.
- returned: success
- type: str
- ports:
- description:
- - An optional list of ports to which this rule applies. This field is only
- applicable for UDP or TCP protocol. Each entry must be either an integer
- or a range. If not specified, this rule applies to connections through
- any port.
- - 'Example inputs include: ["22"], ["80","443"], and ["12345-12349"].'
- returned: success
- type: list
- description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- returned: success
- type: str
- destinationRanges:
- description:
- - If destination ranges are specified, the firewall will apply only to traffic
- that has destination IP address in these ranges. These ranges must be expressed
- in CIDR format. Only IPv4 is supported.
- returned: success
- type: list
- direction:
- description:
- - 'Direction of traffic to which this firewall applies; default is INGRESS.
- Note: For INGRESS traffic, it is NOT supported to specify destinationRanges;
- For EGRESS traffic, it is NOT supported to specify sourceRanges OR sourceTags.'
- returned: success
- type: str
- disabled:
- description:
- - Denotes whether the firewall rule is disabled, i.e not applied to the network
- it is associated with. When set to true, the firewall rule is not enforced
- and the network behaves as if it did not exist. If this is unspecified, the
- firewall rule will be enabled.
- returned: success
- type: bool
- logConfig:
- description:
- - This field denotes whether to enable logging for a particular firewall rule.
- If logging is enabled, logs will be exported to Stackdriver.
- returned: success
- type: complex
- contains:
- enableLogging:
- description:
- - This field denotes whether to enable logging for a particular firewall
- rule. If logging is enabled, logs will be exported to Stackdriver.
- returned: success
- type: bool
- id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created.
- The name must be 1-63 characters long, and comply with RFC1035. Specifically,
- the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
- network:
- description:
- - 'URL of the network resource for this firewall rule. If not specified when
- creating a firewall rule, the default network is used: global/networks/default
- If you choose to specify this property, you can specify the network as a full
- or partial URL. For example, the following are all valid URLs: https://www.googleapis.com/compute/v1/projects/myproject/global/
- networks/my-network projects/myproject/global/networks/my-network global/networks/default
- .'
- returned: success
- type: dict
- priority:
- description:
- - Priority for this rule. This is an integer between 0 and 65535, both inclusive.
- When not specified, the value assumed is 1000. Relative priorities determine
- precedence of conflicting rules. Lower value of priority implies higher precedence
- (eg, a rule with priority 0 has higher precedence than a rule with priority
- 1). DENY rules take precedence over ALLOW rules having equal priority.
- returned: success
- type: int
- sourceRanges:
- description:
- - If source ranges are specified, the firewall will apply only to traffic that
- has source IP address in these ranges. These ranges must be expressed in CIDR
- format. One or both of sourceRanges and sourceTags may be set. If both properties
- are set, the firewall will apply to traffic that has source IP address within
- sourceRanges OR the source IP that belongs to a tag listed in the sourceTags
- property. The connection does not need to match both properties for the firewall
- to apply. Only IPv4 is supported.
- returned: success
- type: list
- sourceServiceAccounts:
- description:
- - If source service accounts are specified, the firewall will apply only to
- traffic originating from an instance with a service account in this list.
- Source service accounts cannot be used to control traffic to an instance's
- external IP address because service accounts are associated with an instance,
- not an IP address. sourceRanges can be set at the same time as sourceServiceAccounts.
- If both are set, the firewall will apply to traffic that has source IP address
- within sourceRanges OR the source IP belongs to an instance with service account
- listed in sourceServiceAccount. The connection does not need to match both
- properties for the firewall to apply. sourceServiceAccounts cannot be used
- at the same time as sourceTags or targetTags.
- returned: success
- type: list
- sourceTags:
- description:
- - If source tags are specified, the firewall will apply only to traffic with
- source IP that belongs to a tag listed in source tags. Source tags cannot
- be used to control traffic to an instance's external IP address. Because tags
- are associated with an instance, not an IP address. One or both of sourceRanges
- and sourceTags may be set. If both properties are set, the firewall will apply
- to traffic that has source IP address within sourceRanges OR the source IP
- that belongs to a tag listed in the sourceTags property. The connection does
- not need to match both properties for the firewall to apply.
- returned: success
- type: list
- targetServiceAccounts:
- description:
- - A list of service accounts indicating sets of instances located in the network
- that may make network connections as specified in allowed[].
- - targetServiceAccounts cannot be used at the same time as targetTags or sourceTags.
- If neither targetServiceAccounts nor targetTags are specified, the firewall
- rule applies to all instances on the specified network.
- returned: success
- type: list
- targetTags:
- description:
- - A list of instance tags indicating sets of instances located in the network
- that may make network connections as specified in allowed[].
- - If no targetTags are specified, the firewall rule applies to all instances
- on the specified network.
- returned: success
- type: list
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/firewalls".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_forwarding_rule.py b/lib/ansible/modules/cloud/google/gcp_compute_forwarding_rule.py
deleted file mode 100644
index c0bf7674aa..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_forwarding_rule.py
+++ /dev/null
@@ -1,707 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_forwarding_rule
-description:
-- A ForwardingRule resource. A ForwardingRule resource specifies which pool of target
- virtual machines to forward a packet to if it matches the given [IPAddress, IPProtocol,
- portRange] tuple.
-short_description: Creates a GCP ForwardingRule
-version_added: '2.6'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- required: false
- type: str
- ip_address:
- description:
- - The IP address that this forwarding rule is serving on behalf of.
- - Addresses are restricted based on the forwarding rule's load balancing scheme
- (EXTERNAL or INTERNAL) and scope (global or regional).
- - When the load balancing scheme is EXTERNAL, for global forwarding rules, the
- address must be a global IP, and for regional forwarding rules, the address
- must live in the same region as the forwarding rule. If this field is empty,
- an ephemeral IPv4 address from the same scope (global or regional) will be assigned.
- A regional forwarding rule supports IPv4 only. A global forwarding rule supports
- either IPv4 or IPv6.
- - When the load balancing scheme is INTERNAL, this can only be an RFC 1918 IP
- address belonging to the network/subnet configured for the forwarding rule.
- By default, if this field is empty, an ephemeral internal IP address will be
- automatically allocated from the IP range of the subnet or network configured
- for this forwarding rule.
- - 'An address can be specified either by a literal IP address or a URL reference
- to an existing Address resource. The following examples are all valid: * 100.1.2.3
- * U(https://www.googleapis.com/compute/v1/projects/project/regions/region/addresses/address)
- * projects/project/regions/region/addresses/address * regions/region/addresses/address
- * global/addresses/address * address .'
- required: false
- type: str
- ip_protocol:
- description:
- - The IP protocol to which this rule applies. Valid options are TCP, UDP, ESP,
- AH, SCTP or ICMP.
- - When the load balancing scheme is INTERNAL, only TCP and UDP are valid.
- - 'Some valid choices include: "TCP", "UDP", "ESP", "AH", "SCTP", "ICMP"'
- required: false
- type: str
- backend_service:
- description:
- - A BackendService to receive the matched traffic. This is used only for INTERNAL
- load balancing.
- - 'This field represents a link to a BackendService resource in GCP. It can be
- specified in two ways. First, you can place a dictionary with key ''selfLink''
- and value of your resource''s selfLink Alternatively, you can add `register:
- name-of-resource` to a gcp_compute_backend_service task and then set this backend_service
- field to "{{ name-of-resource }}"'
- required: false
- type: dict
- load_balancing_scheme:
- description:
- - This signifies what the ForwardingRule will be used for and can be EXTERNAL,
- INTERNAL, or INTERNAL_MANAGED. EXTERNAL is used for Classic Cloud VPN gateways,
- protocol forwarding to VMs from an external IP address, and HTTP(S), SSL Proxy,
- TCP Proxy, and Network TCP/UDP load balancers.
- - INTERNAL is used for protocol forwarding to VMs from an internal IP address,
- and internal TCP/UDP load balancers.
- - INTERNAL_MANAGED is used for internal HTTP(S) load balancers.
- - 'Some valid choices include: "EXTERNAL", "INTERNAL", "INTERNAL_MANAGED"'
- required: false
- type: str
- name:
- description:
- - Name of the resource; provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- required: true
- type: str
- network:
- description:
- - For internal load balancing, this field identifies the network that the load
- balanced IP should belong to for this Forwarding Rule. If this field is not
- specified, the default network will be used.
- - This field is only used for INTERNAL load balancing.
- - 'This field represents a link to a Network resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''selfLink'' and value
- of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
- to a gcp_compute_network task and then set this network field to "{{ name-of-resource
- }}"'
- required: false
- type: dict
- port_range:
- description:
- - This field is used along with the target field for TargetHttpProxy, TargetHttpsProxy,
- TargetSslProxy, TargetTcpProxy, TargetVpnGateway, TargetPool, TargetInstance.
- - Applicable only when IPProtocol is TCP, UDP, or SCTP, only packets addressed
- to ports in the specified range will be forwarded to target.
- - Forwarding rules with the same [IPAddress, IPProtocol] pair must have disjoint
- port ranges.
- - 'Some types of forwarding target have constraints on the acceptable ports: *
- TargetHttpProxy: 80, 8080 * TargetHttpsProxy: 443 * TargetTcpProxy: 25, 43,
- 110, 143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222 * TargetSslProxy: 25,
- 43, 110, 143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222 * TargetVpnGateway:
- 500, 4500 .'
- required: false
- type: str
- ports:
- description:
- - This field is used along with the backend_service field for internal load balancing.
- - When the load balancing scheme is INTERNAL, a single port or a comma separated
- list of ports can be configured. Only packets addressed to these ports will
- be forwarded to the backends configured with this forwarding rule.
- - You may specify a maximum of up to 5 ports.
- required: false
- type: list
- subnetwork:
- description:
- - The subnetwork that the load balanced IP should belong to for this Forwarding
- Rule. This field is only used for INTERNAL load balancing.
- - If the network specified is in auto subnet mode, this field is optional. However,
- if the network is in custom subnet mode, a subnetwork must be specified.
- - 'This field represents a link to a Subnetwork resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''selfLink'' and value
- of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
- to a gcp_compute_subnetwork task and then set this subnetwork field to "{{ name-of-resource
- }}"'
- required: false
- type: dict
- target:
- description:
- - This field is only used for EXTERNAL load balancing.
- - A reference to a TargetPool resource to receive the matched traffic.
- - This target must live in the same region as the forwarding rule.
- - The forwarded traffic must be of a type appropriate to the target object.
- - 'This field represents a link to a TargetPool resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''selfLink'' and value
- of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
- to a gcp_compute_target_pool task and then set this target field to "{{ name-of-resource
- }}"'
- required: false
- type: dict
- version_added: '2.7'
- all_ports:
- description:
- - For internal TCP/UDP load balancing (i.e. load balancing scheme is INTERNAL
- and protocol is TCP/UDP), set this to true to allow packets addressed to any
- ports to be forwarded to the backends configured with this forwarding rule.
- Used with backend service. Cannot be set if port or portRange are set.
- required: false
- type: bool
- version_added: '2.8'
- network_tier:
- description:
- - 'The networking tier used for configuring this address. This field can take
- the following values: PREMIUM or STANDARD. If this field is not specified, it
- is assumed to be PREMIUM.'
- - 'Some valid choices include: "PREMIUM", "STANDARD"'
- required: false
- type: str
- version_added: '2.8'
- service_label:
- description:
- - An optional prefix to the service name for this Forwarding Rule.
- - If specified, will be the first label of the fully qualified service name.
- - The label must be 1-63 characters long, and comply with RFC1035.
- - Specifically, the label must be 1-63 characters long and match the regular expression
- `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase
- letter, and all following characters must be a dash, lowercase letter, or digit,
- except the last character, which cannot be a dash.
- - This field is only used for INTERNAL load balancing.
- required: false
- type: str
- version_added: '2.8'
- region:
- description:
- - A reference to the region where the regional forwarding rule resides.
- - This field is not applicable to global forwarding rules.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/compute/docs/reference/v1/forwardingRule)'
-- 'Official Documentation: U(https://cloud.google.com/compute/docs/load-balancing/network/forwarding-rules)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a address
- gcp_compute_address:
- name: address-forwardingrule
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: address
-
-- name: create a target pool
- gcp_compute_target_pool:
- name: targetpool-forwardingrule
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: targetpool
-
-- name: create a forwarding rule
- gcp_compute_forwarding_rule:
- name: test_object
- region: us-west1
- target: "{{ targetpool }}"
- ip_protocol: TCP
- port_range: 80-80
- ip_address: "{{ address.address }}"
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- returned: success
- type: str
-id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
-IPAddress:
- description:
- - The IP address that this forwarding rule is serving on behalf of.
- - Addresses are restricted based on the forwarding rule's load balancing scheme
- (EXTERNAL or INTERNAL) and scope (global or regional).
- - When the load balancing scheme is EXTERNAL, for global forwarding rules, the address
- must be a global IP, and for regional forwarding rules, the address must live
- in the same region as the forwarding rule. If this field is empty, an ephemeral
- IPv4 address from the same scope (global or regional) will be assigned. A regional
- forwarding rule supports IPv4 only. A global forwarding rule supports either IPv4
- or IPv6.
- - When the load balancing scheme is INTERNAL, this can only be an RFC 1918 IP address
- belonging to the network/subnet configured for the forwarding rule. By default,
- if this field is empty, an ephemeral internal IP address will be automatically
- allocated from the IP range of the subnet or network configured for this forwarding
- rule.
- - 'An address can be specified either by a literal IP address or a URL reference
- to an existing Address resource. The following examples are all valid: * 100.1.2.3
- * U(https://www.googleapis.com/compute/v1/projects/project/regions/region/addresses/address)
- * projects/project/regions/region/addresses/address * regions/region/addresses/address
- * global/addresses/address * address .'
- returned: success
- type: str
-IPProtocol:
- description:
- - The IP protocol to which this rule applies. Valid options are TCP, UDP, ESP, AH,
- SCTP or ICMP.
- - When the load balancing scheme is INTERNAL, only TCP and UDP are valid.
- returned: success
- type: str
-backendService:
- description:
- - A BackendService to receive the matched traffic. This is used only for INTERNAL
- load balancing.
- returned: success
- type: dict
-loadBalancingScheme:
- description:
- - This signifies what the ForwardingRule will be used for and can be EXTERNAL, INTERNAL,
- or INTERNAL_MANAGED. EXTERNAL is used for Classic Cloud VPN gateways, protocol
- forwarding to VMs from an external IP address, and HTTP(S), SSL Proxy, TCP Proxy,
- and Network TCP/UDP load balancers.
- - INTERNAL is used for protocol forwarding to VMs from an internal IP address, and
- internal TCP/UDP load balancers.
- - INTERNAL_MANAGED is used for internal HTTP(S) load balancers.
- returned: success
- type: str
-name:
- description:
- - Name of the resource; provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
-network:
- description:
- - For internal load balancing, this field identifies the network that the load balanced
- IP should belong to for this Forwarding Rule. If this field is not specified,
- the default network will be used.
- - This field is only used for INTERNAL load balancing.
- returned: success
- type: dict
-portRange:
- description:
- - This field is used along with the target field for TargetHttpProxy, TargetHttpsProxy,
- TargetSslProxy, TargetTcpProxy, TargetVpnGateway, TargetPool, TargetInstance.
- - Applicable only when IPProtocol is TCP, UDP, or SCTP, only packets addressed to
- ports in the specified range will be forwarded to target.
- - Forwarding rules with the same [IPAddress, IPProtocol] pair must have disjoint
- port ranges.
- - 'Some types of forwarding target have constraints on the acceptable ports: * TargetHttpProxy:
- 80, 8080 * TargetHttpsProxy: 443 * TargetTcpProxy: 25, 43, 110, 143, 195, 443,
- 465, 587, 700, 993, 995, 1883, 5222 * TargetSslProxy: 25, 43, 110, 143, 195, 443,
- 465, 587, 700, 993, 995, 1883, 5222 * TargetVpnGateway: 500, 4500 .'
- returned: success
- type: str
-ports:
- description:
- - This field is used along with the backend_service field for internal load balancing.
- - When the load balancing scheme is INTERNAL, a single port or a comma separated
- list of ports can be configured. Only packets addressed to these ports will be
- forwarded to the backends configured with this forwarding rule.
- - You may specify a maximum of up to 5 ports.
- returned: success
- type: list
-subnetwork:
- description:
- - The subnetwork that the load balanced IP should belong to for this Forwarding
- Rule. This field is only used for INTERNAL load balancing.
- - If the network specified is in auto subnet mode, this field is optional. However,
- if the network is in custom subnet mode, a subnetwork must be specified.
- returned: success
- type: dict
-target:
- description:
- - This field is only used for EXTERNAL load balancing.
- - A reference to a TargetPool resource to receive the matched traffic.
- - This target must live in the same region as the forwarding rule.
- - The forwarded traffic must be of a type appropriate to the target object.
- returned: success
- type: dict
-allPorts:
- description:
- - For internal TCP/UDP load balancing (i.e. load balancing scheme is INTERNAL and
- protocol is TCP/UDP), set this to true to allow packets addressed to any ports
- to be forwarded to the backends configured with this forwarding rule. Used with
- backend service. Cannot be set if port or portRange are set.
- returned: success
- type: bool
-networkTier:
- description:
- - 'The networking tier used for configuring this address. This field can take the
- following values: PREMIUM or STANDARD. If this field is not specified, it is assumed
- to be PREMIUM.'
- returned: success
- type: str
-serviceLabel:
- description:
- - An optional prefix to the service name for this Forwarding Rule.
- - If specified, will be the first label of the fully qualified service name.
- - The label must be 1-63 characters long, and comply with RFC1035.
- - Specifically, the label must be 1-63 characters long and match the regular expression
- `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase
- letter, and all following characters must be a dash, lowercase letter, or digit,
- except the last character, which cannot be a dash.
- - This field is only used for INTERNAL load balancing.
- returned: success
- type: str
-serviceName:
- description:
- - The internal fully qualified service name for this Forwarding Rule.
- - This field is only used for INTERNAL load balancing.
- returned: success
- type: str
-region:
- description:
- - A reference to the region where the regional forwarding rule resides.
- - This field is not applicable to global forwarding rules.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- description=dict(type='str'),
- ip_address=dict(type='str'),
- ip_protocol=dict(type='str'),
- backend_service=dict(type='dict'),
- load_balancing_scheme=dict(type='str'),
- name=dict(required=True, type='str'),
- network=dict(type='dict'),
- port_range=dict(type='str'),
- ports=dict(type='list', elements='str'),
- subnetwork=dict(type='dict'),
- target=dict(type='dict'),
- all_ports=dict(type='bool'),
- network_tier=dict(type='str'),
- service_label=dict(type='str'),
- region=dict(required=True, type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#forwardingRule'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind, fetch)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind, fetch):
- update_fields(module, resource_to_request(module), response_to_hash(module, fetch))
- return fetch_resource(module, self_link(module), kind)
-
-
-def update_fields(module, request, response):
- if response.get('target') != request.get('target'):
- target_update(module, request, response)
-
-
-def target_update(module, request, response):
- auth = GcpSession(module, 'compute')
- auth.post(
- ''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/regions/{region}/forwardingRules/{name}/setTarget"]).format(**module.params),
- {u'target': replace_resource_dict(module.params.get(u'target', {}), 'selfLink')},
- )
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#forwardingRule',
- u'description': module.params.get('description'),
- u'IPAddress': module.params.get('ip_address'),
- u'IPProtocol': module.params.get('ip_protocol'),
- u'backendService': replace_resource_dict(module.params.get(u'backend_service', {}), 'selfLink'),
- u'loadBalancingScheme': module.params.get('load_balancing_scheme'),
- u'name': module.params.get('name'),
- u'network': replace_resource_dict(module.params.get(u'network', {}), 'selfLink'),
- u'portRange': module.params.get('port_range'),
- u'ports': module.params.get('ports'),
- u'subnetwork': replace_resource_dict(module.params.get(u'subnetwork', {}), 'selfLink'),
- u'target': replace_resource_dict(module.params.get(u'target', {}), 'selfLink'),
- u'allPorts': module.params.get('all_ports'),
- u'networkTier': module.params.get('network_tier'),
- u'serviceLabel': module.params.get('service_label'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/forwardingRules/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/forwardingRules".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'description': response.get(u'description'),
- u'id': response.get(u'id'),
- u'IPAddress': response.get(u'IPAddress'),
- u'IPProtocol': response.get(u'IPProtocol'),
- u'backendService': response.get(u'backendService'),
- u'loadBalancingScheme': response.get(u'loadBalancingScheme'),
- u'name': response.get(u'name'),
- u'network': response.get(u'network'),
- u'portRange': response.get(u'portRange'),
- u'ports': response.get(u'ports'),
- u'subnetwork': response.get(u'subnetwork'),
- u'target': response.get(u'target'),
- u'allPorts': response.get(u'allPorts'),
- u'networkTier': module.params.get('network_tier'),
- u'serviceLabel': response.get(u'serviceLabel'),
- u'serviceName': response.get(u'serviceName'),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#forwardingRule')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_forwarding_rule_info.py b/lib/ansible/modules/cloud/google/gcp_compute_forwarding_rule_info.py
deleted file mode 100644
index e67dccf7cc..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_forwarding_rule_info.py
+++ /dev/null
@@ -1,355 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_forwarding_rule_info
-description:
-- Gather info for GCP ForwardingRule
-short_description: Gather info for GCP ForwardingRule
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- region:
- description:
- - A reference to the region where the regional forwarding rule resides.
- - This field is not applicable to global forwarding rules.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a forwarding rule
- gcp_compute_forwarding_rule_info:
- region: us-west1
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- returned: success
- type: str
- id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
- IPAddress:
- description:
- - The IP address that this forwarding rule is serving on behalf of.
- - Addresses are restricted based on the forwarding rule's load balancing scheme
- (EXTERNAL or INTERNAL) and scope (global or regional).
- - When the load balancing scheme is EXTERNAL, for global forwarding rules, the
- address must be a global IP, and for regional forwarding rules, the address
- must live in the same region as the forwarding rule. If this field is empty,
- an ephemeral IPv4 address from the same scope (global or regional) will be
- assigned. A regional forwarding rule supports IPv4 only. A global forwarding
- rule supports either IPv4 or IPv6.
- - When the load balancing scheme is INTERNAL, this can only be an RFC 1918 IP
- address belonging to the network/subnet configured for the forwarding rule.
- By default, if this field is empty, an ephemeral internal IP address will
- be automatically allocated from the IP range of the subnet or network configured
- for this forwarding rule.
- - 'An address can be specified either by a literal IP address or a URL reference
- to an existing Address resource. The following examples are all valid: * 100.1.2.3
- * https://www.googleapis.com/compute/v1/projects/project/regions/region/addresses/address
- * projects/project/regions/region/addresses/address * regions/region/addresses/address
- * global/addresses/address * address .'
- returned: success
- type: str
- IPProtocol:
- description:
- - The IP protocol to which this rule applies. Valid options are TCP, UDP, ESP,
- AH, SCTP or ICMP.
- - When the load balancing scheme is INTERNAL, only TCP and UDP are valid.
- returned: success
- type: str
- backendService:
- description:
- - A BackendService to receive the matched traffic. This is used only for INTERNAL
- load balancing.
- returned: success
- type: dict
- loadBalancingScheme:
- description:
- - This signifies what the ForwardingRule will be used for and can be EXTERNAL,
- INTERNAL, or INTERNAL_MANAGED. EXTERNAL is used for Classic Cloud VPN gateways,
- protocol forwarding to VMs from an external IP address, and HTTP(S), SSL Proxy,
- TCP Proxy, and Network TCP/UDP load balancers.
- - INTERNAL is used for protocol forwarding to VMs from an internal IP address,
- and internal TCP/UDP load balancers.
- - INTERNAL_MANAGED is used for internal HTTP(S) load balancers.
- returned: success
- type: str
- name:
- description:
- - Name of the resource; provided by the client when the resource is created.
- The name must be 1-63 characters long, and comply with RFC1035. Specifically,
- the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
- network:
- description:
- - For internal load balancing, this field identifies the network that the load
- balanced IP should belong to for this Forwarding Rule. If this field is not
- specified, the default network will be used.
- - This field is only used for INTERNAL load balancing.
- returned: success
- type: dict
- portRange:
- description:
- - This field is used along with the target field for TargetHttpProxy, TargetHttpsProxy,
- TargetSslProxy, TargetTcpProxy, TargetVpnGateway, TargetPool, TargetInstance.
- - Applicable only when IPProtocol is TCP, UDP, or SCTP, only packets addressed
- to ports in the specified range will be forwarded to target.
- - Forwarding rules with the same [IPAddress, IPProtocol] pair must have disjoint
- port ranges.
- - 'Some types of forwarding target have constraints on the acceptable ports:
- * TargetHttpProxy: 80, 8080 * TargetHttpsProxy: 443 * TargetTcpProxy: 25,
- 43, 110, 143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222 * TargetSslProxy:
- 25, 43, 110, 143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222 * TargetVpnGateway:
- 500, 4500 .'
- returned: success
- type: str
- ports:
- description:
- - This field is used along with the backend_service field for internal load
- balancing.
- - When the load balancing scheme is INTERNAL, a single port or a comma separated
- list of ports can be configured. Only packets addressed to these ports will
- be forwarded to the backends configured with this forwarding rule.
- - You may specify a maximum of up to 5 ports.
- returned: success
- type: list
- subnetwork:
- description:
- - The subnetwork that the load balanced IP should belong to for this Forwarding
- Rule. This field is only used for INTERNAL load balancing.
- - If the network specified is in auto subnet mode, this field is optional. However,
- if the network is in custom subnet mode, a subnetwork must be specified.
- returned: success
- type: dict
- target:
- description:
- - This field is only used for EXTERNAL load balancing.
- - A reference to a TargetPool resource to receive the matched traffic.
- - This target must live in the same region as the forwarding rule.
- - The forwarded traffic must be of a type appropriate to the target object.
- returned: success
- type: dict
- allPorts:
- description:
- - For internal TCP/UDP load balancing (i.e. load balancing scheme is INTERNAL
- and protocol is TCP/UDP), set this to true to allow packets addressed to any
- ports to be forwarded to the backends configured with this forwarding rule.
- Used with backend service. Cannot be set if port or portRange are set.
- returned: success
- type: bool
- networkTier:
- description:
- - 'The networking tier used for configuring this address. This field can take
- the following values: PREMIUM or STANDARD. If this field is not specified,
- it is assumed to be PREMIUM.'
- returned: success
- type: str
- serviceLabel:
- description:
- - An optional prefix to the service name for this Forwarding Rule.
- - If specified, will be the first label of the fully qualified service name.
- - The label must be 1-63 characters long, and comply with RFC1035.
- - Specifically, the label must be 1-63 characters long and match the regular
- expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must
- be a lowercase letter, and all following characters must be a dash, lowercase
- letter, or digit, except the last character, which cannot be a dash.
- - This field is only used for INTERNAL load balancing.
- returned: success
- type: str
- serviceName:
- description:
- - The internal fully qualified service name for this Forwarding Rule.
- - This field is only used for INTERNAL load balancing.
- returned: success
- type: str
- region:
- description:
- - A reference to the region where the regional forwarding rule resides.
- - This field is not applicable to global forwarding rules.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str'), region=dict(required=True, type='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/forwardingRules".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_global_address.py b/lib/ansible/modules/cloud/google/gcp_compute_global_address.py
deleted file mode 100644
index 50f1c54e00..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_global_address.py
+++ /dev/null
@@ -1,466 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_global_address
-description:
-- Represents a Global Address resource. Global addresses are used for HTTP(S) load
- balancing.
-short_description: Creates a GCP GlobalAddress
-version_added: '2.6'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- address:
- description:
- - The static external IP address represented by this resource.
- required: false
- type: str
- version_added: '2.8'
- description:
- description:
- - An optional description of this resource.
- required: false
- type: str
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- required: true
- type: str
- ip_version:
- description:
- - The IP Version that will be used by this address. Valid options are `IPV4` or
- `IPV6`. The default value is `IPV4`.
- - 'Some valid choices include: "IPV4", "IPV6"'
- required: false
- type: str
- prefix_length:
- description:
- - The prefix length of the IP range. If not present, it means the address field
- is a single IP address.
- - This field is not applicable to addresses with addressType=EXTERNAL.
- required: false
- type: int
- version_added: '2.9'
- address_type:
- description:
- - The type of the address to reserve, default is EXTERNAL.
- - "* EXTERNAL indicates public/external single IP address."
- - "* INTERNAL indicates internal IP ranges belonging to some network."
- - 'Some valid choices include: "EXTERNAL", "INTERNAL"'
- required: false
- default: EXTERNAL
- type: str
- version_added: '2.8'
- purpose:
- description:
- - The purpose of the resource. For global internal addresses it can be * VPC_PEERING
- - for peer networks This should only be set when using an Internal address.
- - 'Some valid choices include: "VPC_PEERING"'
- required: false
- type: str
- version_added: '2.9'
- network:
- description:
- - The URL of the network in which to reserve the IP range. The IP range must be
- in RFC1918 space. The network cannot be deleted if there are any reserved IP
- ranges referring to it.
- - This should only be set when using an Internal address.
- - 'This field represents a link to a Network resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''selfLink'' and value
- of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
- to a gcp_compute_network task and then set this network field to "{{ name-of-resource
- }}"'
- required: false
- type: dict
- version_added: '2.9'
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/compute/docs/reference/v1/globalAddresses)'
-- 'Reserving a Static External IP Address: U(https://cloud.google.com/compute/docs/ip-addresses/reserve-static-external-ip-address)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a global address
- gcp_compute_global_address:
- name: test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-address:
- description:
- - The static external IP address represented by this resource.
- returned: success
- type: str
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
-id:
- description:
- - The unique identifier for the resource. This identifier is defined by the server.
- returned: success
- type: int
-name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
-ipVersion:
- description:
- - The IP Version that will be used by this address. Valid options are `IPV4` or
- `IPV6`. The default value is `IPV4`.
- returned: success
- type: str
-region:
- description:
- - A reference to the region where the regional address resides.
- returned: success
- type: str
-prefixLength:
- description:
- - The prefix length of the IP range. If not present, it means the address field
- is a single IP address.
- - This field is not applicable to addresses with addressType=EXTERNAL.
- returned: success
- type: int
-addressType:
- description:
- - The type of the address to reserve, default is EXTERNAL.
- - "* EXTERNAL indicates public/external single IP address."
- - "* INTERNAL indicates internal IP ranges belonging to some network."
- returned: success
- type: str
-purpose:
- description:
- - The purpose of the resource. For global internal addresses it can be * VPC_PEERING
- - for peer networks This should only be set when using an Internal address.
- returned: success
- type: str
-network:
- description:
- - The URL of the network in which to reserve the IP range. The IP range must be
- in RFC1918 space. The network cannot be deleted if there are any reserved IP ranges
- referring to it.
- - This should only be set when using an Internal address.
- returned: success
- type: dict
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-import re
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- address=dict(type='str'),
- description=dict(type='str'),
- name=dict(required=True, type='str'),
- ip_version=dict(type='str'),
- prefix_length=dict(type='int'),
- address_type=dict(default='EXTERNAL', type='str'),
- purpose=dict(type='str'),
- network=dict(type='dict'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#address'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind):
- delete(module, self_link(module), kind)
- create(module, collection(module), kind)
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#address',
- u'address': module.params.get('address'),
- u'description': module.params.get('description'),
- u'name': module.params.get('name'),
- u'ipVersion': module.params.get('ip_version'),
- u'prefixLength': module.params.get('prefix_length'),
- u'addressType': module.params.get('address_type'),
- u'purpose': module.params.get('purpose'),
- u'network': replace_resource_dict(module.params.get(u'network', {}), 'selfLink'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/addresses/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/addresses".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'address': response.get(u'address'),
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'description': response.get(u'description'),
- u'id': response.get(u'id'),
- u'name': response.get(u'name'),
- u'ipVersion': response.get(u'ipVersion'),
- u'region': response.get(u'region'),
- u'prefixLength': response.get(u'prefixLength'),
- u'addressType': response.get(u'addressType'),
- u'purpose': response.get(u'purpose'),
- u'network': response.get(u'network'),
- }
-
-
-def region_selflink(name, params):
- if name is None:
- return
- url = r"https://www.googleapis.com/compute/v1/projects/.*/regions/.*"
- if not re.match(url, name):
- name = "https://www.googleapis.com/compute/v1/projects/{project}/regions/%s".format(**params) % name
- return name
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/global/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#address')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_global_address_info.py b/lib/ansible/modules/cloud/google/gcp_compute_global_address_info.py
deleted file mode 100644
index e445a48301..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_global_address_info.py
+++ /dev/null
@@ -1,257 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_global_address_info
-description:
-- Gather info for GCP GlobalAddress
-short_description: Gather info for GCP GlobalAddress
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a global address
- gcp_compute_global_address_info:
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- address:
- description:
- - The static external IP address represented by this resource.
- returned: success
- type: str
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
- id:
- description:
- - The unique identifier for the resource. This identifier is defined by the
- server.
- returned: success
- type: int
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created.
- The name must be 1-63 characters long, and comply with RFC1035. Specifically,
- the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
- ipVersion:
- description:
- - The IP Version that will be used by this address. Valid options are `IPV4`
- or `IPV6`. The default value is `IPV4`.
- returned: success
- type: str
- region:
- description:
- - A reference to the region where the regional address resides.
- returned: success
- type: str
- prefixLength:
- description:
- - The prefix length of the IP range. If not present, it means the address field
- is a single IP address.
- - This field is not applicable to addresses with addressType=EXTERNAL.
- returned: success
- type: int
- addressType:
- description:
- - The type of the address to reserve, default is EXTERNAL.
- - "* EXTERNAL indicates public/external single IP address."
- - "* INTERNAL indicates internal IP ranges belonging to some network."
- returned: success
- type: str
- purpose:
- description:
- - The purpose of the resource. For global internal addresses it can be * VPC_PEERING
- - for peer networks This should only be set when using an Internal address.
- returned: success
- type: str
- network:
- description:
- - The URL of the network in which to reserve the IP range. The IP range must
- be in RFC1918 space. The network cannot be deleted if there are any reserved
- IP ranges referring to it.
- - This should only be set when using an Internal address.
- returned: success
- type: dict
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/addresses".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_global_forwarding_rule.py b/lib/ansible/modules/cloud/google/gcp_compute_global_forwarding_rule.py
deleted file mode 100644
index 74c2e6c506..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_global_forwarding_rule.py
+++ /dev/null
@@ -1,764 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_global_forwarding_rule
-description:
-- Represents a GlobalForwardingRule resource. Global forwarding rules are used to
- forward traffic to the correct load balancer for HTTP load balancing. Global forwarding
- rules can only be used for HTTP load balancing.
-- For more information, see U(https://cloud.google.com/compute/docs/load-balancing/http/)
- .
-short_description: Creates a GCP GlobalForwardingRule
-version_added: '2.6'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- required: false
- type: str
- ip_address:
- description:
- - The IP address that this forwarding rule is serving on behalf of.
- - Addresses are restricted based on the forwarding rule's load balancing scheme
- (EXTERNAL or INTERNAL) and scope (global or regional).
- - When the load balancing scheme is EXTERNAL, for global forwarding rules, the
- address must be a global IP, and for regional forwarding rules, the address
- must live in the same region as the forwarding rule. If this field is empty,
- an ephemeral IPv4 address from the same scope (global or regional) will be assigned.
- A regional forwarding rule supports IPv4 only. A global forwarding rule supports
- either IPv4 or IPv6.
- - When the load balancing scheme is INTERNAL, this can only be an RFC 1918 IP
- address belonging to the network/subnet configured for the forwarding rule.
- By default, if this field is empty, an ephemeral internal IP address will be
- automatically allocated from the IP range of the subnet or network configured
- for this forwarding rule.
- - 'An address can be specified either by a literal IP address or a URL reference
- to an existing Address resource. The following examples are all valid: * 100.1.2.3
- * U(https://www.googleapis.com/compute/v1/projects/project/regions/region/addresses/address)
- * projects/project/regions/region/addresses/address * regions/region/addresses/address
- * global/addresses/address * address .'
- required: false
- type: str
- ip_protocol:
- description:
- - The IP protocol to which this rule applies. Valid options are TCP, UDP, ESP,
- AH, SCTP or ICMP. When the load balancing scheme is INTERNAL_SELF_MANAGED, only
- TCP is valid.
- - 'Some valid choices include: "TCP", "UDP", "ESP", "AH", "SCTP", "ICMP"'
- required: false
- type: str
- ip_version:
- description:
- - The IP Version that will be used by this global forwarding rule.
- - Valid options are IPV4 or IPV6.
- - 'Some valid choices include: "IPV4", "IPV6"'
- required: false
- type: str
- load_balancing_scheme:
- description:
- - This signifies what the GlobalForwardingRule will be used for.
- - 'The value of INTERNAL_SELF_MANAGED means that this will be used for Internal
- Global HTTP(S) LB. The value of EXTERNAL means that this will be used for External
- Global Load Balancing (HTTP(S) LB, External TCP/UDP LB, SSL Proxy) NOTE: Currently
- global forwarding rules cannot be used for INTERNAL load balancing.'
- - 'Some valid choices include: "EXTERNAL", "INTERNAL_SELF_MANAGED"'
- required: false
- default: EXTERNAL
- type: str
- metadata_filters:
- description:
- - Opaque filter criteria used by Loadbalancer to restrict routing configuration
- to a limited set xDS compliant clients. In their xDS requests to Loadbalancer,
- xDS clients present node metadata. If a match takes place, the relevant routing
- configuration is made available to those proxies.
- - For each metadataFilter in this list, if its filterMatchCriteria is set to MATCH_ANY,
- at least one of the filterLabels must match the corresponding label provided
- in the metadata. If its filterMatchCriteria is set to MATCH_ALL, then all of
- its filterLabels must match with corresponding labels in the provided metadata.
- - metadataFilters specified here can be overridden by those specified in the UrlMap
- that this ForwardingRule references.
- - metadataFilters only applies to Loadbalancers that have their loadBalancingScheme
- set to INTERNAL_SELF_MANAGED.
- required: false
- type: list
- version_added: '2.10'
- suboptions:
- filter_match_criteria:
- description:
- - Specifies how individual filterLabel matches within the list of filterLabels
- contribute towards the overall metadataFilter match.
- - MATCH_ANY - At least one of the filterLabels must have a matching label
- in the provided metadata.
- - MATCH_ALL - All filterLabels must have matching labels in the provided metadata.
- - 'Some valid choices include: "MATCH_ANY", "MATCH_ALL"'
- required: true
- type: str
- filter_labels:
- description:
- - The list of label value pairs that must match labels in the provided metadata
- based on filterMatchCriteria This list must not be empty and can have at
- the most 64 entries.
- required: true
- type: list
- suboptions:
- name:
- description:
- - Name of the metadata label. The length must be between 1 and 1024 characters,
- inclusive.
- required: true
- type: str
- value:
- description:
- - The value that the label must match. The value has a maximum length
- of 1024 characters.
- required: true
- type: str
- name:
- description:
- - Name of the resource; provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- required: true
- type: str
- network:
- description:
- - This field is not used for external load balancing.
- - For INTERNAL_SELF_MANAGED load balancing, this field identifies the network
- that the load balanced IP should belong to for this global forwarding rule.
- If this field is not specified, the default network will be used.
- - 'This field represents a link to a Network resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''selfLink'' and value
- of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
- to a gcp_compute_network task and then set this network field to "{{ name-of-resource
- }}"'
- required: false
- type: dict
- port_range:
- description:
- - This field is used along with the target field for TargetHttpProxy, TargetHttpsProxy,
- TargetSslProxy, TargetTcpProxy, TargetVpnGateway, TargetPool, TargetInstance.
- - Applicable only when IPProtocol is TCP, UDP, or SCTP, only packets addressed
- to ports in the specified range will be forwarded to target.
- - Forwarding rules with the same [IPAddress, IPProtocol] pair must have disjoint
- port ranges.
- - 'Some types of forwarding target have constraints on the acceptable ports: *
- TargetHttpProxy: 80, 8080 * TargetHttpsProxy: 443 * TargetTcpProxy: 25, 43,
- 110, 143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222 * TargetSslProxy: 25,
- 43, 110, 143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222 * TargetVpnGateway:
- 500, 4500 .'
- required: false
- type: str
- target:
- description:
- - The URL of the target resource to receive the matched traffic.
- - The forwarded traffic must be of a type appropriate to the target object.
- - For INTERNAL_SELF_MANAGED load balancing, only HTTP and HTTPS targets are valid.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-'''
-
-EXAMPLES = '''
-- name: create a global address
- gcp_compute_global_address:
- name: globaladdress-globalforwardingrule
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: globaladdress
-
-- name: create a instance group
- gcp_compute_instance_group:
- name: instancegroup-globalforwardingrule
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: instancegroup
-
-- name: create a HTTP health check
- gcp_compute_http_health_check:
- name: httphealthcheck-globalforwardingrule
- healthy_threshold: 10
- port: 8080
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: healthcheck
-
-- name: create a backend service
- gcp_compute_backend_service:
- name: backendservice-globalforwardingrule
- backends:
- - group: "{{ instancegroup.selfLink }}"
- health_checks:
- - "{{ healthcheck.selfLink }}"
- enable_cdn: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: backendservice
-
-- name: create a URL map
- gcp_compute_url_map:
- name: urlmap-globalforwardingrule
- default_service: "{{ backendservice }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: urlmap
-
-- name: create a target HTTP proxy
- gcp_compute_target_http_proxy:
- name: targethttpproxy-globalforwardingrule
- url_map: "{{ urlmap }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: httpproxy
-
-- name: create a global forwarding rule
- gcp_compute_global_forwarding_rule:
- name: test_object
- ip_address: "{{ globaladdress.address }}"
- ip_protocol: TCP
- port_range: 80-80
- target: "{{ httpproxy.selfLink }}"
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- returned: success
- type: str
-id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
-IPAddress:
- description:
- - The IP address that this forwarding rule is serving on behalf of.
- - Addresses are restricted based on the forwarding rule's load balancing scheme
- (EXTERNAL or INTERNAL) and scope (global or regional).
- - When the load balancing scheme is EXTERNAL, for global forwarding rules, the address
- must be a global IP, and for regional forwarding rules, the address must live
- in the same region as the forwarding rule. If this field is empty, an ephemeral
- IPv4 address from the same scope (global or regional) will be assigned. A regional
- forwarding rule supports IPv4 only. A global forwarding rule supports either IPv4
- or IPv6.
- - When the load balancing scheme is INTERNAL, this can only be an RFC 1918 IP address
- belonging to the network/subnet configured for the forwarding rule. By default,
- if this field is empty, an ephemeral internal IP address will be automatically
- allocated from the IP range of the subnet or network configured for this forwarding
- rule.
- - 'An address can be specified either by a literal IP address or a URL reference
- to an existing Address resource. The following examples are all valid: * 100.1.2.3
- * U(https://www.googleapis.com/compute/v1/projects/project/regions/region/addresses/address)
- * projects/project/regions/region/addresses/address * regions/region/addresses/address
- * global/addresses/address * address .'
- returned: success
- type: str
-IPProtocol:
- description:
- - The IP protocol to which this rule applies. Valid options are TCP, UDP, ESP, AH,
- SCTP or ICMP. When the load balancing scheme is INTERNAL_SELF_MANAGED, only TCP
- is valid.
- returned: success
- type: str
-ipVersion:
- description:
- - The IP Version that will be used by this global forwarding rule.
- - Valid options are IPV4 or IPV6.
- returned: success
- type: str
-loadBalancingScheme:
- description:
- - This signifies what the GlobalForwardingRule will be used for.
- - 'The value of INTERNAL_SELF_MANAGED means that this will be used for Internal
- Global HTTP(S) LB. The value of EXTERNAL means that this will be used for External
- Global Load Balancing (HTTP(S) LB, External TCP/UDP LB, SSL Proxy) NOTE: Currently
- global forwarding rules cannot be used for INTERNAL load balancing.'
- returned: success
- type: str
-metadataFilters:
- description:
- - Opaque filter criteria used by Loadbalancer to restrict routing configuration
- to a limited set xDS compliant clients. In their xDS requests to Loadbalancer,
- xDS clients present node metadata. If a match takes place, the relevant routing
- configuration is made available to those proxies.
- - For each metadataFilter in this list, if its filterMatchCriteria is set to MATCH_ANY,
- at least one of the filterLabels must match the corresponding label provided in
- the metadata. If its filterMatchCriteria is set to MATCH_ALL, then all of its
- filterLabels must match with corresponding labels in the provided metadata.
- - metadataFilters specified here can be overridden by those specified in the UrlMap
- that this ForwardingRule references.
- - metadataFilters only applies to Loadbalancers that have their loadBalancingScheme
- set to INTERNAL_SELF_MANAGED.
- returned: success
- type: complex
- contains:
- filterMatchCriteria:
- description:
- - Specifies how individual filterLabel matches within the list of filterLabels
- contribute towards the overall metadataFilter match.
- - MATCH_ANY - At least one of the filterLabels must have a matching label in
- the provided metadata.
- - MATCH_ALL - All filterLabels must have matching labels in the provided metadata.
- returned: success
- type: str
- filterLabels:
- description:
- - The list of label value pairs that must match labels in the provided metadata
- based on filterMatchCriteria This list must not be empty and can have at the
- most 64 entries.
- returned: success
- type: complex
- contains:
- name:
- description:
- - Name of the metadata label. The length must be between 1 and 1024 characters,
- inclusive.
- returned: success
- type: str
- value:
- description:
- - The value that the label must match. The value has a maximum length of
- 1024 characters.
- returned: success
- type: str
-name:
- description:
- - Name of the resource; provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
-network:
- description:
- - This field is not used for external load balancing.
- - For INTERNAL_SELF_MANAGED load balancing, this field identifies the network that
- the load balanced IP should belong to for this global forwarding rule. If this
- field is not specified, the default network will be used.
- returned: success
- type: dict
-portRange:
- description:
- - This field is used along with the target field for TargetHttpProxy, TargetHttpsProxy,
- TargetSslProxy, TargetTcpProxy, TargetVpnGateway, TargetPool, TargetInstance.
- - Applicable only when IPProtocol is TCP, UDP, or SCTP, only packets addressed to
- ports in the specified range will be forwarded to target.
- - Forwarding rules with the same [IPAddress, IPProtocol] pair must have disjoint
- port ranges.
- - 'Some types of forwarding target have constraints on the acceptable ports: * TargetHttpProxy:
- 80, 8080 * TargetHttpsProxy: 443 * TargetTcpProxy: 25, 43, 110, 143, 195, 443,
- 465, 587, 700, 993, 995, 1883, 5222 * TargetSslProxy: 25, 43, 110, 143, 195, 443,
- 465, 587, 700, 993, 995, 1883, 5222 * TargetVpnGateway: 500, 4500 .'
- returned: success
- type: str
-target:
- description:
- - The URL of the target resource to receive the matched traffic.
- - The forwarded traffic must be of a type appropriate to the target object.
- - For INTERNAL_SELF_MANAGED load balancing, only HTTP and HTTPS targets are valid.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- description=dict(type='str'),
- ip_address=dict(type='str'),
- ip_protocol=dict(type='str'),
- ip_version=dict(type='str'),
- load_balancing_scheme=dict(default='EXTERNAL', type='str'),
- metadata_filters=dict(
- type='list',
- elements='dict',
- options=dict(
- filter_match_criteria=dict(required=True, type='str'),
- filter_labels=dict(
- required=True, type='list', elements='dict', options=dict(name=dict(required=True, type='str'), value=dict(required=True, type='str'))
- ),
- ),
- ),
- name=dict(required=True, type='str'),
- network=dict(type='dict'),
- port_range=dict(type='str'),
- target=dict(required=True, type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#forwardingRule'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind, fetch)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind, fetch):
- update_fields(module, resource_to_request(module), response_to_hash(module, fetch))
- return fetch_resource(module, self_link(module), kind)
-
-
-def update_fields(module, request, response):
- if response.get('target') != request.get('target'):
- target_update(module, request, response)
-
-
-def target_update(module, request, response):
- auth = GcpSession(module, 'compute')
- auth.post(
- ''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/global/forwardingRules/{name}/setTarget"]).format(**module.params),
- {u'target': module.params.get('target')},
- )
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#forwardingRule',
- u'description': module.params.get('description'),
- u'IPAddress': module.params.get('ip_address'),
- u'IPProtocol': module.params.get('ip_protocol'),
- u'ipVersion': module.params.get('ip_version'),
- u'loadBalancingScheme': module.params.get('load_balancing_scheme'),
- u'metadataFilters': GlobalForwardingRuleMetadatafiltersArray(module.params.get('metadata_filters', []), module).to_request(),
- u'name': module.params.get('name'),
- u'network': replace_resource_dict(module.params.get(u'network', {}), 'selfLink'),
- u'portRange': module.params.get('port_range'),
- u'target': module.params.get('target'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/forwardingRules/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/forwardingRules".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'description': response.get(u'description'),
- u'id': response.get(u'id'),
- u'IPAddress': response.get(u'IPAddress'),
- u'IPProtocol': response.get(u'IPProtocol'),
- u'ipVersion': response.get(u'ipVersion'),
- u'loadBalancingScheme': response.get(u'loadBalancingScheme'),
- u'metadataFilters': GlobalForwardingRuleMetadatafiltersArray(response.get(u'metadataFilters', []), module).from_response(),
- u'name': response.get(u'name'),
- u'network': response.get(u'network'),
- u'portRange': response.get(u'portRange'),
- u'target': response.get(u'target'),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/global/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#forwardingRule')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-class GlobalForwardingRuleMetadatafiltersArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict(
- {
- u'filterMatchCriteria': item.get('filter_match_criteria'),
- u'filterLabels': GlobalForwardingRuleFilterlabelsArray(item.get('filter_labels', []), self.module).to_request(),
- }
- )
-
- def _response_from_item(self, item):
- return remove_nones_from_dict(
- {
- u'filterMatchCriteria': item.get(u'filterMatchCriteria'),
- u'filterLabels': GlobalForwardingRuleFilterlabelsArray(item.get(u'filterLabels', []), self.module).from_response(),
- }
- )
-
-
-class GlobalForwardingRuleFilterlabelsArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'name': item.get('name'), u'value': item.get('value')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'name': item.get(u'name'), u'value': item.get(u'value')})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_global_forwarding_rule_info.py b/lib/ansible/modules/cloud/google/gcp_compute_global_forwarding_rule_info.py
deleted file mode 100644
index 9e92b18e11..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_global_forwarding_rule_info.py
+++ /dev/null
@@ -1,337 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_global_forwarding_rule_info
-description:
-- Gather info for GCP GlobalForwardingRule
-short_description: Gather info for GCP GlobalForwardingRule
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a global forwarding rule
- gcp_compute_global_forwarding_rule_info:
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- returned: success
- type: str
- id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
- IPAddress:
- description:
- - The IP address that this forwarding rule is serving on behalf of.
- - Addresses are restricted based on the forwarding rule's load balancing scheme
- (EXTERNAL or INTERNAL) and scope (global or regional).
- - When the load balancing scheme is EXTERNAL, for global forwarding rules, the
- address must be a global IP, and for regional forwarding rules, the address
- must live in the same region as the forwarding rule. If this field is empty,
- an ephemeral IPv4 address from the same scope (global or regional) will be
- assigned. A regional forwarding rule supports IPv4 only. A global forwarding
- rule supports either IPv4 or IPv6.
- - When the load balancing scheme is INTERNAL, this can only be an RFC 1918 IP
- address belonging to the network/subnet configured for the forwarding rule.
- By default, if this field is empty, an ephemeral internal IP address will
- be automatically allocated from the IP range of the subnet or network configured
- for this forwarding rule.
- - 'An address can be specified either by a literal IP address or a URL reference
- to an existing Address resource. The following examples are all valid: * 100.1.2.3
- * https://www.googleapis.com/compute/v1/projects/project/regions/region/addresses/address
- * projects/project/regions/region/addresses/address * regions/region/addresses/address
- * global/addresses/address * address .'
- returned: success
- type: str
- IPProtocol:
- description:
- - The IP protocol to which this rule applies. Valid options are TCP, UDP, ESP,
- AH, SCTP or ICMP. When the load balancing scheme is INTERNAL_SELF_MANAGED,
- only TCP is valid.
- returned: success
- type: str
- ipVersion:
- description:
- - The IP Version that will be used by this global forwarding rule.
- - Valid options are IPV4 or IPV6.
- returned: success
- type: str
- loadBalancingScheme:
- description:
- - This signifies what the GlobalForwardingRule will be used for.
- - 'The value of INTERNAL_SELF_MANAGED means that this will be used for Internal
- Global HTTP(S) LB. The value of EXTERNAL means that this will be used for
- External Global Load Balancing (HTTP(S) LB, External TCP/UDP LB, SSL Proxy)
- NOTE: Currently global forwarding rules cannot be used for INTERNAL load balancing.'
- returned: success
- type: str
- metadataFilters:
- description:
- - Opaque filter criteria used by Loadbalancer to restrict routing configuration
- to a limited set xDS compliant clients. In their xDS requests to Loadbalancer,
- xDS clients present node metadata. If a match takes place, the relevant routing
- configuration is made available to those proxies.
- - For each metadataFilter in this list, if its filterMatchCriteria is set to
- MATCH_ANY, at least one of the filterLabels must match the corresponding label
- provided in the metadata. If its filterMatchCriteria is set to MATCH_ALL,
- then all of its filterLabels must match with corresponding labels in the provided
- metadata.
- - metadataFilters specified here can be overridden by those specified in the
- UrlMap that this ForwardingRule references.
- - metadataFilters only applies to Loadbalancers that have their loadBalancingScheme
- set to INTERNAL_SELF_MANAGED.
- returned: success
- type: complex
- contains:
- filterMatchCriteria:
- description:
- - Specifies how individual filterLabel matches within the list of filterLabels
- contribute towards the overall metadataFilter match.
- - MATCH_ANY - At least one of the filterLabels must have a matching label
- in the provided metadata.
- - MATCH_ALL - All filterLabels must have matching labels in the provided
- metadata.
- returned: success
- type: str
- filterLabels:
- description:
- - The list of label value pairs that must match labels in the provided metadata
- based on filterMatchCriteria This list must not be empty and can have
- at the most 64 entries.
- returned: success
- type: complex
- contains:
- name:
- description:
- - Name of the metadata label. The length must be between 1 and 1024
- characters, inclusive.
- returned: success
- type: str
- value:
- description:
- - The value that the label must match. The value has a maximum length
- of 1024 characters.
- returned: success
- type: str
- name:
- description:
- - Name of the resource; provided by the client when the resource is created.
- The name must be 1-63 characters long, and comply with RFC1035. Specifically,
- the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
- network:
- description:
- - This field is not used for external load balancing.
- - For INTERNAL_SELF_MANAGED load balancing, this field identifies the network
- that the load balanced IP should belong to for this global forwarding rule.
- If this field is not specified, the default network will be used.
- returned: success
- type: dict
- portRange:
- description:
- - This field is used along with the target field for TargetHttpProxy, TargetHttpsProxy,
- TargetSslProxy, TargetTcpProxy, TargetVpnGateway, TargetPool, TargetInstance.
- - Applicable only when IPProtocol is TCP, UDP, or SCTP, only packets addressed
- to ports in the specified range will be forwarded to target.
- - Forwarding rules with the same [IPAddress, IPProtocol] pair must have disjoint
- port ranges.
- - 'Some types of forwarding target have constraints on the acceptable ports:
- * TargetHttpProxy: 80, 8080 * TargetHttpsProxy: 443 * TargetTcpProxy: 25,
- 43, 110, 143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222 * TargetSslProxy:
- 25, 43, 110, 143, 195, 443, 465, 587, 700, 993, 995, 1883, 5222 * TargetVpnGateway:
- 500, 4500 .'
- returned: success
- type: str
- target:
- description:
- - The URL of the target resource to receive the matched traffic.
- - The forwarded traffic must be of a type appropriate to the target object.
- - For INTERNAL_SELF_MANAGED load balancing, only HTTP and HTTPS targets are
- valid.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/forwardingRules".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_health_check.py b/lib/ansible/modules/cloud/google/gcp_compute_health_check.py
deleted file mode 100644
index 81ce5e1b42..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_health_check.py
+++ /dev/null
@@ -1,1244 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_health_check
-description:
-- Health Checks determine whether instances are responsive and able to do work.
-- They are an important part of a comprehensive load balancing configuration, as they
- enable monitoring instances behind load balancers.
-- Health Checks poll instances at a specified interval. Instances that do not respond
- successfully to some number of probes in a row are marked as unhealthy. No new connections
- are sent to unhealthy instances, though existing connections will continue. The
- health check will continue to poll unhealthy instances. If an instance later responds
- successfully to some number of consecutive probes, it is marked healthy again and
- can receive new connections.
-short_description: Creates a GCP HealthCheck
-version_added: '2.6'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- check_interval_sec:
- description:
- - How often (in seconds) to send a health check. The default value is 5 seconds.
- required: false
- default: '5'
- type: int
- description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- required: false
- type: str
- healthy_threshold:
- description:
- - A so-far unhealthy instance will be marked healthy after this many consecutive
- successes. The default value is 2.
- required: false
- default: '2'
- type: int
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- required: true
- type: str
- timeout_sec:
- description:
- - How long (in seconds) to wait before claiming failure.
- - The default value is 5 seconds. It is invalid for timeoutSec to have greater
- value than checkIntervalSec.
- required: false
- default: '5'
- type: int
- aliases:
- - timeout_seconds
- unhealthy_threshold:
- description:
- - A so-far healthy instance will be marked unhealthy after this many consecutive
- failures. The default value is 2.
- required: false
- default: '2'
- type: int
- type:
- description:
- - Specifies the type of the healthCheck, either TCP, SSL, HTTP or HTTPS. If not
- specified, the default is TCP. Exactly one of the protocol-specific health check
- field must be specified, which must match type field.
- - 'Some valid choices include: "TCP", "SSL", "HTTP", "HTTPS", "HTTP2"'
- required: false
- type: str
- http_health_check:
- description:
- - A nested object resource.
- required: false
- type: dict
- suboptions:
- host:
- description:
- - The value of the host header in the HTTP health check request.
- - If left empty (default value), the public IP on behalf of which this health
- check is performed will be used.
- required: false
- type: str
- request_path:
- description:
- - The request path of the HTTP health check request.
- - The default value is /.
- required: false
- default: "/"
- type: str
- response:
- description:
- - The bytes to match against the beginning of the response data. If left empty
- (the default value), any response will indicate health. The response data
- can only be ASCII.
- required: false
- type: str
- port:
- description:
- - The TCP port number for the HTTP health check request.
- - The default value is 80.
- required: false
- type: int
- port_name:
- description:
- - Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name
- are defined, port takes precedence.
- required: false
- type: str
- proxy_header:
- description:
- - Specifies the type of proxy header to append before sending data to the
- backend, either NONE or PROXY_V1. The default is NONE.
- - 'Some valid choices include: "NONE", "PROXY_V1"'
- required: false
- default: NONE
- type: str
- port_specification:
- description:
- - 'Specifies how port is selected for health checking, can be one of the following
- values: * `USE_FIXED_PORT`: The port number in `port` is used for health
- checking.'
- - "* `USE_NAMED_PORT`: The `portName` is used for health checking."
- - "* `USE_SERVING_PORT`: For NetworkEndpointGroup, the port specified for
- each network endpoint is used for health checking. For other backends, the
- port or named port specified in the Backend Service is used for health checking."
- - If not specified, HTTP health check follows behavior specified in `port`
- and `portName` fields.
- - 'Some valid choices include: "USE_FIXED_PORT", "USE_NAMED_PORT", "USE_SERVING_PORT"'
- required: false
- type: str
- version_added: '2.9'
- https_health_check:
- description:
- - A nested object resource.
- required: false
- type: dict
- suboptions:
- host:
- description:
- - The value of the host header in the HTTPS health check request.
- - If left empty (default value), the public IP on behalf of which this health
- check is performed will be used.
- required: false
- type: str
- request_path:
- description:
- - The request path of the HTTPS health check request.
- - The default value is /.
- required: false
- default: "/"
- type: str
- response:
- description:
- - The bytes to match against the beginning of the response data. If left empty
- (the default value), any response will indicate health. The response data
- can only be ASCII.
- required: false
- type: str
- port:
- description:
- - The TCP port number for the HTTPS health check request.
- - The default value is 443.
- required: false
- type: int
- port_name:
- description:
- - Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name
- are defined, port takes precedence.
- required: false
- type: str
- proxy_header:
- description:
- - Specifies the type of proxy header to append before sending data to the
- backend, either NONE or PROXY_V1. The default is NONE.
- - 'Some valid choices include: "NONE", "PROXY_V1"'
- required: false
- default: NONE
- type: str
- port_specification:
- description:
- - 'Specifies how port is selected for health checking, can be one of the following
- values: * `USE_FIXED_PORT`: The port number in `port` is used for health
- checking.'
- - "* `USE_NAMED_PORT`: The `portName` is used for health checking."
- - "* `USE_SERVING_PORT`: For NetworkEndpointGroup, the port specified for
- each network endpoint is used for health checking. For other backends, the
- port or named port specified in the Backend Service is used for health checking."
- - If not specified, HTTPS health check follows behavior specified in `port`
- and `portName` fields.
- - 'Some valid choices include: "USE_FIXED_PORT", "USE_NAMED_PORT", "USE_SERVING_PORT"'
- required: false
- type: str
- version_added: '2.9'
- tcp_health_check:
- description:
- - A nested object resource.
- required: false
- type: dict
- suboptions:
- request:
- description:
- - The application data to send once the TCP connection has been established
- (default value is empty). If both request and response are empty, the connection
- establishment alone will indicate health. The request data can only be ASCII.
- required: false
- type: str
- response:
- description:
- - The bytes to match against the beginning of the response data. If left empty
- (the default value), any response will indicate health. The response data
- can only be ASCII.
- required: false
- type: str
- port:
- description:
- - The TCP port number for the TCP health check request.
- - The default value is 443.
- required: false
- type: int
- port_name:
- description:
- - Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name
- are defined, port takes precedence.
- required: false
- type: str
- proxy_header:
- description:
- - Specifies the type of proxy header to append before sending data to the
- backend, either NONE or PROXY_V1. The default is NONE.
- - 'Some valid choices include: "NONE", "PROXY_V1"'
- required: false
- default: NONE
- type: str
- port_specification:
- description:
- - 'Specifies how port is selected for health checking, can be one of the following
- values: * `USE_FIXED_PORT`: The port number in `port` is used for health
- checking.'
- - "* `USE_NAMED_PORT`: The `portName` is used for health checking."
- - "* `USE_SERVING_PORT`: For NetworkEndpointGroup, the port specified for
- each network endpoint is used for health checking. For other backends, the
- port or named port specified in the Backend Service is used for health checking."
- - If not specified, TCP health check follows behavior specified in `port`
- and `portName` fields.
- - 'Some valid choices include: "USE_FIXED_PORT", "USE_NAMED_PORT", "USE_SERVING_PORT"'
- required: false
- type: str
- version_added: '2.9'
- ssl_health_check:
- description:
- - A nested object resource.
- required: false
- type: dict
- suboptions:
- request:
- description:
- - The application data to send once the SSL connection has been established
- (default value is empty). If both request and response are empty, the connection
- establishment alone will indicate health. The request data can only be ASCII.
- required: false
- type: str
- response:
- description:
- - The bytes to match against the beginning of the response data. If left empty
- (the default value), any response will indicate health. The response data
- can only be ASCII.
- required: false
- type: str
- port:
- description:
- - The TCP port number for the SSL health check request.
- - The default value is 443.
- required: false
- type: int
- port_name:
- description:
- - Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name
- are defined, port takes precedence.
- required: false
- type: str
- proxy_header:
- description:
- - Specifies the type of proxy header to append before sending data to the
- backend, either NONE or PROXY_V1. The default is NONE.
- - 'Some valid choices include: "NONE", "PROXY_V1"'
- required: false
- default: NONE
- type: str
- port_specification:
- description:
- - 'Specifies how port is selected for health checking, can be one of the following
- values: * `USE_FIXED_PORT`: The port number in `port` is used for health
- checking.'
- - "* `USE_NAMED_PORT`: The `portName` is used for health checking."
- - "* `USE_SERVING_PORT`: For NetworkEndpointGroup, the port specified for
- each network endpoint is used for health checking. For other backends, the
- port or named port specified in the Backend Service is used for health checking."
- - If not specified, SSL health check follows behavior specified in `port`
- and `portName` fields.
- - 'Some valid choices include: "USE_FIXED_PORT", "USE_NAMED_PORT", "USE_SERVING_PORT"'
- required: false
- type: str
- version_added: '2.9'
- http2_health_check:
- description:
- - A nested object resource.
- required: false
- type: dict
- version_added: '2.10'
- suboptions:
- host:
- description:
- - The value of the host header in the HTTP2 health check request.
- - If left empty (default value), the public IP on behalf of which this health
- check is performed will be used.
- required: false
- type: str
- request_path:
- description:
- - The request path of the HTTP2 health check request.
- - The default value is /.
- required: false
- default: "/"
- type: str
- response:
- description:
- - The bytes to match against the beginning of the response data. If left empty
- (the default value), any response will indicate health. The response data
- can only be ASCII.
- required: false
- type: str
- port:
- description:
- - The TCP port number for the HTTP2 health check request.
- - The default value is 443.
- required: false
- type: int
- port_name:
- description:
- - Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name
- are defined, port takes precedence.
- required: false
- type: str
- proxy_header:
- description:
- - Specifies the type of proxy header to append before sending data to the
- backend, either NONE or PROXY_V1. The default is NONE.
- - 'Some valid choices include: "NONE", "PROXY_V1"'
- required: false
- default: NONE
- type: str
- port_specification:
- description:
- - 'Specifies how port is selected for health checking, can be one of the following
- values: * `USE_FIXED_PORT`: The port number in `port` is used for health
- checking.'
- - "* `USE_NAMED_PORT`: The `portName` is used for health checking."
- - "* `USE_SERVING_PORT`: For NetworkEndpointGroup, the port specified for
- each network endpoint is used for health checking. For other backends, the
- port or named port specified in the Backend Service is used for health checking."
- - If not specified, HTTP2 health check follows behavior specified in `port`
- and `portName` fields.
- - 'Some valid choices include: "USE_FIXED_PORT", "USE_NAMED_PORT", "USE_SERVING_PORT"'
- required: false
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/v1/healthChecks)'
-- 'Official Documentation: U(https://cloud.google.com/load-balancing/docs/health-checks)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a health check
- gcp_compute_health_check:
- name: test_object
- type: TCP
- tcp_health_check:
- port_name: service-health
- request: ping
- response: pong
- healthy_threshold: 10
- timeout_sec: 2
- unhealthy_threshold: 5
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-checkIntervalSec:
- description:
- - How often (in seconds) to send a health check. The default value is 5 seconds.
- returned: success
- type: int
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- returned: success
- type: str
-healthyThreshold:
- description:
- - A so-far unhealthy instance will be marked healthy after this many consecutive
- successes. The default value is 2.
- returned: success
- type: int
-id:
- description:
- - The unique identifier for the resource. This identifier is defined by the server.
- returned: success
- type: int
-name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
-timeoutSec:
- description:
- - How long (in seconds) to wait before claiming failure.
- - The default value is 5 seconds. It is invalid for timeoutSec to have greater value
- than checkIntervalSec.
- returned: success
- type: int
-unhealthyThreshold:
- description:
- - A so-far healthy instance will be marked unhealthy after this many consecutive
- failures. The default value is 2.
- returned: success
- type: int
-type:
- description:
- - Specifies the type of the healthCheck, either TCP, SSL, HTTP or HTTPS. If not
- specified, the default is TCP. Exactly one of the protocol-specific health check
- field must be specified, which must match type field.
- returned: success
- type: str
-httpHealthCheck:
- description:
- - A nested object resource.
- returned: success
- type: complex
- contains:
- host:
- description:
- - The value of the host header in the HTTP health check request.
- - If left empty (default value), the public IP on behalf of which this health
- check is performed will be used.
- returned: success
- type: str
- requestPath:
- description:
- - The request path of the HTTP health check request.
- - The default value is /.
- returned: success
- type: str
- response:
- description:
- - The bytes to match against the beginning of the response data. If left empty
- (the default value), any response will indicate health. The response data
- can only be ASCII.
- returned: success
- type: str
- port:
- description:
- - The TCP port number for the HTTP health check request.
- - The default value is 80.
- returned: success
- type: int
- portName:
- description:
- - Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name
- are defined, port takes precedence.
- returned: success
- type: str
- proxyHeader:
- description:
- - Specifies the type of proxy header to append before sending data to the backend,
- either NONE or PROXY_V1. The default is NONE.
- returned: success
- type: str
- portSpecification:
- description:
- - 'Specifies how port is selected for health checking, can be one of the following
- values: * `USE_FIXED_PORT`: The port number in `port` is used for health checking.'
- - "* `USE_NAMED_PORT`: The `portName` is used for health checking."
- - "* `USE_SERVING_PORT`: For NetworkEndpointGroup, the port specified for each
- network endpoint is used for health checking. For other backends, the port
- or named port specified in the Backend Service is used for health checking."
- - If not specified, HTTP health check follows behavior specified in `port` and
- `portName` fields.
- returned: success
- type: str
-httpsHealthCheck:
- description:
- - A nested object resource.
- returned: success
- type: complex
- contains:
- host:
- description:
- - The value of the host header in the HTTPS health check request.
- - If left empty (default value), the public IP on behalf of which this health
- check is performed will be used.
- returned: success
- type: str
- requestPath:
- description:
- - The request path of the HTTPS health check request.
- - The default value is /.
- returned: success
- type: str
- response:
- description:
- - The bytes to match against the beginning of the response data. If left empty
- (the default value), any response will indicate health. The response data
- can only be ASCII.
- returned: success
- type: str
- port:
- description:
- - The TCP port number for the HTTPS health check request.
- - The default value is 443.
- returned: success
- type: int
- portName:
- description:
- - Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name
- are defined, port takes precedence.
- returned: success
- type: str
- proxyHeader:
- description:
- - Specifies the type of proxy header to append before sending data to the backend,
- either NONE or PROXY_V1. The default is NONE.
- returned: success
- type: str
- portSpecification:
- description:
- - 'Specifies how port is selected for health checking, can be one of the following
- values: * `USE_FIXED_PORT`: The port number in `port` is used for health checking.'
- - "* `USE_NAMED_PORT`: The `portName` is used for health checking."
- - "* `USE_SERVING_PORT`: For NetworkEndpointGroup, the port specified for each
- network endpoint is used for health checking. For other backends, the port
- or named port specified in the Backend Service is used for health checking."
- - If not specified, HTTPS health check follows behavior specified in `port`
- and `portName` fields.
- returned: success
- type: str
-tcpHealthCheck:
- description:
- - A nested object resource.
- returned: success
- type: complex
- contains:
- request:
- description:
- - The application data to send once the TCP connection has been established
- (default value is empty). If both request and response are empty, the connection
- establishment alone will indicate health. The request data can only be ASCII.
- returned: success
- type: str
- response:
- description:
- - The bytes to match against the beginning of the response data. If left empty
- (the default value), any response will indicate health. The response data
- can only be ASCII.
- returned: success
- type: str
- port:
- description:
- - The TCP port number for the TCP health check request.
- - The default value is 443.
- returned: success
- type: int
- portName:
- description:
- - Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name
- are defined, port takes precedence.
- returned: success
- type: str
- proxyHeader:
- description:
- - Specifies the type of proxy header to append before sending data to the backend,
- either NONE or PROXY_V1. The default is NONE.
- returned: success
- type: str
- portSpecification:
- description:
- - 'Specifies how port is selected for health checking, can be one of the following
- values: * `USE_FIXED_PORT`: The port number in `port` is used for health checking.'
- - "* `USE_NAMED_PORT`: The `portName` is used for health checking."
- - "* `USE_SERVING_PORT`: For NetworkEndpointGroup, the port specified for each
- network endpoint is used for health checking. For other backends, the port
- or named port specified in the Backend Service is used for health checking."
- - If not specified, TCP health check follows behavior specified in `port` and
- `portName` fields.
- returned: success
- type: str
-sslHealthCheck:
- description:
- - A nested object resource.
- returned: success
- type: complex
- contains:
- request:
- description:
- - The application data to send once the SSL connection has been established
- (default value is empty). If both request and response are empty, the connection
- establishment alone will indicate health. The request data can only be ASCII.
- returned: success
- type: str
- response:
- description:
- - The bytes to match against the beginning of the response data. If left empty
- (the default value), any response will indicate health. The response data
- can only be ASCII.
- returned: success
- type: str
- port:
- description:
- - The TCP port number for the SSL health check request.
- - The default value is 443.
- returned: success
- type: int
- portName:
- description:
- - Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name
- are defined, port takes precedence.
- returned: success
- type: str
- proxyHeader:
- description:
- - Specifies the type of proxy header to append before sending data to the backend,
- either NONE or PROXY_V1. The default is NONE.
- returned: success
- type: str
- portSpecification:
- description:
- - 'Specifies how port is selected for health checking, can be one of the following
- values: * `USE_FIXED_PORT`: The port number in `port` is used for health checking.'
- - "* `USE_NAMED_PORT`: The `portName` is used for health checking."
- - "* `USE_SERVING_PORT`: For NetworkEndpointGroup, the port specified for each
- network endpoint is used for health checking. For other backends, the port
- or named port specified in the Backend Service is used for health checking."
- - If not specified, SSL health check follows behavior specified in `port` and
- `portName` fields.
- returned: success
- type: str
-http2HealthCheck:
- description:
- - A nested object resource.
- returned: success
- type: complex
- contains:
- host:
- description:
- - The value of the host header in the HTTP2 health check request.
- - If left empty (default value), the public IP on behalf of which this health
- check is performed will be used.
- returned: success
- type: str
- requestPath:
- description:
- - The request path of the HTTP2 health check request.
- - The default value is /.
- returned: success
- type: str
- response:
- description:
- - The bytes to match against the beginning of the response data. If left empty
- (the default value), any response will indicate health. The response data
- can only be ASCII.
- returned: success
- type: str
- port:
- description:
- - The TCP port number for the HTTP2 health check request.
- - The default value is 443.
- returned: success
- type: int
- portName:
- description:
- - Port name as defined in InstanceGroup#NamedPort#name. If both port and port_name
- are defined, port takes precedence.
- returned: success
- type: str
- proxyHeader:
- description:
- - Specifies the type of proxy header to append before sending data to the backend,
- either NONE or PROXY_V1. The default is NONE.
- returned: success
- type: str
- portSpecification:
- description:
- - 'Specifies how port is selected for health checking, can be one of the following
- values: * `USE_FIXED_PORT`: The port number in `port` is used for health checking.'
- - "* `USE_NAMED_PORT`: The `portName` is used for health checking."
- - "* `USE_SERVING_PORT`: For NetworkEndpointGroup, the port specified for each
- network endpoint is used for health checking. For other backends, the port
- or named port specified in the Backend Service is used for health checking."
- - If not specified, HTTP2 health check follows behavior specified in `port`
- and `portName` fields.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- check_interval_sec=dict(default=5, type='int'),
- description=dict(type='str'),
- healthy_threshold=dict(default=2, type='int'),
- name=dict(required=True, type='str'),
- timeout_sec=dict(default=5, type='int', aliases=['timeout_seconds']),
- unhealthy_threshold=dict(default=2, type='int'),
- type=dict(type='str'),
- http_health_check=dict(
- type='dict',
- options=dict(
- host=dict(type='str'),
- request_path=dict(default='/', type='str'),
- response=dict(type='str'),
- port=dict(type='int'),
- port_name=dict(type='str'),
- proxy_header=dict(default='NONE', type='str'),
- port_specification=dict(type='str'),
- ),
- ),
- https_health_check=dict(
- type='dict',
- options=dict(
- host=dict(type='str'),
- request_path=dict(default='/', type='str'),
- response=dict(type='str'),
- port=dict(type='int'),
- port_name=dict(type='str'),
- proxy_header=dict(default='NONE', type='str'),
- port_specification=dict(type='str'),
- ),
- ),
- tcp_health_check=dict(
- type='dict',
- options=dict(
- request=dict(type='str'),
- response=dict(type='str'),
- port=dict(type='int'),
- port_name=dict(type='str'),
- proxy_header=dict(default='NONE', type='str'),
- port_specification=dict(type='str'),
- ),
- ),
- ssl_health_check=dict(
- type='dict',
- options=dict(
- request=dict(type='str'),
- response=dict(type='str'),
- port=dict(type='int'),
- port_name=dict(type='str'),
- proxy_header=dict(default='NONE', type='str'),
- port_specification=dict(type='str'),
- ),
- ),
- http2_health_check=dict(
- type='dict',
- options=dict(
- host=dict(type='str'),
- request_path=dict(default='/', type='str'),
- response=dict(type='str'),
- port=dict(type='int'),
- port_name=dict(type='str'),
- proxy_header=dict(default='NONE', type='str'),
- port_specification=dict(type='str'),
- ),
- ),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#healthCheck'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.put(link, resource_to_request(module)))
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#healthCheck',
- u'checkIntervalSec': module.params.get('check_interval_sec'),
- u'description': module.params.get('description'),
- u'healthyThreshold': module.params.get('healthy_threshold'),
- u'name': module.params.get('name'),
- u'timeoutSec': module.params.get('timeout_sec'),
- u'unhealthyThreshold': module.params.get('unhealthy_threshold'),
- u'type': module.params.get('type'),
- u'httpHealthCheck': HealthCheckHttphealthcheck(module.params.get('http_health_check', {}), module).to_request(),
- u'httpsHealthCheck': HealthCheckHttpshealthcheck(module.params.get('https_health_check', {}), module).to_request(),
- u'tcpHealthCheck': HealthCheckTcphealthcheck(module.params.get('tcp_health_check', {}), module).to_request(),
- u'sslHealthCheck': HealthCheckSslhealthcheck(module.params.get('ssl_health_check', {}), module).to_request(),
- u'http2HealthCheck': HealthCheckHttp2healthcheck(module.params.get('http2_health_check', {}), module).to_request(),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/healthChecks/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/healthChecks".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'checkIntervalSec': response.get(u'checkIntervalSec'),
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'description': response.get(u'description'),
- u'healthyThreshold': response.get(u'healthyThreshold'),
- u'id': response.get(u'id'),
- u'name': module.params.get('name'),
- u'timeoutSec': response.get(u'timeoutSec'),
- u'unhealthyThreshold': response.get(u'unhealthyThreshold'),
- u'type': response.get(u'type'),
- u'httpHealthCheck': HealthCheckHttphealthcheck(response.get(u'httpHealthCheck', {}), module).from_response(),
- u'httpsHealthCheck': HealthCheckHttpshealthcheck(response.get(u'httpsHealthCheck', {}), module).from_response(),
- u'tcpHealthCheck': HealthCheckTcphealthcheck(response.get(u'tcpHealthCheck', {}), module).from_response(),
- u'sslHealthCheck': HealthCheckSslhealthcheck(response.get(u'sslHealthCheck', {}), module).from_response(),
- u'http2HealthCheck': HealthCheckHttp2healthcheck(response.get(u'http2HealthCheck', {}), module).from_response(),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/global/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#healthCheck')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-class HealthCheckHttphealthcheck(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'host': self.request.get('host'),
- u'requestPath': self.request.get('request_path'),
- u'response': self.request.get('response'),
- u'port': self.request.get('port'),
- u'portName': self.request.get('port_name'),
- u'proxyHeader': self.request.get('proxy_header'),
- u'portSpecification': self.request.get('port_specification'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'host': self.request.get(u'host'),
- u'requestPath': self.request.get(u'requestPath'),
- u'response': self.request.get(u'response'),
- u'port': self.request.get(u'port'),
- u'portName': self.request.get(u'portName'),
- u'proxyHeader': self.request.get(u'proxyHeader'),
- u'portSpecification': self.request.get(u'portSpecification'),
- }
- )
-
-
-class HealthCheckHttpshealthcheck(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'host': self.request.get('host'),
- u'requestPath': self.request.get('request_path'),
- u'response': self.request.get('response'),
- u'port': self.request.get('port'),
- u'portName': self.request.get('port_name'),
- u'proxyHeader': self.request.get('proxy_header'),
- u'portSpecification': self.request.get('port_specification'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'host': self.request.get(u'host'),
- u'requestPath': self.request.get(u'requestPath'),
- u'response': self.request.get(u'response'),
- u'port': self.request.get(u'port'),
- u'portName': self.request.get(u'portName'),
- u'proxyHeader': self.request.get(u'proxyHeader'),
- u'portSpecification': self.request.get(u'portSpecification'),
- }
- )
-
-
-class HealthCheckTcphealthcheck(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'request': self.request.get('request'),
- u'response': self.request.get('response'),
- u'port': self.request.get('port'),
- u'portName': self.request.get('port_name'),
- u'proxyHeader': self.request.get('proxy_header'),
- u'portSpecification': self.request.get('port_specification'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'request': self.request.get(u'request'),
- u'response': self.request.get(u'response'),
- u'port': self.request.get(u'port'),
- u'portName': self.request.get(u'portName'),
- u'proxyHeader': self.request.get(u'proxyHeader'),
- u'portSpecification': self.request.get(u'portSpecification'),
- }
- )
-
-
-class HealthCheckSslhealthcheck(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'request': self.request.get('request'),
- u'response': self.request.get('response'),
- u'port': self.request.get('port'),
- u'portName': self.request.get('port_name'),
- u'proxyHeader': self.request.get('proxy_header'),
- u'portSpecification': self.request.get('port_specification'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'request': self.request.get(u'request'),
- u'response': self.request.get(u'response'),
- u'port': self.request.get(u'port'),
- u'portName': self.request.get(u'portName'),
- u'proxyHeader': self.request.get(u'proxyHeader'),
- u'portSpecification': self.request.get(u'portSpecification'),
- }
- )
-
-
-class HealthCheckHttp2healthcheck(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'host': self.request.get('host'),
- u'requestPath': self.request.get('request_path'),
- u'response': self.request.get('response'),
- u'port': self.request.get('port'),
- u'portName': self.request.get('port_name'),
- u'proxyHeader': self.request.get('proxy_header'),
- u'portSpecification': self.request.get('port_specification'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'host': self.request.get(u'host'),
- u'requestPath': self.request.get(u'requestPath'),
- u'response': self.request.get(u'response'),
- u'port': self.request.get(u'port'),
- u'portName': self.request.get(u'portName'),
- u'proxyHeader': self.request.get(u'proxyHeader'),
- u'portSpecification': self.request.get(u'portSpecification'),
- }
- )
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_health_check_info.py b/lib/ansible/modules/cloud/google/gcp_compute_health_check_info.py
deleted file mode 100644
index 5aa7d70a5e..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_health_check_info.py
+++ /dev/null
@@ -1,525 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_health_check_info
-description:
-- Gather info for GCP HealthCheck
-short_description: Gather info for GCP HealthCheck
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a health check
- gcp_compute_health_check_info:
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- checkIntervalSec:
- description:
- - How often (in seconds) to send a health check. The default value is 5 seconds.
- returned: success
- type: int
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- returned: success
- type: str
- healthyThreshold:
- description:
- - A so-far unhealthy instance will be marked healthy after this many consecutive
- successes. The default value is 2.
- returned: success
- type: int
- id:
- description:
- - The unique identifier for the resource. This identifier is defined by the
- server.
- returned: success
- type: int
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created.
- The name must be 1-63 characters long, and comply with RFC1035. Specifically,
- the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
- timeoutSec:
- description:
- - How long (in seconds) to wait before claiming failure.
- - The default value is 5 seconds. It is invalid for timeoutSec to have greater
- value than checkIntervalSec.
- returned: success
- type: int
- unhealthyThreshold:
- description:
- - A so-far healthy instance will be marked unhealthy after this many consecutive
- failures. The default value is 2.
- returned: success
- type: int
- type:
- description:
- - Specifies the type of the healthCheck, either TCP, SSL, HTTP or HTTPS. If
- not specified, the default is TCP. Exactly one of the protocol-specific health
- check field must be specified, which must match type field.
- returned: success
- type: str
- httpHealthCheck:
- description:
- - A nested object resource.
- returned: success
- type: complex
- contains:
- host:
- description:
- - The value of the host header in the HTTP health check request.
- - If left empty (default value), the public IP on behalf of which this health
- check is performed will be used.
- returned: success
- type: str
- requestPath:
- description:
- - The request path of the HTTP health check request.
- - The default value is /.
- returned: success
- type: str
- response:
- description:
- - The bytes to match against the beginning of the response data. If left
- empty (the default value), any response will indicate health. The response
- data can only be ASCII.
- returned: success
- type: str
- port:
- description:
- - The TCP port number for the HTTP health check request.
- - The default value is 80.
- returned: success
- type: int
- portName:
- description:
- - Port name as defined in InstanceGroup#NamedPort#name. If both port and
- port_name are defined, port takes precedence.
- returned: success
- type: str
- proxyHeader:
- description:
- - Specifies the type of proxy header to append before sending data to the
- backend, either NONE or PROXY_V1. The default is NONE.
- returned: success
- type: str
- portSpecification:
- description:
- - 'Specifies how port is selected for health checking, can be one of the
- following values: * `USE_FIXED_PORT`: The port number in `port` is used
- for health checking.'
- - "* `USE_NAMED_PORT`: The `portName` is used for health checking."
- - "* `USE_SERVING_PORT`: For NetworkEndpointGroup, the port specified for
- each network endpoint is used for health checking. For other backends,
- the port or named port specified in the Backend Service is used for health
- checking."
- - If not specified, HTTP health check follows behavior specified in `port`
- and `portName` fields.
- returned: success
- type: str
- httpsHealthCheck:
- description:
- - A nested object resource.
- returned: success
- type: complex
- contains:
- host:
- description:
- - The value of the host header in the HTTPS health check request.
- - If left empty (default value), the public IP on behalf of which this health
- check is performed will be used.
- returned: success
- type: str
- requestPath:
- description:
- - The request path of the HTTPS health check request.
- - The default value is /.
- returned: success
- type: str
- response:
- description:
- - The bytes to match against the beginning of the response data. If left
- empty (the default value), any response will indicate health. The response
- data can only be ASCII.
- returned: success
- type: str
- port:
- description:
- - The TCP port number for the HTTPS health check request.
- - The default value is 443.
- returned: success
- type: int
- portName:
- description:
- - Port name as defined in InstanceGroup#NamedPort#name. If both port and
- port_name are defined, port takes precedence.
- returned: success
- type: str
- proxyHeader:
- description:
- - Specifies the type of proxy header to append before sending data to the
- backend, either NONE or PROXY_V1. The default is NONE.
- returned: success
- type: str
- portSpecification:
- description:
- - 'Specifies how port is selected for health checking, can be one of the
- following values: * `USE_FIXED_PORT`: The port number in `port` is used
- for health checking.'
- - "* `USE_NAMED_PORT`: The `portName` is used for health checking."
- - "* `USE_SERVING_PORT`: For NetworkEndpointGroup, the port specified for
- each network endpoint is used for health checking. For other backends,
- the port or named port specified in the Backend Service is used for health
- checking."
- - If not specified, HTTPS health check follows behavior specified in `port`
- and `portName` fields.
- returned: success
- type: str
- tcpHealthCheck:
- description:
- - A nested object resource.
- returned: success
- type: complex
- contains:
- request:
- description:
- - The application data to send once the TCP connection has been established
- (default value is empty). If both request and response are empty, the
- connection establishment alone will indicate health. The request data
- can only be ASCII.
- returned: success
- type: str
- response:
- description:
- - The bytes to match against the beginning of the response data. If left
- empty (the default value), any response will indicate health. The response
- data can only be ASCII.
- returned: success
- type: str
- port:
- description:
- - The TCP port number for the TCP health check request.
- - The default value is 443.
- returned: success
- type: int
- portName:
- description:
- - Port name as defined in InstanceGroup#NamedPort#name. If both port and
- port_name are defined, port takes precedence.
- returned: success
- type: str
- proxyHeader:
- description:
- - Specifies the type of proxy header to append before sending data to the
- backend, either NONE or PROXY_V1. The default is NONE.
- returned: success
- type: str
- portSpecification:
- description:
- - 'Specifies how port is selected for health checking, can be one of the
- following values: * `USE_FIXED_PORT`: The port number in `port` is used
- for health checking.'
- - "* `USE_NAMED_PORT`: The `portName` is used for health checking."
- - "* `USE_SERVING_PORT`: For NetworkEndpointGroup, the port specified for
- each network endpoint is used for health checking. For other backends,
- the port or named port specified in the Backend Service is used for health
- checking."
- - If not specified, TCP health check follows behavior specified in `port`
- and `portName` fields.
- returned: success
- type: str
- sslHealthCheck:
- description:
- - A nested object resource.
- returned: success
- type: complex
- contains:
- request:
- description:
- - The application data to send once the SSL connection has been established
- (default value is empty). If both request and response are empty, the
- connection establishment alone will indicate health. The request data
- can only be ASCII.
- returned: success
- type: str
- response:
- description:
- - The bytes to match against the beginning of the response data. If left
- empty (the default value), any response will indicate health. The response
- data can only be ASCII.
- returned: success
- type: str
- port:
- description:
- - The TCP port number for the SSL health check request.
- - The default value is 443.
- returned: success
- type: int
- portName:
- description:
- - Port name as defined in InstanceGroup#NamedPort#name. If both port and
- port_name are defined, port takes precedence.
- returned: success
- type: str
- proxyHeader:
- description:
- - Specifies the type of proxy header to append before sending data to the
- backend, either NONE or PROXY_V1. The default is NONE.
- returned: success
- type: str
- portSpecification:
- description:
- - 'Specifies how port is selected for health checking, can be one of the
- following values: * `USE_FIXED_PORT`: The port number in `port` is used
- for health checking.'
- - "* `USE_NAMED_PORT`: The `portName` is used for health checking."
- - "* `USE_SERVING_PORT`: For NetworkEndpointGroup, the port specified for
- each network endpoint is used for health checking. For other backends,
- the port or named port specified in the Backend Service is used for health
- checking."
- - If not specified, SSL health check follows behavior specified in `port`
- and `portName` fields.
- returned: success
- type: str
- http2HealthCheck:
- description:
- - A nested object resource.
- returned: success
- type: complex
- contains:
- host:
- description:
- - The value of the host header in the HTTP2 health check request.
- - If left empty (default value), the public IP on behalf of which this health
- check is performed will be used.
- returned: success
- type: str
- requestPath:
- description:
- - The request path of the HTTP2 health check request.
- - The default value is /.
- returned: success
- type: str
- response:
- description:
- - The bytes to match against the beginning of the response data. If left
- empty (the default value), any response will indicate health. The response
- data can only be ASCII.
- returned: success
- type: str
- port:
- description:
- - The TCP port number for the HTTP2 health check request.
- - The default value is 443.
- returned: success
- type: int
- portName:
- description:
- - Port name as defined in InstanceGroup#NamedPort#name. If both port and
- port_name are defined, port takes precedence.
- returned: success
- type: str
- proxyHeader:
- description:
- - Specifies the type of proxy header to append before sending data to the
- backend, either NONE or PROXY_V1. The default is NONE.
- returned: success
- type: str
- portSpecification:
- description:
- - 'Specifies how port is selected for health checking, can be one of the
- following values: * `USE_FIXED_PORT`: The port number in `port` is used
- for health checking.'
- - "* `USE_NAMED_PORT`: The `portName` is used for health checking."
- - "* `USE_SERVING_PORT`: For NetworkEndpointGroup, the port specified for
- each network endpoint is used for health checking. For other backends,
- the port or named port specified in the Backend Service is used for health
- checking."
- - If not specified, HTTP2 health check follows behavior specified in `port`
- and `portName` fields.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/healthChecks".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_http_health_check.py b/lib/ansible/modules/cloud/google/gcp_compute_http_health_check.py
deleted file mode 100644
index 7a23611452..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_http_health_check.py
+++ /dev/null
@@ -1,458 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_http_health_check
-description:
-- An HttpHealthCheck resource. This resource defines a template for how individual
- VMs should be checked for health, via HTTP.
-short_description: Creates a GCP HttpHealthCheck
-version_added: '2.6'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- check_interval_sec:
- description:
- - How often (in seconds) to send a health check. The default value is 5 seconds.
- required: false
- default: '5'
- type: int
- aliases:
- - check_interval_seconds
- description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- required: false
- type: str
- healthy_threshold:
- description:
- - A so-far unhealthy instance will be marked healthy after this many consecutive
- successes. The default value is 2.
- required: false
- type: int
- host:
- description:
- - The value of the host header in the HTTP health check request. If left empty
- (default value), the public IP on behalf of which this health check is performed
- will be used.
- required: false
- type: str
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- required: true
- type: str
- port:
- description:
- - The TCP port number for the HTTP health check request.
- - The default value is 80.
- required: false
- type: int
- request_path:
- description:
- - The request path of the HTTP health check request.
- - The default value is /.
- required: false
- type: str
- timeout_sec:
- description:
- - How long (in seconds) to wait before claiming failure.
- - The default value is 5 seconds. It is invalid for timeoutSec to have greater
- value than checkIntervalSec.
- required: false
- type: int
- aliases:
- - timeout_seconds
- unhealthy_threshold:
- description:
- - A so-far healthy instance will be marked unhealthy after this many consecutive
- failures. The default value is 2.
- required: false
- type: int
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/compute/docs/reference/v1/httpHealthChecks)'
-- 'Adding Health Checks: U(https://cloud.google.com/compute/docs/load-balancing/health-checks#legacy_health_checks)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a HTTP health check
- gcp_compute_http_health_check:
- name: test_object
- healthy_threshold: 10
- port: 8080
- timeout_sec: 2
- unhealthy_threshold: 5
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-checkIntervalSec:
- description:
- - How often (in seconds) to send a health check. The default value is 5 seconds.
- returned: success
- type: int
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- returned: success
- type: str
-healthyThreshold:
- description:
- - A so-far unhealthy instance will be marked healthy after this many consecutive
- successes. The default value is 2.
- returned: success
- type: int
-host:
- description:
- - The value of the host header in the HTTP health check request. If left empty (default
- value), the public IP on behalf of which this health check is performed will be
- used.
- returned: success
- type: str
-id:
- description:
- - The unique identifier for the resource. This identifier is defined by the server.
- returned: success
- type: int
-name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
-port:
- description:
- - The TCP port number for the HTTP health check request.
- - The default value is 80.
- returned: success
- type: int
-requestPath:
- description:
- - The request path of the HTTP health check request.
- - The default value is /.
- returned: success
- type: str
-timeoutSec:
- description:
- - How long (in seconds) to wait before claiming failure.
- - The default value is 5 seconds. It is invalid for timeoutSec to have greater value
- than checkIntervalSec.
- returned: success
- type: int
-unhealthyThreshold:
- description:
- - A so-far healthy instance will be marked unhealthy after this many consecutive
- failures. The default value is 2.
- returned: success
- type: int
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- check_interval_sec=dict(default=5, type='int', aliases=['check_interval_seconds']),
- description=dict(type='str'),
- healthy_threshold=dict(type='int'),
- host=dict(type='str'),
- name=dict(required=True, type='str'),
- port=dict(type='int'),
- request_path=dict(type='str'),
- timeout_sec=dict(type='int', aliases=['timeout_seconds']),
- unhealthy_threshold=dict(type='int'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#httpHealthCheck'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.put(link, resource_to_request(module)))
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#httpHealthCheck',
- u'checkIntervalSec': module.params.get('check_interval_sec'),
- u'description': module.params.get('description'),
- u'healthyThreshold': module.params.get('healthy_threshold'),
- u'host': module.params.get('host'),
- u'name': module.params.get('name'),
- u'port': module.params.get('port'),
- u'requestPath': module.params.get('request_path'),
- u'timeoutSec': module.params.get('timeout_sec'),
- u'unhealthyThreshold': module.params.get('unhealthy_threshold'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/httpHealthChecks/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/httpHealthChecks".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'checkIntervalSec': response.get(u'checkIntervalSec'),
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'description': response.get(u'description'),
- u'healthyThreshold': response.get(u'healthyThreshold'),
- u'host': response.get(u'host'),
- u'id': response.get(u'id'),
- u'name': module.params.get('name'),
- u'port': response.get(u'port'),
- u'requestPath': response.get(u'requestPath'),
- u'timeoutSec': response.get(u'timeoutSec'),
- u'unhealthyThreshold': response.get(u'unhealthyThreshold'),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/global/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#httpHealthCheck')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_http_health_check_info.py b/lib/ansible/modules/cloud/google/gcp_compute_http_health_check_info.py
deleted file mode 100644
index a1ec4c1df6..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_http_health_check_info.py
+++ /dev/null
@@ -1,257 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_http_health_check_info
-description:
-- Gather info for GCP HttpHealthCheck
-short_description: Gather info for GCP HttpHealthCheck
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a HTTP health check
- gcp_compute_http_health_check_info:
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- checkIntervalSec:
- description:
- - How often (in seconds) to send a health check. The default value is 5 seconds.
- returned: success
- type: int
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- returned: success
- type: str
- healthyThreshold:
- description:
- - A so-far unhealthy instance will be marked healthy after this many consecutive
- successes. The default value is 2.
- returned: success
- type: int
- host:
- description:
- - The value of the host header in the HTTP health check request. If left empty
- (default value), the public IP on behalf of which this health check is performed
- will be used.
- returned: success
- type: str
- id:
- description:
- - The unique identifier for the resource. This identifier is defined by the
- server.
- returned: success
- type: int
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created.
- The name must be 1-63 characters long, and comply with RFC1035. Specifically,
- the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
- port:
- description:
- - The TCP port number for the HTTP health check request.
- - The default value is 80.
- returned: success
- type: int
- requestPath:
- description:
- - The request path of the HTTP health check request.
- - The default value is /.
- returned: success
- type: str
- timeoutSec:
- description:
- - How long (in seconds) to wait before claiming failure.
- - The default value is 5 seconds. It is invalid for timeoutSec to have greater
- value than checkIntervalSec.
- returned: success
- type: int
- unhealthyThreshold:
- description:
- - A so-far healthy instance will be marked unhealthy after this many consecutive
- failures. The default value is 2.
- returned: success
- type: int
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/httpHealthChecks".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_https_health_check.py b/lib/ansible/modules/cloud/google/gcp_compute_https_health_check.py
deleted file mode 100644
index d8120a0f64..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_https_health_check.py
+++ /dev/null
@@ -1,455 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_https_health_check
-description:
-- An HttpsHealthCheck resource. This resource defines a template for how individual
- VMs should be checked for health, via HTTPS.
-short_description: Creates a GCP HttpsHealthCheck
-version_added: '2.6'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- check_interval_sec:
- description:
- - How often (in seconds) to send a health check. The default value is 5 seconds.
- required: false
- type: int
- description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- required: false
- type: str
- healthy_threshold:
- description:
- - A so-far unhealthy instance will be marked healthy after this many consecutive
- successes. The default value is 2.
- required: false
- type: int
- host:
- description:
- - The value of the host header in the HTTPS health check request. If left empty
- (default value), the public IP on behalf of which this health check is performed
- will be used.
- required: false
- type: str
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- required: true
- type: str
- port:
- description:
- - The TCP port number for the HTTPS health check request.
- - The default value is 80.
- required: false
- type: int
- request_path:
- description:
- - The request path of the HTTPS health check request.
- - The default value is /.
- required: false
- type: str
- timeout_sec:
- description:
- - How long (in seconds) to wait before claiming failure.
- - The default value is 5 seconds. It is invalid for timeoutSec to have greater
- value than checkIntervalSec.
- required: false
- type: int
- aliases:
- - timeout_seconds
- unhealthy_threshold:
- description:
- - A so-far healthy instance will be marked unhealthy after this many consecutive
- failures. The default value is 2.
- required: false
- type: int
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/compute/docs/reference/v1/httpsHealthChecks)'
-- 'Adding Health Checks: U(https://cloud.google.com/compute/docs/load-balancing/health-checks#legacy_health_checks)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a HTTPS health check
- gcp_compute_https_health_check:
- name: test_object
- healthy_threshold: 10
- port: 8080
- timeout_sec: 2
- unhealthy_threshold: 5
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-checkIntervalSec:
- description:
- - How often (in seconds) to send a health check. The default value is 5 seconds.
- returned: success
- type: int
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- returned: success
- type: str
-healthyThreshold:
- description:
- - A so-far unhealthy instance will be marked healthy after this many consecutive
- successes. The default value is 2.
- returned: success
- type: int
-host:
- description:
- - The value of the host header in the HTTPS health check request. If left empty
- (default value), the public IP on behalf of which this health check is performed
- will be used.
- returned: success
- type: str
-id:
- description:
- - The unique identifier for the resource. This identifier is defined by the server.
- returned: success
- type: int
-name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
-port:
- description:
- - The TCP port number for the HTTPS health check request.
- - The default value is 80.
- returned: success
- type: int
-requestPath:
- description:
- - The request path of the HTTPS health check request.
- - The default value is /.
- returned: success
- type: str
-timeoutSec:
- description:
- - How long (in seconds) to wait before claiming failure.
- - The default value is 5 seconds. It is invalid for timeoutSec to have greater value
- than checkIntervalSec.
- returned: success
- type: int
-unhealthyThreshold:
- description:
- - A so-far healthy instance will be marked unhealthy after this many consecutive
- failures. The default value is 2.
- returned: success
- type: int
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- check_interval_sec=dict(type='int'),
- description=dict(type='str'),
- healthy_threshold=dict(type='int'),
- host=dict(type='str'),
- name=dict(required=True, type='str'),
- port=dict(type='int'),
- request_path=dict(type='str'),
- timeout_sec=dict(type='int', aliases=['timeout_seconds']),
- unhealthy_threshold=dict(type='int'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#httpsHealthCheck'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.put(link, resource_to_request(module)))
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#httpsHealthCheck',
- u'checkIntervalSec': module.params.get('check_interval_sec'),
- u'description': module.params.get('description'),
- u'healthyThreshold': module.params.get('healthy_threshold'),
- u'host': module.params.get('host'),
- u'name': module.params.get('name'),
- u'port': module.params.get('port'),
- u'requestPath': module.params.get('request_path'),
- u'timeoutSec': module.params.get('timeout_sec'),
- u'unhealthyThreshold': module.params.get('unhealthy_threshold'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/httpsHealthChecks/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/httpsHealthChecks".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'checkIntervalSec': response.get(u'checkIntervalSec'),
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'description': response.get(u'description'),
- u'healthyThreshold': response.get(u'healthyThreshold'),
- u'host': response.get(u'host'),
- u'id': response.get(u'id'),
- u'name': module.params.get('name'),
- u'port': response.get(u'port'),
- u'requestPath': response.get(u'requestPath'),
- u'timeoutSec': response.get(u'timeoutSec'),
- u'unhealthyThreshold': response.get(u'unhealthyThreshold'),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/global/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#httpsHealthCheck')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_https_health_check_info.py b/lib/ansible/modules/cloud/google/gcp_compute_https_health_check_info.py
deleted file mode 100644
index 2628e3316b..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_https_health_check_info.py
+++ /dev/null
@@ -1,257 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_https_health_check_info
-description:
-- Gather info for GCP HttpsHealthCheck
-short_description: Gather info for GCP HttpsHealthCheck
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a HTTPS health check
- gcp_compute_https_health_check_info:
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- checkIntervalSec:
- description:
- - How often (in seconds) to send a health check. The default value is 5 seconds.
- returned: success
- type: int
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- returned: success
- type: str
- healthyThreshold:
- description:
- - A so-far unhealthy instance will be marked healthy after this many consecutive
- successes. The default value is 2.
- returned: success
- type: int
- host:
- description:
- - The value of the host header in the HTTPS health check request. If left empty
- (default value), the public IP on behalf of which this health check is performed
- will be used.
- returned: success
- type: str
- id:
- description:
- - The unique identifier for the resource. This identifier is defined by the
- server.
- returned: success
- type: int
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created.
- The name must be 1-63 characters long, and comply with RFC1035. Specifically,
- the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
- port:
- description:
- - The TCP port number for the HTTPS health check request.
- - The default value is 80.
- returned: success
- type: int
- requestPath:
- description:
- - The request path of the HTTPS health check request.
- - The default value is /.
- returned: success
- type: str
- timeoutSec:
- description:
- - How long (in seconds) to wait before claiming failure.
- - The default value is 5 seconds. It is invalid for timeoutSec to have greater
- value than checkIntervalSec.
- returned: success
- type: int
- unhealthyThreshold:
- description:
- - A so-far healthy instance will be marked unhealthy after this many consecutive
- failures. The default value is 2.
- returned: success
- type: int
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/httpsHealthChecks".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_image.py b/lib/ansible/modules/cloud/google/gcp_compute_image.py
deleted file mode 100644
index 4fdbecda5b..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_image.py
+++ /dev/null
@@ -1,818 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_image
-description:
-- Represents an Image resource.
-- Google Compute Engine uses operating system images to create the root persistent
- disks for your instances. You specify an image when you create an instance. Images
- contain a boot loader, an operating system, and a root file system. Linux operating
- system images are also capable of running containers on Compute Engine.
-- Images can be either public or custom.
-- Public images are provided and maintained by Google, open-source communities, and
- third-party vendors. By default, all projects have access to these images and can
- use them to create instances. Custom images are available only to your project.
- You can create a custom image from root persistent disks and other images. Then,
- use the custom image to create an instance.
-short_description: Creates a GCP Image
-version_added: '2.6'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- required: false
- type: str
- disk_size_gb:
- description:
- - Size of the image when restored onto a persistent disk (in GB).
- required: false
- type: int
- family:
- description:
- - The name of the image family to which this image belongs. You can create disks
- by specifying an image family instead of a specific image name. The image family
- always returns its latest image that is not deprecated. The name of the image
- family must comply with RFC1035.
- required: false
- type: str
- guest_os_features:
- description:
- - A list of features to enable on the guest operating system.
- - Applicable only for bootable images.
- required: false
- type: list
- suboptions:
- type:
- description:
- - The type of supported feature.
- - 'Some valid choices include: "MULTI_IP_SUBNET", "SECURE_BOOT", "UEFI_COMPATIBLE",
- "VIRTIO_SCSI_MULTIQUEUE", "WINDOWS"'
- required: true
- type: str
- image_encryption_key:
- description:
- - Encrypts the image using a customer-supplied encryption key.
- - After you encrypt an image with a customer-supplied key, you must provide the
- same key if you use the image later (e.g. to create a disk from the image) .
- required: false
- type: dict
- suboptions:
- raw_key:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
- base64 to either encrypt or decrypt this resource.
- required: false
- type: str
- labels:
- description:
- - Labels to apply to this Image.
- required: false
- type: dict
- version_added: '2.8'
- licenses:
- description:
- - Any applicable license URI.
- required: false
- type: list
- name:
- description:
- - Name of the resource; provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- required: true
- type: str
- raw_disk:
- description:
- - The parameters of the raw disk image.
- required: false
- type: dict
- suboptions:
- container_type:
- description:
- - The format used to encode and transmit the block device, which should be
- TAR. This is just a container and transmission format and not a runtime
- format. Provided by the client when the disk image is created.
- - 'Some valid choices include: "TAR"'
- required: false
- type: str
- sha1_checksum:
- description:
- - An optional SHA1 checksum of the disk image before unpackaging.
- - This is provided by the client when the disk image is created.
- required: false
- type: str
- source:
- description:
- - The full Google Cloud Storage URL where disk storage is stored You must
- provide either this property or the sourceDisk property but not both.
- required: true
- type: str
- source_disk:
- description:
- - The source disk to create this image based on.
- - You must provide either this property or the rawDisk.source property but not
- both to create an image.
- - 'This field represents a link to a Disk resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''selfLink'' and value
- of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
- to a gcp_compute_disk task and then set this source_disk field to "{{ name-of-resource
- }}"'
- required: false
- type: dict
- source_disk_encryption_key:
- description:
- - The customer-supplied encryption key of the source disk. Required if the source
- disk is protected by a customer-supplied encryption key.
- required: false
- type: dict
- suboptions:
- raw_key:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
- base64 to either encrypt or decrypt this resource.
- required: false
- type: str
- source_disk_id:
- description:
- - The ID value of the disk used to create this image. This value may be used to
- determine whether the image was taken from the current or a previous instance
- of a given disk name.
- required: false
- type: str
- source_type:
- description:
- - The type of the image used to create this disk. The default and only value is
- RAW .
- - 'Some valid choices include: "RAW"'
- required: false
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/compute/docs/reference/v1/images)'
-- 'Official Documentation: U(https://cloud.google.com/compute/docs/images)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a disk
- gcp_compute_disk:
- name: disk-image
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: disk
-
-- name: create a image
- gcp_compute_image:
- name: test_object
- source_disk: "{{ disk }}"
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-archiveSizeBytes:
- description:
- - Size of the image tar.gz archive stored in Google Cloud Storage (in bytes).
- returned: success
- type: int
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-deprecated:
- description:
- - The deprecation status associated with this image.
- returned: success
- type: complex
- contains:
- deleted:
- description:
- - An optional RFC3339 timestamp on or after which the state of this resource
- is intended to change to DELETED. This is only informational and the status
- will not change unless the client explicitly changes it.
- returned: success
- type: str
- deprecated:
- description:
- - An optional RFC3339 timestamp on or after which the state of this resource
- is intended to change to DEPRECATED. This is only informational and the status
- will not change unless the client explicitly changes it.
- returned: success
- type: str
- obsolete:
- description:
- - An optional RFC3339 timestamp on or after which the state of this resource
- is intended to change to OBSOLETE. This is only informational and the status
- will not change unless the client explicitly changes it.
- returned: success
- type: str
- replacement:
- description:
- - The URL of the suggested replacement for a deprecated resource.
- - The suggested replacement resource must be the same kind of resource as the
- deprecated resource.
- returned: success
- type: str
- state:
- description:
- - The deprecation state of this resource. This can be DEPRECATED, OBSOLETE,
- or DELETED. Operations which create a new resource using a DEPRECATED resource
- will return successfully, but with a warning indicating the deprecated resource
- and recommending its replacement. Operations which use OBSOLETE or DELETED
- resources will be rejected and result in an error.
- returned: success
- type: str
-description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- returned: success
- type: str
-diskSizeGb:
- description:
- - Size of the image when restored onto a persistent disk (in GB).
- returned: success
- type: int
-family:
- description:
- - The name of the image family to which this image belongs. You can create disks
- by specifying an image family instead of a specific image name. The image family
- always returns its latest image that is not deprecated. The name of the image
- family must comply with RFC1035.
- returned: success
- type: str
-guestOsFeatures:
- description:
- - A list of features to enable on the guest operating system.
- - Applicable only for bootable images.
- returned: success
- type: complex
- contains:
- type:
- description:
- - The type of supported feature.
- returned: success
- type: str
-id:
- description:
- - The unique identifier for the resource. This identifier is defined by the server.
- returned: success
- type: int
-imageEncryptionKey:
- description:
- - Encrypts the image using a customer-supplied encryption key.
- - After you encrypt an image with a customer-supplied key, you must provide the
- same key if you use the image later (e.g. to create a disk from the image) .
- returned: success
- type: complex
- contains:
- rawKey:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
- base64 to either encrypt or decrypt this resource.
- returned: success
- type: str
- sha256:
- description:
- - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
- key that protects this resource.
- returned: success
- type: str
-labels:
- description:
- - Labels to apply to this Image.
- returned: success
- type: dict
-labelFingerprint:
- description:
- - The fingerprint used for optimistic locking of this resource. Used internally
- during updates.
- returned: success
- type: str
-licenses:
- description:
- - Any applicable license URI.
- returned: success
- type: list
-name:
- description:
- - Name of the resource; provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
-rawDisk:
- description:
- - The parameters of the raw disk image.
- returned: success
- type: complex
- contains:
- containerType:
- description:
- - The format used to encode and transmit the block device, which should be TAR.
- This is just a container and transmission format and not a runtime format.
- Provided by the client when the disk image is created.
- returned: success
- type: str
- sha1Checksum:
- description:
- - An optional SHA1 checksum of the disk image before unpackaging.
- - This is provided by the client when the disk image is created.
- returned: success
- type: str
- source:
- description:
- - The full Google Cloud Storage URL where disk storage is stored You must provide
- either this property or the sourceDisk property but not both.
- returned: success
- type: str
-sourceDisk:
- description:
- - The source disk to create this image based on.
- - You must provide either this property or the rawDisk.source property but not both
- to create an image.
- returned: success
- type: dict
-sourceDiskEncryptionKey:
- description:
- - The customer-supplied encryption key of the source disk. Required if the source
- disk is protected by a customer-supplied encryption key.
- returned: success
- type: complex
- contains:
- rawKey:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
- base64 to either encrypt or decrypt this resource.
- returned: success
- type: str
- sha256:
- description:
- - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
- key that protects this resource.
- returned: success
- type: str
-sourceDiskId:
- description:
- - The ID value of the disk used to create this image. This value may be used to
- determine whether the image was taken from the current or a previous instance
- of a given disk name.
- returned: success
- type: str
-sourceType:
- description:
- - The type of the image used to create this disk. The default and only value is
- RAW .
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import re
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- description=dict(type='str'),
- disk_size_gb=dict(type='int'),
- family=dict(type='str'),
- guest_os_features=dict(type='list', elements='dict', options=dict(type=dict(required=True, type='str'))),
- image_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'))),
- labels=dict(type='dict'),
- licenses=dict(type='list', elements='str'),
- name=dict(required=True, type='str'),
- raw_disk=dict(type='dict', options=dict(container_type=dict(type='str'), sha1_checksum=dict(type='str'), source=dict(required=True, type='str'))),
- source_disk=dict(type='dict'),
- source_disk_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'))),
- source_disk_id=dict(type='str'),
- source_type=dict(type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#image'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind, fetch)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind, fetch):
- update_fields(module, resource_to_request(module), response_to_hash(module, fetch))
- return fetch_resource(module, self_link(module), kind)
-
-
-def update_fields(module, request, response):
- if response.get('labels') != request.get('labels'):
- labels_update(module, request, response)
-
-
-def labels_update(module, request, response):
- auth = GcpSession(module, 'compute')
- auth.post(
- ''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/global/images/{name}/setLabels"]).format(**module.params),
- {u'labels': module.params.get('labels'), u'labelFingerprint': response.get('labelFingerprint')},
- )
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#image',
- u'description': module.params.get('description'),
- u'diskSizeGb': module.params.get('disk_size_gb'),
- u'family': module.params.get('family'),
- u'guestOsFeatures': ImageGuestosfeaturesArray(module.params.get('guest_os_features', []), module).to_request(),
- u'imageEncryptionKey': ImageImageencryptionkey(module.params.get('image_encryption_key', {}), module).to_request(),
- u'labels': module.params.get('labels'),
- u'licenses': module.params.get('licenses'),
- u'name': module.params.get('name'),
- u'rawDisk': ImageRawdisk(module.params.get('raw_disk', {}), module).to_request(),
- u'sourceDisk': replace_resource_dict(module.params.get(u'source_disk', {}), 'selfLink'),
- u'sourceDiskEncryptionKey': ImageSourcediskencryptionkey(module.params.get('source_disk_encryption_key', {}), module).to_request(),
- u'sourceDiskId': module.params.get('source_disk_id'),
- u'sourceType': module.params.get('source_type'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/images/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/images".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'archiveSizeBytes': response.get(u'archiveSizeBytes'),
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'deprecated': ImageDeprecated(response.get(u'deprecated', {}), module).from_response(),
- u'description': response.get(u'description'),
- u'diskSizeGb': response.get(u'diskSizeGb'),
- u'family': response.get(u'family'),
- u'guestOsFeatures': ImageGuestosfeaturesArray(response.get(u'guestOsFeatures', []), module).from_response(),
- u'id': response.get(u'id'),
- u'imageEncryptionKey': ImageImageencryptionkey(response.get(u'imageEncryptionKey', {}), module).from_response(),
- u'labels': response.get(u'labels'),
- u'labelFingerprint': response.get(u'labelFingerprint'),
- u'licenses': response.get(u'licenses'),
- u'name': response.get(u'name'),
- u'rawDisk': ImageRawdisk(response.get(u'rawDisk', {}), module).from_response(),
- u'sourceDisk': response.get(u'sourceDisk'),
- u'sourceDiskEncryptionKey': ImageSourcediskencryptionkey(response.get(u'sourceDiskEncryptionKey', {}), module).from_response(),
- u'sourceDiskId': response.get(u'sourceDiskId'),
- u'sourceType': response.get(u'sourceType'),
- }
-
-
-def license_selflink(name, params):
- if name is None:
- return
- url = r"https://www.googleapis.com/compute/v1//projects/.*/global/licenses/.*"
- if not re.match(url, name):
- name = "https://www.googleapis.com/compute/v1//projects/{project}/global/licenses/%s".format(**params) % name
- return name
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/global/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#image')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-class ImageDeprecated(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'deleted': self.request.get('deleted'),
- u'deprecated': self.request.get('deprecated'),
- u'obsolete': self.request.get('obsolete'),
- u'replacement': self.request.get('replacement'),
- u'state': self.request.get('state'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'deleted': self.request.get(u'deleted'),
- u'deprecated': self.request.get(u'deprecated'),
- u'obsolete': self.request.get(u'obsolete'),
- u'replacement': self.request.get(u'replacement'),
- u'state': self.request.get(u'state'),
- }
- )
-
-
-class ImageGuestosfeaturesArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'type': item.get('type')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'type': item.get(u'type')})
-
-
-class ImageImageencryptionkey(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'rawKey': self.request.get('raw_key')})
-
- def from_response(self):
- return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey')})
-
-
-class ImageRawdisk(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {u'containerType': self.request.get('container_type'), u'sha1Checksum': self.request.get('sha1_checksum'), u'source': self.request.get('source')}
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {u'containerType': self.request.get(u'containerType'), u'sha1Checksum': self.request.get(u'sha1Checksum'), u'source': self.request.get(u'source')}
- )
-
-
-class ImageSourcediskencryptionkey(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'rawKey': self.request.get('raw_key')})
-
- def from_response(self):
- return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey')})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_image_info.py b/lib/ansible/modules/cloud/google/gcp_compute_image_info.py
deleted file mode 100644
index 729b034b48..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_image_info.py
+++ /dev/null
@@ -1,388 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_image_info
-description:
-- Gather info for GCP Image
-short_description: Gather info for GCP Image
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on an image
- gcp_compute_image_info:
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- archiveSizeBytes:
- description:
- - Size of the image tar.gz archive stored in Google Cloud Storage (in bytes).
- returned: success
- type: int
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- deprecated:
- description:
- - The deprecation status associated with this image.
- returned: success
- type: complex
- contains:
- deleted:
- description:
- - An optional RFC3339 timestamp on or after which the state of this resource
- is intended to change to DELETED. This is only informational and the status
- will not change unless the client explicitly changes it.
- returned: success
- type: str
- deprecated:
- description:
- - An optional RFC3339 timestamp on or after which the state of this resource
- is intended to change to DEPRECATED. This is only informational and the
- status will not change unless the client explicitly changes it.
- returned: success
- type: str
- obsolete:
- description:
- - An optional RFC3339 timestamp on or after which the state of this resource
- is intended to change to OBSOLETE. This is only informational and the
- status will not change unless the client explicitly changes it.
- returned: success
- type: str
- replacement:
- description:
- - The URL of the suggested replacement for a deprecated resource.
- - The suggested replacement resource must be the same kind of resource as
- the deprecated resource.
- returned: success
- type: str
- state:
- description:
- - The deprecation state of this resource. This can be DEPRECATED, OBSOLETE,
- or DELETED. Operations which create a new resource using a DEPRECATED
- resource will return successfully, but with a warning indicating the deprecated
- resource and recommending its replacement. Operations which use OBSOLETE
- or DELETED resources will be rejected and result in an error.
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- returned: success
- type: str
- diskSizeGb:
- description:
- - Size of the image when restored onto a persistent disk (in GB).
- returned: success
- type: int
- family:
- description:
- - The name of the image family to which this image belongs. You can create disks
- by specifying an image family instead of a specific image name. The image
- family always returns its latest image that is not deprecated. The name of
- the image family must comply with RFC1035.
- returned: success
- type: str
- guestOsFeatures:
- description:
- - A list of features to enable on the guest operating system.
- - Applicable only for bootable images.
- returned: success
- type: complex
- contains:
- type:
- description:
- - The type of supported feature.
- returned: success
- type: str
- id:
- description:
- - The unique identifier for the resource. This identifier is defined by the
- server.
- returned: success
- type: int
- imageEncryptionKey:
- description:
- - Encrypts the image using a customer-supplied encryption key.
- - After you encrypt an image with a customer-supplied key, you must provide
- the same key if you use the image later (e.g. to create a disk from the image)
- .
- returned: success
- type: complex
- contains:
- rawKey:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
- base64 to either encrypt or decrypt this resource.
- returned: success
- type: str
- sha256:
- description:
- - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
- key that protects this resource.
- returned: success
- type: str
- labels:
- description:
- - Labels to apply to this Image.
- returned: success
- type: dict
- labelFingerprint:
- description:
- - The fingerprint used for optimistic locking of this resource. Used internally
- during updates.
- returned: success
- type: str
- licenses:
- description:
- - Any applicable license URI.
- returned: success
- type: list
- name:
- description:
- - Name of the resource; provided by the client when the resource is created.
- The name must be 1-63 characters long, and comply with RFC1035. Specifically,
- the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
- rawDisk:
- description:
- - The parameters of the raw disk image.
- returned: success
- type: complex
- contains:
- containerType:
- description:
- - The format used to encode and transmit the block device, which should
- be TAR. This is just a container and transmission format and not a runtime
- format. Provided by the client when the disk image is created.
- returned: success
- type: str
- sha1Checksum:
- description:
- - An optional SHA1 checksum of the disk image before unpackaging.
- - This is provided by the client when the disk image is created.
- returned: success
- type: str
- source:
- description:
- - The full Google Cloud Storage URL where disk storage is stored You must
- provide either this property or the sourceDisk property but not both.
- returned: success
- type: str
- sourceDisk:
- description:
- - The source disk to create this image based on.
- - You must provide either this property or the rawDisk.source property but not
- both to create an image.
- returned: success
- type: dict
- sourceDiskEncryptionKey:
- description:
- - The customer-supplied encryption key of the source disk. Required if the source
- disk is protected by a customer-supplied encryption key.
- returned: success
- type: complex
- contains:
- rawKey:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
- base64 to either encrypt or decrypt this resource.
- returned: success
- type: str
- sha256:
- description:
- - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
- key that protects this resource.
- returned: success
- type: str
- sourceDiskId:
- description:
- - The ID value of the disk used to create this image. This value may be used
- to determine whether the image was taken from the current or a previous instance
- of a given disk name.
- returned: success
- type: str
- sourceType:
- description:
- - The type of the image used to create this disk. The default and only value
- is RAW .
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/images".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_instance.py b/lib/ansible/modules/cloud/google/gcp_compute_instance.py
deleted file mode 100644
index 4d4be472eb..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_instance.py
+++ /dev/null
@@ -1,1850 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_instance
-description:
-- An instance is a virtual machine (VM) hosted on Google's infrastructure.
-short_description: Creates a GCP Instance
-version_added: '2.6'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- can_ip_forward:
- description:
- - Allows this instance to send and receive packets with non-matching destination
- or source IPs. This is required if you plan to use this instance to forward
- routes.
- required: false
- type: bool
- aliases:
- - ip_forward
- deletion_protection:
- description:
- - Whether the resource should be protected against deletion.
- required: false
- type: bool
- version_added: '2.9'
- disks:
- description:
- - An array of disks that are associated with the instances that are created from
- this template.
- required: false
- type: list
- suboptions:
- auto_delete:
- description:
- - Specifies whether the disk will be auto-deleted when the instance is deleted
- (but not when the disk is detached from the instance).
- - 'Tip: Disks should be set to autoDelete=true so that leftover disks are
- not left behind on machine deletion.'
- required: false
- type: bool
- boot:
- description:
- - Indicates that this is a boot disk. The virtual machine will use the first
- partition of the disk for its root filesystem.
- required: false
- type: bool
- device_name:
- description:
- - Specifies a unique device name of your choice that is reflected into the
- /dev/disk/by-id/google-* tree of a Linux operating system running within
- the instance. This name can be used to reference the device for mounting,
- resizing, and so on, from within the instance.
- required: false
- type: str
- disk_encryption_key:
- description:
- - Encrypts or decrypts a disk using a customer-supplied encryption key.
- required: false
- type: dict
- suboptions:
- raw_key:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded in RFC
- 4648 base64 to either encrypt or decrypt this resource.
- required: false
- type: str
- rsa_encrypted_key:
- description:
- - Specifies an RFC 4648 base64 encoded, RSA-wrapped 2048-bit customer-supplied
- encryption key to either encrypt or decrypt this resource.
- required: false
- type: str
- index:
- description:
- - Assigns a zero-based index to this disk, where 0 is reserved for the boot
- disk. For example, if you have many disks attached to an instance, each
- disk would have a unique index number. If not specified, the server will
- choose an appropriate value.
- required: false
- type: int
- initialize_params:
- description:
- - Specifies the parameters for a new disk that will be created alongside the
- new instance. Use initialization parameters to create boot disks or local
- SSDs attached to the new instance.
- required: false
- type: dict
- suboptions:
- disk_name:
- description:
- - Specifies the disk name. If not specified, the default is to use the
- name of the instance.
- required: false
- type: str
- disk_size_gb:
- description:
- - Specifies the size of the disk in base-2 GB.
- required: false
- type: int
- disk_type:
- description:
- - Reference to a disk type.
- - Specifies the disk type to use to create the instance.
- - If not specified, the default is pd-standard.
- required: false
- type: str
- source_image:
- description:
- - The source image to create this disk. When creating a new instance,
- one of initializeParams.sourceImage or disks.source is required. To
- create a disk with one of the public operating system images, specify
- the image by its family name.
- required: false
- type: str
- aliases:
- - image
- - image_family
- source_image_encryption_key:
- description:
- - The customer-supplied encryption key of the source image. Required if
- the source image is protected by a customer-supplied encryption key.
- - Instance templates do not store customer-supplied encryption keys, so
- you cannot create disks for instances in a managed instance group if
- the source images are encrypted with your own keys.
- required: false
- type: dict
- suboptions:
- raw_key:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded in
- RFC 4648 base64 to either encrypt or decrypt this resource.
- required: false
- type: str
- interface:
- description:
- - Specifies the disk interface to use for attaching this disk, which is either
- SCSI or NVME. The default is SCSI.
- - Persistent disks must always use SCSI and the request will fail if you attempt
- to attach a persistent disk in any other format than SCSI.
- - 'Some valid choices include: "SCSI", "NVME"'
- required: false
- type: str
- mode:
- description:
- - The mode in which to attach this disk, either READ_WRITE or READ_ONLY. If
- not specified, the default is to attach the disk in READ_WRITE mode.
- - 'Some valid choices include: "READ_WRITE", "READ_ONLY"'
- required: false
- type: str
- source:
- description:
- - Reference to a disk. When creating a new instance, one of initializeParams.sourceImage
- or disks.source is required.
- - If desired, you can also attach existing non-root persistent disks using
- this property. This field is only applicable for persistent disks.
- - 'This field represents a link to a Disk resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''selfLink'' and
- value of your resource''s selfLink Alternatively, you can add `register:
- name-of-resource` to a gcp_compute_disk task and then set this source field
- to "{{ name-of-resource }}"'
- required: false
- type: dict
- type:
- description:
- - Specifies the type of the disk, either SCRATCH or PERSISTENT. If not specified,
- the default is PERSISTENT.
- - 'Some valid choices include: "SCRATCH", "PERSISTENT"'
- required: false
- type: str
- guest_accelerators:
- description:
- - List of the type and count of accelerator cards attached to the instance .
- required: false
- type: list
- suboptions:
- accelerator_count:
- description:
- - The number of the guest accelerator cards exposed to this instance.
- required: false
- type: int
- accelerator_type:
- description:
- - Full or partial URL of the accelerator type resource to expose to this instance.
- required: false
- type: str
- hostname:
- description:
- - The hostname of the instance to be created. The specified hostname must be RFC1035
- compliant. If hostname is not specified, the default hostname is [INSTANCE_NAME].c.[PROJECT_ID].internal
- when using the global DNS, and [INSTANCE_NAME].[ZONE].c.[PROJECT_ID].internal
- when using zonal DNS.
- required: false
- type: str
- version_added: '2.9'
- labels:
- description:
- - Labels to apply to this instance. A list of key->value pairs.
- required: false
- type: dict
- version_added: '2.9'
- metadata:
- description:
- - The metadata key/value pairs to assign to instances that are created from this
- template. These pairs can consist of custom metadata or predefined keys.
- required: false
- type: dict
- machine_type:
- description:
- - A reference to a machine type which defines VM kind.
- required: false
- type: str
- min_cpu_platform:
- description:
- - Specifies a minimum CPU platform for the VM instance. Applicable values are
- the friendly names of CPU platforms .
- required: false
- type: str
- name:
- description:
- - The name of the resource, provided by the client when initially creating the
- resource. The resource name must be 1-63 characters long, and comply with RFC1035.
- Specifically, the name must be 1-63 characters long and match the regular expression
- `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase
- letter, and all following characters must be a dash, lowercase letter, or digit,
- except the last character, which cannot be a dash.
- required: false
- type: str
- network_interfaces:
- description:
- - An array of configurations for this interface. This specifies how this interface
- is configured to interact with other network services, such as connecting to
- the internet. Only one network interface is supported per instance.
- required: false
- type: list
- suboptions:
- access_configs:
- description:
- - An array of configurations for this interface. Currently, only one access
- config, ONE_TO_ONE_NAT, is supported. If there are no accessConfigs specified,
- then this instance will have no external internet access.
- required: false
- type: list
- suboptions:
- name:
- description:
- - The name of this access configuration. The default and recommended name
- is External NAT but you can use any arbitrary string you would like.
- For example, My external IP or Network Access.
- required: true
- type: str
- nat_ip:
- description:
- - Reference to an address.
- - An external IP address associated with this instance.
- - Specify an unused static external IP address available to the project
- or leave this field undefined to use an IP from a shared ephemeral IP
- address pool. If you specify a static external IP address, it must live
- in the same region as the zone of the instance.
- - 'This field represents a link to a Address resource in GCP. It can be
- specified in two ways. First, you can place a dictionary with key ''address''
- and value of your resource''s address Alternatively, you can add `register:
- name-of-resource` to a gcp_compute_address task and then set this nat_ip
- field to "{{ name-of-resource }}"'
- required: false
- type: dict
- type:
- description:
- - The type of configuration. The default and only option is ONE_TO_ONE_NAT.
- - 'Some valid choices include: "ONE_TO_ONE_NAT"'
- required: true
- type: str
- set_public_ptr:
- description:
- - Specifies whether a public DNS PTR record should be created to map the
- external IP address of the instance to a DNS domain name.
- required: false
- type: bool
- version_added: '2.10'
- public_ptr_domain_name:
- description:
- - The DNS domain name for the public PTR record. You can set this field
- only if the setPublicPtr field is enabled.
- required: false
- type: str
- version_added: '2.10'
- network_tier:
- description:
- - This signifies the networking tier used for configuring this access
- configuration. If an AccessConfig is specified without a valid external
- IP address, an ephemeral IP will be created with this networkTier. If
- an AccessConfig with a valid external IP address is specified, it must
- match that of the networkTier associated with the Address resource owning
- that IP.
- - 'Some valid choices include: "PREMIUM", "STANDARD"'
- required: false
- type: str
- version_added: '2.10'
- alias_ip_ranges:
- description:
- - An array of alias IP ranges for this network interface. Can only be specified
- for network interfaces on subnet-mode networks.
- required: false
- type: list
- suboptions:
- ip_cidr_range:
- description:
- - The IP CIDR range represented by this alias IP range.
- - This IP CIDR range must belong to the specified subnetwork and cannot
- contain IP addresses reserved by system or used by other network interfaces.
- This range may be a single IP address (e.g. 10.2.3.4), a netmask (e.g.
- /24) or a CIDR format string (e.g. 10.1.2.0/24).
- required: false
- type: str
- subnetwork_range_name:
- description:
- - Optional subnetwork secondary range name specifying the secondary range
- from which to allocate the IP CIDR range for this alias IP range. If
- left unspecified, the primary range of the subnetwork will be used.
- required: false
- type: str
- network:
- description:
- - Specifies the title of an existing network. Not setting the network title
- will select the default network interface, which could have SSH already
- configured .
- - 'This field represents a link to a Network resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''selfLink'' and
- value of your resource''s selfLink Alternatively, you can add `register:
- name-of-resource` to a gcp_compute_network task and then set this network
- field to "{{ name-of-resource }}"'
- required: false
- type: dict
- network_ip:
- description:
- - An IPv4 internal network address to assign to the instance for this network
- interface. If not specified by the user, an unused internal IP is assigned
- by the system.
- required: false
- type: str
- subnetwork:
- description:
- - Reference to a VPC network.
- - If the network resource is in legacy mode, do not provide this property.
- If the network is in auto subnet mode, providing the subnetwork is optional.
- If the network is in custom subnet mode, then this field should be specified.
- - 'This field represents a link to a Subnetwork resource in GCP. It can be
- specified in two ways. First, you can place a dictionary with key ''selfLink''
- and value of your resource''s selfLink Alternatively, you can add `register:
- name-of-resource` to a gcp_compute_subnetwork task and then set this subnetwork
- field to "{{ name-of-resource }}"'
- required: false
- type: dict
- scheduling:
- description:
- - Sets the scheduling options for this instance.
- required: false
- type: dict
- suboptions:
- automatic_restart:
- description:
- - Specifies whether the instance should be automatically restarted if it is
- terminated by Compute Engine (not terminated by a user).
- - You can only set the automatic restart option for standard instances. Preemptible
- instances cannot be automatically restarted.
- required: false
- type: bool
- on_host_maintenance:
- description:
- - Defines the maintenance behavior for this instance. For standard instances,
- the default behavior is MIGRATE. For preemptible instances, the default
- and only possible behavior is TERMINATE.
- - For more information, see Setting Instance Scheduling Options.
- required: false
- type: str
- preemptible:
- description:
- - Defines whether the instance is preemptible. This can only be set during
- instance creation, it cannot be set or changed after the instance has been
- created.
- required: false
- type: bool
- service_accounts:
- description:
- - A list of service accounts, with their specified scopes, authorized for this
- instance. Only one service account per VM instance is supported.
- required: false
- type: list
- suboptions:
- email:
- description:
- - Email address of the service account.
- required: false
- type: str
- scopes:
- description:
- - The list of scopes to be made available for this service account.
- required: false
- type: list
- shielded_instance_config:
- description:
- - Configuration for various parameters related to shielded instances.
- required: false
- type: dict
- version_added: '2.9'
- suboptions:
- enable_secure_boot:
- description:
- - Defines whether the instance has Secure Boot enabled.
- required: false
- type: bool
- enable_vtpm:
- description:
- - Defines whether the instance has the vTPM enabled.
- required: false
- type: bool
- enable_integrity_monitoring:
- description:
- - Defines whether the instance has integrity monitoring enabled.
- required: false
- type: bool
- status:
- description:
- - 'The status of the instance. One of the following values: PROVISIONING, STAGING,
- RUNNING, STOPPING, SUSPENDING, SUSPENDED, and TERMINATED.'
- - As a user, use RUNNING to keep a machine "on" and TERMINATED to turn a machine
- off .
- - 'Some valid choices include: "PROVISIONING", "STAGING", "RUNNING", "STOPPING",
- "SUSPENDING", "SUSPENDED", "TERMINATED"'
- required: false
- type: str
- version_added: '2.8'
- tags:
- description:
- - A list of tags to apply to this instance. Tags are used to identify valid sources
- or targets for network firewalls and are specified by the client during instance
- creation. The tags can be later modified by the setTags method. Each tag within
- the list must comply with RFC1035.
- required: false
- type: dict
- suboptions:
- fingerprint:
- description:
- - Specifies a fingerprint for this request, which is essentially a hash of
- the metadata's contents and used for optimistic locking.
- - The fingerprint is initially generated by Compute Engine and changes after
- every request to modify or update metadata. You must always provide an up-to-date
- fingerprint hash in order to update or change metadata.
- required: false
- type: str
- items:
- description:
- - An array of tags. Each tag must be 1-63 characters long, and comply with
- RFC1035.
- required: false
- type: list
- zone:
- description:
- - A reference to the zone where the machine resides.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-'''
-
-EXAMPLES = '''
-- name: create a disk
- gcp_compute_disk:
- name: disk-instance
- size_gb: 50
- source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: disk
-
-- name: create a network
- gcp_compute_network:
- name: network-instance
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: network
-
-- name: create a address
- gcp_compute_address:
- name: address-instance
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: address
-
-- name: create a instance
- gcp_compute_instance:
- name: test_object
- machine_type: n1-standard-1
- disks:
- - auto_delete: 'true'
- boot: 'true'
- source: "{{ disk }}"
- - auto_delete: 'true'
- interface: NVME
- type: SCRATCH
- initialize_params:
- disk_type: local-ssd
- metadata:
- startup-script-url: gs:://graphite-playground/bootstrap.sh
- cost-center: '12345'
- labels:
- environment: production
- network_interfaces:
- - network: "{{ network }}"
- access_configs:
- - name: External NAT
- nat_ip: "{{ address }}"
- type: ONE_TO_ONE_NAT
- zone: us-central1-a
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-canIpForward:
- description:
- - Allows this instance to send and receive packets with non-matching destination
- or source IPs. This is required if you plan to use this instance to forward routes.
- returned: success
- type: bool
-cpuPlatform:
- description:
- - The CPU platform used by this instance.
- returned: success
- type: str
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-deletionProtection:
- description:
- - Whether the resource should be protected against deletion.
- returned: success
- type: bool
-disks:
- description:
- - An array of disks that are associated with the instances that are created from
- this template.
- returned: success
- type: complex
- contains:
- autoDelete:
- description:
- - Specifies whether the disk will be auto-deleted when the instance is deleted
- (but not when the disk is detached from the instance).
- - 'Tip: Disks should be set to autoDelete=true so that leftover disks are not
- left behind on machine deletion.'
- returned: success
- type: bool
- boot:
- description:
- - Indicates that this is a boot disk. The virtual machine will use the first
- partition of the disk for its root filesystem.
- returned: success
- type: bool
- deviceName:
- description:
- - Specifies a unique device name of your choice that is reflected into the /dev/disk/by-id/google-*
- tree of a Linux operating system running within the instance. This name can
- be used to reference the device for mounting, resizing, and so on, from within
- the instance.
- returned: success
- type: str
- diskEncryptionKey:
- description:
- - Encrypts or decrypts a disk using a customer-supplied encryption key.
- returned: success
- type: complex
- contains:
- rawKey:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
- base64 to either encrypt or decrypt this resource.
- returned: success
- type: str
- rsaEncryptedKey:
- description:
- - Specifies an RFC 4648 base64 encoded, RSA-wrapped 2048-bit customer-supplied
- encryption key to either encrypt or decrypt this resource.
- returned: success
- type: str
- sha256:
- description:
- - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
- key that protects this resource.
- returned: success
- type: str
- index:
- description:
- - Assigns a zero-based index to this disk, where 0 is reserved for the boot
- disk. For example, if you have many disks attached to an instance, each disk
- would have a unique index number. If not specified, the server will choose
- an appropriate value.
- returned: success
- type: int
- initializeParams:
- description:
- - Specifies the parameters for a new disk that will be created alongside the
- new instance. Use initialization parameters to create boot disks or local
- SSDs attached to the new instance.
- returned: success
- type: complex
- contains:
- diskName:
- description:
- - Specifies the disk name. If not specified, the default is to use the name
- of the instance.
- returned: success
- type: str
- diskSizeGb:
- description:
- - Specifies the size of the disk in base-2 GB.
- returned: success
- type: int
- diskType:
- description:
- - Reference to a disk type.
- - Specifies the disk type to use to create the instance.
- - If not specified, the default is pd-standard.
- returned: success
- type: str
- sourceImage:
- description:
- - The source image to create this disk. When creating a new instance, one
- of initializeParams.sourceImage or disks.source is required. To create
- a disk with one of the public operating system images, specify the image
- by its family name.
- returned: success
- type: str
- sourceImageEncryptionKey:
- description:
- - The customer-supplied encryption key of the source image. Required if
- the source image is protected by a customer-supplied encryption key.
- - Instance templates do not store customer-supplied encryption keys, so
- you cannot create disks for instances in a managed instance group if the
- source images are encrypted with your own keys.
- returned: success
- type: complex
- contains:
- rawKey:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded in RFC
- 4648 base64 to either encrypt or decrypt this resource.
- returned: success
- type: str
- sha256:
- description:
- - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied
- encryption key that protects this resource.
- returned: success
- type: str
- interface:
- description:
- - Specifies the disk interface to use for attaching this disk, which is either
- SCSI or NVME. The default is SCSI.
- - Persistent disks must always use SCSI and the request will fail if you attempt
- to attach a persistent disk in any other format than SCSI.
- returned: success
- type: str
- mode:
- description:
- - The mode in which to attach this disk, either READ_WRITE or READ_ONLY. If
- not specified, the default is to attach the disk in READ_WRITE mode.
- returned: success
- type: str
- source:
- description:
- - Reference to a disk. When creating a new instance, one of initializeParams.sourceImage
- or disks.source is required.
- - If desired, you can also attach existing non-root persistent disks using this
- property. This field is only applicable for persistent disks.
- returned: success
- type: dict
- type:
- description:
- - Specifies the type of the disk, either SCRATCH or PERSISTENT. If not specified,
- the default is PERSISTENT.
- returned: success
- type: str
-guestAccelerators:
- description:
- - List of the type and count of accelerator cards attached to the instance .
- returned: success
- type: complex
- contains:
- acceleratorCount:
- description:
- - The number of the guest accelerator cards exposed to this instance.
- returned: success
- type: int
- acceleratorType:
- description:
- - Full or partial URL of the accelerator type resource to expose to this instance.
- returned: success
- type: str
-hostname:
- description:
- - The hostname of the instance to be created. The specified hostname must be RFC1035
- compliant. If hostname is not specified, the default hostname is [INSTANCE_NAME].c.[PROJECT_ID].internal
- when using the global DNS, and [INSTANCE_NAME].[ZONE].c.[PROJECT_ID].internal
- when using zonal DNS.
- returned: success
- type: str
-id:
- description:
- - The unique identifier for the resource. This identifier is defined by the server.
- returned: success
- type: int
-labelFingerprint:
- description:
- - The fingerprint used for optimistic locking of this resource. Used internally
- during updates.
- returned: success
- type: str
-labels:
- description:
- - Labels to apply to this instance. A list of key->value pairs.
- returned: success
- type: dict
-metadata:
- description:
- - The metadata key/value pairs to assign to instances that are created from this
- template. These pairs can consist of custom metadata or predefined keys.
- returned: success
- type: dict
-machineType:
- description:
- - A reference to a machine type which defines VM kind.
- returned: success
- type: str
-minCpuPlatform:
- description:
- - Specifies a minimum CPU platform for the VM instance. Applicable values are the
- friendly names of CPU platforms .
- returned: success
- type: str
-name:
- description:
- - The name of the resource, provided by the client when initially creating the resource.
- The resource name must be 1-63 characters long, and comply with RFC1035. Specifically,
- the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
-networkInterfaces:
- description:
- - An array of configurations for this interface. This specifies how this interface
- is configured to interact with other network services, such as connecting to the
- internet. Only one network interface is supported per instance.
- returned: success
- type: complex
- contains:
- accessConfigs:
- description:
- - An array of configurations for this interface. Currently, only one access
- config, ONE_TO_ONE_NAT, is supported. If there are no accessConfigs specified,
- then this instance will have no external internet access.
- returned: success
- type: complex
- contains:
- name:
- description:
- - The name of this access configuration. The default and recommended name
- is External NAT but you can use any arbitrary string you would like. For
- example, My external IP or Network Access.
- returned: success
- type: str
- natIP:
- description:
- - Reference to an address.
- - An external IP address associated with this instance.
- - Specify an unused static external IP address available to the project
- or leave this field undefined to use an IP from a shared ephemeral IP
- address pool. If you specify a static external IP address, it must live
- in the same region as the zone of the instance.
- returned: success
- type: dict
- type:
- description:
- - The type of configuration. The default and only option is ONE_TO_ONE_NAT.
- returned: success
- type: str
- setPublicPtr:
- description:
- - Specifies whether a public DNS PTR record should be created to map the
- external IP address of the instance to a DNS domain name.
- returned: success
- type: bool
- publicPtrDomainName:
- description:
- - The DNS domain name for the public PTR record. You can set this field
- only if the setPublicPtr field is enabled.
- returned: success
- type: str
- networkTier:
- description:
- - This signifies the networking tier used for configuring this access configuration.
- If an AccessConfig is specified without a valid external IP address, an
- ephemeral IP will be created with this networkTier. If an AccessConfig
- with a valid external IP address is specified, it must match that of the
- networkTier associated with the Address resource owning that IP.
- returned: success
- type: str
- aliasIpRanges:
- description:
- - An array of alias IP ranges for this network interface. Can only be specified
- for network interfaces on subnet-mode networks.
- returned: success
- type: complex
- contains:
- ipCidrRange:
- description:
- - The IP CIDR range represented by this alias IP range.
- - This IP CIDR range must belong to the specified subnetwork and cannot
- contain IP addresses reserved by system or used by other network interfaces.
- This range may be a single IP address (e.g. 10.2.3.4), a netmask (e.g.
- /24) or a CIDR format string (e.g. 10.1.2.0/24).
- returned: success
- type: str
- subnetworkRangeName:
- description:
- - Optional subnetwork secondary range name specifying the secondary range
- from which to allocate the IP CIDR range for this alias IP range. If left
- unspecified, the primary range of the subnetwork will be used.
- returned: success
- type: str
- name:
- description:
- - The name of the network interface, generated by the server. For network devices,
- these are eth0, eth1, etc .
- returned: success
- type: str
- network:
- description:
- - Specifies the title of an existing network. Not setting the network title
- will select the default network interface, which could have SSH already configured
- .
- returned: success
- type: dict
- networkIP:
- description:
- - An IPv4 internal network address to assign to the instance for this network
- interface. If not specified by the user, an unused internal IP is assigned
- by the system.
- returned: success
- type: str
- subnetwork:
- description:
- - Reference to a VPC network.
- - If the network resource is in legacy mode, do not provide this property. If
- the network is in auto subnet mode, providing the subnetwork is optional.
- If the network is in custom subnet mode, then this field should be specified.
- returned: success
- type: dict
-scheduling:
- description:
- - Sets the scheduling options for this instance.
- returned: success
- type: complex
- contains:
- automaticRestart:
- description:
- - Specifies whether the instance should be automatically restarted if it is
- terminated by Compute Engine (not terminated by a user).
- - You can only set the automatic restart option for standard instances. Preemptible
- instances cannot be automatically restarted.
- returned: success
- type: bool
- onHostMaintenance:
- description:
- - Defines the maintenance behavior for this instance. For standard instances,
- the default behavior is MIGRATE. For preemptible instances, the default and
- only possible behavior is TERMINATE.
- - For more information, see Setting Instance Scheduling Options.
- returned: success
- type: str
- preemptible:
- description:
- - Defines whether the instance is preemptible. This can only be set during instance
- creation, it cannot be set or changed after the instance has been created.
- returned: success
- type: bool
-serviceAccounts:
- description:
- - A list of service accounts, with their specified scopes, authorized for this instance.
- Only one service account per VM instance is supported.
- returned: success
- type: complex
- contains:
- email:
- description:
- - Email address of the service account.
- returned: success
- type: str
- scopes:
- description:
- - The list of scopes to be made available for this service account.
- returned: success
- type: list
-shieldedInstanceConfig:
- description:
- - Configuration for various parameters related to shielded instances.
- returned: success
- type: complex
- contains:
- enableSecureBoot:
- description:
- - Defines whether the instance has Secure Boot enabled.
- returned: success
- type: bool
- enableVtpm:
- description:
- - Defines whether the instance has the vTPM enabled.
- returned: success
- type: bool
- enableIntegrityMonitoring:
- description:
- - Defines whether the instance has integrity monitoring enabled.
- returned: success
- type: bool
-status:
- description:
- - 'The status of the instance. One of the following values: PROVISIONING, STAGING,
- RUNNING, STOPPING, SUSPENDING, SUSPENDED, and TERMINATED.'
- - As a user, use RUNNING to keep a machine "on" and TERMINATED to turn a machine
- off .
- returned: success
- type: str
-statusMessage:
- description:
- - An optional, human-readable explanation of the status.
- returned: success
- type: str
-tags:
- description:
- - A list of tags to apply to this instance. Tags are used to identify valid sources
- or targets for network firewalls and are specified by the client during instance
- creation. The tags can be later modified by the setTags method. Each tag within
- the list must comply with RFC1035.
- returned: success
- type: complex
- contains:
- fingerprint:
- description:
- - Specifies a fingerprint for this request, which is essentially a hash of the
- metadata's contents and used for optimistic locking.
- - The fingerprint is initially generated by Compute Engine and changes after
- every request to modify or update metadata. You must always provide an up-to-date
- fingerprint hash in order to update or change metadata.
- returned: success
- type: str
- items:
- description:
- - An array of tags. Each tag must be 1-63 characters long, and comply with RFC1035.
- returned: success
- type: list
-zone:
- description:
- - A reference to the zone where the machine resides.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import re
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- can_ip_forward=dict(type='bool', aliases=['ip_forward']),
- deletion_protection=dict(type='bool'),
- disks=dict(
- type='list',
- elements='dict',
- options=dict(
- auto_delete=dict(type='bool'),
- boot=dict(type='bool'),
- device_name=dict(type='str'),
- disk_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), rsa_encrypted_key=dict(type='str'))),
- index=dict(type='int'),
- initialize_params=dict(
- type='dict',
- options=dict(
- disk_name=dict(type='str'),
- disk_size_gb=dict(type='int'),
- disk_type=dict(type='str'),
- source_image=dict(type='str', aliases=['image', 'image_family']),
- source_image_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'))),
- ),
- ),
- interface=dict(type='str'),
- mode=dict(type='str'),
- source=dict(type='dict'),
- type=dict(type='str'),
- ),
- ),
- guest_accelerators=dict(type='list', elements='dict', options=dict(accelerator_count=dict(type='int'), accelerator_type=dict(type='str'))),
- hostname=dict(type='str'),
- labels=dict(type='dict'),
- metadata=dict(type='dict'),
- machine_type=dict(type='str'),
- min_cpu_platform=dict(type='str'),
- name=dict(type='str'),
- network_interfaces=dict(
- type='list',
- elements='dict',
- options=dict(
- access_configs=dict(
- type='list',
- elements='dict',
- options=dict(
- name=dict(required=True, type='str'),
- nat_ip=dict(type='dict'),
- type=dict(required=True, type='str'),
- set_public_ptr=dict(type='bool'),
- public_ptr_domain_name=dict(type='str'),
- network_tier=dict(type='str'),
- ),
- ),
- alias_ip_ranges=dict(type='list', elements='dict', options=dict(ip_cidr_range=dict(type='str'), subnetwork_range_name=dict(type='str'))),
- network=dict(type='dict'),
- network_ip=dict(type='str'),
- subnetwork=dict(type='dict'),
- ),
- ),
- scheduling=dict(
- type='dict', options=dict(automatic_restart=dict(type='bool'), on_host_maintenance=dict(type='str'), preemptible=dict(type='bool'))
- ),
- service_accounts=dict(type='list', elements='dict', options=dict(email=dict(type='str'), scopes=dict(type='list', elements='str'))),
- shielded_instance_config=dict(
- type='dict', options=dict(enable_secure_boot=dict(type='bool'), enable_vtpm=dict(type='bool'), enable_integrity_monitoring=dict(type='bool'))
- ),
- status=dict(type='str'),
- tags=dict(type='dict', options=dict(fingerprint=dict(type='str'), items=dict(type='list', elements='str'))),
- zone=dict(required=True, type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#instance'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind, fetch)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- if fetch:
- instance = InstancePower(module, fetch.get('status'))
- instance.run()
- if module.params.get('status'):
- fetch.update({'status': module.params['status']})
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind, fetch):
- update_fields(module, resource_to_request(module), response_to_hash(module, fetch))
- return fetch_resource(module, self_link(module), kind)
-
-
-def update_fields(module, request, response):
- if response.get('deletionProtection') != request.get('deletionProtection'):
- deletion_protection_update(module, request, response)
- if response.get('labels') != request.get('labels'):
- label_fingerprint_update(module, request, response)
- if response.get('machineType') != request.get('machineType'):
- machine_type_update(module, request, response)
- if response.get('shieldedInstanceConfig') != request.get('shieldedInstanceConfig'):
- shielded_instance_config_update(module, request, response)
-
-
-def label_fingerprint_update(module, request, response):
- auth = GcpSession(module, 'compute')
- auth.post(
- ''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/zones/{zone}/instances/{name}/setLabels"]).format(**module.params),
- {u'labelFingerprint': response.get('labelFingerprint'), u'labels': module.params.get('labels')},
- )
-
-
-def machine_type_update(module, request, response):
- auth = GcpSession(module, 'compute')
- auth.post(
- ''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/zones/{zone}/instances/{name}/setMachineType"]).format(**module.params),
- {u'machineType': machine_type_selflink(module.params.get('machine_type'), module.params)},
- )
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#instance',
- u'canIpForward': module.params.get('can_ip_forward'),
- u'deletionProtection': module.params.get('deletion_protection'),
- u'disks': InstanceDisksArray(module.params.get('disks', []), module).to_request(),
- u'guestAccelerators': InstanceGuestacceleratorsArray(module.params.get('guest_accelerators', []), module).to_request(),
- u'hostname': module.params.get('hostname'),
- u'labels': module.params.get('labels'),
- u'metadata': module.params.get('metadata'),
- u'machineType': machine_type_selflink(module.params.get('machine_type'), module.params),
- u'minCpuPlatform': module.params.get('min_cpu_platform'),
- u'name': module.params.get('name'),
- u'networkInterfaces': InstanceNetworkinterfacesArray(module.params.get('network_interfaces', []), module).to_request(),
- u'scheduling': InstanceScheduling(module.params.get('scheduling', {}), module).to_request(),
- u'serviceAccounts': InstanceServiceaccountsArray(module.params.get('service_accounts', []), module).to_request(),
- u'shieldedInstanceConfig': InstanceShieldedinstanceconfig(module.params.get('shielded_instance_config', {}), module).to_request(),
- u'status': module.params.get('status'),
- u'tags': InstanceTags(module.params.get('tags', {}), module).to_request(),
- }
- request = encode_request(request, module)
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instances/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instances".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- result = decode_response(result, module)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
- request = decode_response(request, module)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'canIpForward': response.get(u'canIpForward'),
- u'cpuPlatform': response.get(u'cpuPlatform'),
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'deletionProtection': response.get(u'deletionProtection'),
- u'disks': InstanceDisksArray(module.params.get('disks', []), module).to_request(),
- u'guestAccelerators': InstanceGuestacceleratorsArray(response.get(u'guestAccelerators', []), module).from_response(),
- u'hostname': response.get(u'hostname'),
- u'id': response.get(u'id'),
- u'labelFingerprint': response.get(u'labelFingerprint'),
- u'labels': response.get(u'labels'),
- u'metadata': response.get(u'metadata'),
- u'machineType': response.get(u'machineType'),
- u'minCpuPlatform': response.get(u'minCpuPlatform'),
- u'name': response.get(u'name'),
- u'networkInterfaces': InstanceNetworkinterfacesArray(response.get(u'networkInterfaces', []), module).from_response(),
- u'scheduling': InstanceScheduling(response.get(u'scheduling', {}), module).from_response(),
- u'serviceAccounts': InstanceServiceaccountsArray(response.get(u'serviceAccounts', []), module).from_response(),
- u'shieldedInstanceConfig': InstanceShieldedinstanceconfig(response.get(u'shieldedInstanceConfig', {}), module).from_response(),
- u'status': response.get(u'status'),
- u'statusMessage': response.get(u'statusMessage'),
- u'tags': InstanceTags(response.get(u'tags', {}), module).from_response(),
- }
-
-
-def disk_type_selflink(name, params):
- if name is None:
- return
- url = r"https://www.googleapis.com/compute/v1/projects/.*/zones/.*/diskTypes/.*"
- if not re.match(url, name):
- name = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/diskTypes/%s".format(**params) % name
- return name
-
-
-def machine_type_selflink(name, params):
- if name is None:
- return
- url = r"https://www.googleapis.com/compute/v1/projects/.*/zones/.*/machineTypes/.*"
- if not re.match(url, name):
- name = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/machineTypes/%s".format(**params) % name
- return name
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- response = fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#instance')
- if response:
- return decode_response(response, module)
- else:
- return {}
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-def encode_request(request, module):
- if 'metadata' in request and request['metadata'] is not None:
- request['metadata'] = metadata_encoder(request['metadata'])
- return request
-
-
-def decode_response(response, module):
- if 'metadata' in response and response['metadata'] is not None:
- response['metadata'] = metadata_decoder(response['metadata'])
- return response
-
-
-# TODO(alexstephen): Implement updating metadata on existing resources.
-
-# Expose instance 'metadata' as a simple name/value pair hash. However the API
-# defines metadata as a NestedObject with the following layout:
-#
-# metadata {
-# fingerprint: 'hash-of-last-metadata'
-# items: [
-# {
-# key: 'metadata1-key'
-# value: 'metadata1-value'
-# },
-# ...
-# ]
-# }
-#
-def metadata_encoder(metadata):
- metadata_new = []
- for key in metadata:
- value = metadata[key]
- metadata_new.append({"key": key, "value": value})
- return {'items': metadata_new}
-
-
-# Map metadata.items[]{key:,value:} => metadata[key]=value
-def metadata_decoder(metadata):
- items = {}
- if 'items' in metadata:
- metadata_items = metadata['items']
- for item in metadata_items:
- items[item['key']] = item['value']
- return items
-
-
-class InstancePower(object):
- def __init__(self, module, current_status):
- self.module = module
- self.current_status = current_status
- self.desired_status = self.module.params.get('status')
-
- def run(self):
- # GcpRequest handles unicode text handling
- if GcpRequest({'status': self.current_status}) == GcpRequest({'status': self.desired_status}):
- return
- elif self.desired_status == 'RUNNING':
- self.start()
- elif self.desired_status == 'TERMINATED':
- self.stop()
- elif self.desired_status == 'SUSPENDED':
- self.module.fail_json(msg="Instances cannot be suspended using Ansible")
-
- def start(self):
- auth = GcpSession(self.module, 'compute')
- wait_for_operation(self.module, auth.post(self._start_url()))
-
- def stop(self):
- auth = GcpSession(self.module, 'compute')
- wait_for_operation(self.module, auth.post(self._stop_url()))
-
- def _start_url(self):
- return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instances/{name}/start".format(**self.module.params)
-
- def _stop_url(self):
- return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instances/{name}/stop".format(**self.module.params)
-
-
-def deletion_protection_update(module, request, response):
- auth = GcpSession(module, 'compute')
- auth.post(
- ''.join(
- [
- "https://www.googleapis.com/compute/v1/",
- "projects/{project}/zones/{zone}/instances/{name}/setDeletionProtection?deletionProtection={deletionProtection}",
- ]
- ).format(**module.params),
- {},
- )
-
-
-def shielded_instance_config_update(module, request, response):
- auth = GcpSession(module, 'compute')
- auth.post(
- ''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/zones/{zone}/instances/{name}/updateShieldedInstanceConfig"]).format(
- **module.params
- ),
- {
- u'enableSecureBoot': navigate_hash(module.params, ['shielded_instance_config', 'enable_secure_boot']),
- u'enableVtpm': navigate_hash(module.params, ['shielded_instance_config', 'enable_vtpm']),
- u'enableIntegrityMonitoring': navigate_hash(module.params, ['shielded_instance_config', 'enable_integrity_monitoring']),
- },
- )
-
-
-class InstanceDisksArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict(
- {
- u'autoDelete': item.get('auto_delete'),
- u'boot': item.get('boot'),
- u'deviceName': item.get('device_name'),
- u'diskEncryptionKey': InstanceDiskencryptionkey(item.get('disk_encryption_key', {}), self.module).to_request(),
- u'index': item.get('index'),
- u'initializeParams': InstanceInitializeparams(item.get('initialize_params', {}), self.module).to_request(),
- u'interface': item.get('interface'),
- u'mode': item.get('mode'),
- u'source': replace_resource_dict(item.get(u'source', {}), 'selfLink'),
- u'type': item.get('type'),
- }
- )
-
- def _response_from_item(self, item):
- return remove_nones_from_dict(
- {
- u'autoDelete': item.get(u'autoDelete'),
- u'boot': item.get(u'boot'),
- u'deviceName': item.get(u'deviceName'),
- u'diskEncryptionKey': InstanceDiskencryptionkey(item.get(u'diskEncryptionKey', {}), self.module).from_response(),
- u'index': item.get(u'index'),
- u'initializeParams': InstanceInitializeparams(self.module.params.get('initialize_params', {}), self.module).to_request(),
- u'interface': item.get(u'interface'),
- u'mode': item.get(u'mode'),
- u'source': item.get(u'source'),
- u'type': item.get(u'type'),
- }
- )
-
-
-class InstanceDiskencryptionkey(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'rawKey': self.request.get('raw_key'), u'rsaEncryptedKey': self.request.get('rsa_encrypted_key')})
-
- def from_response(self):
- return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey'), u'rsaEncryptedKey': self.request.get(u'rsaEncryptedKey')})
-
-
-class InstanceInitializeparams(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'diskName': self.request.get('disk_name'),
- u'diskSizeGb': self.request.get('disk_size_gb'),
- u'diskType': disk_type_selflink(self.request.get('disk_type'), self.module.params),
- u'sourceImage': self.request.get('source_image'),
- u'sourceImageEncryptionKey': InstanceSourceimageencryptionkey(self.request.get('source_image_encryption_key', {}), self.module).to_request(),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'diskName': self.request.get(u'diskName'),
- u'diskSizeGb': self.request.get(u'diskSizeGb'),
- u'diskType': self.request.get(u'diskType'),
- u'sourceImage': self.request.get(u'sourceImage'),
- u'sourceImageEncryptionKey': InstanceSourceimageencryptionkey(self.request.get(u'sourceImageEncryptionKey', {}), self.module).from_response(),
- }
- )
-
-
-class InstanceSourceimageencryptionkey(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'rawKey': self.request.get('raw_key')})
-
- def from_response(self):
- return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey')})
-
-
-class InstanceGuestacceleratorsArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'acceleratorCount': item.get('accelerator_count'), u'acceleratorType': item.get('accelerator_type')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'acceleratorCount': item.get(u'acceleratorCount'), u'acceleratorType': item.get(u'acceleratorType')})
-
-
-class InstanceNetworkinterfacesArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict(
- {
- u'accessConfigs': InstanceAccessconfigsArray(item.get('access_configs', []), self.module).to_request(),
- u'aliasIpRanges': InstanceAliasiprangesArray(item.get('alias_ip_ranges', []), self.module).to_request(),
- u'network': replace_resource_dict(item.get(u'network', {}), 'selfLink'),
- u'networkIP': item.get('network_ip'),
- u'subnetwork': replace_resource_dict(item.get(u'subnetwork', {}), 'selfLink'),
- }
- )
-
- def _response_from_item(self, item):
- return remove_nones_from_dict(
- {
- u'accessConfigs': InstanceAccessconfigsArray(item.get(u'accessConfigs', []), self.module).from_response(),
- u'aliasIpRanges': InstanceAliasiprangesArray(item.get(u'aliasIpRanges', []), self.module).from_response(),
- u'network': item.get(u'network'),
- u'networkIP': item.get(u'networkIP'),
- u'subnetwork': item.get(u'subnetwork'),
- }
- )
-
-
-class InstanceAccessconfigsArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict(
- {
- u'name': item.get('name'),
- u'natIP': replace_resource_dict(item.get(u'nat_ip', {}), 'address'),
- u'type': item.get('type'),
- u'setPublicPtr': item.get('set_public_ptr'),
- u'publicPtrDomainName': item.get('public_ptr_domain_name'),
- u'networkTier': item.get('network_tier'),
- }
- )
-
- def _response_from_item(self, item):
- return remove_nones_from_dict(
- {
- u'name': item.get(u'name'),
- u'natIP': item.get(u'natIP'),
- u'type': item.get(u'type'),
- u'setPublicPtr': item.get(u'setPublicPtr'),
- u'publicPtrDomainName': item.get(u'publicPtrDomainName'),
- u'networkTier': item.get(u'networkTier'),
- }
- )
-
-
-class InstanceAliasiprangesArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'ipCidrRange': item.get('ip_cidr_range'), u'subnetworkRangeName': item.get('subnetwork_range_name')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'ipCidrRange': item.get(u'ipCidrRange'), u'subnetworkRangeName': item.get(u'subnetworkRangeName')})
-
-
-class InstanceScheduling(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'automaticRestart': self.request.get('automatic_restart'),
- u'onHostMaintenance': self.request.get('on_host_maintenance'),
- u'preemptible': self.request.get('preemptible'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'automaticRestart': self.request.get(u'automaticRestart'),
- u'onHostMaintenance': self.request.get(u'onHostMaintenance'),
- u'preemptible': self.request.get(u'preemptible'),
- }
- )
-
-
-class InstanceServiceaccountsArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'email': item.get('email'), u'scopes': item.get('scopes')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'email': item.get(u'email'), u'scopes': item.get(u'scopes')})
-
-
-class InstanceShieldedinstanceconfig(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'enableSecureBoot': self.request.get('enable_secure_boot'),
- u'enableVtpm': self.request.get('enable_vtpm'),
- u'enableIntegrityMonitoring': self.request.get('enable_integrity_monitoring'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'enableSecureBoot': self.request.get(u'enableSecureBoot'),
- u'enableVtpm': self.request.get(u'enableVtpm'),
- u'enableIntegrityMonitoring': self.request.get(u'enableIntegrityMonitoring'),
- }
- )
-
-
-class InstanceTags(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'fingerprint': self.request.get('fingerprint'), u'items': self.request.get('items')})
-
- def from_response(self):
- return remove_nones_from_dict({u'fingerprint': self.request.get(u'fingerprint'), u'items': self.request.get(u'items')})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_instance_group.py b/lib/ansible/modules/cloud/google/gcp_compute_instance_group.py
deleted file mode 100644
index 75def45f4a..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_instance_group.py
+++ /dev/null
@@ -1,562 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_instance_group
-description:
-- Represents an Instance Group resource. Instance groups are self-managed and can
- contain identical or different instances. Instance groups do not use an instance
- template. Unlike managed instance groups, you must create and add instances to an
- instance group manually.
-short_description: Creates a GCP InstanceGroup
-version_added: '2.6'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- required: false
- type: str
- name:
- description:
- - The name of the instance group.
- - The name must be 1-63 characters long, and comply with RFC1035.
- required: false
- type: str
- named_ports:
- description:
- - Assigns a name to a port number.
- - 'For example: {name: "http", port: 80}.'
- - This allows the system to reference ports by the assigned name instead of a
- port number. Named ports can also contain multiple ports.
- - 'For example: [{name: "http", port: 80},{name: "http", port: 8080}] Named ports
- apply to all instances in this instance group.'
- required: false
- type: list
- suboptions:
- name:
- description:
- - The name for this named port.
- - The name must be 1-63 characters long, and comply with RFC1035.
- required: false
- type: str
- port:
- description:
- - The port number, which can be a value between 1 and 65535.
- required: false
- type: int
- network:
- description:
- - The network to which all instances in the instance group belong.
- - 'This field represents a link to a Network resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''selfLink'' and value
- of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
- to a gcp_compute_network task and then set this network field to "{{ name-of-resource
- }}"'
- required: false
- type: dict
- region:
- description:
- - The region where the instance group is located (for regional resources).
- required: false
- type: str
- subnetwork:
- description:
- - The subnetwork to which all instances in the instance group belong.
- - 'This field represents a link to a Subnetwork resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''selfLink'' and value
- of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
- to a gcp_compute_subnetwork task and then set this subnetwork field to "{{ name-of-resource
- }}"'
- required: false
- type: dict
- zone:
- description:
- - A reference to the zone where the instance group resides.
- required: true
- type: str
- instances:
- description:
- - The list of instances associated with this InstanceGroup.
- - All instances must be created before being added to an InstanceGroup.
- - All instances not in this list will be removed from the InstanceGroup and will
- not be deleted.
- - Only the full identifier of the instance will be returned.
- required: false
- type: list
- version_added: '2.8'
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-'''
-
-EXAMPLES = '''
-- name: create a network
- gcp_compute_network:
- name: network-instancegroup
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: network
-
-- name: create a instance group
- gcp_compute_instance_group:
- name: test_object
- named_ports:
- - name: ansible
- port: 1234
- network: "{{ network }}"
- zone: us-central1-a
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- returned: success
- type: str
-id:
- description:
- - A unique identifier for this instance group.
- returned: success
- type: int
-name:
- description:
- - The name of the instance group.
- - The name must be 1-63 characters long, and comply with RFC1035.
- returned: success
- type: str
-namedPorts:
- description:
- - Assigns a name to a port number.
- - 'For example: {name: "http", port: 80}.'
- - This allows the system to reference ports by the assigned name instead of a port
- number. Named ports can also contain multiple ports.
- - 'For example: [{name: "http", port: 80},{name: "http", port: 8080}] Named ports
- apply to all instances in this instance group.'
- returned: success
- type: complex
- contains:
- name:
- description:
- - The name for this named port.
- - The name must be 1-63 characters long, and comply with RFC1035.
- returned: success
- type: str
- port:
- description:
- - The port number, which can be a value between 1 and 65535.
- returned: success
- type: int
-network:
- description:
- - The network to which all instances in the instance group belong.
- returned: success
- type: dict
-region:
- description:
- - The region where the instance group is located (for regional resources).
- returned: success
- type: str
-subnetwork:
- description:
- - The subnetwork to which all instances in the instance group belong.
- returned: success
- type: dict
-zone:
- description:
- - A reference to the zone where the instance group resides.
- returned: success
- type: str
-instances:
- description:
- - The list of instances associated with this InstanceGroup.
- - All instances must be created before being added to an InstanceGroup.
- - All instances not in this list will be removed from the InstanceGroup and will
- not be deleted.
- - Only the full identifier of the instance will be returned.
- returned: success
- type: list
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import re
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- description=dict(type='str'),
- name=dict(type='str'),
- named_ports=dict(type='list', elements='dict', options=dict(name=dict(type='str'), port=dict(type='int'))),
- network=dict(type='dict'),
- region=dict(type='str'),
- subnetwork=dict(type='dict'),
- zone=dict(required=True, type='str'),
- instances=dict(type='list', elements='dict'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#instanceGroup'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- if fetch:
- instance = InstanceLogic(module)
- instance.run()
- fetch.update({'instances': instance.list_instances()})
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind):
- instance = InstanceLogic(module)
- instance.run()
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#instanceGroup',
- u'description': module.params.get('description'),
- u'name': module.params.get('name'),
- u'namedPorts': InstanceGroupNamedportsArray(module.params.get('named_ports', []), module).to_request(),
- u'network': replace_resource_dict(module.params.get(u'network', {}), 'selfLink'),
- u'region': region_selflink(module.params.get('region'), module.params),
- u'subnetwork': replace_resource_dict(module.params.get(u'subnetwork', {}), 'selfLink'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroups/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroups".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'description': response.get(u'description'),
- u'id': response.get(u'id'),
- u'name': response.get(u'name'),
- u'namedPorts': InstanceGroupNamedportsArray(response.get(u'namedPorts', []), module).from_response(),
- u'network': response.get(u'network'),
- u'region': response.get(u'region'),
- u'subnetwork': response.get(u'subnetwork'),
- }
-
-
-def region_selflink(name, params):
- if name is None:
- return
- url = r"https://www.googleapis.com/compute/v1/projects/.*/regions/.*"
- if not re.match(url, name):
- name = "https://www.googleapis.com/compute/v1/projects/{project}/regions/%s".format(**params) % name
- return name
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#instanceGroup')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-class InstanceLogic(object):
- def __init__(self, module):
- self.module = module
- self.current_instances = self.list_instances()
- self.module_instances = []
-
- # Transform module list of instances (dicts of instance responses) into a list of selfLinks.
- instances = self.module.params.get('instances')
- if instances:
- for instance in instances:
- self.module_instances.append(replace_resource_dict(instance, 'selfLink'))
-
- def run(self):
- # Find all instances to add and add them
- instances_to_add = list(set(self.module_instances) - set(self.current_instances))
- if instances_to_add:
- self.add_instances(instances_to_add)
-
- # Find all instances to remove and remove them
- instances_to_remove = list(set(self.current_instances) - set(self.module_instances))
- if instances_to_remove:
- self.remove_instances(instances_to_remove)
-
- def list_instances(self):
- auth = GcpSession(self.module, 'compute')
- response = return_if_object(self.module, auth.post(self._list_instances_url(), {'instanceState': 'ALL'}), 'compute#instanceGroupsListInstances')
-
- # Transform instance list into a list of selfLinks for diffing with module parameters
- instances = []
- for instance in response.get('items', []):
- instances.append(instance['instance'])
- return instances
-
- def add_instances(self, instances):
- auth = GcpSession(self.module, 'compute')
- wait_for_operation(self.module, auth.post(self._add_instances_url(), self._build_request(instances)))
-
- def remove_instances(self, instances):
- auth = GcpSession(self.module, 'compute')
- wait_for_operation(self.module, auth.post(self._remove_instances_url(), self._build_request(instances)))
-
- def _list_instances_url(self):
- return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroups/{name}/listInstances".format(**self.module.params)
-
- def _remove_instances_url(self):
- return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroups/{name}/removeInstances".format(**self.module.params)
-
- def _add_instances_url(self):
- return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroups/{name}/addInstances".format(**self.module.params)
-
- def _build_request(self, instances):
- request = {'instances': []}
- for instance in instances:
- request['instances'].append({'instance': instance})
- return request
-
-
-class InstanceGroupNamedportsArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'name': item.get('name'), u'port': item.get('port')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'name': item.get(u'name'), u'port': item.get(u'port')})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_instance_group_info.py b/lib/ansible/modules/cloud/google/gcp_compute_instance_group_info.py
deleted file mode 100644
index ee29929f3f..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_instance_group_info.py
+++ /dev/null
@@ -1,266 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_instance_group_info
-description:
-- Gather info for GCP InstanceGroup
-short_description: Gather info for GCP InstanceGroup
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- zone:
- description:
- - A reference to the zone where the instance group resides.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on an instance group
- gcp_compute_instance_group_info:
- zone: us-central1-a
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- returned: success
- type: str
- id:
- description:
- - A unique identifier for this instance group.
- returned: success
- type: int
- name:
- description:
- - The name of the instance group.
- - The name must be 1-63 characters long, and comply with RFC1035.
- returned: success
- type: str
- namedPorts:
- description:
- - Assigns a name to a port number.
- - 'For example: {name: "http", port: 80}.'
- - This allows the system to reference ports by the assigned name instead of
- a port number. Named ports can also contain multiple ports.
- - 'For example: [{name: "http", port: 80},{name: "http", port: 8080}] Named
- ports apply to all instances in this instance group.'
- returned: success
- type: complex
- contains:
- name:
- description:
- - The name for this named port.
- - The name must be 1-63 characters long, and comply with RFC1035.
- returned: success
- type: str
- port:
- description:
- - The port number, which can be a value between 1 and 65535.
- returned: success
- type: int
- network:
- description:
- - The network to which all instances in the instance group belong.
- returned: success
- type: dict
- region:
- description:
- - The region where the instance group is located (for regional resources).
- returned: success
- type: str
- subnetwork:
- description:
- - The subnetwork to which all instances in the instance group belong.
- returned: success
- type: dict
- zone:
- description:
- - A reference to the zone where the instance group resides.
- returned: success
- type: str
- instances:
- description:
- - The list of instances associated with this InstanceGroup.
- - All instances must be created before being added to an InstanceGroup.
- - All instances not in this list will be removed from the InstanceGroup and
- will not be deleted.
- - Only the full identifier of the instance will be returned.
- returned: success
- type: list
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str'), zone=dict(required=True, type='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroups".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_instance_group_manager.py b/lib/ansible/modules/cloud/google/gcp_compute_instance_group_manager.py
deleted file mode 100644
index 14b18a48e8..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_instance_group_manager.py
+++ /dev/null
@@ -1,621 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_instance_group_manager
-description:
-- Creates a managed instance group using the information that you specify in the request.
- After the group is created, it schedules an action to create instances in the group
- using the specified instance template. This operation is marked as DONE when the
- group is created even if the instances in the group have not yet been created. You
- must separately verify the status of the individual instances.
-- A managed instance group can have up to 1000 VM instances per group.
-short_description: Creates a GCP InstanceGroupManager
-version_added: '2.6'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- base_instance_name:
- description:
- - The base instance name to use for instances in this group. The value must be
- 1-58 characters long. Instances are named by appending a hyphen and a random
- four-character string to the base instance name.
- - The base instance name must comply with RFC1035.
- required: true
- type: str
- description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- required: false
- type: str
- instance_template:
- description:
- - The instance template that is specified for this managed instance group. The
- group uses this template to create all new instances in the managed instance
- group.
- - 'This field represents a link to a InstanceTemplate resource in GCP. It can
- be specified in two ways. First, you can place a dictionary with key ''selfLink''
- and value of your resource''s selfLink Alternatively, you can add `register:
- name-of-resource` to a gcp_compute_instance_template task and then set this
- instance_template field to "{{ name-of-resource }}"'
- required: true
- type: dict
- name:
- description:
- - The name of the managed instance group. The name must be 1-63 characters long,
- and comply with RFC1035.
- required: true
- type: str
- named_ports:
- description:
- - Named ports configured for the Instance Groups complementary to this Instance
- Group Manager.
- required: false
- type: list
- suboptions:
- name:
- description:
- - The name for this named port. The name must be 1-63 characters long, and
- comply with RFC1035.
- required: false
- type: str
- port:
- description:
- - The port number, which can be a value between 1 and 65535.
- required: false
- type: int
- target_pools:
- description:
- - TargetPool resources to which instances in the instanceGroup field are added.
- The target pools automatically apply to all of the instances in the managed
- instance group.
- required: false
- type: list
- target_size:
- description:
- - The target number of running instances for this managed instance group. Deleting
- or abandoning instances reduces this number. Resizing the group changes this
- number.
- required: false
- type: int
- zone:
- description:
- - The zone the managed instance group resides.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-'''
-
-EXAMPLES = '''
-- name: create a network
- gcp_compute_network:
- name: network-instancetemplate
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: network
-
-- name: create a address
- gcp_compute_address:
- name: address-instancetemplate
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: address
-
-- name: create a instance template
- gcp_compute_instance_template:
- name: "{{ resource_name }}"
- properties:
- disks:
- - auto_delete: 'true'
- boot: 'true'
- initialize_params:
- source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
- machine_type: n1-standard-1
- network_interfaces:
- - network: "{{ network }}"
- access_configs:
- - name: test-config
- type: ONE_TO_ONE_NAT
- nat_ip: "{{ address }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: instancetemplate
-
-- name: create a instance group manager
- gcp_compute_instance_group_manager:
- name: test_object
- base_instance_name: test1-child
- instance_template: "{{ instancetemplate }}"
- target_size: 3
- zone: us-west1-a
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-baseInstanceName:
- description:
- - The base instance name to use for instances in this group. The value must be 1-58
- characters long. Instances are named by appending a hyphen and a random four-character
- string to the base instance name.
- - The base instance name must comply with RFC1035.
- returned: success
- type: str
-creationTimestamp:
- description:
- - The creation timestamp for this managed instance group in RFC3339 text format.
- returned: success
- type: str
-currentActions:
- description:
- - The list of instance actions and the number of instances in this managed instance
- group that are scheduled for each of those actions.
- returned: success
- type: complex
- contains:
- abandoning:
- description:
- - The total number of instances in the managed instance group that are scheduled
- to be abandoned. Abandoning an instance removes it from the managed instance
- group without deleting it.
- returned: success
- type: int
- creating:
- description:
- - The number of instances in the managed instance group that are scheduled to
- be created or are currently being created. If the group fails to create any
- of these instances, it tries again until it creates the instance successfully.
- - If you have disabled creation retries, this field will not be populated; instead,
- the creatingWithoutRetries field will be populated.
- returned: success
- type: int
- creatingWithoutRetries:
- description:
- - The number of instances that the managed instance group will attempt to create.
- The group attempts to create each instance only once. If the group fails to
- create any of these instances, it decreases the group's targetSize value accordingly.
- returned: success
- type: int
- deleting:
- description:
- - The number of instances in the managed instance group that are scheduled to
- be deleted or are currently being deleted.
- returned: success
- type: int
- none:
- description:
- - The number of instances in the managed instance group that are running and
- have no scheduled actions.
- returned: success
- type: int
- recreating:
- description:
- - The number of instances in the managed instance group that are scheduled to
- be recreated or are currently being being recreated.
- - Recreating an instance deletes the existing root persistent disk and creates
- a new disk from the image that is defined in the instance template.
- returned: success
- type: int
- refreshing:
- description:
- - The number of instances in the managed instance group that are being reconfigured
- with properties that do not require a restart or a recreate action. For example,
- setting or removing target pools for the instance.
- returned: success
- type: int
- restarting:
- description:
- - The number of instances in the managed instance group that are scheduled to
- be restarted or are currently being restarted.
- returned: success
- type: int
-description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- returned: success
- type: str
-id:
- description:
- - A unique identifier for this resource.
- returned: success
- type: int
-instanceGroup:
- description:
- - The instance group being managed.
- returned: success
- type: dict
-instanceTemplate:
- description:
- - The instance template that is specified for this managed instance group. The group
- uses this template to create all new instances in the managed instance group.
- returned: success
- type: dict
-name:
- description:
- - The name of the managed instance group. The name must be 1-63 characters long,
- and comply with RFC1035.
- returned: success
- type: str
-namedPorts:
- description:
- - Named ports configured for the Instance Groups complementary to this Instance
- Group Manager.
- returned: success
- type: complex
- contains:
- name:
- description:
- - The name for this named port. The name must be 1-63 characters long, and comply
- with RFC1035.
- returned: success
- type: str
- port:
- description:
- - The port number, which can be a value between 1 and 65535.
- returned: success
- type: int
-region:
- description:
- - The region this managed instance group resides (for regional resources).
- returned: success
- type: str
-targetPools:
- description:
- - TargetPool resources to which instances in the instanceGroup field are added.
- The target pools automatically apply to all of the instances in the managed instance
- group.
- returned: success
- type: list
-targetSize:
- description:
- - The target number of running instances for this managed instance group. Deleting
- or abandoning instances reduces this number. Resizing the group changes this number.
- returned: success
- type: int
-zone:
- description:
- - The zone the managed instance group resides.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import re
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- base_instance_name=dict(required=True, type='str'),
- description=dict(type='str'),
- instance_template=dict(required=True, type='dict'),
- name=dict(required=True, type='str'),
- named_ports=dict(type='list', elements='dict', options=dict(name=dict(type='str'), port=dict(type='int'))),
- target_pools=dict(type='list', elements='dict'),
- target_size=dict(type='int'),
- zone=dict(required=True, type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#instanceGroupManager'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.put(link, resource_to_request(module)))
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#instanceGroupManager',
- u'baseInstanceName': module.params.get('base_instance_name'),
- u'description': module.params.get('description'),
- u'instanceTemplate': replace_resource_dict(module.params.get(u'instance_template', {}), 'selfLink'),
- u'name': module.params.get('name'),
- u'namedPorts': InstanceGroupManagerNamedportsArray(module.params.get('named_ports', []), module).to_request(),
- u'targetPools': replace_resource_dict(module.params.get('target_pools', []), 'selfLink'),
- u'targetSize': module.params.get('target_size'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'baseInstanceName': response.get(u'baseInstanceName'),
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'currentActions': InstanceGroupManagerCurrentactions(response.get(u'currentActions', {}), module).from_response(),
- u'description': module.params.get('description'),
- u'id': response.get(u'id'),
- u'instanceGroup': response.get(u'instanceGroup'),
- u'instanceTemplate': response.get(u'instanceTemplate'),
- u'name': response.get(u'name'),
- u'namedPorts': InstanceGroupManagerNamedportsArray(response.get(u'namedPorts', []), module).from_response(),
- u'region': response.get(u'region'),
- u'targetPools': response.get(u'targetPools'),
- u'targetSize': response.get(u'targetSize'),
- }
-
-
-def region_selflink(name, params):
- if name is None:
- return
- url = r"https://www.googleapis.com/compute/v1/projects/.*/regions/.*"
- if not re.match(url, name):
- name = "https://www.googleapis.com/compute/v1/projects/{project}/regions/%s".format(**params) % name
- return name
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#instanceGroupManager')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-class InstanceGroupManagerCurrentactions(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({})
-
- def from_response(self):
- return remove_nones_from_dict({})
-
-
-class InstanceGroupManagerNamedportsArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'name': item.get('name'), u'port': item.get('port')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'name': item.get(u'name'), u'port': item.get(u'port')})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_instance_group_manager_info.py b/lib/ansible/modules/cloud/google/gcp_compute_instance_group_manager_info.py
deleted file mode 100644
index beca92bad5..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_instance_group_manager_info.py
+++ /dev/null
@@ -1,341 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_instance_group_manager_info
-description:
-- Gather info for GCP InstanceGroupManager
-short_description: Gather info for GCP InstanceGroupManager
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- zone:
- description:
- - The zone the managed instance group resides.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on an instance group manager
- gcp_compute_instance_group_manager_info:
- zone: us-west1-a
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- baseInstanceName:
- description:
- - The base instance name to use for instances in this group. The value must
- be 1-58 characters long. Instances are named by appending a hyphen and a random
- four-character string to the base instance name.
- - The base instance name must comply with RFC1035.
- returned: success
- type: str
- creationTimestamp:
- description:
- - The creation timestamp for this managed instance group in RFC3339 text format.
- returned: success
- type: str
- currentActions:
- description:
- - The list of instance actions and the number of instances in this managed instance
- group that are scheduled for each of those actions.
- returned: success
- type: complex
- contains:
- abandoning:
- description:
- - The total number of instances in the managed instance group that are scheduled
- to be abandoned. Abandoning an instance removes it from the managed instance
- group without deleting it.
- returned: success
- type: int
- creating:
- description:
- - The number of instances in the managed instance group that are scheduled
- to be created or are currently being created. If the group fails to create
- any of these instances, it tries again until it creates the instance successfully.
- - If you have disabled creation retries, this field will not be populated;
- instead, the creatingWithoutRetries field will be populated.
- returned: success
- type: int
- creatingWithoutRetries:
- description:
- - The number of instances that the managed instance group will attempt to
- create. The group attempts to create each instance only once. If the group
- fails to create any of these instances, it decreases the group's targetSize
- value accordingly.
- returned: success
- type: int
- deleting:
- description:
- - The number of instances in the managed instance group that are scheduled
- to be deleted or are currently being deleted.
- returned: success
- type: int
- none:
- description:
- - The number of instances in the managed instance group that are running
- and have no scheduled actions.
- returned: success
- type: int
- recreating:
- description:
- - The number of instances in the managed instance group that are scheduled
- to be recreated or are currently being being recreated.
- - Recreating an instance deletes the existing root persistent disk and creates
- a new disk from the image that is defined in the instance template.
- returned: success
- type: int
- refreshing:
- description:
- - The number of instances in the managed instance group that are being reconfigured
- with properties that do not require a restart or a recreate action. For
- example, setting or removing target pools for the instance.
- returned: success
- type: int
- restarting:
- description:
- - The number of instances in the managed instance group that are scheduled
- to be restarted or are currently being restarted.
- returned: success
- type: int
- description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- returned: success
- type: str
- id:
- description:
- - A unique identifier for this resource.
- returned: success
- type: int
- instanceGroup:
- description:
- - The instance group being managed.
- returned: success
- type: dict
- instanceTemplate:
- description:
- - The instance template that is specified for this managed instance group. The
- group uses this template to create all new instances in the managed instance
- group.
- returned: success
- type: dict
- name:
- description:
- - The name of the managed instance group. The name must be 1-63 characters long,
- and comply with RFC1035.
- returned: success
- type: str
- namedPorts:
- description:
- - Named ports configured for the Instance Groups complementary to this Instance
- Group Manager.
- returned: success
- type: complex
- contains:
- name:
- description:
- - The name for this named port. The name must be 1-63 characters long, and
- comply with RFC1035.
- returned: success
- type: str
- port:
- description:
- - The port number, which can be a value between 1 and 65535.
- returned: success
- type: int
- region:
- description:
- - The region this managed instance group resides (for regional resources).
- returned: success
- type: str
- targetPools:
- description:
- - TargetPool resources to which instances in the instanceGroup field are added.
- The target pools automatically apply to all of the instances in the managed
- instance group.
- returned: success
- type: list
- targetSize:
- description:
- - The target number of running instances for this managed instance group. Deleting
- or abandoning instances reduces this number. Resizing the group changes this
- number.
- returned: success
- type: int
- zone:
- description:
- - The zone the managed instance group resides.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str'), zone=dict(required=True, type='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instanceGroupManagers".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_instance_info.py b/lib/ansible/modules/cloud/google/gcp_compute_instance_info.py
deleted file mode 100644
index 9d91b19578..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_instance_info.py
+++ /dev/null
@@ -1,650 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_instance_info
-description:
-- Gather info for GCP Instance
-short_description: Gather info for GCP Instance
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- zone:
- description:
- - A reference to the zone where the machine resides.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on an instance
- gcp_compute_instance_info:
- zone: us-central1-a
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- canIpForward:
- description:
- - Allows this instance to send and receive packets with non-matching destination
- or source IPs. This is required if you plan to use this instance to forward
- routes.
- returned: success
- type: bool
- cpuPlatform:
- description:
- - The CPU platform used by this instance.
- returned: success
- type: str
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- deletionProtection:
- description:
- - Whether the resource should be protected against deletion.
- returned: success
- type: bool
- disks:
- description:
- - An array of disks that are associated with the instances that are created
- from this template.
- returned: success
- type: complex
- contains:
- autoDelete:
- description:
- - Specifies whether the disk will be auto-deleted when the instance is deleted
- (but not when the disk is detached from the instance).
- - 'Tip: Disks should be set to autoDelete=true so that leftover disks are
- not left behind on machine deletion.'
- returned: success
- type: bool
- boot:
- description:
- - Indicates that this is a boot disk. The virtual machine will use the first
- partition of the disk for its root filesystem.
- returned: success
- type: bool
- deviceName:
- description:
- - Specifies a unique device name of your choice that is reflected into the
- /dev/disk/by-id/google-* tree of a Linux operating system running within
- the instance. This name can be used to reference the device for mounting,
- resizing, and so on, from within the instance.
- returned: success
- type: str
- diskEncryptionKey:
- description:
- - Encrypts or decrypts a disk using a customer-supplied encryption key.
- returned: success
- type: complex
- contains:
- rawKey:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded in RFC
- 4648 base64 to either encrypt or decrypt this resource.
- returned: success
- type: str
- rsaEncryptedKey:
- description:
- - Specifies an RFC 4648 base64 encoded, RSA-wrapped 2048-bit customer-supplied
- encryption key to either encrypt or decrypt this resource.
- returned: success
- type: str
- sha256:
- description:
- - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied
- encryption key that protects this resource.
- returned: success
- type: str
- index:
- description:
- - Assigns a zero-based index to this disk, where 0 is reserved for the boot
- disk. For example, if you have many disks attached to an instance, each
- disk would have a unique index number. If not specified, the server will
- choose an appropriate value.
- returned: success
- type: int
- initializeParams:
- description:
- - Specifies the parameters for a new disk that will be created alongside
- the new instance. Use initialization parameters to create boot disks or
- local SSDs attached to the new instance.
- returned: success
- type: complex
- contains:
- diskName:
- description:
- - Specifies the disk name. If not specified, the default is to use the
- name of the instance.
- returned: success
- type: str
- diskSizeGb:
- description:
- - Specifies the size of the disk in base-2 GB.
- returned: success
- type: int
- diskType:
- description:
- - Reference to a disk type.
- - Specifies the disk type to use to create the instance.
- - If not specified, the default is pd-standard.
- returned: success
- type: str
- sourceImage:
- description:
- - The source image to create this disk. When creating a new instance,
- one of initializeParams.sourceImage or disks.source is required. To
- create a disk with one of the public operating system images, specify
- the image by its family name.
- returned: success
- type: str
- sourceImageEncryptionKey:
- description:
- - The customer-supplied encryption key of the source image. Required
- if the source image is protected by a customer-supplied encryption
- key.
- - Instance templates do not store customer-supplied encryption keys,
- so you cannot create disks for instances in a managed instance group
- if the source images are encrypted with your own keys.
- returned: success
- type: complex
- contains:
- rawKey:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded
- in RFC 4648 base64 to either encrypt or decrypt this resource.
- returned: success
- type: str
- sha256:
- description:
- - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied
- encryption key that protects this resource.
- returned: success
- type: str
- interface:
- description:
- - Specifies the disk interface to use for attaching this disk, which is
- either SCSI or NVME. The default is SCSI.
- - Persistent disks must always use SCSI and the request will fail if you
- attempt to attach a persistent disk in any other format than SCSI.
- returned: success
- type: str
- mode:
- description:
- - The mode in which to attach this disk, either READ_WRITE or READ_ONLY.
- If not specified, the default is to attach the disk in READ_WRITE mode.
- returned: success
- type: str
- source:
- description:
- - Reference to a disk. When creating a new instance, one of initializeParams.sourceImage
- or disks.source is required.
- - If desired, you can also attach existing non-root persistent disks using
- this property. This field is only applicable for persistent disks.
- returned: success
- type: dict
- type:
- description:
- - Specifies the type of the disk, either SCRATCH or PERSISTENT. If not specified,
- the default is PERSISTENT.
- returned: success
- type: str
- guestAccelerators:
- description:
- - List of the type and count of accelerator cards attached to the instance .
- returned: success
- type: complex
- contains:
- acceleratorCount:
- description:
- - The number of the guest accelerator cards exposed to this instance.
- returned: success
- type: int
- acceleratorType:
- description:
- - Full or partial URL of the accelerator type resource to expose to this
- instance.
- returned: success
- type: str
- hostname:
- description:
- - The hostname of the instance to be created. The specified hostname must be
- RFC1035 compliant. If hostname is not specified, the default hostname is [INSTANCE_NAME].c.[PROJECT_ID].internal
- when using the global DNS, and [INSTANCE_NAME].[ZONE].c.[PROJECT_ID].internal
- when using zonal DNS.
- returned: success
- type: str
- id:
- description:
- - The unique identifier for the resource. This identifier is defined by the
- server.
- returned: success
- type: int
- labelFingerprint:
- description:
- - The fingerprint used for optimistic locking of this resource. Used internally
- during updates.
- returned: success
- type: str
- labels:
- description:
- - Labels to apply to this instance. A list of key->value pairs.
- returned: success
- type: dict
- metadata:
- description:
- - The metadata key/value pairs to assign to instances that are created from
- this template. These pairs can consist of custom metadata or predefined keys.
- returned: success
- type: dict
- machineType:
- description:
- - A reference to a machine type which defines VM kind.
- returned: success
- type: str
- minCpuPlatform:
- description:
- - Specifies a minimum CPU platform for the VM instance. Applicable values are
- the friendly names of CPU platforms .
- returned: success
- type: str
- name:
- description:
- - The name of the resource, provided by the client when initially creating the
- resource. The resource name must be 1-63 characters long, and comply with
- RFC1035. Specifically, the name must be 1-63 characters long and match the
- regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character
- must be a lowercase letter, and all following characters must be a dash, lowercase
- letter, or digit, except the last character, which cannot be a dash.
- returned: success
- type: str
- networkInterfaces:
- description:
- - An array of configurations for this interface. This specifies how this interface
- is configured to interact with other network services, such as connecting
- to the internet. Only one network interface is supported per instance.
- returned: success
- type: complex
- contains:
- accessConfigs:
- description:
- - An array of configurations for this interface. Currently, only one access
- config, ONE_TO_ONE_NAT, is supported. If there are no accessConfigs specified,
- then this instance will have no external internet access.
- returned: success
- type: complex
- contains:
- name:
- description:
- - The name of this access configuration. The default and recommended
- name is External NAT but you can use any arbitrary string you would
- like. For example, My external IP or Network Access.
- returned: success
- type: str
- natIP:
- description:
- - Reference to an address.
- - An external IP address associated with this instance.
- - Specify an unused static external IP address available to the project
- or leave this field undefined to use an IP from a shared ephemeral
- IP address pool. If you specify a static external IP address, it must
- live in the same region as the zone of the instance.
- returned: success
- type: dict
- type:
- description:
- - The type of configuration. The default and only option is ONE_TO_ONE_NAT.
- returned: success
- type: str
- setPublicPtr:
- description:
- - Specifies whether a public DNS PTR record should be created to map
- the external IP address of the instance to a DNS domain name.
- returned: success
- type: bool
- publicPtrDomainName:
- description:
- - The DNS domain name for the public PTR record. You can set this field
- only if the setPublicPtr field is enabled.
- returned: success
- type: str
- networkTier:
- description:
- - This signifies the networking tier used for configuring this access
- configuration. If an AccessConfig is specified without a valid external
- IP address, an ephemeral IP will be created with this networkTier.
- If an AccessConfig with a valid external IP address is specified,
- it must match that of the networkTier associated with the Address
- resource owning that IP.
- returned: success
- type: str
- aliasIpRanges:
- description:
- - An array of alias IP ranges for this network interface. Can only be specified
- for network interfaces on subnet-mode networks.
- returned: success
- type: complex
- contains:
- ipCidrRange:
- description:
- - The IP CIDR range represented by this alias IP range.
- - This IP CIDR range must belong to the specified subnetwork and cannot
- contain IP addresses reserved by system or used by other network interfaces.
- This range may be a single IP address (e.g. 10.2.3.4), a netmask (e.g.
- /24) or a CIDR format string (e.g. 10.1.2.0/24).
- returned: success
- type: str
- subnetworkRangeName:
- description:
- - Optional subnetwork secondary range name specifying the secondary
- range from which to allocate the IP CIDR range for this alias IP range.
- If left unspecified, the primary range of the subnetwork will be used.
- returned: success
- type: str
- name:
- description:
- - The name of the network interface, generated by the server. For network
- devices, these are eth0, eth1, etc .
- returned: success
- type: str
- network:
- description:
- - Specifies the title of an existing network. Not setting the network title
- will select the default network interface, which could have SSH already
- configured .
- returned: success
- type: dict
- networkIP:
- description:
- - An IPv4 internal network address to assign to the instance for this network
- interface. If not specified by the user, an unused internal IP is assigned
- by the system.
- returned: success
- type: str
- subnetwork:
- description:
- - Reference to a VPC network.
- - If the network resource is in legacy mode, do not provide this property.
- If the network is in auto subnet mode, providing the subnetwork is optional.
- If the network is in custom subnet mode, then this field should be specified.
- returned: success
- type: dict
- scheduling:
- description:
- - Sets the scheduling options for this instance.
- returned: success
- type: complex
- contains:
- automaticRestart:
- description:
- - Specifies whether the instance should be automatically restarted if it
- is terminated by Compute Engine (not terminated by a user).
- - You can only set the automatic restart option for standard instances.
- Preemptible instances cannot be automatically restarted.
- returned: success
- type: bool
- onHostMaintenance:
- description:
- - Defines the maintenance behavior for this instance. For standard instances,
- the default behavior is MIGRATE. For preemptible instances, the default
- and only possible behavior is TERMINATE.
- - For more information, see Setting Instance Scheduling Options.
- returned: success
- type: str
- preemptible:
- description:
- - Defines whether the instance is preemptible. This can only be set during
- instance creation, it cannot be set or changed after the instance has
- been created.
- returned: success
- type: bool
- serviceAccounts:
- description:
- - A list of service accounts, with their specified scopes, authorized for this
- instance. Only one service account per VM instance is supported.
- returned: success
- type: complex
- contains:
- email:
- description:
- - Email address of the service account.
- returned: success
- type: str
- scopes:
- description:
- - The list of scopes to be made available for this service account.
- returned: success
- type: list
- shieldedInstanceConfig:
- description:
- - Configuration for various parameters related to shielded instances.
- returned: success
- type: complex
- contains:
- enableSecureBoot:
- description:
- - Defines whether the instance has Secure Boot enabled.
- returned: success
- type: bool
- enableVtpm:
- description:
- - Defines whether the instance has the vTPM enabled.
- returned: success
- type: bool
- enableIntegrityMonitoring:
- description:
- - Defines whether the instance has integrity monitoring enabled.
- returned: success
- type: bool
- status:
- description:
- - 'The status of the instance. One of the following values: PROVISIONING, STAGING,
- RUNNING, STOPPING, SUSPENDING, SUSPENDED, and TERMINATED.'
- - As a user, use RUNNING to keep a machine "on" and TERMINATED to turn a machine
- off .
- returned: success
- type: str
- statusMessage:
- description:
- - An optional, human-readable explanation of the status.
- returned: success
- type: str
- tags:
- description:
- - A list of tags to apply to this instance. Tags are used to identify valid
- sources or targets for network firewalls and are specified by the client during
- instance creation. The tags can be later modified by the setTags method. Each
- tag within the list must comply with RFC1035.
- returned: success
- type: complex
- contains:
- fingerprint:
- description:
- - Specifies a fingerprint for this request, which is essentially a hash
- of the metadata's contents and used for optimistic locking.
- - The fingerprint is initially generated by Compute Engine and changes after
- every request to modify or update metadata. You must always provide an
- up-to-date fingerprint hash in order to update or change metadata.
- returned: success
- type: str
- items:
- description:
- - An array of tags. Each tag must be 1-63 characters long, and comply with
- RFC1035.
- returned: success
- type: list
- zone:
- description:
- - A reference to the zone where the machine resides.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str'), zone=dict(required=True, type='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/instances".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_instance_template.py b/lib/ansible/modules/cloud/google/gcp_compute_instance_template.py
deleted file mode 100644
index eaf7c9baac..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_instance_template.py
+++ /dev/null
@@ -1,1661 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_instance_template
-description:
-- Defines an Instance Template resource that provides configuration settings for your
- virtual machine instances. Instance templates are not tied to the lifetime of an
- instance and can be used and reused as to deploy virtual machines. You can also
- use different templates to create different virtual machine configurations. Instance
- templates are required when you create a managed instance group.
-- 'Tip: Disks should be set to autoDelete=true so that leftover disks are not left
- behind on machine deletion.'
-short_description: Creates a GCP InstanceTemplate
-version_added: '2.6'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- required: false
- type: str
- name:
- description:
- - Name of the resource. The name is 1-63 characters long and complies with RFC1035.
- required: true
- type: str
- properties:
- description:
- - The instance properties for this instance template.
- required: false
- type: dict
- suboptions:
- can_ip_forward:
- description:
- - Enables instances created based on this template to send packets with source
- IP addresses other than their own and receive packets with destination IP
- addresses other than their own. If these instances will be used as an IP
- gateway or it will be set as the next-hop in a Route resource, specify true.
- If unsure, leave this set to false.
- required: false
- type: bool
- description:
- description:
- - An optional text description for the instances that are created from this
- instance template.
- required: false
- type: str
- disks:
- description:
- - An array of disks that are associated with the instances that are created
- from this template.
- required: false
- type: list
- suboptions:
- auto_delete:
- description:
- - Specifies whether the disk will be auto-deleted when the instance is
- deleted (but not when the disk is detached from the instance).
- - 'Tip: Disks should be set to autoDelete=true so that leftover disks
- are not left behind on machine deletion.'
- required: false
- type: bool
- boot:
- description:
- - Indicates that this is a boot disk. The virtual machine will use the
- first partition of the disk for its root filesystem.
- required: false
- type: bool
- device_name:
- description:
- - Specifies a unique device name of your choice that is reflected into
- the /dev/disk/by-id/google-* tree of a Linux operating system running
- within the instance. This name can be used to reference the device for
- mounting, resizing, and so on, from within the instance.
- required: false
- type: str
- disk_encryption_key:
- description:
- - Encrypts or decrypts a disk using a customer-supplied encryption key.
- required: false
- type: dict
- suboptions:
- raw_key:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded in
- RFC 4648 base64 to either encrypt or decrypt this resource.
- required: false
- type: str
- rsa_encrypted_key:
- description:
- - Specifies an RFC 4648 base64 encoded, RSA-wrapped 2048-bit customer-supplied
- encryption key to either encrypt or decrypt this resource.
- required: false
- type: str
- index:
- description:
- - Assigns a zero-based index to this disk, where 0 is reserved for the
- boot disk. For example, if you have many disks attached to an instance,
- each disk would have a unique index number. If not specified, the server
- will choose an appropriate value.
- required: false
- type: int
- initialize_params:
- description:
- - Specifies the parameters for a new disk that will be created alongside
- the new instance. Use initialization parameters to create boot disks
- or local SSDs attached to the new instance.
- required: false
- type: dict
- suboptions:
- disk_name:
- description:
- - Specifies the disk name. If not specified, the default is to use
- the name of the instance.
- required: false
- type: str
- disk_size_gb:
- description:
- - Specifies the size of the disk in base-2 GB.
- required: false
- type: int
- disk_type:
- description:
- - Reference to a disk type.
- - Specifies the disk type to use to create the instance.
- - If not specified, the default is pd-standard.
- required: false
- type: str
- source_image:
- description:
- - The source image to create this disk. When creating a new instance,
- one of initializeParams.sourceImage or disks.source is required.
- To create a disk with one of the public operating system images,
- specify the image by its family name.
- required: false
- type: str
- source_image_encryption_key:
- description:
- - The customer-supplied encryption key of the source image. Required
- if the source image is protected by a customer-supplied encryption
- key.
- - Instance templates do not store customer-supplied encryption keys,
- so you cannot create disks for instances in a managed instance group
- if the source images are encrypted with your own keys.
- required: false
- type: dict
- suboptions:
- raw_key:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded
- in RFC 4648 base64 to either encrypt or decrypt this resource.
- required: false
- type: str
- interface:
- description:
- - Specifies the disk interface to use for attaching this disk, which is
- either SCSI or NVME. The default is SCSI.
- - Persistent disks must always use SCSI and the request will fail if you
- attempt to attach a persistent disk in any other format than SCSI.
- - 'Some valid choices include: "SCSI", "NVME"'
- required: false
- type: str
- mode:
- description:
- - The mode in which to attach this disk, either READ_WRITE or READ_ONLY.
- If not specified, the default is to attach the disk in READ_WRITE mode.
- - 'Some valid choices include: "READ_WRITE", "READ_ONLY"'
- required: false
- type: str
- source:
- description:
- - Reference to a disk. When creating a new instance, one of initializeParams.sourceImage
- or disks.source is required.
- - If desired, you can also attach existing non-root persistent disks using
- this property. This field is only applicable for persistent disks.
- - Note that for InstanceTemplate, specify the disk name, not the URL for
- the disk.
- - 'This field represents a link to a Disk resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''name'' and
- value of your resource''s name Alternatively, you can add `register:
- name-of-resource` to a gcp_compute_disk task and then set this source
- field to "{{ name-of-resource }}"'
- required: false
- type: dict
- type:
- description:
- - Specifies the type of the disk, either SCRATCH or PERSISTENT. If not
- specified, the default is PERSISTENT.
- - 'Some valid choices include: "SCRATCH", "PERSISTENT"'
- required: false
- type: str
- labels:
- description:
- - Labels to apply to this address. A list of key->value pairs.
- required: false
- type: dict
- version_added: '2.9'
- machine_type:
- description:
- - The machine type to use in the VM instance template.
- required: true
- type: str
- min_cpu_platform:
- description:
- - Specifies a minimum CPU platform for the VM instance. Applicable values
- are the friendly names of CPU platforms .
- required: false
- type: str
- metadata:
- description:
- - The metadata key/value pairs to assign to instances that are created from
- this template. These pairs can consist of custom metadata or predefined
- keys.
- required: false
- type: dict
- guest_accelerators:
- description:
- - List of the type and count of accelerator cards attached to the instance
- .
- required: false
- type: list
- suboptions:
- accelerator_count:
- description:
- - The number of the guest accelerator cards exposed to this instance.
- required: false
- type: int
- accelerator_type:
- description:
- - Full or partial URL of the accelerator type resource to expose to this
- instance.
- required: false
- type: str
- network_interfaces:
- description:
- - An array of configurations for this interface. This specifies how this interface
- is configured to interact with other network services, such as connecting
- to the internet. Only one network interface is supported per instance.
- required: false
- type: list
- suboptions:
- access_configs:
- description:
- - An array of configurations for this interface. Currently, only one access
- config, ONE_TO_ONE_NAT, is supported. If there are no accessConfigs
- specified, then this instance will have no external internet access.
- required: false
- type: list
- suboptions:
- name:
- description:
- - The name of this access configuration. The default and recommended
- name is External NAT but you can use any arbitrary string you would
- like. For example, My external IP or Network Access.
- required: true
- type: str
- nat_ip:
- description:
- - Reference to an address.
- - An external IP address associated with this instance.
- - Specify an unused static external IP address available to the project
- or leave this field undefined to use an IP from a shared ephemeral
- IP address pool. If you specify a static external IP address, it
- must live in the same region as the zone of the instance.
- - 'This field represents a link to a Address resource in GCP. It can
- be specified in two ways. First, you can place a dictionary with
- key ''address'' and value of your resource''s address Alternatively,
- you can add `register: name-of-resource` to a gcp_compute_address
- task and then set this nat_ip field to "{{ name-of-resource }}"'
- required: false
- type: dict
- type:
- description:
- - The type of configuration. The default and only option is ONE_TO_ONE_NAT.
- - 'Some valid choices include: "ONE_TO_ONE_NAT"'
- required: true
- type: str
- set_public_ptr:
- description:
- - Specifies whether a public DNS PTR record should be created to map
- the external IP address of the instance to a DNS domain name.
- required: false
- type: bool
- version_added: '2.10'
- public_ptr_domain_name:
- description:
- - The DNS domain name for the public PTR record. You can set this
- field only if the setPublicPtr field is enabled.
- required: false
- type: str
- version_added: '2.10'
- network_tier:
- description:
- - This signifies the networking tier used for configuring this access
- configuration. If an AccessConfig is specified without a valid external
- IP address, an ephemeral IP will be created with this networkTier.
- If an AccessConfig with a valid external IP address is specified,
- it must match that of the networkTier associated with the Address
- resource owning that IP.
- - 'Some valid choices include: "PREMIUM", "STANDARD"'
- required: false
- type: str
- version_added: '2.10'
- alias_ip_ranges:
- description:
- - An array of alias IP ranges for this network interface. Can only be
- specified for network interfaces on subnet-mode networks.
- required: false
- type: list
- suboptions:
- ip_cidr_range:
- description:
- - The IP CIDR range represented by this alias IP range.
- - This IP CIDR range must belong to the specified subnetwork and cannot
- contain IP addresses reserved by system or used by other network
- interfaces. This range may be a single IP address (e.g. 10.2.3.4),
- a netmask (e.g. /24) or a CIDR format string (e.g. 10.1.2.0/24).
- required: false
- type: str
- subnetwork_range_name:
- description:
- - Optional subnetwork secondary range name specifying the secondary
- range from which to allocate the IP CIDR range for this alias IP
- range. If left unspecified, the primary range of the subnetwork
- will be used.
- required: false
- type: str
- network:
- description:
- - Specifies the title of an existing network. When creating an instance,
- if neither the network nor the subnetwork is specified, the default
- network global/networks/default is used; if the network is not specified
- but the subnetwork is specified, the network is inferred.
- - 'This field represents a link to a Network resource in GCP. It can be
- specified in two ways. First, you can place a dictionary with key ''selfLink''
- and value of your resource''s selfLink Alternatively, you can add `register:
- name-of-resource` to a gcp_compute_network task and then set this network
- field to "{{ name-of-resource }}"'
- required: false
- type: dict
- network_ip:
- description:
- - An IPv4 internal network address to assign to the instance for this
- network interface. If not specified by the user, an unused internal
- IP is assigned by the system.
- required: false
- type: str
- subnetwork:
- description:
- - Reference to a VPC network.
- - If the network resource is in legacy mode, do not provide this property.
- If the network is in auto subnet mode, providing the subnetwork is optional.
- If the network is in custom subnet mode, then this field should be specified.
- - 'This field represents a link to a Subnetwork resource in GCP. It can
- be specified in two ways. First, you can place a dictionary with key
- ''selfLink'' and value of your resource''s selfLink Alternatively, you
- can add `register: name-of-resource` to a gcp_compute_subnetwork task
- and then set this subnetwork field to "{{ name-of-resource }}"'
- required: false
- type: dict
- scheduling:
- description:
- - Sets the scheduling options for this instance.
- required: false
- type: dict
- suboptions:
- automatic_restart:
- description:
- - Specifies whether the instance should be automatically restarted if
- it is terminated by Compute Engine (not terminated by a user).
- - You can only set the automatic restart option for standard instances.
- Preemptible instances cannot be automatically restarted.
- required: false
- type: bool
- on_host_maintenance:
- description:
- - Defines the maintenance behavior for this instance. For standard instances,
- the default behavior is MIGRATE. For preemptible instances, the default
- and only possible behavior is TERMINATE.
- - For more information, see Setting Instance Scheduling Options.
- required: false
- type: str
- preemptible:
- description:
- - Defines whether the instance is preemptible. This can only be set during
- instance creation, it cannot be set or changed after the instance has
- been created.
- required: false
- type: bool
- service_accounts:
- description:
- - A list of service accounts, with their specified scopes, authorized for
- this instance. Only one service account per VM instance is supported.
- required: false
- type: list
- suboptions:
- email:
- description:
- - Email address of the service account.
- required: false
- type: str
- scopes:
- description:
- - The list of scopes to be made available for this service account.
- required: false
- type: list
- tags:
- description:
- - A list of tags to apply to this instance. Tags are used to identify valid
- sources or targets for network firewalls and are specified by the client
- during instance creation. The tags can be later modified by the setTags
- method. Each tag within the list must comply with RFC1035.
- required: false
- type: dict
- suboptions:
- fingerprint:
- description:
- - Specifies a fingerprint for this request, which is essentially a hash
- of the metadata's contents and used for optimistic locking.
- - The fingerprint is initially generated by Compute Engine and changes
- after every request to modify or update metadata. You must always provide
- an up-to-date fingerprint hash in order to update or change metadata.
- required: false
- type: str
- items:
- description:
- - An array of tags. Each tag must be 1-63 characters long, and comply
- with RFC1035.
- required: false
- type: list
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-'''
-
-EXAMPLES = '''
-- name: create a network
- gcp_compute_network:
- name: network-instancetemplate
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: network
-
-- name: create a address
- gcp_compute_address:
- name: address-instancetemplate
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: address
-
-- name: create a instance template
- gcp_compute_instance_template:
- name: test_object
- properties:
- disks:
- - auto_delete: 'true'
- boot: 'true'
- initialize_params:
- source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
- machine_type: n1-standard-1
- network_interfaces:
- - network: "{{ network }}"
- access_configs:
- - name: test-config
- type: ONE_TO_ONE_NAT
- nat_ip: "{{ address }}"
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- returned: success
- type: str
-id:
- description:
- - The unique identifier for the resource. This identifier is defined by the server.
- returned: success
- type: int
-name:
- description:
- - Name of the resource. The name is 1-63 characters long and complies with RFC1035.
- returned: success
- type: str
-properties:
- description:
- - The instance properties for this instance template.
- returned: success
- type: complex
- contains:
- canIpForward:
- description:
- - Enables instances created based on this template to send packets with source
- IP addresses other than their own and receive packets with destination IP
- addresses other than their own. If these instances will be used as an IP gateway
- or it will be set as the next-hop in a Route resource, specify true. If unsure,
- leave this set to false.
- returned: success
- type: bool
- description:
- description:
- - An optional text description for the instances that are created from this
- instance template.
- returned: success
- type: str
- disks:
- description:
- - An array of disks that are associated with the instances that are created
- from this template.
- returned: success
- type: complex
- contains:
- autoDelete:
- description:
- - Specifies whether the disk will be auto-deleted when the instance is deleted
- (but not when the disk is detached from the instance).
- - 'Tip: Disks should be set to autoDelete=true so that leftover disks are
- not left behind on machine deletion.'
- returned: success
- type: bool
- boot:
- description:
- - Indicates that this is a boot disk. The virtual machine will use the first
- partition of the disk for its root filesystem.
- returned: success
- type: bool
- deviceName:
- description:
- - Specifies a unique device name of your choice that is reflected into the
- /dev/disk/by-id/google-* tree of a Linux operating system running within
- the instance. This name can be used to reference the device for mounting,
- resizing, and so on, from within the instance.
- returned: success
- type: str
- diskEncryptionKey:
- description:
- - Encrypts or decrypts a disk using a customer-supplied encryption key.
- returned: success
- type: complex
- contains:
- rawKey:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded in RFC
- 4648 base64 to either encrypt or decrypt this resource.
- returned: success
- type: str
- rsaEncryptedKey:
- description:
- - Specifies an RFC 4648 base64 encoded, RSA-wrapped 2048-bit customer-supplied
- encryption key to either encrypt or decrypt this resource.
- returned: success
- type: str
- sha256:
- description:
- - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied
- encryption key that protects this resource.
- returned: success
- type: str
- index:
- description:
- - Assigns a zero-based index to this disk, where 0 is reserved for the boot
- disk. For example, if you have many disks attached to an instance, each
- disk would have a unique index number. If not specified, the server will
- choose an appropriate value.
- returned: success
- type: int
- initializeParams:
- description:
- - Specifies the parameters for a new disk that will be created alongside
- the new instance. Use initialization parameters to create boot disks or
- local SSDs attached to the new instance.
- returned: success
- type: complex
- contains:
- diskName:
- description:
- - Specifies the disk name. If not specified, the default is to use the
- name of the instance.
- returned: success
- type: str
- diskSizeGb:
- description:
- - Specifies the size of the disk in base-2 GB.
- returned: success
- type: int
- diskType:
- description:
- - Reference to a disk type.
- - Specifies the disk type to use to create the instance.
- - If not specified, the default is pd-standard.
- returned: success
- type: str
- sourceImage:
- description:
- - The source image to create this disk. When creating a new instance,
- one of initializeParams.sourceImage or disks.source is required. To
- create a disk with one of the public operating system images, specify
- the image by its family name.
- returned: success
- type: str
- sourceImageEncryptionKey:
- description:
- - The customer-supplied encryption key of the source image. Required
- if the source image is protected by a customer-supplied encryption
- key.
- - Instance templates do not store customer-supplied encryption keys,
- so you cannot create disks for instances in a managed instance group
- if the source images are encrypted with your own keys.
- returned: success
- type: complex
- contains:
- rawKey:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded
- in RFC 4648 base64 to either encrypt or decrypt this resource.
- returned: success
- type: str
- sha256:
- description:
- - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied
- encryption key that protects this resource.
- returned: success
- type: str
- interface:
- description:
- - Specifies the disk interface to use for attaching this disk, which is
- either SCSI or NVME. The default is SCSI.
- - Persistent disks must always use SCSI and the request will fail if you
- attempt to attach a persistent disk in any other format than SCSI.
- returned: success
- type: str
- mode:
- description:
- - The mode in which to attach this disk, either READ_WRITE or READ_ONLY.
- If not specified, the default is to attach the disk in READ_WRITE mode.
- returned: success
- type: str
- source:
- description:
- - Reference to a disk. When creating a new instance, one of initializeParams.sourceImage
- or disks.source is required.
- - If desired, you can also attach existing non-root persistent disks using
- this property. This field is only applicable for persistent disks.
- - Note that for InstanceTemplate, specify the disk name, not the URL for
- the disk.
- returned: success
- type: dict
- type:
- description:
- - Specifies the type of the disk, either SCRATCH or PERSISTENT. If not specified,
- the default is PERSISTENT.
- returned: success
- type: str
- labels:
- description:
- - Labels to apply to this address. A list of key->value pairs.
- returned: success
- type: dict
- machineType:
- description:
- - The machine type to use in the VM instance template.
- returned: success
- type: str
- minCpuPlatform:
- description:
- - Specifies a minimum CPU platform for the VM instance. Applicable values are
- the friendly names of CPU platforms .
- returned: success
- type: str
- metadata:
- description:
- - The metadata key/value pairs to assign to instances that are created from
- this template. These pairs can consist of custom metadata or predefined keys.
- returned: success
- type: dict
- guestAccelerators:
- description:
- - List of the type and count of accelerator cards attached to the instance .
- returned: success
- type: complex
- contains:
- acceleratorCount:
- description:
- - The number of the guest accelerator cards exposed to this instance.
- returned: success
- type: int
- acceleratorType:
- description:
- - Full or partial URL of the accelerator type resource to expose to this
- instance.
- returned: success
- type: str
- networkInterfaces:
- description:
- - An array of configurations for this interface. This specifies how this interface
- is configured to interact with other network services, such as connecting
- to the internet. Only one network interface is supported per instance.
- returned: success
- type: complex
- contains:
- accessConfigs:
- description:
- - An array of configurations for this interface. Currently, only one access
- config, ONE_TO_ONE_NAT, is supported. If there are no accessConfigs specified,
- then this instance will have no external internet access.
- returned: success
- type: complex
- contains:
- name:
- description:
- - The name of this access configuration. The default and recommended
- name is External NAT but you can use any arbitrary string you would
- like. For example, My external IP or Network Access.
- returned: success
- type: str
- natIP:
- description:
- - Reference to an address.
- - An external IP address associated with this instance.
- - Specify an unused static external IP address available to the project
- or leave this field undefined to use an IP from a shared ephemeral
- IP address pool. If you specify a static external IP address, it must
- live in the same region as the zone of the instance.
- returned: success
- type: dict
- type:
- description:
- - The type of configuration. The default and only option is ONE_TO_ONE_NAT.
- returned: success
- type: str
- setPublicPtr:
- description:
- - Specifies whether a public DNS PTR record should be created to map
- the external IP address of the instance to a DNS domain name.
- returned: success
- type: bool
- publicPtrDomainName:
- description:
- - The DNS domain name for the public PTR record. You can set this field
- only if the setPublicPtr field is enabled.
- returned: success
- type: str
- networkTier:
- description:
- - This signifies the networking tier used for configuring this access
- configuration. If an AccessConfig is specified without a valid external
- IP address, an ephemeral IP will be created with this networkTier.
- If an AccessConfig with a valid external IP address is specified,
- it must match that of the networkTier associated with the Address
- resource owning that IP.
- returned: success
- type: str
- aliasIpRanges:
- description:
- - An array of alias IP ranges for this network interface. Can only be specified
- for network interfaces on subnet-mode networks.
- returned: success
- type: complex
- contains:
- ipCidrRange:
- description:
- - The IP CIDR range represented by this alias IP range.
- - This IP CIDR range must belong to the specified subnetwork and cannot
- contain IP addresses reserved by system or used by other network interfaces.
- This range may be a single IP address (e.g. 10.2.3.4), a netmask (e.g.
- /24) or a CIDR format string (e.g. 10.1.2.0/24).
- returned: success
- type: str
- subnetworkRangeName:
- description:
- - Optional subnetwork secondary range name specifying the secondary
- range from which to allocate the IP CIDR range for this alias IP range.
- If left unspecified, the primary range of the subnetwork will be used.
- returned: success
- type: str
- name:
- description:
- - The name of the network interface, generated by the server. For network
- devices, these are eth0, eth1, etc .
- returned: success
- type: str
- network:
- description:
- - Specifies the title of an existing network. When creating an instance,
- if neither the network nor the subnetwork is specified, the default network
- global/networks/default is used; if the network is not specified but the
- subnetwork is specified, the network is inferred.
- returned: success
- type: dict
- networkIP:
- description:
- - An IPv4 internal network address to assign to the instance for this network
- interface. If not specified by the user, an unused internal IP is assigned
- by the system.
- returned: success
- type: str
- subnetwork:
- description:
- - Reference to a VPC network.
- - If the network resource is in legacy mode, do not provide this property.
- If the network is in auto subnet mode, providing the subnetwork is optional.
- If the network is in custom subnet mode, then this field should be specified.
- returned: success
- type: dict
- scheduling:
- description:
- - Sets the scheduling options for this instance.
- returned: success
- type: complex
- contains:
- automaticRestart:
- description:
- - Specifies whether the instance should be automatically restarted if it
- is terminated by Compute Engine (not terminated by a user).
- - You can only set the automatic restart option for standard instances.
- Preemptible instances cannot be automatically restarted.
- returned: success
- type: bool
- onHostMaintenance:
- description:
- - Defines the maintenance behavior for this instance. For standard instances,
- the default behavior is MIGRATE. For preemptible instances, the default
- and only possible behavior is TERMINATE.
- - For more information, see Setting Instance Scheduling Options.
- returned: success
- type: str
- preemptible:
- description:
- - Defines whether the instance is preemptible. This can only be set during
- instance creation, it cannot be set or changed after the instance has
- been created.
- returned: success
- type: bool
- serviceAccounts:
- description:
- - A list of service accounts, with their specified scopes, authorized for this
- instance. Only one service account per VM instance is supported.
- returned: success
- type: complex
- contains:
- email:
- description:
- - Email address of the service account.
- returned: success
- type: str
- scopes:
- description:
- - The list of scopes to be made available for this service account.
- returned: success
- type: list
- tags:
- description:
- - A list of tags to apply to this instance. Tags are used to identify valid
- sources or targets for network firewalls and are specified by the client during
- instance creation. The tags can be later modified by the setTags method. Each
- tag within the list must comply with RFC1035.
- returned: success
- type: complex
- contains:
- fingerprint:
- description:
- - Specifies a fingerprint for this request, which is essentially a hash
- of the metadata's contents and used for optimistic locking.
- - The fingerprint is initially generated by Compute Engine and changes after
- every request to modify or update metadata. You must always provide an
- up-to-date fingerprint hash in order to update or change metadata.
- returned: success
- type: str
- items:
- description:
- - An array of tags. Each tag must be 1-63 characters long, and comply with
- RFC1035.
- returned: success
- type: list
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import re
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- description=dict(type='str'),
- name=dict(required=True, type='str'),
- properties=dict(
- type='dict',
- options=dict(
- can_ip_forward=dict(type='bool'),
- description=dict(type='str'),
- disks=dict(
- type='list',
- elements='dict',
- options=dict(
- auto_delete=dict(type='bool'),
- boot=dict(type='bool'),
- device_name=dict(type='str'),
- disk_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), rsa_encrypted_key=dict(type='str'))),
- index=dict(type='int'),
- initialize_params=dict(
- type='dict',
- options=dict(
- disk_name=dict(type='str'),
- disk_size_gb=dict(type='int'),
- disk_type=dict(type='str'),
- source_image=dict(type='str'),
- source_image_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'))),
- ),
- ),
- interface=dict(type='str'),
- mode=dict(type='str'),
- source=dict(type='dict'),
- type=dict(type='str'),
- ),
- ),
- labels=dict(type='dict'),
- machine_type=dict(required=True, type='str'),
- min_cpu_platform=dict(type='str'),
- metadata=dict(type='dict'),
- guest_accelerators=dict(type='list', elements='dict', options=dict(accelerator_count=dict(type='int'), accelerator_type=dict(type='str'))),
- network_interfaces=dict(
- type='list',
- elements='dict',
- options=dict(
- access_configs=dict(
- type='list',
- elements='dict',
- options=dict(
- name=dict(required=True, type='str'),
- nat_ip=dict(type='dict'),
- type=dict(required=True, type='str'),
- set_public_ptr=dict(type='bool'),
- public_ptr_domain_name=dict(type='str'),
- network_tier=dict(type='str'),
- ),
- ),
- alias_ip_ranges=dict(
- type='list', elements='dict', options=dict(ip_cidr_range=dict(type='str'), subnetwork_range_name=dict(type='str'))
- ),
- network=dict(type='dict'),
- network_ip=dict(type='str'),
- subnetwork=dict(type='dict'),
- ),
- ),
- scheduling=dict(
- type='dict', options=dict(automatic_restart=dict(type='bool'), on_host_maintenance=dict(type='str'), preemptible=dict(type='bool'))
- ),
- service_accounts=dict(type='list', elements='dict', options=dict(email=dict(type='str'), scopes=dict(type='list', elements='str'))),
- tags=dict(type='dict', options=dict(fingerprint=dict(type='str'), items=dict(type='list', elements='str'))),
- ),
- ),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#instanceTemplate'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind):
- delete(module, self_link(module), kind)
- create(module, collection(module), kind)
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#instanceTemplate',
- u'description': module.params.get('description'),
- u'name': module.params.get('name'),
- u'properties': InstanceTemplateProperties(module.params.get('properties', {}), module).to_request(),
- }
- request = encode_request(request, module)
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/instanceTemplates/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/instanceTemplates".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- result = decode_response(result, module)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
- request = decode_response(request, module)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'description': response.get(u'description'),
- u'id': response.get(u'id'),
- u'name': response.get(u'name'),
- u'properties': InstanceTemplateProperties(response.get(u'properties', {}), module).from_response(),
- }
-
-
-def disk_type_selflink(name, params):
- if name is None:
- return
- url = r"https://www.googleapis.com/compute/v1/projects/.*/zones/.*/diskTypes/.*"
- if not re.match(url, name):
- name = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/diskTypes/%s".format(**params) % name
- return name
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/global/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- response = fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#instanceTemplate')
- if response:
- return decode_response(response, module)
- else:
- return {}
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-def encode_request(request, module):
- if 'properties' in request and request['properties'] is not None and 'metadata' in request['properties'] and request['properties']['metadata'] is not None:
- request['properties']['metadata'] = metadata_encoder(request['properties']['metadata'])
- return request
-
-
-def decode_response(response, module):
- if (
- 'properties' in response
- and response['properties'] is not None
- and 'metadata' in response['properties']
- and response['properties']['metadata'] is not None
- ):
- response['properties']['metadata'] = metadata_decoder(response['properties']['metadata'])
- return response
-
-
-# TODO(alexstephen): Implement updating metadata on existing resources.
-
-# Expose instance 'metadata' as a simple name/value pair hash. However the API
-# defines metadata as a NestedObject with the following layout:
-#
-# metadata {
-# fingerprint: 'hash-of-last-metadata'
-# items: [
-# {
-# key: 'metadata1-key'
-# value: 'metadata1-value'
-# },
-# ...
-# ]
-# }
-#
-def metadata_encoder(metadata):
- metadata_new = []
- for key in metadata:
- value = metadata[key]
- metadata_new.append({"key": key, "value": value})
- return {'items': metadata_new}
-
-
-# Map metadata.items[]{key:,value:} => metadata[key]=value
-def metadata_decoder(metadata):
- items = {}
- if 'items' in metadata:
- metadata_items = metadata['items']
- for item in metadata_items:
- items[item['key']] = item['value']
- return items
-
-
-class InstanceTemplateProperties(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'canIpForward': self.request.get('can_ip_forward'),
- u'description': self.request.get('description'),
- u'disks': InstanceTemplateDisksArray(self.request.get('disks', []), self.module).to_request(),
- u'labels': self.request.get('labels'),
- u'machineType': self.request.get('machine_type'),
- u'minCpuPlatform': self.request.get('min_cpu_platform'),
- u'metadata': self.request.get('metadata'),
- u'guestAccelerators': InstanceTemplateGuestacceleratorsArray(self.request.get('guest_accelerators', []), self.module).to_request(),
- u'networkInterfaces': InstanceTemplateNetworkinterfacesArray(self.request.get('network_interfaces', []), self.module).to_request(),
- u'scheduling': InstanceTemplateScheduling(self.request.get('scheduling', {}), self.module).to_request(),
- u'serviceAccounts': InstanceTemplateServiceaccountsArray(self.request.get('service_accounts', []), self.module).to_request(),
- u'tags': InstanceTemplateTags(self.request.get('tags', {}), self.module).to_request(),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'canIpForward': self.request.get(u'canIpForward'),
- u'description': self.request.get(u'description'),
- u'disks': InstanceTemplateDisksArray(self.request.get(u'disks', []), self.module).from_response(),
- u'labels': self.request.get(u'labels'),
- u'machineType': self.request.get(u'machineType'),
- u'minCpuPlatform': self.request.get(u'minCpuPlatform'),
- u'metadata': self.request.get(u'metadata'),
- u'guestAccelerators': InstanceTemplateGuestacceleratorsArray(self.request.get(u'guestAccelerators', []), self.module).from_response(),
- u'networkInterfaces': InstanceTemplateNetworkinterfacesArray(self.request.get(u'networkInterfaces', []), self.module).from_response(),
- u'scheduling': InstanceTemplateScheduling(self.request.get(u'scheduling', {}), self.module).from_response(),
- u'serviceAccounts': InstanceTemplateServiceaccountsArray(self.request.get(u'serviceAccounts', []), self.module).from_response(),
- u'tags': InstanceTemplateTags(self.request.get(u'tags', {}), self.module).from_response(),
- }
- )
-
-
-class InstanceTemplateDisksArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict(
- {
- u'autoDelete': item.get('auto_delete'),
- u'boot': item.get('boot'),
- u'deviceName': item.get('device_name'),
- u'diskEncryptionKey': InstanceTemplateDiskencryptionkey(item.get('disk_encryption_key', {}), self.module).to_request(),
- u'index': item.get('index'),
- u'initializeParams': InstanceTemplateInitializeparams(item.get('initialize_params', {}), self.module).to_request(),
- u'interface': item.get('interface'),
- u'mode': item.get('mode'),
- u'source': replace_resource_dict(item.get(u'source', {}), 'name'),
- u'type': item.get('type'),
- }
- )
-
- def _response_from_item(self, item):
- return remove_nones_from_dict(
- {
- u'autoDelete': item.get(u'autoDelete'),
- u'boot': item.get(u'boot'),
- u'deviceName': item.get(u'deviceName'),
- u'diskEncryptionKey': InstanceTemplateDiskencryptionkey(item.get(u'diskEncryptionKey', {}), self.module).from_response(),
- u'index': item.get(u'index'),
- u'initializeParams': InstanceTemplateInitializeparams(self.module.params.get('initialize_params', {}), self.module).to_request(),
- u'interface': item.get(u'interface'),
- u'mode': item.get(u'mode'),
- u'source': item.get(u'source'),
- u'type': item.get(u'type'),
- }
- )
-
-
-class InstanceTemplateDiskencryptionkey(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'rawKey': self.request.get('raw_key'), u'rsaEncryptedKey': self.request.get('rsa_encrypted_key')})
-
- def from_response(self):
- return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey'), u'rsaEncryptedKey': self.request.get(u'rsaEncryptedKey')})
-
-
-class InstanceTemplateInitializeparams(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'diskName': self.request.get('disk_name'),
- u'diskSizeGb': self.request.get('disk_size_gb'),
- u'diskType': disk_type_selflink(self.request.get('disk_type'), self.module.params),
- u'sourceImage': self.request.get('source_image'),
- u'sourceImageEncryptionKey': InstanceTemplateSourceimageencryptionkey(
- self.request.get('source_image_encryption_key', {}), self.module
- ).to_request(),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'diskName': self.request.get(u'diskName'),
- u'diskSizeGb': self.request.get(u'diskSizeGb'),
- u'diskType': self.request.get(u'diskType'),
- u'sourceImage': self.request.get(u'sourceImage'),
- u'sourceImageEncryptionKey': InstanceTemplateSourceimageencryptionkey(
- self.request.get(u'sourceImageEncryptionKey', {}), self.module
- ).from_response(),
- }
- )
-
-
-class InstanceTemplateSourceimageencryptionkey(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'rawKey': self.request.get('raw_key')})
-
- def from_response(self):
- return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey')})
-
-
-class InstanceTemplateGuestacceleratorsArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'acceleratorCount': item.get('accelerator_count'), u'acceleratorType': item.get('accelerator_type')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'acceleratorCount': item.get(u'acceleratorCount'), u'acceleratorType': item.get(u'acceleratorType')})
-
-
-class InstanceTemplateNetworkinterfacesArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict(
- {
- u'accessConfigs': InstanceTemplateAccessconfigsArray(item.get('access_configs', []), self.module).to_request(),
- u'aliasIpRanges': InstanceTemplateAliasiprangesArray(item.get('alias_ip_ranges', []), self.module).to_request(),
- u'network': replace_resource_dict(item.get(u'network', {}), 'selfLink'),
- u'networkIP': item.get('network_ip'),
- u'subnetwork': replace_resource_dict(item.get(u'subnetwork', {}), 'selfLink'),
- }
- )
-
- def _response_from_item(self, item):
- return remove_nones_from_dict(
- {
- u'accessConfigs': InstanceTemplateAccessconfigsArray(item.get(u'accessConfigs', []), self.module).from_response(),
- u'aliasIpRanges': InstanceTemplateAliasiprangesArray(item.get(u'aliasIpRanges', []), self.module).from_response(),
- u'network': item.get(u'network'),
- u'networkIP': item.get(u'networkIP'),
- u'subnetwork': item.get(u'subnetwork'),
- }
- )
-
-
-class InstanceTemplateAccessconfigsArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict(
- {
- u'name': item.get('name'),
- u'natIP': replace_resource_dict(item.get(u'nat_ip', {}), 'address'),
- u'type': item.get('type'),
- u'setPublicPtr': item.get('set_public_ptr'),
- u'publicPtrDomainName': item.get('public_ptr_domain_name'),
- u'networkTier': item.get('network_tier'),
- }
- )
-
- def _response_from_item(self, item):
- return remove_nones_from_dict(
- {
- u'name': item.get(u'name'),
- u'natIP': item.get(u'natIP'),
- u'type': item.get(u'type'),
- u'setPublicPtr': item.get(u'setPublicPtr'),
- u'publicPtrDomainName': item.get(u'publicPtrDomainName'),
- u'networkTier': item.get(u'networkTier'),
- }
- )
-
-
-class InstanceTemplateAliasiprangesArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'ipCidrRange': item.get('ip_cidr_range'), u'subnetworkRangeName': item.get('subnetwork_range_name')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'ipCidrRange': item.get(u'ipCidrRange'), u'subnetworkRangeName': item.get(u'subnetworkRangeName')})
-
-
-class InstanceTemplateScheduling(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'automaticRestart': self.request.get('automatic_restart'),
- u'onHostMaintenance': self.request.get('on_host_maintenance'),
- u'preemptible': self.request.get('preemptible'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'automaticRestart': self.request.get(u'automaticRestart'),
- u'onHostMaintenance': self.request.get(u'onHostMaintenance'),
- u'preemptible': self.request.get(u'preemptible'),
- }
- )
-
-
-class InstanceTemplateServiceaccountsArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'email': item.get('email'), u'scopes': item.get('scopes')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'email': item.get(u'email'), u'scopes': item.get(u'scopes')})
-
-
-class InstanceTemplateTags(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'fingerprint': self.request.get('fingerprint'), u'items': self.request.get('items')})
-
- def from_response(self):
- return remove_nones_from_dict({u'fingerprint': self.request.get(u'fingerprint'), u'items': self.request.get(u'items')})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_instance_template_info.py b/lib/ansible/modules/cloud/google/gcp_compute_instance_template_info.py
deleted file mode 100644
index a1453c78b1..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_instance_template_info.py
+++ /dev/null
@@ -1,608 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_instance_template_info
-description:
-- Gather info for GCP InstanceTemplate
-short_description: Gather info for GCP InstanceTemplate
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on an instance template
- gcp_compute_instance_template_info:
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- returned: success
- type: str
- id:
- description:
- - The unique identifier for the resource. This identifier is defined by the
- server.
- returned: success
- type: int
- name:
- description:
- - Name of the resource. The name is 1-63 characters long and complies with RFC1035.
- returned: success
- type: str
- properties:
- description:
- - The instance properties for this instance template.
- returned: success
- type: complex
- contains:
- canIpForward:
- description:
- - Enables instances created based on this template to send packets with
- source IP addresses other than their own and receive packets with destination
- IP addresses other than their own. If these instances will be used as
- an IP gateway or it will be set as the next-hop in a Route resource, specify
- true. If unsure, leave this set to false.
- returned: success
- type: bool
- description:
- description:
- - An optional text description for the instances that are created from this
- instance template.
- returned: success
- type: str
- disks:
- description:
- - An array of disks that are associated with the instances that are created
- from this template.
- returned: success
- type: complex
- contains:
- autoDelete:
- description:
- - Specifies whether the disk will be auto-deleted when the instance
- is deleted (but not when the disk is detached from the instance).
- - 'Tip: Disks should be set to autoDelete=true so that leftover disks
- are not left behind on machine deletion.'
- returned: success
- type: bool
- boot:
- description:
- - Indicates that this is a boot disk. The virtual machine will use the
- first partition of the disk for its root filesystem.
- returned: success
- type: bool
- deviceName:
- description:
- - Specifies a unique device name of your choice that is reflected into
- the /dev/disk/by-id/google-* tree of a Linux operating system running
- within the instance. This name can be used to reference the device
- for mounting, resizing, and so on, from within the instance.
- returned: success
- type: str
- diskEncryptionKey:
- description:
- - Encrypts or decrypts a disk using a customer-supplied encryption key.
- returned: success
- type: complex
- contains:
- rawKey:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded
- in RFC 4648 base64 to either encrypt or decrypt this resource.
- returned: success
- type: str
- rsaEncryptedKey:
- description:
- - Specifies an RFC 4648 base64 encoded, RSA-wrapped 2048-bit customer-supplied
- encryption key to either encrypt or decrypt this resource.
- returned: success
- type: str
- sha256:
- description:
- - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied
- encryption key that protects this resource.
- returned: success
- type: str
- index:
- description:
- - Assigns a zero-based index to this disk, where 0 is reserved for the
- boot disk. For example, if you have many disks attached to an instance,
- each disk would have a unique index number. If not specified, the
- server will choose an appropriate value.
- returned: success
- type: int
- initializeParams:
- description:
- - Specifies the parameters for a new disk that will be created alongside
- the new instance. Use initialization parameters to create boot disks
- or local SSDs attached to the new instance.
- returned: success
- type: complex
- contains:
- diskName:
- description:
- - Specifies the disk name. If not specified, the default is to use
- the name of the instance.
- returned: success
- type: str
- diskSizeGb:
- description:
- - Specifies the size of the disk in base-2 GB.
- returned: success
- type: int
- diskType:
- description:
- - Reference to a disk type.
- - Specifies the disk type to use to create the instance.
- - If not specified, the default is pd-standard.
- returned: success
- type: str
- sourceImage:
- description:
- - The source image to create this disk. When creating a new instance,
- one of initializeParams.sourceImage or disks.source is required.
- To create a disk with one of the public operating system images,
- specify the image by its family name.
- returned: success
- type: str
- sourceImageEncryptionKey:
- description:
- - The customer-supplied encryption key of the source image. Required
- if the source image is protected by a customer-supplied encryption
- key.
- - Instance templates do not store customer-supplied encryption keys,
- so you cannot create disks for instances in a managed instance
- group if the source images are encrypted with your own keys.
- returned: success
- type: complex
- contains:
- rawKey:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded
- in RFC 4648 base64 to either encrypt or decrypt this resource.
- returned: success
- type: str
- sha256:
- description:
- - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied
- encryption key that protects this resource.
- returned: success
- type: str
- interface:
- description:
- - Specifies the disk interface to use for attaching this disk, which
- is either SCSI or NVME. The default is SCSI.
- - Persistent disks must always use SCSI and the request will fail if
- you attempt to attach a persistent disk in any other format than SCSI.
- returned: success
- type: str
- mode:
- description:
- - The mode in which to attach this disk, either READ_WRITE or READ_ONLY.
- If not specified, the default is to attach the disk in READ_WRITE
- mode.
- returned: success
- type: str
- source:
- description:
- - Reference to a disk. When creating a new instance, one of initializeParams.sourceImage
- or disks.source is required.
- - If desired, you can also attach existing non-root persistent disks
- using this property. This field is only applicable for persistent
- disks.
- - Note that for InstanceTemplate, specify the disk name, not the URL
- for the disk.
- returned: success
- type: dict
- type:
- description:
- - Specifies the type of the disk, either SCRATCH or PERSISTENT. If not
- specified, the default is PERSISTENT.
- returned: success
- type: str
- labels:
- description:
- - Labels to apply to this address. A list of key->value pairs.
- returned: success
- type: dict
- machineType:
- description:
- - The machine type to use in the VM instance template.
- returned: success
- type: str
- minCpuPlatform:
- description:
- - Specifies a minimum CPU platform for the VM instance. Applicable values
- are the friendly names of CPU platforms .
- returned: success
- type: str
- metadata:
- description:
- - The metadata key/value pairs to assign to instances that are created from
- this template. These pairs can consist of custom metadata or predefined
- keys.
- returned: success
- type: dict
- guestAccelerators:
- description:
- - List of the type and count of accelerator cards attached to the instance
- .
- returned: success
- type: complex
- contains:
- acceleratorCount:
- description:
- - The number of the guest accelerator cards exposed to this instance.
- returned: success
- type: int
- acceleratorType:
- description:
- - Full or partial URL of the accelerator type resource to expose to
- this instance.
- returned: success
- type: str
- networkInterfaces:
- description:
- - An array of configurations for this interface. This specifies how this
- interface is configured to interact with other network services, such
- as connecting to the internet. Only one network interface is supported
- per instance.
- returned: success
- type: complex
- contains:
- accessConfigs:
- description:
- - An array of configurations for this interface. Currently, only one
- access config, ONE_TO_ONE_NAT, is supported. If there are no accessConfigs
- specified, then this instance will have no external internet access.
- returned: success
- type: complex
- contains:
- name:
- description:
- - The name of this access configuration. The default and recommended
- name is External NAT but you can use any arbitrary string you
- would like. For example, My external IP or Network Access.
- returned: success
- type: str
- natIP:
- description:
- - Reference to an address.
- - An external IP address associated with this instance.
- - Specify an unused static external IP address available to the
- project or leave this field undefined to use an IP from a shared
- ephemeral IP address pool. If you specify a static external IP
- address, it must live in the same region as the zone of the instance.
- returned: success
- type: dict
- type:
- description:
- - The type of configuration. The default and only option is ONE_TO_ONE_NAT.
- returned: success
- type: str
- setPublicPtr:
- description:
- - Specifies whether a public DNS PTR record should be created to
- map the external IP address of the instance to a DNS domain name.
- returned: success
- type: bool
- publicPtrDomainName:
- description:
- - The DNS domain name for the public PTR record. You can set this
- field only if the setPublicPtr field is enabled.
- returned: success
- type: str
- networkTier:
- description:
- - This signifies the networking tier used for configuring this access
- configuration. If an AccessConfig is specified without a valid
- external IP address, an ephemeral IP will be created with this
- networkTier. If an AccessConfig with a valid external IP address
- is specified, it must match that of the networkTier associated
- with the Address resource owning that IP.
- returned: success
- type: str
- aliasIpRanges:
- description:
- - An array of alias IP ranges for this network interface. Can only be
- specified for network interfaces on subnet-mode networks.
- returned: success
- type: complex
- contains:
- ipCidrRange:
- description:
- - The IP CIDR range represented by this alias IP range.
- - This IP CIDR range must belong to the specified subnetwork and
- cannot contain IP addresses reserved by system or used by other
- network interfaces. This range may be a single IP address (e.g.
- 10.2.3.4), a netmask (e.g. /24) or a CIDR format string (e.g.
- 10.1.2.0/24).
- returned: success
- type: str
- subnetworkRangeName:
- description:
- - Optional subnetwork secondary range name specifying the secondary
- range from which to allocate the IP CIDR range for this alias
- IP range. If left unspecified, the primary range of the subnetwork
- will be used.
- returned: success
- type: str
- name:
- description:
- - The name of the network interface, generated by the server. For network
- devices, these are eth0, eth1, etc .
- returned: success
- type: str
- network:
- description:
- - Specifies the title of an existing network. When creating an instance,
- if neither the network nor the subnetwork is specified, the default
- network global/networks/default is used; if the network is not specified
- but the subnetwork is specified, the network is inferred.
- returned: success
- type: dict
- networkIP:
- description:
- - An IPv4 internal network address to assign to the instance for this
- network interface. If not specified by the user, an unused internal
- IP is assigned by the system.
- returned: success
- type: str
- subnetwork:
- description:
- - Reference to a VPC network.
- - If the network resource is in legacy mode, do not provide this property.
- If the network is in auto subnet mode, providing the subnetwork is
- optional. If the network is in custom subnet mode, then this field
- should be specified.
- returned: success
- type: dict
- scheduling:
- description:
- - Sets the scheduling options for this instance.
- returned: success
- type: complex
- contains:
- automaticRestart:
- description:
- - Specifies whether the instance should be automatically restarted if
- it is terminated by Compute Engine (not terminated by a user).
- - You can only set the automatic restart option for standard instances.
- Preemptible instances cannot be automatically restarted.
- returned: success
- type: bool
- onHostMaintenance:
- description:
- - Defines the maintenance behavior for this instance. For standard instances,
- the default behavior is MIGRATE. For preemptible instances, the default
- and only possible behavior is TERMINATE.
- - For more information, see Setting Instance Scheduling Options.
- returned: success
- type: str
- preemptible:
- description:
- - Defines whether the instance is preemptible. This can only be set
- during instance creation, it cannot be set or changed after the instance
- has been created.
- returned: success
- type: bool
- serviceAccounts:
- description:
- - A list of service accounts, with their specified scopes, authorized for
- this instance. Only one service account per VM instance is supported.
- returned: success
- type: complex
- contains:
- email:
- description:
- - Email address of the service account.
- returned: success
- type: str
- scopes:
- description:
- - The list of scopes to be made available for this service account.
- returned: success
- type: list
- tags:
- description:
- - A list of tags to apply to this instance. Tags are used to identify valid
- sources or targets for network firewalls and are specified by the client
- during instance creation. The tags can be later modified by the setTags
- method. Each tag within the list must comply with RFC1035.
- returned: success
- type: complex
- contains:
- fingerprint:
- description:
- - Specifies a fingerprint for this request, which is essentially a hash
- of the metadata's contents and used for optimistic locking.
- - The fingerprint is initially generated by Compute Engine and changes
- after every request to modify or update metadata. You must always
- provide an up-to-date fingerprint hash in order to update or change
- metadata.
- returned: success
- type: str
- items:
- description:
- - An array of tags. Each tag must be 1-63 characters long, and comply
- with RFC1035.
- returned: success
- type: list
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/instanceTemplates".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_interconnect_attachment.py b/lib/ansible/modules/cloud/google/gcp_compute_interconnect_attachment.py
deleted file mode 100644
index ed26a683a3..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_interconnect_attachment.py
+++ /dev/null
@@ -1,584 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_interconnect_attachment
-description:
-- Represents an InterconnectAttachment (VLAN attachment) resource. For more information,
- see Creating VLAN Attachments.
-short_description: Creates a GCP InterconnectAttachment
-version_added: '2.8'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- admin_enabled:
- description:
- - Whether the VLAN attachment is enabled or disabled. When using PARTNER type
- this will Pre-Activate the interconnect attachment .
- required: false
- type: bool
- version_added: '2.9'
- interconnect:
- description:
- - URL of the underlying Interconnect object that this attachment's traffic will
- traverse through. Required if type is DEDICATED, must not be set if type is
- PARTNER.
- required: false
- type: str
- description:
- description:
- - An optional description of this resource.
- required: false
- type: str
- bandwidth:
- description:
- - Provisioned bandwidth capacity for the interconnect attachment.
- - For attachments of type DEDICATED, the user can set the bandwidth.
- - For attachments of type PARTNER, the Google Partner that is operating the interconnect
- must set the bandwidth.
- - Output only for PARTNER type, mutable for PARTNER_PROVIDER and DEDICATED, Defaults
- to BPS_10G .
- - 'Some valid choices include: "BPS_50M", "BPS_100M", "BPS_200M", "BPS_300M",
- "BPS_400M", "BPS_500M", "BPS_1G", "BPS_2G", "BPS_5G", "BPS_10G", "BPS_20G",
- "BPS_50G"'
- required: false
- type: str
- version_added: '2.9'
- edge_availability_domain:
- description:
- - Desired availability domain for the attachment. Only available for type PARTNER,
- at creation time. For improved reliability, customers should configure a pair
- of attachments with one per availability domain. The selected availability domain
- will be provided to the Partner via the pairing key so that the provisioned
- circuit will lie in the specified domain. If not specified, the value will default
- to AVAILABILITY_DOMAIN_ANY.
- required: false
- type: str
- type:
- description:
- - The type of InterconnectAttachment you wish to create. Defaults to DEDICATED.
- - 'Some valid choices include: "DEDICATED", "PARTNER", "PARTNER_PROVIDER"'
- required: false
- type: str
- router:
- description:
- - URL of the cloud router to be used for dynamic routing. This router must be
- in the same region as this InterconnectAttachment. The InterconnectAttachment
- will automatically connect the Interconnect to the network & region within which
- the Cloud Router is configured.
- - 'This field represents a link to a Router resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''selfLink'' and value
- of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
- to a gcp_compute_router task and then set this router field to "{{ name-of-resource
- }}"'
- required: true
- type: dict
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- required: true
- type: str
- candidate_subnets:
- description:
- - Up to 16 candidate prefixes that can be used to restrict the allocation of cloudRouterIpAddress
- and customerRouterIpAddress for this attachment.
- - All prefixes must be within link-local address space (169.254.0.0/16) and must
- be /29 or shorter (/28, /27, etc). Google will attempt to select an unused /29
- from the supplied candidate prefix(es). The request will fail if all possible
- /29s are in use on Google's edge. If not supplied, Google will randomly select
- an unused /29 from all of link-local space.
- required: false
- type: list
- vlan_tag8021q:
- description:
- - The IEEE 802.1Q VLAN tag for this attachment, in the range 2-4094. When using
- PARTNER type this will be managed upstream.
- required: false
- type: int
- region:
- description:
- - Region where the regional interconnect attachment resides.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-'''
-
-EXAMPLES = '''
-- name: create a interconnect attachment
- gcp_compute_interconnect_attachment:
- name: test_object
- region: us-central1
- project: test_project
- auth_kind: serviceaccount
- interconnect: https://googleapis.com/compute/v1/projects/test_project/global/interconnects/...
- router: https://googleapis.com/compute/v1/projects/test_project/regions/us-central1/routers/...
- service_account_file: "/tmp/auth.pem"
- state: present
- register: disk
-'''
-
-RETURN = '''
-adminEnabled:
- description:
- - Whether the VLAN attachment is enabled or disabled. When using PARTNER type this
- will Pre-Activate the interconnect attachment .
- returned: success
- type: bool
-cloudRouterIpAddress:
- description:
- - IPv4 address + prefix length to be configured on Cloud Router Interface for this
- interconnect attachment.
- returned: success
- type: str
-customerRouterIpAddress:
- description:
- - IPv4 address + prefix length to be configured on the customer router subinterface
- for this interconnect attachment.
- returned: success
- type: str
-interconnect:
- description:
- - URL of the underlying Interconnect object that this attachment's traffic will
- traverse through. Required if type is DEDICATED, must not be set if type is PARTNER.
- returned: success
- type: str
-description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
-bandwidth:
- description:
- - Provisioned bandwidth capacity for the interconnect attachment.
- - For attachments of type DEDICATED, the user can set the bandwidth.
- - For attachments of type PARTNER, the Google Partner that is operating the interconnect
- must set the bandwidth.
- - Output only for PARTNER type, mutable for PARTNER_PROVIDER and DEDICATED, Defaults
- to BPS_10G .
- returned: success
- type: str
-edgeAvailabilityDomain:
- description:
- - Desired availability domain for the attachment. Only available for type PARTNER,
- at creation time. For improved reliability, customers should configure a pair
- of attachments with one per availability domain. The selected availability domain
- will be provided to the Partner via the pairing key so that the provisioned circuit
- will lie in the specified domain. If not specified, the value will default to
- AVAILABILITY_DOMAIN_ANY.
- returned: success
- type: str
-pairingKey:
- description:
- - '[Output only for type PARTNER. Not present for DEDICATED]. The opaque identifier
- of an PARTNER attachment used to initiate provisioning with a selected partner.
- Of the form "XXXXX/region/domain" .'
- returned: success
- type: str
-partnerAsn:
- description:
- - "[Output only for type PARTNER. Not present for DEDICATED]. Optional BGP ASN for
- the router that should be supplied by a layer 3 Partner if they configured BGP
- on behalf of the customer."
- returned: success
- type: str
-privateInterconnectInfo:
- description:
- - Information specific to an InterconnectAttachment. This property is populated
- if the interconnect that this is attached to is of type DEDICATED.
- returned: success
- type: complex
- contains:
- tag8021q:
- description:
- - 802.1q encapsulation tag to be used for traffic between Google and the customer,
- going to and from this network and region.
- returned: success
- type: int
-type:
- description:
- - The type of InterconnectAttachment you wish to create. Defaults to DEDICATED.
- returned: success
- type: str
-state:
- description:
- - "[Output Only] The current state of this attachment's functionality."
- returned: success
- type: str
-googleReferenceId:
- description:
- - Google reference ID, to be used when raising support tickets with Google or otherwise
- to debug backend connectivity issues.
- returned: success
- type: str
-router:
- description:
- - URL of the cloud router to be used for dynamic routing. This router must be in
- the same region as this InterconnectAttachment. The InterconnectAttachment will
- automatically connect the Interconnect to the network & region within which the
- Cloud Router is configured.
- returned: success
- type: dict
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-id:
- description:
- - The unique identifier for the resource. This identifier is defined by the server.
- returned: success
- type: str
-name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
-candidateSubnets:
- description:
- - Up to 16 candidate prefixes that can be used to restrict the allocation of cloudRouterIpAddress
- and customerRouterIpAddress for this attachment.
- - All prefixes must be within link-local address space (169.254.0.0/16) and must
- be /29 or shorter (/28, /27, etc). Google will attempt to select an unused /29
- from the supplied candidate prefix(es). The request will fail if all possible
- /29s are in use on Google's edge. If not supplied, Google will randomly select
- an unused /29 from all of link-local space.
- returned: success
- type: list
-vlanTag8021q:
- description:
- - The IEEE 802.1Q VLAN tag for this attachment, in the range 2-4094. When using
- PARTNER type this will be managed upstream.
- returned: success
- type: int
-region:
- description:
- - Region where the regional interconnect attachment resides.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import re
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- admin_enabled=dict(type='bool'),
- interconnect=dict(type='str'),
- description=dict(type='str'),
- bandwidth=dict(type='str'),
- edge_availability_domain=dict(type='str'),
- type=dict(type='str'),
- router=dict(required=True, type='dict'),
- name=dict(required=True, type='str'),
- candidate_subnets=dict(type='list', elements='str'),
- vlan_tag8021q=dict(type='int'),
- region=dict(required=True, type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#interconnectAttachment'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind):
- delete(module, self_link(module), kind)
- create(module, collection(module), kind)
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#interconnectAttachment',
- u'adminEnabled': module.params.get('admin_enabled'),
- u'interconnect': module.params.get('interconnect'),
- u'description': module.params.get('description'),
- u'bandwidth': module.params.get('bandwidth'),
- u'edgeAvailabilityDomain': module.params.get('edge_availability_domain'),
- u'type': module.params.get('type'),
- u'router': replace_resource_dict(module.params.get(u'router', {}), 'selfLink'),
- u'name': module.params.get('name'),
- u'candidateSubnets': module.params.get('candidate_subnets'),
- u'vlanTag8021q': module.params.get('vlan_tag8021q'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/interconnectAttachments/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/interconnectAttachments".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'adminEnabled': response.get(u'adminEnabled'),
- u'cloudRouterIpAddress': response.get(u'cloudRouterIpAddress'),
- u'customerRouterIpAddress': response.get(u'customerRouterIpAddress'),
- u'interconnect': response.get(u'interconnect'),
- u'description': response.get(u'description'),
- u'bandwidth': response.get(u'bandwidth'),
- u'edgeAvailabilityDomain': response.get(u'edgeAvailabilityDomain'),
- u'pairingKey': response.get(u'pairingKey'),
- u'partnerAsn': response.get(u'partnerAsn'),
- u'privateInterconnectInfo': InterconnectAttachmentPrivateinterconnectinfo(response.get(u'privateInterconnectInfo', {}), module).from_response(),
- u'type': response.get(u'type'),
- u'state': response.get(u'state'),
- u'googleReferenceId': response.get(u'googleReferenceId'),
- u'router': response.get(u'router'),
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'id': response.get(u'id'),
- u'name': response.get(u'name'),
- u'candidateSubnets': response.get(u'candidateSubnets'),
- u'vlanTag8021q': response.get(u'vlanTag8021q'),
- }
-
-
-def region_selflink(name, params):
- if name is None:
- return
- url = r"https://www.googleapis.com/compute/v1/projects/.*/regions/.*"
- if not re.match(url, name):
- name = "https://www.googleapis.com/compute/v1/projects/{project}/regions/%s".format(**params) % name
- return name
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#interconnectAttachment')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-class InterconnectAttachmentPrivateinterconnectinfo(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({})
-
- def from_response(self):
- return remove_nones_from_dict({})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_interconnect_attachment_info.py b/lib/ansible/modules/cloud/google/gcp_compute_interconnect_attachment_info.py
deleted file mode 100644
index 819d95238a..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_interconnect_attachment_info.py
+++ /dev/null
@@ -1,337 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_interconnect_attachment_info
-description:
-- Gather info for GCP InterconnectAttachment
-short_description: Gather info for GCP InterconnectAttachment
-version_added: '2.8'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- region:
- description:
- - Region where the regional interconnect attachment resides.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on an interconnect attachment
- gcp_compute_interconnect_attachment_info:
- region: us-central1
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- adminEnabled:
- description:
- - Whether the VLAN attachment is enabled or disabled. When using PARTNER type
- this will Pre-Activate the interconnect attachment .
- returned: success
- type: bool
- cloudRouterIpAddress:
- description:
- - IPv4 address + prefix length to be configured on Cloud Router Interface for
- this interconnect attachment.
- returned: success
- type: str
- customerRouterIpAddress:
- description:
- - IPv4 address + prefix length to be configured on the customer router subinterface
- for this interconnect attachment.
- returned: success
- type: str
- interconnect:
- description:
- - URL of the underlying Interconnect object that this attachment's traffic will
- traverse through. Required if type is DEDICATED, must not be set if type is
- PARTNER.
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
- bandwidth:
- description:
- - Provisioned bandwidth capacity for the interconnect attachment.
- - For attachments of type DEDICATED, the user can set the bandwidth.
- - For attachments of type PARTNER, the Google Partner that is operating the
- interconnect must set the bandwidth.
- - Output only for PARTNER type, mutable for PARTNER_PROVIDER and DEDICATED,
- Defaults to BPS_10G .
- returned: success
- type: str
- edgeAvailabilityDomain:
- description:
- - Desired availability domain for the attachment. Only available for type PARTNER,
- at creation time. For improved reliability, customers should configure a pair
- of attachments with one per availability domain. The selected availability
- domain will be provided to the Partner via the pairing key so that the provisioned
- circuit will lie in the specified domain. If not specified, the value will
- default to AVAILABILITY_DOMAIN_ANY.
- returned: success
- type: str
- pairingKey:
- description:
- - '[Output only for type PARTNER. Not present for DEDICATED]. The opaque identifier
- of an PARTNER attachment used to initiate provisioning with a selected partner.
- Of the form "XXXXX/region/domain" .'
- returned: success
- type: str
- partnerAsn:
- description:
- - "[Output only for type PARTNER. Not present for DEDICATED]. Optional BGP ASN
- for the router that should be supplied by a layer 3 Partner if they configured
- BGP on behalf of the customer."
- returned: success
- type: str
- privateInterconnectInfo:
- description:
- - Information specific to an InterconnectAttachment. This property is populated
- if the interconnect that this is attached to is of type DEDICATED.
- returned: success
- type: complex
- contains:
- tag8021q:
- description:
- - 802.1q encapsulation tag to be used for traffic between Google and the
- customer, going to and from this network and region.
- returned: success
- type: int
- type:
- description:
- - The type of InterconnectAttachment you wish to create. Defaults to DEDICATED.
- returned: success
- type: str
- state:
- description:
- - "[Output Only] The current state of this attachment's functionality."
- returned: success
- type: str
- googleReferenceId:
- description:
- - Google reference ID, to be used when raising support tickets with Google or
- otherwise to debug backend connectivity issues.
- returned: success
- type: str
- router:
- description:
- - URL of the cloud router to be used for dynamic routing. This router must be
- in the same region as this InterconnectAttachment. The InterconnectAttachment
- will automatically connect the Interconnect to the network & region within
- which the Cloud Router is configured.
- returned: success
- type: dict
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- id:
- description:
- - The unique identifier for the resource. This identifier is defined by the
- server.
- returned: success
- type: str
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created.
- The name must be 1-63 characters long, and comply with RFC1035. Specifically,
- the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
- candidateSubnets:
- description:
- - Up to 16 candidate prefixes that can be used to restrict the allocation of
- cloudRouterIpAddress and customerRouterIpAddress for this attachment.
- - All prefixes must be within link-local address space (169.254.0.0/16) and
- must be /29 or shorter (/28, /27, etc). Google will attempt to select an unused
- /29 from the supplied candidate prefix(es). The request will fail if all possible
- /29s are in use on Google's edge. If not supplied, Google will randomly select
- an unused /29 from all of link-local space.
- returned: success
- type: list
- vlanTag8021q:
- description:
- - The IEEE 802.1Q VLAN tag for this attachment, in the range 2-4094. When using
- PARTNER type this will be managed upstream.
- returned: success
- type: int
- region:
- description:
- - Region where the regional interconnect attachment resides.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str'), region=dict(required=True, type='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/interconnectAttachments".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_network.py b/lib/ansible/modules/cloud/google/gcp_compute_network.py
deleted file mode 100644
index cb338902b7..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_network.py
+++ /dev/null
@@ -1,440 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_network
-description:
-- Manages a VPC network or legacy network resource on GCP.
-short_description: Creates a GCP Network
-version_added: '2.6'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- description:
- description:
- - An optional description of this resource. The resource must be recreated to
- modify this field.
- required: false
- type: str
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- required: true
- type: str
- auto_create_subnetworks:
- description:
- - When set to `true`, the network is created in "auto subnet mode" and it will
- create a subnet for each region automatically across the `10.128.0.0/9` address
- range.
- - When set to `false`, the network is created in "custom subnet mode" so the user
- can explicitly connect subnetwork resources.
- required: false
- type: bool
- routing_config:
- description:
- - The network-level routing configuration for this network. Used by Cloud Router
- to determine what type of network-wide routing behavior to enforce.
- required: false
- type: dict
- version_added: '2.8'
- suboptions:
- routing_mode:
- description:
- - The network-wide routing mode to use. If set to `REGIONAL`, this network's
- cloud routers will only advertise routes with subnetworks of this network
- in the same region as the router. If set to `GLOBAL`, this network's cloud
- routers will advertise routes with all subnetworks of this network, across
- regions.
- - 'Some valid choices include: "REGIONAL", "GLOBAL"'
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/v1/networks)'
-- 'Official Documentation: U(https://cloud.google.com/vpc/docs/vpc)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a network
- gcp_compute_network:
- name: test_object
- auto_create_subnetworks: 'true'
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-description:
- description:
- - An optional description of this resource. The resource must be recreated to modify
- this field.
- returned: success
- type: str
-gateway_ipv4:
- description:
- - The gateway address for default routing out of the network. This value is selected
- by GCP.
- returned: success
- type: str
-id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
-name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
-subnetworks:
- description:
- - Server-defined fully-qualified URLs for all subnetworks in this network.
- returned: success
- type: list
-autoCreateSubnetworks:
- description:
- - When set to `true`, the network is created in "auto subnet mode" and it will create
- a subnet for each region automatically across the `10.128.0.0/9` address range.
- - When set to `false`, the network is created in "custom subnet mode" so the user
- can explicitly connect subnetwork resources.
- returned: success
- type: bool
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-routingConfig:
- description:
- - The network-level routing configuration for this network. Used by Cloud Router
- to determine what type of network-wide routing behavior to enforce.
- returned: success
- type: complex
- contains:
- routingMode:
- description:
- - The network-wide routing mode to use. If set to `REGIONAL`, this network's
- cloud routers will only advertise routes with subnetworks of this network
- in the same region as the router. If set to `GLOBAL`, this network's cloud
- routers will advertise routes with all subnetworks of this network, across
- regions.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- description=dict(type='str'),
- name=dict(required=True, type='str'),
- auto_create_subnetworks=dict(type='bool'),
- routing_config=dict(type='dict', options=dict(routing_mode=dict(required=True, type='str'))),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#network'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind, fetch)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind, fetch):
- update_fields(module, resource_to_request(module), response_to_hash(module, fetch))
- return fetch_resource(module, self_link(module), kind)
-
-
-def update_fields(module, request, response):
- if response.get('routingConfig') != request.get('routingConfig'):
- routing_config_update(module, request, response)
-
-
-def routing_config_update(module, request, response):
- auth = GcpSession(module, 'compute')
- auth.patch(
- ''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/global/networks/{name}"]).format(**module.params),
- {u'routingConfig': NetworkRoutingconfig(module.params.get('routing_config', {}), module).to_request()},
- )
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#network',
- u'description': module.params.get('description'),
- u'name': module.params.get('name'),
- u'autoCreateSubnetworks': module.params.get('auto_create_subnetworks'),
- u'routingConfig': NetworkRoutingconfig(module.params.get('routing_config', {}), module).to_request(),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/networks/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/networks".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'description': module.params.get('description'),
- u'gatewayIPv4': response.get(u'gatewayIPv4'),
- u'id': response.get(u'id'),
- u'name': module.params.get('name'),
- u'subnetworks': response.get(u'subnetworks'),
- u'autoCreateSubnetworks': module.params.get('auto_create_subnetworks'),
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'routingConfig': NetworkRoutingconfig(response.get(u'routingConfig', {}), module).from_response(),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/global/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#network')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-class NetworkRoutingconfig(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'routingMode': self.request.get('routing_mode')})
-
- def from_response(self):
- return remove_nones_from_dict({u'routingMode': self.request.get(u'routingMode')})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_network_endpoint_group.py b/lib/ansible/modules/cloud/google/gcp_compute_network_endpoint_group.py
deleted file mode 100644
index 5c8c922ee2..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_network_endpoint_group.py
+++ /dev/null
@@ -1,453 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_network_endpoint_group
-description:
-- Network endpoint groups (NEGs) are zonal resources that represent collections of
- IP address and port combinations for GCP resources within a single subnet. Each
- IP address and port combination is called a network endpoint.
-- Network endpoint groups can be used as backends in backend services for HTTP(S),
- TCP proxy, and SSL proxy load balancers. You cannot use NEGs as a backend with internal
- load balancers. Because NEG backends allow you to specify IP addresses and ports,
- you can distribute traffic in a granular fashion among applications or containers
- running within VM instances.
-short_description: Creates a GCP NetworkEndpointGroup
-version_added: '2.10'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- name:
- description:
- - Name of the resource; provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- required: true
- type: str
- description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- required: false
- type: str
- network_endpoint_type:
- description:
- - Type of network endpoints in this network endpoint group. Currently the only
- supported value is GCE_VM_IP_PORT.
- - 'Some valid choices include: "GCE_VM_IP_PORT"'
- required: false
- default: GCE_VM_IP_PORT
- type: str
- network:
- description:
- - The network to which all network endpoints in the NEG belong.
- - Uses "default" project network if unspecified.
- - 'This field represents a link to a Network resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''selfLink'' and value
- of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
- to a gcp_compute_network task and then set this network field to "{{ name-of-resource
- }}"'
- required: true
- type: dict
- subnetwork:
- description:
- - Optional subnetwork to which all network endpoints in the NEG belong.
- - 'This field represents a link to a Subnetwork resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''selfLink'' and value
- of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
- to a gcp_compute_subnetwork task and then set this subnetwork field to "{{ name-of-resource
- }}"'
- required: false
- type: dict
- default_port:
- description:
- - The default port used if the port number is not specified in the network endpoint.
- required: false
- type: int
- zone:
- description:
- - Zone where the network endpoint group is located.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/beta/networkEndpointGroups)'
-- 'Official Documentation: U(https://cloud.google.com/load-balancing/docs/negs/)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a network
- gcp_compute_network:
- name: "{{ resource_name }}"
- auto_create_subnetworks: 'false'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: network
-
-- name: create a subnetwork
- gcp_compute_subnetwork:
- name: "{{ resource_name }}"
- ip_cidr_range: 10.0.0.0/16
- region: us-central1
- network: "{{ network }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: subnetwork
-
-- name: create a network endpoint group
- gcp_compute_network_endpoint_group:
- name: test_object
- network: "{{ network }}"
- subnetwork: "{{ subnetwork }}"
- default_port: 90
- zone: us-central1-a
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
-name:
- description:
- - Name of the resource; provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
-description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- returned: success
- type: str
-networkEndpointType:
- description:
- - Type of network endpoints in this network endpoint group. Currently the only supported
- value is GCE_VM_IP_PORT.
- returned: success
- type: str
-size:
- description:
- - Number of network endpoints in the network endpoint group.
- returned: success
- type: int
-network:
- description:
- - The network to which all network endpoints in the NEG belong.
- - Uses "default" project network if unspecified.
- returned: success
- type: dict
-subnetwork:
- description:
- - Optional subnetwork to which all network endpoints in the NEG belong.
- returned: success
- type: dict
-defaultPort:
- description:
- - The default port used if the port number is not specified in the network endpoint.
- returned: success
- type: int
-zone:
- description:
- - Zone where the network endpoint group is located.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- name=dict(required=True, type='str'),
- description=dict(type='str'),
- network_endpoint_type=dict(default='GCE_VM_IP_PORT', type='str'),
- network=dict(required=True, type='dict'),
- subnetwork=dict(type='dict'),
- default_port=dict(type='int'),
- zone=dict(required=True, type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#networkEndpointGroup'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind):
- delete(module, self_link(module), kind)
- create(module, collection(module), kind)
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#networkEndpointGroup',
- u'name': module.params.get('name'),
- u'description': module.params.get('description'),
- u'networkEndpointType': module.params.get('network_endpoint_type'),
- u'network': replace_resource_dict(module.params.get(u'network', {}), 'selfLink'),
- u'subnetwork': replace_resource_dict(module.params.get(u'subnetwork', {}), 'selfLink'),
- u'defaultPort': module.params.get('default_port'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/networkEndpointGroups/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/networkEndpointGroups".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'id': response.get(u'id'),
- u'name': response.get(u'name'),
- u'description': response.get(u'description'),
- u'networkEndpointType': response.get(u'networkEndpointType'),
- u'size': response.get(u'size'),
- u'network': response.get(u'network'),
- u'subnetwork': response.get(u'subnetwork'),
- u'defaultPort': response.get(u'defaultPort'),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#networkEndpointGroup')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_network_endpoint_group_info.py b/lib/ansible/modules/cloud/google/gcp_compute_network_endpoint_group_info.py
deleted file mode 100644
index 17ac045ddf..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_network_endpoint_group_info.py
+++ /dev/null
@@ -1,246 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_network_endpoint_group_info
-description:
-- Gather info for GCP NetworkEndpointGroup
-short_description: Gather info for GCP NetworkEndpointGroup
-version_added: '2.10'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- zone:
- description:
- - Zone where the network endpoint group is located.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a network endpoint group
- gcp_compute_network_endpoint_group_info:
- zone: us-central1-a
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
- name:
- description:
- - Name of the resource; provided by the client when the resource is created.
- The name must be 1-63 characters long, and comply with RFC1035. Specifically,
- the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- returned: success
- type: str
- networkEndpointType:
- description:
- - Type of network endpoints in this network endpoint group. Currently the only
- supported value is GCE_VM_IP_PORT.
- returned: success
- type: str
- size:
- description:
- - Number of network endpoints in the network endpoint group.
- returned: success
- type: int
- network:
- description:
- - The network to which all network endpoints in the NEG belong.
- - Uses "default" project network if unspecified.
- returned: success
- type: dict
- subnetwork:
- description:
- - Optional subnetwork to which all network endpoints in the NEG belong.
- returned: success
- type: dict
- defaultPort:
- description:
- - The default port used if the port number is not specified in the network endpoint.
- returned: success
- type: int
- zone:
- description:
- - Zone where the network endpoint group is located.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str'), zone=dict(required=True, type='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/networkEndpointGroups".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_network_info.py b/lib/ansible/modules/cloud/google/gcp_compute_network_info.py
deleted file mode 100644
index 5de6884745..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_network_info.py
+++ /dev/null
@@ -1,249 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_network_info
-description:
-- Gather info for GCP Network
-short_description: Gather info for GCP Network
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a network
- gcp_compute_network_info:
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- description:
- description:
- - An optional description of this resource. The resource must be recreated to
- modify this field.
- returned: success
- type: str
- gateway_ipv4:
- description:
- - The gateway address for default routing out of the network. This value is
- selected by GCP.
- returned: success
- type: str
- id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created.
- The name must be 1-63 characters long, and comply with RFC1035. Specifically,
- the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
- subnetworks:
- description:
- - Server-defined fully-qualified URLs for all subnetworks in this network.
- returned: success
- type: list
- autoCreateSubnetworks:
- description:
- - When set to `true`, the network is created in "auto subnet mode" and it will
- create a subnet for each region automatically across the `10.128.0.0/9` address
- range.
- - When set to `false`, the network is created in "custom subnet mode" so the
- user can explicitly connect subnetwork resources.
- returned: success
- type: bool
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- routingConfig:
- description:
- - The network-level routing configuration for this network. Used by Cloud Router
- to determine what type of network-wide routing behavior to enforce.
- returned: success
- type: complex
- contains:
- routingMode:
- description:
- - The network-wide routing mode to use. If set to `REGIONAL`, this network's
- cloud routers will only advertise routes with subnetworks of this network
- in the same region as the router. If set to `GLOBAL`, this network's cloud
- routers will advertise routes with all subnetworks of this network, across
- regions.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/networks".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_node_group.py b/lib/ansible/modules/cloud/google/gcp_compute_node_group.py
deleted file mode 100644
index c275d4c5d1..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_node_group.py
+++ /dev/null
@@ -1,416 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_node_group
-description:
-- Represents a NodeGroup resource to manage a group of sole-tenant nodes.
-short_description: Creates a GCP NodeGroup
-version_added: '2.10'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- description:
- description:
- - An optional textual description of the resource.
- required: false
- type: str
- name:
- description:
- - Name of the resource.
- required: false
- type: str
- node_template:
- description:
- - The URL of the node template to which this node group belongs.
- - 'This field represents a link to a NodeTemplate resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''selfLink'' and value
- of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
- to a gcp_compute_node_template task and then set this node_template field to
- "{{ name-of-resource }}"'
- required: true
- type: dict
- size:
- description:
- - The total number of nodes in the node group.
- required: true
- type: int
- zone:
- description:
- - Zone where this node group is located .
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/v1/nodeGroups)'
-- 'Sole-Tenant Nodes: U(https://cloud.google.com/compute/docs/nodes/)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a node template
- gcp_compute_node_template:
- name: "{{ resource_name }}"
- region: us-central1
- node_type: n1-node-96-624
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: node_template
-
-- name: create a node group
- gcp_compute_node_group:
- name: test_object
- zone: us-central1-a
- description: example group for ansible
- size: 1
- node_template: "{{ node_template }}"
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-description:
- description:
- - An optional textual description of the resource.
- returned: success
- type: str
-name:
- description:
- - Name of the resource.
- returned: success
- type: str
-nodeTemplate:
- description:
- - The URL of the node template to which this node group belongs.
- returned: success
- type: dict
-size:
- description:
- - The total number of nodes in the node group.
- returned: success
- type: int
-zone:
- description:
- - Zone where this node group is located .
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-import re
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- description=dict(type='str'),
- name=dict(type='str'),
- node_template=dict(required=True, type='dict'),
- size=dict(required=True, type='int'),
- zone=dict(required=True, type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#NodeGroup'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind, fetch)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, create_link(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind, fetch):
- update_fields(module, resource_to_request(module), response_to_hash(module, fetch))
- return fetch_resource(module, self_link(module), kind)
-
-
-def update_fields(module, request, response):
- if response.get('nodeTemplate') != request.get('nodeTemplate'):
- node_template_update(module, request, response)
-
-
-def node_template_update(module, request, response):
- auth = GcpSession(module, 'compute')
- auth.post(
- ''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/zones/{zone}/nodeGroups/{name}/setNodeTemplate"]).format(**module.params),
- {u'nodeTemplate': replace_resource_dict(module.params.get(u'node_template', {}), 'selfLink')},
- )
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#NodeGroup',
- u'description': module.params.get('description'),
- u'name': module.params.get('name'),
- u'nodeTemplate': replace_resource_dict(module.params.get(u'node_template', {}), 'selfLink'),
- u'size': module.params.get('size'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/nodeGroups/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/nodeGroups".format(**module.params)
-
-
-def create_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/nodeGroups?initialNodeCount={size}".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'description': response.get(u'description'),
- u'name': response.get(u'name'),
- u'nodeTemplate': response.get(u'nodeTemplate'),
- u'size': response.get(u'size'),
- }
-
-
-def region_selflink(name, params):
- if name is None:
- return
- url = r"https://www.googleapis.com/compute/v1/projects/.*/regions/.*"
- if not re.match(url, name):
- name = "https://www.googleapis.com/compute/v1/projects/{project}/regions/%s".format(**params) % name
- return name
-
-
-def zone_selflink(name, params):
- if name is None:
- return
- url = r"https://www.googleapis.com/compute/v1/projects/.*/zones/.*"
- if not re.match(url, name):
- name = "https://www.googleapis.com/compute/v1/projects/{project}/zones/%s".format(**params) % name
- return name
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#NodeGroup')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_node_group_info.py b/lib/ansible/modules/cloud/google/gcp_compute_node_group_info.py
deleted file mode 100644
index f85939d259..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_node_group_info.py
+++ /dev/null
@@ -1,223 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_node_group_info
-description:
-- Gather info for GCP NodeGroup
-short_description: Gather info for GCP NodeGroup
-version_added: '2.10'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- zone:
- description:
- - Zone where this node group is located .
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a node group
- gcp_compute_node_group_info:
- zone: us-central1-a
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- description:
- description:
- - An optional textual description of the resource.
- returned: success
- type: str
- name:
- description:
- - Name of the resource.
- returned: success
- type: str
- nodeTemplate:
- description:
- - The URL of the node template to which this node group belongs.
- returned: success
- type: dict
- size:
- description:
- - The total number of nodes in the node group.
- returned: success
- type: int
- zone:
- description:
- - Zone where this node group is located .
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str'), zone=dict(required=True, type='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/nodeGroups".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_node_template.py b/lib/ansible/modules/cloud/google/gcp_compute_node_template.py
deleted file mode 100644
index 3cb1ab7817..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_node_template.py
+++ /dev/null
@@ -1,436 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_node_template
-description:
-- Represents a NodeTemplate resource. Node templates specify properties for creating
- sole-tenant nodes, such as node type, vCPU and memory requirements, node affinity
- labels, and region.
-short_description: Creates a GCP NodeTemplate
-version_added: '2.10'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- description:
- description:
- - An optional textual description of the resource.
- required: false
- type: str
- name:
- description:
- - Name of the resource.
- required: false
- type: str
- node_affinity_labels:
- description:
- - Labels to use for node affinity, which will be used in instance scheduling.
- required: false
- type: dict
- node_type:
- description:
- - Node type to use for nodes group that are created from this template.
- - Only one of nodeTypeFlexibility and nodeType can be specified.
- required: false
- type: str
- node_type_flexibility:
- description:
- - Flexible properties for the desired node type. Node groups that use this node
- template will create nodes of a type that matches these properties. Only one
- of nodeTypeFlexibility and nodeType can be specified.
- required: false
- type: dict
- suboptions:
- cpus:
- description:
- - Number of virtual CPUs to use.
- required: false
- type: str
- memory:
- description:
- - Physical memory available to the node, defined in MB.
- required: false
- type: str
- region:
- description:
- - Region where nodes using the node template will be created .
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/v1/nodeTemplates)'
-- 'Sole-Tenant Nodes: U(https://cloud.google.com/compute/docs/nodes/)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a node template
- gcp_compute_node_template:
- name: test_object
- region: us-central1
- node_type: n1-node-96-624
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-description:
- description:
- - An optional textual description of the resource.
- returned: success
- type: str
-name:
- description:
- - Name of the resource.
- returned: success
- type: str
-nodeAffinityLabels:
- description:
- - Labels to use for node affinity, which will be used in instance scheduling.
- returned: success
- type: dict
-nodeType:
- description:
- - Node type to use for nodes group that are created from this template.
- - Only one of nodeTypeFlexibility and nodeType can be specified.
- returned: success
- type: str
-nodeTypeFlexibility:
- description:
- - Flexible properties for the desired node type. Node groups that use this node
- template will create nodes of a type that matches these properties. Only one of
- nodeTypeFlexibility and nodeType can be specified.
- returned: success
- type: complex
- contains:
- cpus:
- description:
- - Number of virtual CPUs to use.
- returned: success
- type: str
- memory:
- description:
- - Physical memory available to the node, defined in MB.
- returned: success
- type: str
- localSsd:
- description:
- - Use local SSD .
- returned: success
- type: str
-region:
- description:
- - Region where nodes using the node template will be created .
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import re
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- description=dict(type='str'),
- name=dict(type='str'),
- node_affinity_labels=dict(type='dict'),
- node_type=dict(type='str'),
- node_type_flexibility=dict(type='dict', options=dict(cpus=dict(type='str'), memory=dict(type='str'))),
- region=dict(required=True, type='str'),
- ),
- mutually_exclusive=[['node_type', 'node_type_flexibility']],
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#nodeTemplate'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind):
- delete(module, self_link(module), kind)
- create(module, collection(module), kind)
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#nodeTemplate',
- u'description': module.params.get('description'),
- u'name': module.params.get('name'),
- u'nodeAffinityLabels': module.params.get('node_affinity_labels'),
- u'nodeType': module.params.get('node_type'),
- u'nodeTypeFlexibility': NodeTemplateNodetypeflexibility(module.params.get('node_type_flexibility', {}), module).to_request(),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/nodeTemplates/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/nodeTemplates".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'description': response.get(u'description'),
- u'name': response.get(u'name'),
- u'nodeAffinityLabels': response.get(u'nodeAffinityLabels'),
- u'nodeType': response.get(u'nodeType'),
- u'nodeTypeFlexibility': NodeTemplateNodetypeflexibility(response.get(u'nodeTypeFlexibility', {}), module).from_response(),
- }
-
-
-def region_selflink(name, params):
- if name is None:
- return
- url = r"https://www.googleapis.com/compute/v1/projects/.*/regions/.*"
- if not re.match(url, name):
- name = "https://www.googleapis.com/compute/v1/projects/{project}/regions/%s".format(**params) % name
- return name
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#nodeTemplate')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-class NodeTemplateNodetypeflexibility(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'cpus': self.request.get('cpus'), u'memory': self.request.get('memory')})
-
- def from_response(self):
- return remove_nones_from_dict({u'cpus': self.request.get(u'cpus'), u'memory': self.request.get(u'memory')})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_node_template_info.py b/lib/ansible/modules/cloud/google/gcp_compute_node_template_info.py
deleted file mode 100644
index c4ad2daefa..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_node_template_info.py
+++ /dev/null
@@ -1,247 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_node_template_info
-description:
-- Gather info for GCP NodeTemplate
-short_description: Gather info for GCP NodeTemplate
-version_added: '2.10'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- region:
- description:
- - Region where nodes using the node template will be created .
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a node template
- gcp_compute_node_template_info:
- region: us-central1
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- description:
- description:
- - An optional textual description of the resource.
- returned: success
- type: str
- name:
- description:
- - Name of the resource.
- returned: success
- type: str
- nodeAffinityLabels:
- description:
- - Labels to use for node affinity, which will be used in instance scheduling.
- returned: success
- type: dict
- nodeType:
- description:
- - Node type to use for nodes group that are created from this template.
- - Only one of nodeTypeFlexibility and nodeType can be specified.
- returned: success
- type: str
- nodeTypeFlexibility:
- description:
- - Flexible properties for the desired node type. Node groups that use this node
- template will create nodes of a type that matches these properties. Only one
- of nodeTypeFlexibility and nodeType can be specified.
- returned: success
- type: complex
- contains:
- cpus:
- description:
- - Number of virtual CPUs to use.
- returned: success
- type: str
- memory:
- description:
- - Physical memory available to the node, defined in MB.
- returned: success
- type: str
- localSsd:
- description:
- - Use local SSD .
- returned: success
- type: str
- region:
- description:
- - Region where nodes using the node template will be created .
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str'), region=dict(required=True, type='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/nodeTemplates".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_region_backend_service.py b/lib/ansible/modules/cloud/google/gcp_compute_region_backend_service.py
deleted file mode 100644
index 7b1946f8d5..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_region_backend_service.py
+++ /dev/null
@@ -1,778 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_region_backend_service
-description:
-- A Region Backend Service defines a regionally-scoped group of virtual machines that
- will serve traffic for load balancing.
-short_description: Creates a GCP RegionBackendService
-version_added: '2.10'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- backends:
- description:
- - The set of backends that serve this RegionBackendService.
- required: false
- type: list
- suboptions:
- balancing_mode:
- description:
- - Specifies the balancing mode for this backend. Defaults to CONNECTION.
- - 'Some valid choices include: "UTILIZATION", "RATE", "CONNECTION"'
- required: false
- default: CONNECTION
- type: str
- capacity_scaler:
- description:
- - A multiplier applied to the group's maximum servicing capacity (based on
- UTILIZATION, RATE or CONNECTION).
- - A setting of 0 means the group is completely drained, offering 0% of its
- available Capacity. Valid range is [0.0,1.0].
- required: false
- type: str
- description:
- description:
- - An optional description of this resource.
- - Provide this property when you create the resource.
- required: false
- type: str
- group:
- description:
- - The fully-qualified URL of an Instance Group or Network Endpoint Group resource.
- In case of instance group this defines the list of instances that serve
- traffic. Member virtual machine instances from each instance group must
- live in the same zone as the instance group itself. No two backends in a
- backend service are allowed to use same Instance Group resource.
- - For Network Endpoint Groups this defines list of endpoints. All endpoints
- of Network Endpoint Group must be hosted on instances located in the same
- zone as the Network Endpoint Group.
- - Backend services cannot mix Instance Group and Network Endpoint Group backends.
- - When the `load_balancing_scheme` is INTERNAL, only instance groups are supported.
- - Note that you must specify an Instance Group or Network Endpoint Group resource
- using the fully-qualified URL, rather than a partial URL.
- required: true
- type: str
- max_connections:
- description:
- - The max number of simultaneous connections for the group. Can be used with
- either CONNECTION or UTILIZATION balancing modes.
- - For CONNECTION mode, either maxConnections or one of maxConnectionsPerInstance
- or maxConnectionsPerEndpoint, as appropriate for group type, must be set.
- required: false
- type: int
- max_connections_per_instance:
- description:
- - The max number of simultaneous connections that a single backend instance
- can handle. This is used to calculate the capacity of the group. Can be
- used in either CONNECTION or UTILIZATION balancing modes.
- - For CONNECTION mode, either maxConnections or maxConnectionsPerInstance
- must be set.
- required: false
- type: int
- max_connections_per_endpoint:
- description:
- - The max number of simultaneous connections that a single backend network
- endpoint can handle. This is used to calculate the capacity of the group.
- Can be used in either CONNECTION or UTILIZATION balancing modes.
- - For CONNECTION mode, either maxConnections or maxConnectionsPerEndpoint
- must be set.
- required: false
- type: int
- max_rate:
- description:
- - The max requests per second (RPS) of the group.
- - Can be used with either RATE or UTILIZATION balancing modes, but required
- if RATE mode. Either maxRate or one of maxRatePerInstance or maxRatePerEndpoint,
- as appropriate for group type, must be set.
- required: false
- type: int
- max_rate_per_instance:
- description:
- - The max requests per second (RPS) that a single backend instance can handle.
- This is used to calculate the capacity of the group. Can be used in either
- balancing mode. For RATE mode, either maxRate or maxRatePerInstance must
- be set.
- required: false
- type: str
- max_rate_per_endpoint:
- description:
- - The max requests per second (RPS) that a single backend network endpoint
- can handle. This is used to calculate the capacity of the group. Can be
- used in either balancing mode. For RATE mode, either maxRate or maxRatePerEndpoint
- must be set.
- required: false
- type: str
- max_utilization:
- description:
- - Used when balancingMode is UTILIZATION. This ratio defines the CPU utilization
- target for the group. Valid range is [0.0, 1.0].
- required: false
- type: str
- connection_draining:
- description:
- - Settings for connection draining .
- required: false
- type: dict
- suboptions:
- draining_timeout_sec:
- description:
- - Time for which instance will be drained (not accept new connections, but
- still work to finish started).
- required: false
- default: '300'
- type: int
- description:
- description:
- - An optional description of this resource.
- required: false
- type: str
- health_checks:
- description:
- - The set of URLs to HealthCheck resources for health checking this RegionBackendService.
- Currently at most one health check can be specified, and a health check is required.
- required: true
- type: list
- load_balancing_scheme:
- description:
- - Indicates what kind of load balancing this regional backend service will be
- used for. A backend service created for one type of load balancing cannot be
- used with the other(s). Must be `INTERNAL` or `INTERNAL_MANAGED`. Defaults to
- `INTERNAL`.
- - 'Some valid choices include: "INTERNAL", "INTERNAL_MANAGED"'
- required: false
- default: INTERNAL
- type: str
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- required: true
- type: str
- protocol:
- description:
- - The protocol this RegionBackendService uses to communicate with backends.
- - 'Possible values are HTTP, HTTPS, HTTP2, SSL, TCP, and UDP. The default is HTTP.
- **NOTE**: HTTP2 is only valid for beta HTTP/2 load balancer types and may result
- in errors if used with the GA API.'
- - 'Some valid choices include: "HTTP", "HTTPS", "HTTP2", "SSL", "TCP", "UDP"'
- required: false
- type: str
- session_affinity:
- description:
- - Type of session affinity to use. The default is NONE. Session affinity is not
- applicable if the protocol is UDP.
- - 'Some valid choices include: "NONE", "CLIENT_IP", "CLIENT_IP_PORT_PROTO", "CLIENT_IP_PROTO",
- "GENERATED_COOKIE", "HEADER_FIELD", "HTTP_COOKIE"'
- required: false
- type: str
- timeout_sec:
- description:
- - How many seconds to wait for the backend before considering it a failed request.
- Default is 30 seconds. Valid range is [1, 86400].
- required: false
- type: int
- region:
- description:
- - A reference to the region where the regional backend service resides.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/compute/docs/reference/latest/regionBackendServices)'
-- 'Internal TCP/UDP Load Balancing: U(https://cloud.google.com/compute/docs/load-balancing/internal/)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a health check
- gcp_compute_health_check:
- name: "{{ resource_name }}"
- type: TCP
- tcp_health_check:
- port: 80
- check_interval_sec: 1
- timeout_sec: 1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: healthcheck
-
-- name: create a region backend service
- gcp_compute_region_backend_service:
- name: test_object
- region: us-central1
- health_checks:
- - "{{ healthcheck.selfLink }}"
- connection_draining:
- draining_timeout_sec: 10
- session_affinity: CLIENT_IP
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-backends:
- description:
- - The set of backends that serve this RegionBackendService.
- returned: success
- type: complex
- contains:
- balancingMode:
- description:
- - Specifies the balancing mode for this backend. Defaults to CONNECTION.
- returned: success
- type: str
- capacityScaler:
- description:
- - A multiplier applied to the group's maximum servicing capacity (based on UTILIZATION,
- RATE or CONNECTION).
- - A setting of 0 means the group is completely drained, offering 0% of its available
- Capacity. Valid range is [0.0,1.0].
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource.
- - Provide this property when you create the resource.
- returned: success
- type: str
- group:
- description:
- - The fully-qualified URL of an Instance Group or Network Endpoint Group resource.
- In case of instance group this defines the list of instances that serve traffic.
- Member virtual machine instances from each instance group must live in the
- same zone as the instance group itself. No two backends in a backend service
- are allowed to use same Instance Group resource.
- - For Network Endpoint Groups this defines list of endpoints. All endpoints
- of Network Endpoint Group must be hosted on instances located in the same
- zone as the Network Endpoint Group.
- - Backend services cannot mix Instance Group and Network Endpoint Group backends.
- - When the `load_balancing_scheme` is INTERNAL, only instance groups are supported.
- - Note that you must specify an Instance Group or Network Endpoint Group resource
- using the fully-qualified URL, rather than a partial URL.
- returned: success
- type: str
- maxConnections:
- description:
- - The max number of simultaneous connections for the group. Can be used with
- either CONNECTION or UTILIZATION balancing modes.
- - For CONNECTION mode, either maxConnections or one of maxConnectionsPerInstance
- or maxConnectionsPerEndpoint, as appropriate for group type, must be set.
- returned: success
- type: int
- maxConnectionsPerInstance:
- description:
- - The max number of simultaneous connections that a single backend instance
- can handle. This is used to calculate the capacity of the group. Can be used
- in either CONNECTION or UTILIZATION balancing modes.
- - For CONNECTION mode, either maxConnections or maxConnectionsPerInstance must
- be set.
- returned: success
- type: int
- maxConnectionsPerEndpoint:
- description:
- - The max number of simultaneous connections that a single backend network endpoint
- can handle. This is used to calculate the capacity of the group. Can be used
- in either CONNECTION or UTILIZATION balancing modes.
- - For CONNECTION mode, either maxConnections or maxConnectionsPerEndpoint must
- be set.
- returned: success
- type: int
- maxRate:
- description:
- - The max requests per second (RPS) of the group.
- - Can be used with either RATE or UTILIZATION balancing modes, but required
- if RATE mode. Either maxRate or one of maxRatePerInstance or maxRatePerEndpoint,
- as appropriate for group type, must be set.
- returned: success
- type: int
- maxRatePerInstance:
- description:
- - The max requests per second (RPS) that a single backend instance can handle.
- This is used to calculate the capacity of the group. Can be used in either
- balancing mode. For RATE mode, either maxRate or maxRatePerInstance must be
- set.
- returned: success
- type: str
- maxRatePerEndpoint:
- description:
- - The max requests per second (RPS) that a single backend network endpoint can
- handle. This is used to calculate the capacity of the group. Can be used in
- either balancing mode. For RATE mode, either maxRate or maxRatePerEndpoint
- must be set.
- returned: success
- type: str
- maxUtilization:
- description:
- - Used when balancingMode is UTILIZATION. This ratio defines the CPU utilization
- target for the group. Valid range is [0.0, 1.0].
- returned: success
- type: str
-connectionDraining:
- description:
- - Settings for connection draining .
- returned: success
- type: complex
- contains:
- drainingTimeoutSec:
- description:
- - Time for which instance will be drained (not accept new connections, but still
- work to finish started).
- returned: success
- type: int
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
-fingerprint:
- description:
- - Fingerprint of this resource. A hash of the contents stored in this object. This
- field is used in optimistic locking.
- returned: success
- type: str
-healthChecks:
- description:
- - The set of URLs to HealthCheck resources for health checking this RegionBackendService.
- Currently at most one health check can be specified, and a health check is required.
- returned: success
- type: list
-id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
-loadBalancingScheme:
- description:
- - Indicates what kind of load balancing this regional backend service will be used
- for. A backend service created for one type of load balancing cannot be used with
- the other(s). Must be `INTERNAL` or `INTERNAL_MANAGED`. Defaults to `INTERNAL`.
- returned: success
- type: str
-name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
-protocol:
- description:
- - The protocol this RegionBackendService uses to communicate with backends.
- - 'Possible values are HTTP, HTTPS, HTTP2, SSL, TCP, and UDP. The default is HTTP.
- **NOTE**: HTTP2 is only valid for beta HTTP/2 load balancer types and may result
- in errors if used with the GA API.'
- returned: success
- type: str
-sessionAffinity:
- description:
- - Type of session affinity to use. The default is NONE. Session affinity is not
- applicable if the protocol is UDP.
- returned: success
- type: str
-timeoutSec:
- description:
- - How many seconds to wait for the backend before considering it a failed request.
- Default is 30 seconds. Valid range is [1, 86400].
- returned: success
- type: int
-region:
- description:
- - A reference to the region where the regional backend service resides.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- backends=dict(
- type='list',
- elements='dict',
- options=dict(
- balancing_mode=dict(default='CONNECTION', type='str'),
- capacity_scaler=dict(type='str'),
- description=dict(type='str'),
- group=dict(required=True, type='str'),
- max_connections=dict(type='int'),
- max_connections_per_instance=dict(type='int'),
- max_connections_per_endpoint=dict(type='int'),
- max_rate=dict(type='int'),
- max_rate_per_instance=dict(type='str'),
- max_rate_per_endpoint=dict(type='str'),
- max_utilization=dict(type='str'),
- ),
- ),
- connection_draining=dict(type='dict', options=dict(draining_timeout_sec=dict(default=300, type='int'))),
- description=dict(type='str'),
- health_checks=dict(required=True, type='list', elements='str'),
- load_balancing_scheme=dict(default='INTERNAL', type='str'),
- name=dict(required=True, type='str'),
- protocol=dict(type='str'),
- session_affinity=dict(type='str'),
- timeout_sec=dict(type='int'),
- region=dict(required=True, type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#backendService'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.put(link, resource_to_request(module)))
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#backendService',
- u'backends': RegionBackendServiceBackendsArray(module.params.get('backends', []), module).to_request(),
- u'connectionDraining': RegionBackendServiceConnectiondraining(module.params.get('connection_draining', {}), module).to_request(),
- u'description': module.params.get('description'),
- u'healthChecks': module.params.get('health_checks'),
- u'loadBalancingScheme': module.params.get('load_balancing_scheme'),
- u'name': module.params.get('name'),
- u'protocol': module.params.get('protocol'),
- u'sessionAffinity': module.params.get('session_affinity'),
- u'timeoutSec': module.params.get('timeout_sec'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/backendServices/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/backendServices".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'backends': RegionBackendServiceBackendsArray(response.get(u'backends', []), module).from_response(),
- u'connectionDraining': RegionBackendServiceConnectiondraining(response.get(u'connectionDraining', {}), module).from_response(),
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'description': response.get(u'description'),
- u'fingerprint': response.get(u'fingerprint'),
- u'healthChecks': response.get(u'healthChecks'),
- u'id': response.get(u'id'),
- u'loadBalancingScheme': module.params.get('load_balancing_scheme'),
- u'name': module.params.get('name'),
- u'protocol': response.get(u'protocol'),
- u'sessionAffinity': response.get(u'sessionAffinity'),
- u'timeoutSec': response.get(u'timeoutSec'),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#backendService')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-class RegionBackendServiceBackendsArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict(
- {
- u'balancingMode': item.get('balancing_mode'),
- u'capacityScaler': item.get('capacity_scaler'),
- u'description': item.get('description'),
- u'group': item.get('group'),
- u'maxConnections': item.get('max_connections'),
- u'maxConnectionsPerInstance': item.get('max_connections_per_instance'),
- u'maxConnectionsPerEndpoint': item.get('max_connections_per_endpoint'),
- u'maxRate': item.get('max_rate'),
- u'maxRatePerInstance': item.get('max_rate_per_instance'),
- u'maxRatePerEndpoint': item.get('max_rate_per_endpoint'),
- u'maxUtilization': item.get('max_utilization'),
- }
- )
-
- def _response_from_item(self, item):
- return remove_nones_from_dict(
- {
- u'balancingMode': item.get(u'balancingMode'),
- u'capacityScaler': item.get(u'capacityScaler'),
- u'description': item.get(u'description'),
- u'group': item.get(u'group'),
- u'maxConnections': item.get(u'maxConnections'),
- u'maxConnectionsPerInstance': item.get(u'maxConnectionsPerInstance'),
- u'maxConnectionsPerEndpoint': item.get(u'maxConnectionsPerEndpoint'),
- u'maxRate': item.get(u'maxRate'),
- u'maxRatePerInstance': item.get(u'maxRatePerInstance'),
- u'maxRatePerEndpoint': item.get(u'maxRatePerEndpoint'),
- u'maxUtilization': item.get(u'maxUtilization'),
- }
- )
-
-
-class RegionBackendServiceConnectiondraining(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'drainingTimeoutSec': self.request.get('draining_timeout_sec')})
-
- def from_response(self):
- return remove_nones_from_dict({u'drainingTimeoutSec': self.request.get(u'drainingTimeoutSec')})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_region_backend_service_info.py b/lib/ansible/modules/cloud/google/gcp_compute_region_backend_service_info.py
deleted file mode 100644
index 94db1cc5ab..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_region_backend_service_info.py
+++ /dev/null
@@ -1,375 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_region_backend_service_info
-description:
-- Gather info for GCP RegionBackendService
-short_description: Gather info for GCP RegionBackendService
-version_added: '2.10'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- region:
- description:
- - A reference to the region where the regional backend service resides.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a region backend service
- gcp_compute_region_backend_service_info:
- region: us-central1
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- backends:
- description:
- - The set of backends that serve this RegionBackendService.
- returned: success
- type: complex
- contains:
- balancingMode:
- description:
- - Specifies the balancing mode for this backend. Defaults to CONNECTION.
- returned: success
- type: str
- capacityScaler:
- description:
- - A multiplier applied to the group's maximum servicing capacity (based
- on UTILIZATION, RATE or CONNECTION).
- - A setting of 0 means the group is completely drained, offering 0% of its
- available Capacity. Valid range is [0.0,1.0].
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource.
- - Provide this property when you create the resource.
- returned: success
- type: str
- group:
- description:
- - The fully-qualified URL of an Instance Group or Network Endpoint Group
- resource. In case of instance group this defines the list of instances
- that serve traffic. Member virtual machine instances from each instance
- group must live in the same zone as the instance group itself. No two
- backends in a backend service are allowed to use same Instance Group resource.
- - For Network Endpoint Groups this defines list of endpoints. All endpoints
- of Network Endpoint Group must be hosted on instances located in the same
- zone as the Network Endpoint Group.
- - Backend services cannot mix Instance Group and Network Endpoint Group
- backends.
- - When the `load_balancing_scheme` is INTERNAL, only instance groups are
- supported.
- - Note that you must specify an Instance Group or Network Endpoint Group
- resource using the fully-qualified URL, rather than a partial URL.
- returned: success
- type: str
- maxConnections:
- description:
- - The max number of simultaneous connections for the group. Can be used
- with either CONNECTION or UTILIZATION balancing modes.
- - For CONNECTION mode, either maxConnections or one of maxConnectionsPerInstance
- or maxConnectionsPerEndpoint, as appropriate for group type, must be set.
- returned: success
- type: int
- maxConnectionsPerInstance:
- description:
- - The max number of simultaneous connections that a single backend instance
- can handle. This is used to calculate the capacity of the group. Can be
- used in either CONNECTION or UTILIZATION balancing modes.
- - For CONNECTION mode, either maxConnections or maxConnectionsPerInstance
- must be set.
- returned: success
- type: int
- maxConnectionsPerEndpoint:
- description:
- - The max number of simultaneous connections that a single backend network
- endpoint can handle. This is used to calculate the capacity of the group.
- Can be used in either CONNECTION or UTILIZATION balancing modes.
- - For CONNECTION mode, either maxConnections or maxConnectionsPerEndpoint
- must be set.
- returned: success
- type: int
- maxRate:
- description:
- - The max requests per second (RPS) of the group.
- - Can be used with either RATE or UTILIZATION balancing modes, but required
- if RATE mode. Either maxRate or one of maxRatePerInstance or maxRatePerEndpoint,
- as appropriate for group type, must be set.
- returned: success
- type: int
- maxRatePerInstance:
- description:
- - The max requests per second (RPS) that a single backend instance can handle.
- This is used to calculate the capacity of the group. Can be used in either
- balancing mode. For RATE mode, either maxRate or maxRatePerInstance must
- be set.
- returned: success
- type: str
- maxRatePerEndpoint:
- description:
- - The max requests per second (RPS) that a single backend network endpoint
- can handle. This is used to calculate the capacity of the group. Can be
- used in either balancing mode. For RATE mode, either maxRate or maxRatePerEndpoint
- must be set.
- returned: success
- type: str
- maxUtilization:
- description:
- - Used when balancingMode is UTILIZATION. This ratio defines the CPU utilization
- target for the group. Valid range is [0.0, 1.0].
- returned: success
- type: str
- connectionDraining:
- description:
- - Settings for connection draining .
- returned: success
- type: complex
- contains:
- drainingTimeoutSec:
- description:
- - Time for which instance will be drained (not accept new connections, but
- still work to finish started).
- returned: success
- type: int
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
- fingerprint:
- description:
- - Fingerprint of this resource. A hash of the contents stored in this object.
- This field is used in optimistic locking.
- returned: success
- type: str
- healthChecks:
- description:
- - The set of URLs to HealthCheck resources for health checking this RegionBackendService.
- Currently at most one health check can be specified, and a health check is
- required.
- returned: success
- type: list
- id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
- loadBalancingScheme:
- description:
- - Indicates what kind of load balancing this regional backend service will be
- used for. A backend service created for one type of load balancing cannot
- be used with the other(s). Must be `INTERNAL` or `INTERNAL_MANAGED`. Defaults
- to `INTERNAL`.
- returned: success
- type: str
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created.
- The name must be 1-63 characters long, and comply with RFC1035. Specifically,
- the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
- protocol:
- description:
- - The protocol this RegionBackendService uses to communicate with backends.
- - 'Possible values are HTTP, HTTPS, HTTP2, SSL, TCP, and UDP. The default is
- HTTP. **NOTE**: HTTP2 is only valid for beta HTTP/2 load balancer types and
- may result in errors if used with the GA API.'
- returned: success
- type: str
- sessionAffinity:
- description:
- - Type of session affinity to use. The default is NONE. Session affinity is
- not applicable if the protocol is UDP.
- returned: success
- type: str
- timeoutSec:
- description:
- - How many seconds to wait for the backend before considering it a failed request.
- Default is 30 seconds. Valid range is [1, 86400].
- returned: success
- type: int
- region:
- description:
- - A reference to the region where the regional backend service resides.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str'), region=dict(required=True, type='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/backendServices".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_region_disk.py b/lib/ansible/modules/cloud/google/gcp_compute_region_disk.py
deleted file mode 100644
index 45fd14d526..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_region_disk.py
+++ /dev/null
@@ -1,672 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_region_disk
-description:
-- Persistent disks are durable storage devices that function similarly to the physical
- disks in a desktop or a server. Compute Engine manages the hardware behind these
- devices to ensure data redundancy and optimize performance for you. Persistent disks
- are available as either standard hard disk drives (HDD) or solid-state drives (SSD).
-- Persistent disks are located independently from your virtual machine instances,
- so you can detach or move persistent disks to keep your data even after you delete
- your instances. Persistent disk performance scales automatically with size, so you
- can resize your existing persistent disks or add more persistent disks to an instance
- to meet your performance and storage space requirements.
-- Add a persistent disk to your instance when you need reliable and affordable storage
- with consistent performance characteristics.
-short_description: Creates a GCP RegionDisk
-version_added: '2.8'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- required: false
- type: str
- labels:
- description:
- - Labels to apply to this disk. A list of key->value pairs.
- required: false
- type: dict
- licenses:
- description:
- - Any applicable publicly visible licenses.
- required: false
- type: list
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- required: true
- type: str
- size_gb:
- description:
- - Size of the persistent disk, specified in GB. You can specify this field when
- creating a persistent disk using the sourceImage or sourceSnapshot parameter,
- or specify it alone to create an empty persistent disk.
- - If you specify this field along with sourceImage or sourceSnapshot, the value
- of sizeGb must not be less than the size of the sourceImage or the size of the
- snapshot.
- required: false
- type: int
- physical_block_size_bytes:
- description:
- - Physical block size of the persistent disk, in bytes. If not present in a request,
- a default value is used. Currently supported sizes are 4096 and 16384, other
- sizes may be added in the future.
- - If an unsupported value is requested, the error message will list the supported
- values for the caller's project.
- required: false
- type: int
- replica_zones:
- description:
- - URLs of the zones where the disk should be replicated to.
- required: true
- type: list
- type:
- description:
- - URL of the disk type resource describing which disk type to use to create the
- disk. Provide this when creating the disk.
- required: false
- type: str
- region:
- description:
- - A reference to the region where the disk resides.
- required: true
- type: str
- disk_encryption_key:
- description:
- - Encrypts the disk using a customer-supplied encryption key.
- - After you encrypt a disk with a customer-supplied key, you must provide the
- same key if you use the disk later (e.g. to create a disk snapshot or an image,
- or to attach the disk to a virtual machine).
- - Customer-supplied encryption keys do not protect access to metadata of the disk.
- - If you do not provide an encryption key when creating the disk, then the disk
- will be encrypted using an automatically generated key and you do not need to
- provide a key to use the disk later.
- required: false
- type: dict
- suboptions:
- raw_key:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
- base64 to either encrypt or decrypt this resource.
- required: false
- type: str
- source_snapshot:
- description:
- - The source snapshot used to create this disk. You can provide this as a partial
- or full URL to the resource.
- - 'This field represents a link to a Snapshot resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''selfLink'' and value
- of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
- to a gcp_compute_snapshot task and then set this source_snapshot field to "{{
- name-of-resource }}"'
- required: false
- type: dict
- source_snapshot_encryption_key:
- description:
- - The customer-supplied encryption key of the source snapshot. Required if the
- source snapshot is protected by a customer-supplied encryption key.
- required: false
- type: dict
- suboptions:
- raw_key:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
- base64 to either encrypt or decrypt this resource.
- required: false
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/beta/regionDisks)'
-- 'Adding or Resizing Regional Persistent Disks: U(https://cloud.google.com/compute/docs/disks/regional-persistent-disk)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a region disk
- gcp_compute_region_disk:
- name: test_object
- size_gb: 500
- disk_encryption_key:
- raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0=
- region: us-central1
- replica_zones:
- - https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-a
- - https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-b
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-labelFingerprint:
- description:
- - The fingerprint used for optimistic locking of this resource. Used internally
- during updates.
- returned: success
- type: str
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- returned: success
- type: str
-id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
-lastAttachTimestamp:
- description:
- - Last attach timestamp in RFC3339 text format.
- returned: success
- type: str
-lastDetachTimestamp:
- description:
- - Last detach timestamp in RFC3339 text format.
- returned: success
- type: str
-labels:
- description:
- - Labels to apply to this disk. A list of key->value pairs.
- returned: success
- type: dict
-licenses:
- description:
- - Any applicable publicly visible licenses.
- returned: success
- type: list
-name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
-sizeGb:
- description:
- - Size of the persistent disk, specified in GB. You can specify this field when
- creating a persistent disk using the sourceImage or sourceSnapshot parameter,
- or specify it alone to create an empty persistent disk.
- - If you specify this field along with sourceImage or sourceSnapshot, the value
- of sizeGb must not be less than the size of the sourceImage or the size of the
- snapshot.
- returned: success
- type: int
-users:
- description:
- - 'Links to the users of the disk (attached instances) in form: project/zones/zone/instances/instance
- .'
- returned: success
- type: list
-physicalBlockSizeBytes:
- description:
- - Physical block size of the persistent disk, in bytes. If not present in a request,
- a default value is used. Currently supported sizes are 4096 and 16384, other sizes
- may be added in the future.
- - If an unsupported value is requested, the error message will list the supported
- values for the caller's project.
- returned: success
- type: int
-replicaZones:
- description:
- - URLs of the zones where the disk should be replicated to.
- returned: success
- type: list
-type:
- description:
- - URL of the disk type resource describing which disk type to use to create the
- disk. Provide this when creating the disk.
- returned: success
- type: str
-region:
- description:
- - A reference to the region where the disk resides.
- returned: success
- type: str
-diskEncryptionKey:
- description:
- - Encrypts the disk using a customer-supplied encryption key.
- - After you encrypt a disk with a customer-supplied key, you must provide the same
- key if you use the disk later (e.g. to create a disk snapshot or an image, or
- to attach the disk to a virtual machine).
- - Customer-supplied encryption keys do not protect access to metadata of the disk.
- - If you do not provide an encryption key when creating the disk, then the disk
- will be encrypted using an automatically generated key and you do not need to
- provide a key to use the disk later.
- returned: success
- type: complex
- contains:
- rawKey:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
- base64 to either encrypt or decrypt this resource.
- returned: success
- type: str
- sha256:
- description:
- - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
- key that protects this resource.
- returned: success
- type: str
-sourceSnapshot:
- description:
- - The source snapshot used to create this disk. You can provide this as a partial
- or full URL to the resource.
- returned: success
- type: dict
-sourceSnapshotEncryptionKey:
- description:
- - The customer-supplied encryption key of the source snapshot. Required if the source
- snapshot is protected by a customer-supplied encryption key.
- returned: success
- type: complex
- contains:
- rawKey:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
- base64 to either encrypt or decrypt this resource.
- returned: success
- type: str
- sha256:
- description:
- - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
- key that protects this resource.
- returned: success
- type: str
-sourceSnapshotId:
- description:
- - The unique ID of the snapshot used to create this disk. This value identifies
- the exact snapshot that was used to create this persistent disk. For example,
- if you created the persistent disk from a snapshot that was later deleted and
- recreated under the same name, the source snapshot ID would identify the exact
- version of the snapshot that was used.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import re
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- description=dict(type='str'),
- labels=dict(type='dict'),
- licenses=dict(type='list', elements='str'),
- name=dict(required=True, type='str'),
- size_gb=dict(type='int'),
- physical_block_size_bytes=dict(type='int'),
- replica_zones=dict(required=True, type='list', elements='str'),
- type=dict(type='str'),
- region=dict(required=True, type='str'),
- disk_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'))),
- source_snapshot=dict(type='dict'),
- source_snapshot_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'))),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#disk'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind, fetch)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind, fetch):
- update_fields(module, resource_to_request(module), response_to_hash(module, fetch))
- return fetch_resource(module, self_link(module), kind)
-
-
-def update_fields(module, request, response):
- if response.get('labels') != request.get('labels'):
- label_fingerprint_update(module, request, response)
- if response.get('sizeGb') != request.get('sizeGb'):
- size_gb_update(module, request, response)
-
-
-def label_fingerprint_update(module, request, response):
- auth = GcpSession(module, 'compute')
- auth.post(
- ''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/regions/{region}/disks/{name}/setLabels"]).format(**module.params),
- {u'labelFingerprint': response.get('labelFingerprint'), u'labels': module.params.get('labels')},
- )
-
-
-def size_gb_update(module, request, response):
- auth = GcpSession(module, 'compute')
- auth.post(
- ''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/regions/{region}/disks/{name}/resize"]).format(**module.params),
- {u'sizeGb': module.params.get('size_gb')},
- )
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#disk',
- u'diskEncryptionKey': RegionDiskDiskencryptionkey(module.params.get('disk_encryption_key', {}), module).to_request(),
- u'sourceSnapshotEncryptionKey': RegionDiskSourcesnapshotencryptionkey(module.params.get('source_snapshot_encryption_key', {}), module).to_request(),
- u'description': module.params.get('description'),
- u'labels': module.params.get('labels'),
- u'licenses': module.params.get('licenses'),
- u'name': module.params.get('name'),
- u'sizeGb': module.params.get('size_gb'),
- u'physicalBlockSizeBytes': module.params.get('physical_block_size_bytes'),
- u'replicaZones': module.params.get('replica_zones'),
- u'type': region_disk_type_selflink(module.params.get('type'), module.params),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/disks/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/disks".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'labelFingerprint': response.get(u'labelFingerprint'),
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'description': response.get(u'description'),
- u'id': response.get(u'id'),
- u'lastAttachTimestamp': response.get(u'lastAttachTimestamp'),
- u'lastDetachTimestamp': response.get(u'lastDetachTimestamp'),
- u'labels': response.get(u'labels'),
- u'licenses': response.get(u'licenses'),
- u'name': module.params.get('name'),
- u'sizeGb': response.get(u'sizeGb'),
- u'users': response.get(u'users'),
- u'physicalBlockSizeBytes': response.get(u'physicalBlockSizeBytes'),
- u'replicaZones': response.get(u'replicaZones'),
- u'type': response.get(u'type'),
- }
-
-
-def zone_selflink(name, params):
- if name is None:
- return
- url = r"https://www.googleapis.com/compute/v1/projects/.*/zones/.*"
- if not re.match(url, name):
- name = "https://www.googleapis.com/compute/v1/projects/{project}/zones/%s".format(**params) % name
- return name
-
-
-def region_disk_type_selflink(name, params):
- if name is None:
- return
- url = r"https://www.googleapis.com/compute/v1/projects/.*/regions/.*/diskTypes/.*"
- if not re.match(url, name):
- name = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/diskTypes/%s".format(**params) % name
- return name
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#disk')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-class RegionDiskDiskencryptionkey(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'rawKey': self.request.get('raw_key')})
-
- def from_response(self):
- return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey')})
-
-
-class RegionDiskSourcesnapshotencryptionkey(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'rawKey': self.request.get('raw_key')})
-
- def from_response(self):
- return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey')})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_region_disk_info.py b/lib/ansible/modules/cloud/google/gcp_compute_region_disk_info.py
deleted file mode 100644
index e3112e274d..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_region_disk_info.py
+++ /dev/null
@@ -1,346 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_region_disk_info
-description:
-- Gather info for GCP RegionDisk
-short_description: Gather info for GCP RegionDisk
-version_added: '2.8'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- region:
- description:
- - A reference to the region where the disk resides.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a region disk
- gcp_compute_region_disk_info:
- region: us-central1
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- labelFingerprint:
- description:
- - The fingerprint used for optimistic locking of this resource. Used internally
- during updates.
- returned: success
- type: str
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- returned: success
- type: str
- id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
- lastAttachTimestamp:
- description:
- - Last attach timestamp in RFC3339 text format.
- returned: success
- type: str
- lastDetachTimestamp:
- description:
- - Last detach timestamp in RFC3339 text format.
- returned: success
- type: str
- labels:
- description:
- - Labels to apply to this disk. A list of key->value pairs.
- returned: success
- type: dict
- licenses:
- description:
- - Any applicable publicly visible licenses.
- returned: success
- type: list
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created.
- The name must be 1-63 characters long, and comply with RFC1035. Specifically,
- the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
- sizeGb:
- description:
- - Size of the persistent disk, specified in GB. You can specify this field when
- creating a persistent disk using the sourceImage or sourceSnapshot parameter,
- or specify it alone to create an empty persistent disk.
- - If you specify this field along with sourceImage or sourceSnapshot, the value
- of sizeGb must not be less than the size of the sourceImage or the size of
- the snapshot.
- returned: success
- type: int
- users:
- description:
- - 'Links to the users of the disk (attached instances) in form: project/zones/zone/instances/instance
- .'
- returned: success
- type: list
- physicalBlockSizeBytes:
- description:
- - Physical block size of the persistent disk, in bytes. If not present in a
- request, a default value is used. Currently supported sizes are 4096 and 16384,
- other sizes may be added in the future.
- - If an unsupported value is requested, the error message will list the supported
- values for the caller's project.
- returned: success
- type: int
- replicaZones:
- description:
- - URLs of the zones where the disk should be replicated to.
- returned: success
- type: list
- type:
- description:
- - URL of the disk type resource describing which disk type to use to create
- the disk. Provide this when creating the disk.
- returned: success
- type: str
- region:
- description:
- - A reference to the region where the disk resides.
- returned: success
- type: str
- diskEncryptionKey:
- description:
- - Encrypts the disk using a customer-supplied encryption key.
- - After you encrypt a disk with a customer-supplied key, you must provide the
- same key if you use the disk later (e.g. to create a disk snapshot or an image,
- or to attach the disk to a virtual machine).
- - Customer-supplied encryption keys do not protect access to metadata of the
- disk.
- - If you do not provide an encryption key when creating the disk, then the disk
- will be encrypted using an automatically generated key and you do not need
- to provide a key to use the disk later.
- returned: success
- type: complex
- contains:
- rawKey:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
- base64 to either encrypt or decrypt this resource.
- returned: success
- type: str
- sha256:
- description:
- - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
- key that protects this resource.
- returned: success
- type: str
- sourceSnapshot:
- description:
- - The source snapshot used to create this disk. You can provide this as a partial
- or full URL to the resource.
- returned: success
- type: dict
- sourceSnapshotEncryptionKey:
- description:
- - The customer-supplied encryption key of the source snapshot. Required if the
- source snapshot is protected by a customer-supplied encryption key.
- returned: success
- type: complex
- contains:
- rawKey:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
- base64 to either encrypt or decrypt this resource.
- returned: success
- type: str
- sha256:
- description:
- - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
- key that protects this resource.
- returned: success
- type: str
- sourceSnapshotId:
- description:
- - The unique ID of the snapshot used to create this disk. This value identifies
- the exact snapshot that was used to create this persistent disk. For example,
- if you created the persistent disk from a snapshot that was later deleted
- and recreated under the same name, the source snapshot ID would identify the
- exact version of the snapshot that was used.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str'), region=dict(required=True, type='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/disks".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_reservation.py b/lib/ansible/modules/cloud/google/gcp_compute_reservation.py
deleted file mode 100644
index ce5f41c4e1..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_reservation.py
+++ /dev/null
@@ -1,665 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_reservation
-description:
-- Represents a reservation resource. A reservation ensures that capacity is held in
- a specific zone even if the reserved VMs are not running.
-- Reservations apply only to Compute Engine, Cloud Dataproc, and Google Kubernetes
- Engine VM usage.Reservations do not apply to `f1-micro` or `g1-small` machine types,
- preemptible VMs, sole tenant nodes, or other services not listed above like Cloud
- SQL and Dataflow.
-short_description: Creates a GCP Reservation
-version_added: '2.10'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- description:
- description:
- - An optional description of this resource.
- required: false
- type: str
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- required: true
- type: str
- specific_reservation_required:
- description:
- - When set to true, only VMs that target this reservation by name can consume
- this reservation. Otherwise, it can be consumed by VMs with affinity for any
- reservation. Defaults to false.
- required: false
- default: 'false'
- type: bool
- specific_reservation:
- description:
- - Reservation for instances with specific machine shapes.
- required: true
- type: dict
- suboptions:
- count:
- description:
- - The number of resources that are allocated.
- required: true
- type: int
- instance_properties:
- description:
- - The instance properties for the reservation.
- required: true
- type: dict
- suboptions:
- machine_type:
- description:
- - The name of the machine type to reserve.
- required: true
- type: str
- min_cpu_platform:
- description:
- - The minimum CPU platform for the reservation. For example, `"Intel Skylake"`.
- See U(https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform#availablezones)
- for information on available CPU platforms.
- required: false
- type: str
- guest_accelerators:
- description:
- - Guest accelerator type and count.
- required: false
- type: list
- suboptions:
- accelerator_type:
- description:
- - 'The full or partial URL of the accelerator type to attach to this
- instance. For example: `projects/my-project/zones/us-central1-c/acceleratorTypes/nvidia-tesla-p100`
- If you are creating an instance template, specify only the accelerator
- name.'
- required: true
- type: str
- accelerator_count:
- description:
- - The number of the guest accelerator cards exposed to this instance.
- required: true
- type: int
- local_ssds:
- description:
- - The amount of local ssd to reserve with each instance. This reserves
- disks of type `local-ssd`.
- required: false
- type: list
- suboptions:
- interface:
- description:
- - The disk interface to use for attaching this disk, one of `SCSI`
- or `NVME`. The default is `SCSI`.
- - 'Some valid choices include: "SCSI", "NVME"'
- required: false
- default: SCSI
- type: str
- disk_size_gb:
- description:
- - The size of the disk in base-2 GB.
- required: true
- type: int
- zone:
- description:
- - The zone where the reservation is made.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/v1/reservations)'
-- 'Reserving zonal resources: U(https://cloud.google.com/compute/docs/instances/reserving-zonal-resources)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a reservation
- gcp_compute_reservation:
- name: test_object
- zone: us-central1-a
- specific_reservation:
- count: 1
- instance_properties:
- min_cpu_platform: Intel Cascade Lake
- machine_type: n2-standard-2
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
-id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
-name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
-commitment:
- description:
- - Full or partial URL to a parent commitment. This field displays for reservations
- that are tied to a commitment.
- returned: success
- type: str
-specificReservationRequired:
- description:
- - When set to true, only VMs that target this reservation by name can consume this
- reservation. Otherwise, it can be consumed by VMs with affinity for any reservation.
- Defaults to false.
- returned: success
- type: bool
-status:
- description:
- - The status of the reservation.
- returned: success
- type: str
-specificReservation:
- description:
- - Reservation for instances with specific machine shapes.
- returned: success
- type: complex
- contains:
- count:
- description:
- - The number of resources that are allocated.
- returned: success
- type: int
- inUseCount:
- description:
- - How many instances are in use.
- returned: success
- type: int
- instanceProperties:
- description:
- - The instance properties for the reservation.
- returned: success
- type: complex
- contains:
- machineType:
- description:
- - The name of the machine type to reserve.
- returned: success
- type: str
- minCpuPlatform:
- description:
- - The minimum CPU platform for the reservation. For example, `"Intel Skylake"`.
- See U(https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform#availablezones)
- for information on available CPU platforms.
- returned: success
- type: str
- guestAccelerators:
- description:
- - Guest accelerator type and count.
- returned: success
- type: complex
- contains:
- acceleratorType:
- description:
- - 'The full or partial URL of the accelerator type to attach to this
- instance. For example: `projects/my-project/zones/us-central1-c/acceleratorTypes/nvidia-tesla-p100`
- If you are creating an instance template, specify only the accelerator
- name.'
- returned: success
- type: str
- acceleratorCount:
- description:
- - The number of the guest accelerator cards exposed to this instance.
- returned: success
- type: int
- localSsds:
- description:
- - The amount of local ssd to reserve with each instance. This reserves disks
- of type `local-ssd`.
- returned: success
- type: complex
- contains:
- interface:
- description:
- - The disk interface to use for attaching this disk, one of `SCSI` or
- `NVME`. The default is `SCSI`.
- returned: success
- type: str
- diskSizeGb:
- description:
- - The size of the disk in base-2 GB.
- returned: success
- type: int
-zone:
- description:
- - The zone where the reservation is made.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- description=dict(type='str'),
- name=dict(required=True, type='str'),
- specific_reservation_required=dict(type='bool'),
- specific_reservation=dict(
- required=True,
- type='dict',
- options=dict(
- count=dict(required=True, type='int'),
- instance_properties=dict(
- required=True,
- type='dict',
- options=dict(
- machine_type=dict(required=True, type='str'),
- min_cpu_platform=dict(type='str'),
- guest_accelerators=dict(
- type='list',
- elements='dict',
- options=dict(accelerator_type=dict(required=True, type='str'), accelerator_count=dict(required=True, type='int')),
- ),
- local_ssds=dict(
- type='list',
- elements='dict',
- options=dict(interface=dict(default='SCSI', type='str'), disk_size_gb=dict(required=True, type='int')),
- ),
- ),
- ),
- ),
- ),
- zone=dict(required=True, type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
-
- fetch = fetch_resource(module, self_link(module))
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module))
- fetch = fetch_resource(module, self_link(module))
- changed = True
- else:
- delete(module, self_link(module))
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module))
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link):
- delete(module, self_link(module))
- create(module, collection(module))
-
-
-def delete(module, link):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'zone': module.params.get('zone'),
- u'description': module.params.get('description'),
- u'name': module.params.get('name'),
- u'specificReservationRequired': module.params.get('specific_reservation_required'),
- u'specificReservation': ReservationSpecificreservation(module.params.get('specific_reservation', {}), module).to_request(),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/reservations/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/reservations".format(**module.params)
-
-
-def return_if_object(module, response, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'description': response.get(u'description'),
- u'id': response.get(u'id'),
- u'name': response.get(u'name'),
- u'commitment': response.get(u'commitment'),
- u'specificReservationRequired': response.get(u'specificReservationRequired'),
- u'status': response.get(u'status'),
- u'specificReservation': ReservationSpecificreservation(response.get(u'specificReservation', {}), module).from_response(),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response)
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']))
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-class ReservationSpecificreservation(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'count': self.request.get('count'),
- u'instanceProperties': ReservationInstanceproperties(self.request.get('instance_properties', {}), self.module).to_request(),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'count': self.request.get(u'count'),
- u'instanceProperties': ReservationInstanceproperties(self.request.get(u'instanceProperties', {}), self.module).from_response(),
- }
- )
-
-
-class ReservationInstanceproperties(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'machineType': self.request.get('machine_type'),
- u'minCpuPlatform': self.request.get('min_cpu_platform'),
- u'guestAccelerators': ReservationGuestacceleratorsArray(self.request.get('guest_accelerators', []), self.module).to_request(),
- u'localSsds': ReservationLocalssdsArray(self.request.get('local_ssds', []), self.module).to_request(),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'machineType': self.request.get(u'machineType'),
- u'minCpuPlatform': self.request.get(u'minCpuPlatform'),
- u'guestAccelerators': ReservationGuestacceleratorsArray(self.request.get(u'guestAccelerators', []), self.module).from_response(),
- u'localSsds': ReservationLocalssdsArray(self.request.get(u'localSsds', []), self.module).from_response(),
- }
- )
-
-
-class ReservationGuestacceleratorsArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'acceleratorType': item.get('accelerator_type'), u'acceleratorCount': item.get('accelerator_count')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'acceleratorType': item.get(u'acceleratorType'), u'acceleratorCount': item.get(u'acceleratorCount')})
-
-
-class ReservationLocalssdsArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'interface': item.get('interface'), u'diskSizeGb': item.get('disk_size_gb')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'interface': item.get(u'interface'), u'diskSizeGb': item.get(u'diskSizeGb')})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_reservation_info.py b/lib/ansible/modules/cloud/google/gcp_compute_reservation_info.py
deleted file mode 100644
index fd23e00c3b..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_reservation_info.py
+++ /dev/null
@@ -1,312 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_reservation_info
-description:
-- Gather info for GCP Reservation
-short_description: Gather info for GCP Reservation
-version_added: '2.10'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- zone:
- description:
- - The zone where the reservation is made.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a reservation
- gcp_compute_reservation_info:
- zone: us-central1-a
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
- id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created.
- The name must be 1-63 characters long, and comply with RFC1035. Specifically,
- the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
- commitment:
- description:
- - Full or partial URL to a parent commitment. This field displays for reservations
- that are tied to a commitment.
- returned: success
- type: str
- specificReservationRequired:
- description:
- - When set to true, only VMs that target this reservation by name can consume
- this reservation. Otherwise, it can be consumed by VMs with affinity for any
- reservation. Defaults to false.
- returned: success
- type: bool
- status:
- description:
- - The status of the reservation.
- returned: success
- type: str
- specificReservation:
- description:
- - Reservation for instances with specific machine shapes.
- returned: success
- type: complex
- contains:
- count:
- description:
- - The number of resources that are allocated.
- returned: success
- type: int
- inUseCount:
- description:
- - How many instances are in use.
- returned: success
- type: int
- instanceProperties:
- description:
- - The instance properties for the reservation.
- returned: success
- type: complex
- contains:
- machineType:
- description:
- - The name of the machine type to reserve.
- returned: success
- type: str
- minCpuPlatform:
- description:
- - The minimum CPU platform for the reservation. For example, `"Intel
- Skylake"`. See U(https://cloud.google.com/compute/docs/instances/specify-min-cpu-platform#availablezones)
- for information on available CPU platforms.
- returned: success
- type: str
- guestAccelerators:
- description:
- - Guest accelerator type and count.
- returned: success
- type: complex
- contains:
- acceleratorType:
- description:
- - 'The full or partial URL of the accelerator type to attach to
- this instance. For example: `projects/my-project/zones/us-central1-c/acceleratorTypes/nvidia-tesla-p100`
- If you are creating an instance template, specify only the accelerator
- name.'
- returned: success
- type: str
- acceleratorCount:
- description:
- - The number of the guest accelerator cards exposed to this instance.
- returned: success
- type: int
- localSsds:
- description:
- - The amount of local ssd to reserve with each instance. This reserves
- disks of type `local-ssd`.
- returned: success
- type: complex
- contains:
- interface:
- description:
- - The disk interface to use for attaching this disk, one of `SCSI`
- or `NVME`. The default is `SCSI`.
- returned: success
- type: str
- diskSizeGb:
- description:
- - The size of the disk in base-2 GB.
- returned: success
- type: int
- zone:
- description:
- - The zone where the reservation is made.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str'), zone=dict(required=True, type='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/reservations".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_route.py b/lib/ansible/modules/cloud/google/gcp_compute_route.py
deleted file mode 100644
index ae98a4c42e..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_route.py
+++ /dev/null
@@ -1,538 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_route
-description:
-- Represents a Route resource.
-- A route is a rule that specifies how certain packets should be handled by the virtual
- network. Routes are associated with virtual machines by tag, and the set of routes
- for a particular virtual machine is called its routing table. For each packet leaving
- a virtual machine, the system searches that virtual machine's routing table for
- a single best matching route.
-- Routes match packets by destination IP address, preferring smaller or more specific
- ranges over larger ones. If there is a tie, the system selects the route with the
- smallest priority value. If there is still a tie, it uses the layer three and four
- packet headers to select just one of the remaining matching routes. The packet is
- then forwarded as specified by the next_hop field of the winning route -- either
- to another virtual machine destination, a virtual machine gateway or a Compute Engine-operated
- gateway. Packets that do not match any route in the sending virtual machine's routing
- table will be dropped.
-- A Route resource must have exactly one specification of either nextHopGateway, nextHopInstance,
- nextHopIp, nextHopVpnTunnel, or nextHopIlb.
-short_description: Creates a GCP Route
-version_added: '2.6'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- dest_range:
- description:
- - The destination range of outgoing packets that this route applies to.
- - Only IPv4 is supported.
- required: true
- type: str
- description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- required: false
- type: str
- version_added: '2.7'
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- required: true
- type: str
- network:
- description:
- - The network that this route applies to.
- - 'This field represents a link to a Network resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''selfLink'' and value
- of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
- to a gcp_compute_network task and then set this network field to "{{ name-of-resource
- }}"'
- required: true
- type: dict
- priority:
- description:
- - The priority of this route. Priority is used to break ties in cases where there
- is more than one matching route of equal prefix length.
- - In the case of two routes with equal prefix length, the one with the lowest-numbered
- priority value wins.
- - Default value is 1000. Valid range is 0 through 65535.
- required: false
- type: int
- tags:
- description:
- - A list of instance tags to which this route applies.
- required: false
- type: list
- next_hop_gateway:
- description:
- - URL to a gateway that should handle matching packets.
- - 'Currently, you can only specify the internet gateway, using a full or partial
- valid URL: * U(https://www.googleapis.com/compute/v1/projects/project/global/gateways/default-internet-gateway)
- * projects/project/global/gateways/default-internet-gateway * global/gateways/default-internet-gateway
- .'
- required: false
- type: str
- next_hop_instance:
- description:
- - URL to an instance that should handle matching packets.
- - 'You can specify this as a full or partial URL. For example: * U(https://www.googleapis.com/compute/v1/projects/project/zones/zone/)
- instances/instance * projects/project/zones/zone/instances/instance * zones/zone/instances/instance
- .'
- - 'This field represents a link to a Instance resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''selfLink'' and value
- of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
- to a gcp_compute_instance task and then set this next_hop_instance field to
- "{{ name-of-resource }}"'
- required: false
- type: dict
- next_hop_ip:
- description:
- - Network IP address of an instance that should handle matching packets.
- required: false
- type: str
- next_hop_vpn_tunnel:
- description:
- - URL to a VpnTunnel that should handle matching packets.
- - 'This field represents a link to a VpnTunnel resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''selfLink'' and value
- of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
- to a gcp_compute_vpn_tunnel task and then set this next_hop_vpn_tunnel field
- to "{{ name-of-resource }}"'
- required: false
- type: dict
- next_hop_ilb:
- description:
- - The URL to a forwarding rule of type loadBalancingScheme=INTERNAL that should
- handle matching packets.
- - 'You can only specify the forwarding rule as a partial or full URL. For example,
- the following are all valid URLs: U(https://www.googleapis.com/compute/v1/projects/project/regions/region/forwardingRules/forwardingRule)
- regions/region/forwardingRules/forwardingRule Note that this can only be used
- when the destinationRange is a public (non-RFC 1918) IP CIDR range.'
- - 'This field represents a link to a ForwardingRule resource in GCP. It can be
- specified in two ways. First, you can place a dictionary with key ''selfLink''
- and value of your resource''s selfLink Alternatively, you can add `register:
- name-of-resource` to a gcp_compute_forwarding_rule task and then set this next_hop_ilb
- field to "{{ name-of-resource }}"'
- required: false
- type: dict
- version_added: '2.10'
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/v1/routes)'
-- 'Using Routes: U(https://cloud.google.com/vpc/docs/using-routes)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a network
- gcp_compute_network:
- name: network-route
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: network
-
-- name: create a route
- gcp_compute_route:
- name: test_object
- dest_range: 192.168.6.0/24
- next_hop_gateway: global/gateways/default-internet-gateway
- network: "{{ network }}"
- tags:
- - backends
- - databases
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-destRange:
- description:
- - The destination range of outgoing packets that this route applies to.
- - Only IPv4 is supported.
- returned: success
- type: str
-description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- returned: success
- type: str
-name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
-network:
- description:
- - The network that this route applies to.
- returned: success
- type: dict
-priority:
- description:
- - The priority of this route. Priority is used to break ties in cases where there
- is more than one matching route of equal prefix length.
- - In the case of two routes with equal prefix length, the one with the lowest-numbered
- priority value wins.
- - Default value is 1000. Valid range is 0 through 65535.
- returned: success
- type: int
-tags:
- description:
- - A list of instance tags to which this route applies.
- returned: success
- type: list
-nextHopGateway:
- description:
- - URL to a gateway that should handle matching packets.
- - 'Currently, you can only specify the internet gateway, using a full or partial
- valid URL: * U(https://www.googleapis.com/compute/v1/projects/project/global/gateways/default-internet-gateway)
- * projects/project/global/gateways/default-internet-gateway * global/gateways/default-internet-gateway
- .'
- returned: success
- type: str
-nextHopInstance:
- description:
- - URL to an instance that should handle matching packets.
- - 'You can specify this as a full or partial URL. For example: * U(https://www.googleapis.com/compute/v1/projects/project/zones/zone/)
- instances/instance * projects/project/zones/zone/instances/instance * zones/zone/instances/instance
- .'
- returned: success
- type: dict
-nextHopIp:
- description:
- - Network IP address of an instance that should handle matching packets.
- returned: success
- type: str
-nextHopVpnTunnel:
- description:
- - URL to a VpnTunnel that should handle matching packets.
- returned: success
- type: dict
-nextHopNetwork:
- description:
- - URL to a Network that should handle matching packets.
- returned: success
- type: str
-nextHopIlb:
- description:
- - The URL to a forwarding rule of type loadBalancingScheme=INTERNAL that should
- handle matching packets.
- - 'You can only specify the forwarding rule as a partial or full URL. For example,
- the following are all valid URLs: U(https://www.googleapis.com/compute/v1/projects/project/regions/region/forwardingRules/forwardingRule)
- regions/region/forwardingRules/forwardingRule Note that this can only be used
- when the destinationRange is a public (non-RFC 1918) IP CIDR range.'
- returned: success
- type: dict
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- dest_range=dict(required=True, type='str'),
- description=dict(type='str'),
- name=dict(required=True, type='str'),
- network=dict(required=True, type='dict'),
- priority=dict(type='int'),
- tags=dict(type='list', elements='str'),
- next_hop_gateway=dict(type='str'),
- next_hop_instance=dict(type='dict'),
- next_hop_ip=dict(type='str'),
- next_hop_vpn_tunnel=dict(type='dict'),
- next_hop_ilb=dict(type='dict'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#route'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind):
- delete(module, self_link(module), kind)
- create(module, collection(module), kind)
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#route',
- u'destRange': module.params.get('dest_range'),
- u'description': module.params.get('description'),
- u'name': module.params.get('name'),
- u'network': replace_resource_dict(module.params.get(u'network', {}), 'selfLink'),
- u'priority': module.params.get('priority'),
- u'tags': module.params.get('tags'),
- u'nextHopGateway': module.params.get('next_hop_gateway'),
- u'nextHopInstance': replace_resource_dict(module.params.get(u'next_hop_instance', {}), 'selfLink'),
- u'nextHopIp': module.params.get('next_hop_ip'),
- u'nextHopVpnTunnel': replace_resource_dict(module.params.get(u'next_hop_vpn_tunnel', {}), 'selfLink'),
- u'nextHopIlb': replace_resource_dict(module.params.get(u'next_hop_ilb', {}), 'selfLink'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/routes/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/routes".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'destRange': response.get(u'destRange'),
- u'description': response.get(u'description'),
- u'name': response.get(u'name'),
- u'network': replace_resource_dict(module.params.get(u'network', {}), 'selfLink'),
- u'priority': module.params.get('priority'),
- u'tags': module.params.get('tags'),
- u'nextHopGateway': module.params.get('next_hop_gateway'),
- u'nextHopInstance': replace_resource_dict(module.params.get(u'next_hop_instance', {}), 'selfLink'),
- u'nextHopIp': module.params.get('next_hop_ip'),
- u'nextHopVpnTunnel': replace_resource_dict(module.params.get(u'next_hop_vpn_tunnel', {}), 'selfLink'),
- u'nextHopNetwork': response.get(u'nextHopNetwork'),
- u'nextHopIlb': replace_resource_dict(module.params.get(u'next_hop_ilb', {}), 'selfLink'),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/global/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#route')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_route_info.py b/lib/ansible/modules/cloud/google/gcp_compute_route_info.py
deleted file mode 100644
index 76dbcf7d03..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_route_info.py
+++ /dev/null
@@ -1,271 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_route_info
-description:
-- Gather info for GCP Route
-short_description: Gather info for GCP Route
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a route
- gcp_compute_route_info:
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- destRange:
- description:
- - The destination range of outgoing packets that this route applies to.
- - Only IPv4 is supported.
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- returned: success
- type: str
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created.
- The name must be 1-63 characters long, and comply with RFC1035. Specifically,
- the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
- network:
- description:
- - The network that this route applies to.
- returned: success
- type: dict
- priority:
- description:
- - The priority of this route. Priority is used to break ties in cases where
- there is more than one matching route of equal prefix length.
- - In the case of two routes with equal prefix length, the one with the lowest-numbered
- priority value wins.
- - Default value is 1000. Valid range is 0 through 65535.
- returned: success
- type: int
- tags:
- description:
- - A list of instance tags to which this route applies.
- returned: success
- type: list
- nextHopGateway:
- description:
- - URL to a gateway that should handle matching packets.
- - 'Currently, you can only specify the internet gateway, using a full or partial valid URL:'
- - ' * https://www.googleapis.com/compute/v1/projects/project/global/gateways/default-internet-gateway'
- - ' * projects/project/global/gateways/default-internet-gateway'
- - ' * global/gateways/default-internet-gateway'
- returned: success
- type: str
- nextHopInstance:
- description:
- - URL to an instance that should handle matching packets.
- - 'You can specify this as a full or partial URL. For example:'
- - ' * https://www.googleapis.com/compute/v1/projects/project/zones/zone/instances/instance'
- - ' * projects/project/zones/zone/instances/instance'
- - ' * zones/zone/instances/instance'
- returned: success
- type: dict
- nextHopIp:
- description:
- - Network IP address of an instance that should handle matching packets.
- returned: success
- type: str
- nextHopVpnTunnel:
- description:
- - URL to a VpnTunnel that should handle matching packets.
- returned: success
- type: dict
- nextHopNetwork:
- description:
- - URL to a Network that should handle matching packets.
- returned: success
- type: str
- nextHopIlb:
- description:
- - The URL to a forwarding rule of type loadBalancingScheme=INTERNAL that should
- handle matching packets.
- - 'You can only specify the forwarding rule as a partial or full URL. For example,
- the following are all valid URLs: U(https://www.googleapis.com/compute/v1/projects/project/regions/region/forwardingRules/forwardingRule)
- regions/region/forwardingRules/forwardingRule Note that this can only be used
- when the destinationRange is a public (non-RFC 1918) IP CIDR range.'
- returned: success
- type: dict
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/routes".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_router.py b/lib/ansible/modules/cloud/google/gcp_compute_router.py
deleted file mode 100644
index bef8993fcd..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_router.py
+++ /dev/null
@@ -1,552 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_router
-description:
-- Represents a Router resource.
-short_description: Creates a GCP Router
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- name:
- description:
- - Name of the resource. The name must be 1-63 characters long, and comply with
- RFC1035. Specifically, the name must be 1-63 characters long and match the regular
- expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must
- be a lowercase letter, and all following characters must be a dash, lowercase
- letter, or digit, except the last character, which cannot be a dash.
- required: true
- type: str
- description:
- description:
- - An optional description of this resource.
- required: false
- type: str
- network:
- description:
- - A reference to the network to which this router belongs.
- - 'This field represents a link to a Network resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''selfLink'' and value
- of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
- to a gcp_compute_network task and then set this network field to "{{ name-of-resource
- }}"'
- required: true
- type: dict
- bgp:
- description:
- - BGP information specific to this router.
- required: false
- type: dict
- suboptions:
- asn:
- description:
- - Local BGP Autonomous System Number (ASN). Must be an RFC6996 private ASN,
- either 16-bit or 32-bit. The value will be fixed for this router resource.
- All VPN tunnels that link to this router will have the same local ASN.
- required: true
- type: int
- advertise_mode:
- description:
- - User-specified flag to indicate which mode to use for advertisement.
- - 'Valid values of this enum field are: DEFAULT, CUSTOM .'
- - 'Some valid choices include: "DEFAULT", "CUSTOM"'
- required: false
- default: DEFAULT
- type: str
- advertised_groups:
- description:
- - User-specified list of prefix groups to advertise in custom mode.
- - This field can only be populated if advertiseMode is CUSTOM and is advertised
- to all peers of the router. These groups will be advertised in addition
- to any specified prefixes. Leave this field blank to advertise no custom
- groups.
- - 'This enum field has the one valid value: ALL_SUBNETS .'
- required: false
- type: list
- advertised_ip_ranges:
- description:
- - User-specified list of individual IP ranges to advertise in custom mode.
- This field can only be populated if advertiseMode is CUSTOM and is advertised
- to all peers of the router. These IP ranges will be advertised in addition
- to any specified groups.
- - Leave this field blank to advertise no custom IP ranges.
- required: false
- type: list
- suboptions:
- range:
- description:
- - The IP range to advertise. The value must be a CIDR-formatted string.
- required: true
- type: str
- description:
- description:
- - User-specified description for the IP range.
- required: false
- type: str
- region:
- description:
- - Region where the router resides.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/v1/routers)'
-- 'Google Cloud Router: U(https://cloud.google.com/router/docs/)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a network
- gcp_compute_network:
- name: network-router
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: network
-
-- name: create a router
- gcp_compute_router:
- name: test_object
- network: "{{ network }}"
- bgp:
- asn: 64514
- advertise_mode: CUSTOM
- advertised_groups:
- - ALL_SUBNETS
- advertised_ip_ranges:
- - range: 1.2.3.4
- - range: 6.7.0.0/16
- region: us-central1
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-name:
- description:
- - Name of the resource. The name must be 1-63 characters long, and comply with RFC1035.
- Specifically, the name must be 1-63 characters long and match the regular expression
- `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase
- letter, and all following characters must be a dash, lowercase letter, or digit,
- except the last character, which cannot be a dash.
- returned: success
- type: str
-description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
-network:
- description:
- - A reference to the network to which this router belongs.
- returned: success
- type: dict
-bgp:
- description:
- - BGP information specific to this router.
- returned: success
- type: complex
- contains:
- asn:
- description:
- - Local BGP Autonomous System Number (ASN). Must be an RFC6996 private ASN,
- either 16-bit or 32-bit. The value will be fixed for this router resource.
- All VPN tunnels that link to this router will have the same local ASN.
- returned: success
- type: int
- advertiseMode:
- description:
- - User-specified flag to indicate which mode to use for advertisement.
- - 'Valid values of this enum field are: DEFAULT, CUSTOM .'
- returned: success
- type: str
- advertisedGroups:
- description:
- - User-specified list of prefix groups to advertise in custom mode.
- - This field can only be populated if advertiseMode is CUSTOM and is advertised
- to all peers of the router. These groups will be advertised in addition to
- any specified prefixes. Leave this field blank to advertise no custom groups.
- - 'This enum field has the one valid value: ALL_SUBNETS .'
- returned: success
- type: list
- advertisedIpRanges:
- description:
- - User-specified list of individual IP ranges to advertise in custom mode. This
- field can only be populated if advertiseMode is CUSTOM and is advertised to
- all peers of the router. These IP ranges will be advertised in addition to
- any specified groups.
- - Leave this field blank to advertise no custom IP ranges.
- returned: success
- type: complex
- contains:
- range:
- description:
- - The IP range to advertise. The value must be a CIDR-formatted string.
- returned: success
- type: str
- description:
- description:
- - User-specified description for the IP range.
- returned: success
- type: str
-region:
- description:
- - Region where the router resides.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- name=dict(required=True, type='str'),
- description=dict(type='str'),
- network=dict(required=True, type='dict'),
- bgp=dict(
- type='dict',
- options=dict(
- asn=dict(required=True, type='int'),
- advertise_mode=dict(default='DEFAULT', type='str'),
- advertised_groups=dict(type='list', elements='str'),
- advertised_ip_ranges=dict(type='list', elements='dict', options=dict(range=dict(required=True, type='str'), description=dict(type='str'))),
- ),
- ),
- region=dict(required=True, type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#router'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.patch(link, resource_to_request(module)))
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#router',
- u'region': module.params.get('region'),
- u'name': module.params.get('name'),
- u'description': module.params.get('description'),
- u'network': replace_resource_dict(module.params.get(u'network', {}), 'selfLink'),
- u'bgp': RouterBgp(module.params.get('bgp', {}), module).to_request(),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/routers/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/routers".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'id': response.get(u'id'),
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'name': module.params.get('name'),
- u'description': response.get(u'description'),
- u'network': replace_resource_dict(module.params.get(u'network', {}), 'selfLink'),
- u'bgp': RouterBgp(response.get(u'bgp', {}), module).from_response(),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#router')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-class RouterBgp(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'asn': self.request.get('asn'),
- u'advertiseMode': self.request.get('advertise_mode'),
- u'advertisedGroups': self.request.get('advertised_groups'),
- u'advertisedIpRanges': RouterAdvertisediprangesArray(self.request.get('advertised_ip_ranges', []), self.module).to_request(),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'asn': self.request.get(u'asn'),
- u'advertiseMode': self.request.get(u'advertiseMode'),
- u'advertisedGroups': self.request.get(u'advertisedGroups'),
- u'advertisedIpRanges': RouterAdvertisediprangesArray(self.request.get(u'advertisedIpRanges', []), self.module).from_response(),
- }
- )
-
-
-class RouterAdvertisediprangesArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'range': item.get('range'), u'description': item.get('description')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'range': item.get(u'range'), u'description': item.get(u'description')})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_router_info.py b/lib/ansible/modules/cloud/google/gcp_compute_router_info.py
deleted file mode 100644
index 83167c45ab..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_router_info.py
+++ /dev/null
@@ -1,276 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_router_info
-description:
-- Gather info for GCP Router
-short_description: Gather info for GCP Router
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- region:
- description:
- - Region where the router resides.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a router
- gcp_compute_router_info:
- region: us-central1
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- name:
- description:
- - Name of the resource. The name must be 1-63 characters long, and comply with
- RFC1035. Specifically, the name must be 1-63 characters long and match the
- regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character
- must be a lowercase letter, and all following characters must be a dash, lowercase
- letter, or digit, except the last character, which cannot be a dash.
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
- network:
- description:
- - A reference to the network to which this router belongs.
- returned: success
- type: dict
- bgp:
- description:
- - BGP information specific to this router.
- returned: success
- type: complex
- contains:
- asn:
- description:
- - Local BGP Autonomous System Number (ASN). Must be an RFC6996 private ASN,
- either 16-bit or 32-bit. The value will be fixed for this router resource.
- All VPN tunnels that link to this router will have the same local ASN.
- returned: success
- type: int
- advertiseMode:
- description:
- - User-specified flag to indicate which mode to use for advertisement.
- - 'Valid values of this enum field are: DEFAULT, CUSTOM .'
- returned: success
- type: str
- advertisedGroups:
- description:
- - User-specified list of prefix groups to advertise in custom mode.
- - This field can only be populated if advertiseMode is CUSTOM and is advertised
- to all peers of the router. These groups will be advertised in addition
- to any specified prefixes. Leave this field blank to advertise no custom
- groups.
- - 'This enum field has the one valid value: ALL_SUBNETS .'
- returned: success
- type: list
- advertisedIpRanges:
- description:
- - User-specified list of individual IP ranges to advertise in custom mode.
- This field can only be populated if advertiseMode is CUSTOM and is advertised
- to all peers of the router. These IP ranges will be advertised in addition
- to any specified groups.
- - Leave this field blank to advertise no custom IP ranges.
- returned: success
- type: complex
- contains:
- range:
- description:
- - The IP range to advertise. The value must be a CIDR-formatted string.
- returned: success
- type: str
- description:
- description:
- - User-specified description for the IP range.
- returned: success
- type: str
- region:
- description:
- - Region where the router resides.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str'), region=dict(required=True, type='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/routers".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_snapshot.py b/lib/ansible/modules/cloud/google/gcp_compute_snapshot.py
deleted file mode 100644
index 29b27e8e61..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_snapshot.py
+++ /dev/null
@@ -1,569 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_snapshot
-description:
-- Represents a Persistent Disk Snapshot resource.
-- Use snapshots to back up data from your persistent disks. Snapshots are different
- from public images and custom images, which are used primarily to create instances
- or configure instance templates. Snapshots are useful for periodic backup of the
- data on your persistent disks. You can create snapshots from persistent disks even
- while they are attached to running instances.
-- Snapshots are incremental, so you can create regular snapshots on a persistent disk
- faster and at a much lower cost than if you regularly created a full image of the
- disk.
-short_description: Creates a GCP Snapshot
-version_added: '2.9'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- name:
- description:
- - Name of the resource; provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- required: true
- type: str
- description:
- description:
- - An optional description of this resource.
- required: false
- type: str
- labels:
- description:
- - Labels to apply to this Snapshot.
- required: false
- type: dict
- source_disk:
- description:
- - A reference to the disk used to create this snapshot.
- - 'This field represents a link to a Disk resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''name'' and value of
- your resource''s name Alternatively, you can add `register: name-of-resource`
- to a gcp_compute_disk task and then set this source_disk field to "{{ name-of-resource
- }}"'
- required: true
- type: dict
- zone:
- description:
- - A reference to the zone where the disk is hosted.
- required: false
- type: str
- snapshot_encryption_key:
- description:
- - The customer-supplied encryption key of the snapshot. Required if the source
- snapshot is protected by a customer-supplied encryption key.
- required: false
- type: dict
- suboptions:
- raw_key:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
- base64 to either encrypt or decrypt this resource.
- required: false
- type: str
- kms_key_name:
- description:
- - The name of the encryption key that is stored in Google Cloud KMS.
- required: false
- type: str
- source_disk_encryption_key:
- description:
- - The customer-supplied encryption key of the source snapshot. Required if the
- source snapshot is protected by a customer-supplied encryption key.
- required: false
- type: dict
- suboptions:
- raw_key:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
- base64 to either encrypt or decrypt this resource.
- required: false
- type: str
- kms_key_name:
- description:
- - The name of the encryption key that is stored in Google Cloud KMS.
- required: false
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/v1/snapshots)'
-- 'Official Documentation: U(https://cloud.google.com/compute/docs/disks/create-snapshots)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a disk
- gcp_compute_disk:
- name: disk-snapshot
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: disk
-
-- name: create a snapshot
- gcp_compute_snapshot:
- name: test_object
- source_disk: "{{ disk }}"
- zone: us-central1-a
- labels:
- my_label: value
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
-diskSizeGb:
- description:
- - Size of the snapshot, specified in GB.
- returned: success
- type: int
-name:
- description:
- - Name of the resource; provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
-description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
-storageBytes:
- description:
- - A size of the storage used by the snapshot. As snapshots share storage, this
- number is expected to change with snapshot creation/deletion.
- returned: success
- type: int
-licenses:
- description:
- - A list of public visible licenses that apply to this snapshot. This can be because
- the original image had licenses attached (such as a Windows image). snapshotEncryptionKey
- nested object Encrypts the snapshot using a customer-supplied encryption key.
- returned: success
- type: list
-labels:
- description:
- - Labels to apply to this Snapshot.
- returned: success
- type: dict
-labelFingerprint:
- description:
- - The fingerprint used for optimistic locking of this resource. Used internally
- during updates.
- returned: success
- type: str
-sourceDisk:
- description:
- - A reference to the disk used to create this snapshot.
- returned: success
- type: dict
-zone:
- description:
- - A reference to the zone where the disk is hosted.
- returned: success
- type: str
-snapshotEncryptionKey:
- description:
- - The customer-supplied encryption key of the snapshot. Required if the source snapshot
- is protected by a customer-supplied encryption key.
- returned: success
- type: complex
- contains:
- rawKey:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
- base64 to either encrypt or decrypt this resource.
- returned: success
- type: str
- sha256:
- description:
- - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
- key that protects this resource.
- returned: success
- type: str
- kmsKeyName:
- description:
- - The name of the encryption key that is stored in Google Cloud KMS.
- returned: success
- type: str
-sourceDiskEncryptionKey:
- description:
- - The customer-supplied encryption key of the source snapshot. Required if the source
- snapshot is protected by a customer-supplied encryption key.
- returned: success
- type: complex
- contains:
- rawKey:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
- base64 to either encrypt or decrypt this resource.
- returned: success
- type: str
- kmsKeyName:
- description:
- - The name of the encryption key that is stored in Google Cloud KMS.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import re
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- name=dict(required=True, type='str'),
- description=dict(type='str'),
- labels=dict(type='dict'),
- source_disk=dict(required=True, type='dict'),
- zone=dict(type='str'),
- snapshot_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), kms_key_name=dict(type='str'))),
- source_disk_encryption_key=dict(type='dict', options=dict(raw_key=dict(type='str'), kms_key_name=dict(type='str'))),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#snapshot'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind, fetch)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, create_link(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind, fetch):
- update_fields(module, resource_to_request(module), response_to_hash(module, fetch))
- return fetch_resource(module, self_link(module), kind)
-
-
-def update_fields(module, request, response):
- if response.get('labels') != request.get('labels'):
- labels_update(module, request, response)
-
-
-def labels_update(module, request, response):
- auth = GcpSession(module, 'compute')
- auth.post(
- ''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/global/snapshots/{name}/setLabels"]).format(**module.params),
- {u'labels': module.params.get('labels'), u'labelFingerprint': response.get('labelFingerprint')},
- )
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#snapshot',
- u'sourceDisk': replace_resource_dict(module.params.get(u'source_disk', {}), 'name'),
- u'zone': module.params.get('zone'),
- u'name': module.params.get('name'),
- u'description': module.params.get('description'),
- u'labels': module.params.get('labels'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/snapshots/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/snapshots".format(**module.params)
-
-
-def create_link(module):
- res = {'project': module.params['project'], 'zone': module.params['zone'], 'source_disk': replace_resource_dict(module.params['source_disk'], 'name')}
- return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/disks/{source_disk}/createSnapshot".format(**res)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'id': response.get(u'id'),
- u'diskSizeGb': response.get(u'diskSizeGb'),
- u'name': module.params.get('name'),
- u'description': module.params.get('description'),
- u'storageBytes': response.get(u'storageBytes'),
- u'licenses': response.get(u'licenses'),
- u'labels': response.get(u'labels'),
- u'labelFingerprint': response.get(u'labelFingerprint'),
- }
-
-
-def license_selflink(name, params):
- if name is None:
- return
- url = r"https://www.googleapis.com/compute/v1//projects/.*/global/licenses/.*"
- if not re.match(url, name):
- name = "https://www.googleapis.com/compute/v1//projects/{project}/global/licenses/%s".format(**params) % name
- return name
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#snapshot')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = navigate_hash(op_result, ['selfLink'])
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-class SnapshotSnapshotencryptionkey(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'rawKey': self.request.get('raw_key'), u'kmsKeyName': self.request.get('kms_key_name')})
-
- def from_response(self):
- return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey'), u'kmsKeyName': self.request.get(u'kmsKeyName')})
-
-
-class SnapshotSourcediskencryptionkey(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'rawKey': self.request.get('raw_key'), u'kmsKeyName': self.request.get('kms_key_name')})
-
- def from_response(self):
- return remove_nones_from_dict({u'rawKey': self.request.get(u'rawKey'), u'kmsKeyName': self.request.get(u'kmsKeyName')})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_snapshot_info.py b/lib/ansible/modules/cloud/google/gcp_compute_snapshot_info.py
deleted file mode 100644
index dc652b50ae..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_snapshot_info.py
+++ /dev/null
@@ -1,294 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_snapshot_info
-description:
-- Gather info for GCP Snapshot
-short_description: Gather info for GCP Snapshot
-version_added: '2.9'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a snapshot
- gcp_compute_snapshot_info:
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
- diskSizeGb:
- description:
- - Size of the snapshot, specified in GB.
- returned: success
- type: int
- name:
- description:
- - Name of the resource; provided by the client when the resource is created.
- The name must be 1-63 characters long, and comply with RFC1035. Specifically,
- the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
- storageBytes:
- description:
- - A size of the storage used by the snapshot. As snapshots share storage,
- this number is expected to change with snapshot creation/deletion.
- returned: success
- type: int
- licenses:
- description:
- - A list of public visible licenses that apply to this snapshot. This can be
- because the original image had licenses attached (such as a Windows image).
- snapshotEncryptionKey nested object Encrypts the snapshot using a customer-supplied
- encryption key.
- returned: success
- type: list
- labels:
- description:
- - Labels to apply to this Snapshot.
- returned: success
- type: dict
- labelFingerprint:
- description:
- - The fingerprint used for optimistic locking of this resource. Used internally
- during updates.
- returned: success
- type: str
- sourceDisk:
- description:
- - A reference to the disk used to create this snapshot.
- returned: success
- type: dict
- zone:
- description:
- - A reference to the zone where the disk is hosted.
- returned: success
- type: str
- snapshotEncryptionKey:
- description:
- - The customer-supplied encryption key of the snapshot. Required if the source
- snapshot is protected by a customer-supplied encryption key.
- returned: success
- type: complex
- contains:
- rawKey:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
- base64 to either encrypt or decrypt this resource.
- returned: success
- type: str
- sha256:
- description:
- - The RFC 4648 base64 encoded SHA-256 hash of the customer-supplied encryption
- key that protects this resource.
- returned: success
- type: str
- kmsKeyName:
- description:
- - The name of the encryption key that is stored in Google Cloud KMS.
- returned: success
- type: str
- sourceDiskEncryptionKey:
- description:
- - The customer-supplied encryption key of the source snapshot. Required if the
- source snapshot is protected by a customer-supplied encryption key.
- returned: success
- type: complex
- contains:
- rawKey:
- description:
- - Specifies a 256-bit customer-supplied encryption key, encoded in RFC 4648
- base64 to either encrypt or decrypt this resource.
- returned: success
- type: str
- kmsKeyName:
- description:
- - The name of the encryption key that is stored in Google Cloud KMS.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/snapshots".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_ssl_certificate.py b/lib/ansible/modules/cloud/google/gcp_compute_ssl_certificate.py
deleted file mode 100644
index e0f1ff7a6a..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_ssl_certificate.py
+++ /dev/null
@@ -1,396 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_ssl_certificate
-description:
-- An SslCertificate resource, used for HTTPS load balancing. This resource provides
- a mechanism to upload an SSL key and certificate to the load balancer to serve secure
- connections from the user.
-short_description: Creates a GCP SslCertificate
-version_added: '2.6'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- certificate:
- description:
- - The certificate in PEM format.
- - The certificate chain must be no greater than 5 certs long.
- - The chain must include at least one intermediate cert.
- required: true
- type: str
- description:
- description:
- - An optional description of this resource.
- required: false
- type: str
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- required: false
- type: str
- private_key:
- description:
- - The write-only private key in PEM format.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/v1/sslCertificates)'
-- 'Official Documentation: U(https://cloud.google.com/load-balancing/docs/ssl-certificates)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a SSL certificate
- gcp_compute_ssl_certificate:
- name: test_object
- description: A certificate for testing. Do not use this certificate in production
- certificate: |-
- -----BEGIN CERTIFICATE-----
- MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG
- EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT
- BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm
- b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN
- AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2
- MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP
- BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM
- FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z
- aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH
- KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ
- 4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O
- BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn
- 0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O
- M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ
- zqGNhIPGq2ULqXKK8BY=
- -----END CERTIFICATE-----
- private_key: |-
- -----BEGIN EC PRIVATE KEY-----
- MHcCAQEEIObtRo8tkUqoMjeHhsOh2ouPpXCgBcP+EDxZCB/tws15oAoGCCqGSM49
- AwEHoUQDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ4mzkzTv0dXyB750f
- OGN02HtkpBOZzzvUARTR10JQoSe2/5PIwQ==
- -----END EC PRIVATE KEY-----
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-certificate:
- description:
- - The certificate in PEM format.
- - The certificate chain must be no greater than 5 certs long.
- - The chain must include at least one intermediate cert.
- returned: success
- type: str
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
-id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
-name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
-privateKey:
- description:
- - The write-only private key in PEM format.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- certificate=dict(required=True, type='str'),
- description=dict(type='str'),
- name=dict(type='str'),
- private_key=dict(required=True, type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#sslCertificate'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind):
- delete(module, self_link(module), kind)
- create(module, collection(module), kind)
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#sslCertificate',
- u'certificate': module.params.get('certificate'),
- u'description': module.params.get('description'),
- u'name': module.params.get('name'),
- u'privateKey': module.params.get('private_key'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/sslCertificates/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/sslCertificates".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'certificate': response.get(u'certificate'),
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'description': response.get(u'description'),
- u'id': response.get(u'id'),
- u'name': response.get(u'name'),
- u'privateKey': module.params.get('private_key'),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/global/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#sslCertificate')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_ssl_certificate_info.py b/lib/ansible/modules/cloud/google/gcp_compute_ssl_certificate_info.py
deleted file mode 100644
index 59efe3c34b..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_ssl_certificate_info.py
+++ /dev/null
@@ -1,224 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_ssl_certificate_info
-description:
-- Gather info for GCP SslCertificate
-short_description: Gather info for GCP SslCertificate
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a SSL certificate
- gcp_compute_ssl_certificate_info:
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- certificate:
- description:
- - The certificate in PEM format.
- - The certificate chain must be no greater than 5 certs long.
- - The chain must include at least one intermediate cert.
- returned: success
- type: str
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
- id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created.
- The name must be 1-63 characters long, and comply with RFC1035. Specifically,
- the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
- privateKey:
- description:
- - The write-only private key in PEM format.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/sslCertificates".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_ssl_policy.py b/lib/ansible/modules/cloud/google/gcp_compute_ssl_policy.py
deleted file mode 100644
index 87457f901c..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_ssl_policy.py
+++ /dev/null
@@ -1,458 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_ssl_policy
-description:
-- Represents a SSL policy. SSL policies give you the ability to control the features
- of SSL that your SSL proxy or HTTPS load balancer negotiates.
-short_description: Creates a GCP SslPolicy
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- description:
- description:
- - An optional description of this resource.
- required: false
- type: str
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- required: true
- type: str
- profile:
- description:
- - Profile specifies the set of SSL features that can be used by the load balancer
- when negotiating SSL with clients. This can be one of `COMPATIBLE`, `MODERN`,
- `RESTRICTED`, or `CUSTOM`. If using `CUSTOM`, the set of SSL features to enable
- must be specified in the `customFeatures` field.
- - 'Some valid choices include: "COMPATIBLE", "MODERN", "RESTRICTED", "CUSTOM"'
- required: false
- type: str
- min_tls_version:
- description:
- - The minimum version of SSL protocol that can be used by the clients to establish
- a connection with the load balancer. This can be one of `TLS_1_0`, `TLS_1_1`,
- `TLS_1_2`.
- - 'Some valid choices include: "TLS_1_0", "TLS_1_1", "TLS_1_2"'
- required: false
- type: str
- custom_features:
- description:
- - A list of features enabled when the selected profile is CUSTOM. The method returns
- the set of features that can be specified in this list. This field must be empty
- if the profile is not CUSTOM.
- required: false
- type: list
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/v1/sslPolicies)'
-- 'Using SSL Policies: U(https://cloud.google.com/compute/docs/load-balancing/ssl-policies)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a SSL policy
- gcp_compute_ssl_policy:
- name: test_object
- profile: CUSTOM
- min_tls_version: TLS_1_2
- custom_features:
- - TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
- - TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
-id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
-name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
-profile:
- description:
- - Profile specifies the set of SSL features that can be used by the load balancer
- when negotiating SSL with clients. This can be one of `COMPATIBLE`, `MODERN`,
- `RESTRICTED`, or `CUSTOM`. If using `CUSTOM`, the set of SSL features to enable
- must be specified in the `customFeatures` field.
- returned: success
- type: str
-minTlsVersion:
- description:
- - The minimum version of SSL protocol that can be used by the clients to establish
- a connection with the load balancer. This can be one of `TLS_1_0`, `TLS_1_1`,
- `TLS_1_2`.
- returned: success
- type: str
-enabledFeatures:
- description:
- - The list of features enabled in the SSL policy.
- returned: success
- type: list
-customFeatures:
- description:
- - A list of features enabled when the selected profile is CUSTOM. The method returns
- the set of features that can be specified in this list. This field must be empty
- if the profile is not CUSTOM.
- returned: success
- type: list
-fingerprint:
- description:
- - Fingerprint of this resource. A hash of the contents stored in this object. This
- field is used in optimistic locking.
- returned: success
- type: str
-warnings:
- description:
- - If potential misconfigurations are detected for this SSL policy, this field will
- be populated with warning messages.
- returned: success
- type: complex
- contains:
- code:
- description:
- - A warning code, if applicable.
- returned: success
- type: str
- message:
- description:
- - A human-readable description of the warning code.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- description=dict(type='str'),
- name=dict(required=True, type='str'),
- profile=dict(type='str'),
- min_tls_version=dict(type='str'),
- custom_features=dict(type='list', elements='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#sslPolicy'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.patch(link, resource_to_request(module)))
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#sslPolicy',
- u'description': module.params.get('description'),
- u'name': module.params.get('name'),
- u'profile': module.params.get('profile'),
- u'minTlsVersion': module.params.get('min_tls_version'),
- u'customFeatures': module.params.get('custom_features'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/sslPolicies/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/sslPolicies".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'description': module.params.get('description'),
- u'id': response.get(u'id'),
- u'name': module.params.get('name'),
- u'profile': response.get(u'profile'),
- u'minTlsVersion': response.get(u'minTlsVersion'),
- u'enabledFeatures': response.get(u'enabledFeatures'),
- u'customFeatures': response.get(u'customFeatures'),
- u'fingerprint': response.get(u'fingerprint'),
- u'warnings': SslPolicyWarningsArray(response.get(u'warnings', []), module).from_response(),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/global/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#sslPolicy')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-class SslPolicyWarningsArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_ssl_policy_info.py b/lib/ansible/modules/cloud/google/gcp_compute_ssl_policy_info.py
deleted file mode 100644
index 93eb80f8cf..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_ssl_policy_info.py
+++ /dev/null
@@ -1,262 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_ssl_policy_info
-description:
-- Gather info for GCP SslPolicy
-short_description: Gather info for GCP SslPolicy
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a SSL policy
- gcp_compute_ssl_policy_info:
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
- id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created.
- The name must be 1-63 characters long, and comply with RFC1035. Specifically,
- the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
- profile:
- description:
- - Profile specifies the set of SSL features that can be used by the load balancer
- when negotiating SSL with clients. This can be one of `COMPATIBLE`, `MODERN`,
- `RESTRICTED`, or `CUSTOM`. If using `CUSTOM`, the set of SSL features to enable
- must be specified in the `customFeatures` field.
- returned: success
- type: str
- minTlsVersion:
- description:
- - The minimum version of SSL protocol that can be used by the clients to establish
- a connection with the load balancer. This can be one of `TLS_1_0`, `TLS_1_1`,
- `TLS_1_2`.
- returned: success
- type: str
- enabledFeatures:
- description:
- - The list of features enabled in the SSL policy.
- returned: success
- type: list
- customFeatures:
- description:
- - A list of features enabled when the selected profile is CUSTOM. The method
- returns the set of features that can be specified in this list. This field
- must be empty if the profile is not CUSTOM.
- returned: success
- type: list
- fingerprint:
- description:
- - Fingerprint of this resource. A hash of the contents stored in this object.
- This field is used in optimistic locking.
- returned: success
- type: str
- warnings:
- description:
- - If potential misconfigurations are detected for this SSL policy, this field
- will be populated with warning messages.
- returned: success
- type: complex
- contains:
- code:
- description:
- - A warning code, if applicable.
- returned: success
- type: str
- message:
- description:
- - A human-readable description of the warning code.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/sslPolicies".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_subnetwork.py b/lib/ansible/modules/cloud/google/gcp_compute_subnetwork.py
deleted file mode 100644
index 186ce4cc53..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_subnetwork.py
+++ /dev/null
@@ -1,559 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_subnetwork
-description:
-- A VPC network is a virtual version of the traditional physical networks that exist
- within and between physical data centers. A VPC network provides connectivity for
- your Compute Engine virtual machine (VM) instances, Container Engine containers,
- App Engine Flex services, and other network-related resources.
-- Each GCP project contains one or more VPC networks. Each VPC network is a global
- entity spanning all GCP regions. This global VPC network allows VM instances and
- other resources to communicate with each other via internal, private IP addresses.
-- Each VPC network is subdivided into subnets, and each subnet is contained within
- a single region. You can have more than one subnet in a region for a given VPC network.
- Each subnet has a contiguous private RFC1918 IP space. You create instances, containers,
- and the like in these subnets.
-- When you create an instance, you must create it in a subnet, and the instance draws
- its internal IP address from that subnet.
-- Virtual machine (VM) instances in a VPC network can communicate with instances in
- all other subnets of the same VPC network, regardless of region, using their RFC1918
- private IP addresses. You can isolate portions of the network, even entire subnets,
- using firewall rules.
-short_description: Creates a GCP Subnetwork
-version_added: '2.6'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource. This field can be set only at resource creation time.
- required: false
- type: str
- ip_cidr_range:
- description:
- - The range of internal addresses that are owned by this subnetwork.
- - Provide this property when you create the subnetwork. For example, 10.0.0.0/8
- or 192.168.0.0/16. Ranges must be unique and non-overlapping within a network.
- Only IPv4 is supported.
- required: true
- type: str
- name:
- description:
- - The name of the resource, provided by the client when initially creating the
- resource. The name must be 1-63 characters long, and comply with RFC1035. Specifically,
- the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- required: true
- type: str
- network:
- description:
- - The network this subnet belongs to.
- - Only networks that are in the distributed mode can have subnetworks.
- - 'This field represents a link to a Network resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''selfLink'' and value
- of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
- to a gcp_compute_network task and then set this network field to "{{ name-of-resource
- }}"'
- required: true
- type: dict
- secondary_ip_ranges:
- description:
- - An array of configurations for secondary IP ranges for VM instances contained
- in this subnetwork. The primary IP of such VM must belong to the primary ipCidrRange
- of the subnetwork. The alias IPs may belong to either primary or secondary ranges.
- required: false
- type: list
- version_added: '2.8'
- suboptions:
- range_name:
- description:
- - The name associated with this subnetwork secondary range, used when adding
- an alias IP range to a VM instance. The name must be 1-63 characters long,
- and comply with RFC1035. The name must be unique within the subnetwork.
- required: true
- type: str
- ip_cidr_range:
- description:
- - The range of IP addresses belonging to this subnetwork secondary range.
- Provide this property when you create the subnetwork.
- - Ranges must be unique and non-overlapping with all primary and secondary
- IP ranges within a network. Only IPv4 is supported.
- required: true
- type: str
- private_ip_google_access:
- description:
- - When enabled, VMs in this subnetwork without external IP addresses can access
- Google APIs and services by using Private Google Access.
- required: false
- type: bool
- region:
- description:
- - URL of the GCP region for this subnetwork.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/beta/subnetworks)'
-- 'Private Google Access: U(https://cloud.google.com/vpc/docs/configure-private-google-access)'
-- 'Cloud Networking: U(https://cloud.google.com/vpc/docs/using-vpc)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a network
- gcp_compute_network:
- name: network-subnetwork
- auto_create_subnetworks: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: network
-
-- name: create a subnetwork
- gcp_compute_subnetwork:
- name: ansiblenet
- region: us-west1
- network: "{{ network }}"
- ip_cidr_range: 172.16.0.0/16
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource. This field can be set only at resource creation time.
- returned: success
- type: str
-gatewayAddress:
- description:
- - The gateway address for default routes to reach destination addresses outside
- this subnetwork.
- returned: success
- type: str
-id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
-ipCidrRange:
- description:
- - The range of internal addresses that are owned by this subnetwork.
- - Provide this property when you create the subnetwork. For example, 10.0.0.0/8
- or 192.168.0.0/16. Ranges must be unique and non-overlapping within a network.
- Only IPv4 is supported.
- returned: success
- type: str
-name:
- description:
- - The name of the resource, provided by the client when initially creating the resource.
- The name must be 1-63 characters long, and comply with RFC1035. Specifically,
- the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
-network:
- description:
- - The network this subnet belongs to.
- - Only networks that are in the distributed mode can have subnetworks.
- returned: success
- type: dict
-secondaryIpRanges:
- description:
- - An array of configurations for secondary IP ranges for VM instances contained
- in this subnetwork. The primary IP of such VM must belong to the primary ipCidrRange
- of the subnetwork. The alias IPs may belong to either primary or secondary ranges.
- returned: success
- type: complex
- contains:
- rangeName:
- description:
- - The name associated with this subnetwork secondary range, used when adding
- an alias IP range to a VM instance. The name must be 1-63 characters long,
- and comply with RFC1035. The name must be unique within the subnetwork.
- returned: success
- type: str
- ipCidrRange:
- description:
- - The range of IP addresses belonging to this subnetwork secondary range. Provide
- this property when you create the subnetwork.
- - Ranges must be unique and non-overlapping with all primary and secondary IP
- ranges within a network. Only IPv4 is supported.
- returned: success
- type: str
-privateIpGoogleAccess:
- description:
- - When enabled, VMs in this subnetwork without external IP addresses can access
- Google APIs and services by using Private Google Access.
- returned: success
- type: bool
-region:
- description:
- - URL of the GCP region for this subnetwork.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- description=dict(type='str'),
- ip_cidr_range=dict(required=True, type='str'),
- name=dict(required=True, type='str'),
- network=dict(required=True, type='dict'),
- secondary_ip_ranges=dict(
- type='list', elements='dict', options=dict(range_name=dict(required=True, type='str'), ip_cidr_range=dict(required=True, type='str'))
- ),
- private_ip_google_access=dict(type='bool'),
- region=dict(required=True, type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#subnetwork'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind, fetch)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind, fetch):
- update_fields(module, resource_to_request(module), response_to_hash(module, fetch))
- return fetch_resource(module, self_link(module), kind)
-
-
-def update_fields(module, request, response):
- if response.get('ipCidrRange') != request.get('ipCidrRange'):
- ip_cidr_range_update(module, request, response)
- if response.get('secondaryIpRanges') != request.get('secondaryIpRanges'):
- secondary_ip_ranges_update(module, request, response)
- if response.get('privateIpGoogleAccess') != request.get('privateIpGoogleAccess'):
- private_ip_google_access_update(module, request, response)
-
-
-def ip_cidr_range_update(module, request, response):
- auth = GcpSession(module, 'compute')
- auth.post(
- ''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/regions/{region}/subnetworks/{name}/expandIpCidrRange"]).format(**module.params),
- {u'ipCidrRange': module.params.get('ip_cidr_range')},
- )
-
-
-def secondary_ip_ranges_update(module, request, response):
- auth = GcpSession(module, 'compute')
- auth.patch(
- ''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/regions/{region}/subnetworks/{name}"]).format(**module.params),
- {u'secondaryIpRanges': SubnetworkSecondaryiprangesArray(module.params.get('secondary_ip_ranges', []), module).to_request()},
- )
-
-
-def private_ip_google_access_update(module, request, response):
- auth = GcpSession(module, 'compute')
- auth.post(
- ''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/regions/{region}/subnetworks/{name}/setPrivateIpGoogleAccess"]).format(
- **module.params
- ),
- {u'privateIpGoogleAccess': module.params.get('private_ip_google_access')},
- )
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#subnetwork',
- u'description': module.params.get('description'),
- u'ipCidrRange': module.params.get('ip_cidr_range'),
- u'name': module.params.get('name'),
- u'network': replace_resource_dict(module.params.get(u'network', {}), 'selfLink'),
- u'secondaryIpRanges': SubnetworkSecondaryiprangesArray(module.params.get('secondary_ip_ranges', []), module).to_request(),
- u'privateIpGoogleAccess': module.params.get('private_ip_google_access'),
- u'region': module.params.get('region'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/subnetworks/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/subnetworks".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'description': response.get(u'description'),
- u'gatewayAddress': response.get(u'gatewayAddress'),
- u'id': response.get(u'id'),
- u'ipCidrRange': response.get(u'ipCidrRange'),
- u'name': response.get(u'name'),
- u'network': replace_resource_dict(module.params.get(u'network', {}), 'selfLink'),
- u'secondaryIpRanges': SubnetworkSecondaryiprangesArray(response.get(u'secondaryIpRanges', []), module).from_response(),
- u'privateIpGoogleAccess': response.get(u'privateIpGoogleAccess'),
- u'region': module.params.get('region'),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#subnetwork')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-class SubnetworkSecondaryiprangesArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'rangeName': item.get('range_name'), u'ipCidrRange': item.get('ip_cidr_range')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'rangeName': item.get(u'rangeName'), u'ipCidrRange': item.get(u'ipCidrRange')})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_subnetwork_info.py b/lib/ansible/modules/cloud/google/gcp_compute_subnetwork_info.py
deleted file mode 100644
index e46966ea77..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_subnetwork_info.py
+++ /dev/null
@@ -1,274 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_subnetwork_info
-description:
-- Gather info for GCP Subnetwork
-short_description: Gather info for GCP Subnetwork
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- region:
- description:
- - URL of the GCP region for this subnetwork.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a subnetwork
- gcp_compute_subnetwork_info:
- region: us-west1
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource. This field can be set only at resource creation time.
- returned: success
- type: str
- gatewayAddress:
- description:
- - The gateway address for default routes to reach destination addresses outside
- this subnetwork.
- returned: success
- type: str
- id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
- ipCidrRange:
- description:
- - The range of internal addresses that are owned by this subnetwork.
- - Provide this property when you create the subnetwork. For example, 10.0.0.0/8
- or 192.168.0.0/16. Ranges must be unique and non-overlapping within a network.
- Only IPv4 is supported.
- returned: success
- type: str
- name:
- description:
- - The name of the resource, provided by the client when initially creating the
- resource. The name must be 1-63 characters long, and comply with RFC1035.
- Specifically, the name must be 1-63 characters long and match the regular
- expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must
- be a lowercase letter, and all following characters must be a dash, lowercase
- letter, or digit, except the last character, which cannot be a dash.
- returned: success
- type: str
- network:
- description:
- - The network this subnet belongs to.
- - Only networks that are in the distributed mode can have subnetworks.
- returned: success
- type: dict
- secondaryIpRanges:
- description:
- - An array of configurations for secondary IP ranges for VM instances contained
- in this subnetwork. The primary IP of such VM must belong to the primary ipCidrRange
- of the subnetwork. The alias IPs may belong to either primary or secondary
- ranges.
- returned: success
- type: complex
- contains:
- rangeName:
- description:
- - The name associated with this subnetwork secondary range, used when adding
- an alias IP range to a VM instance. The name must be 1-63 characters long,
- and comply with RFC1035. The name must be unique within the subnetwork.
- returned: success
- type: str
- ipCidrRange:
- description:
- - The range of IP addresses belonging to this subnetwork secondary range.
- Provide this property when you create the subnetwork.
- - Ranges must be unique and non-overlapping with all primary and secondary
- IP ranges within a network. Only IPv4 is supported.
- returned: success
- type: str
- privateIpGoogleAccess:
- description:
- - When enabled, VMs in this subnetwork without external IP addresses can access
- Google APIs and services by using Private Google Access.
- returned: success
- type: bool
- region:
- description:
- - URL of the GCP region for this subnetwork.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str'), region=dict(required=True, type='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/subnetworks".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_target_http_proxy.py b/lib/ansible/modules/cloud/google/gcp_compute_target_http_proxy.py
deleted file mode 100644
index af661b93dd..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_target_http_proxy.py
+++ /dev/null
@@ -1,420 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_target_http_proxy
-description:
-- Represents a TargetHttpProxy resource, which is used by one or more global forwarding
- rule to route incoming HTTP requests to a URL map.
-short_description: Creates a GCP TargetHttpProxy
-version_added: '2.6'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- description:
- description:
- - An optional description of this resource.
- required: false
- type: str
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- required: true
- type: str
- url_map:
- description:
- - A reference to the UrlMap resource that defines the mapping from URL to the
- BackendService.
- - 'This field represents a link to a UrlMap resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''selfLink'' and value
- of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
- to a gcp_compute_url_map task and then set this url_map field to "{{ name-of-resource
- }}"'
- required: true
- type: dict
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/compute/docs/reference/v1/targetHttpProxies)'
-- 'Official Documentation: U(https://cloud.google.com/compute/docs/load-balancing/http/target-proxies)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a instance group
- gcp_compute_instance_group:
- name: instancegroup-targethttpproxy
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: instancegroup
-
-- name: create a HTTP health check
- gcp_compute_http_health_check:
- name: httphealthcheck-targethttpproxy
- healthy_threshold: 10
- port: 8080
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: healthcheck
-
-- name: create a backend service
- gcp_compute_backend_service:
- name: backendservice-targethttpproxy
- backends:
- - group: "{{ instancegroup.selfLink }}"
- health_checks:
- - "{{ healthcheck.selfLink }}"
- enable_cdn: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: backendservice
-
-- name: create a URL map
- gcp_compute_url_map:
- name: urlmap-targethttpproxy
- default_service: "{{ backendservice }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: urlmap
-
-- name: create a target HTTP proxy
- gcp_compute_target_http_proxy:
- name: test_object
- url_map: "{{ urlmap }}"
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
-id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
-name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
-urlMap:
- description:
- - A reference to the UrlMap resource that defines the mapping from URL to the BackendService.
- returned: success
- type: dict
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- description=dict(type='str'),
- name=dict(required=True, type='str'),
- url_map=dict(required=True, type='dict'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#targetHttpProxy'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind, fetch)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind, fetch):
- update_fields(module, resource_to_request(module), response_to_hash(module, fetch))
- return fetch_resource(module, self_link(module), kind)
-
-
-def update_fields(module, request, response):
- if response.get('urlMap') != request.get('urlMap'):
- url_map_update(module, request, response)
-
-
-def url_map_update(module, request, response):
- auth = GcpSession(module, 'compute')
- auth.post(
- ''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/targetHttpProxies/{name}/setUrlMap"]).format(**module.params),
- {u'urlMap': replace_resource_dict(module.params.get(u'url_map', {}), 'selfLink')},
- )
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#targetHttpProxy',
- u'description': module.params.get('description'),
- u'name': module.params.get('name'),
- u'urlMap': replace_resource_dict(module.params.get(u'url_map', {}), 'selfLink'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/targetHttpProxies/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/targetHttpProxies".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'description': response.get(u'description'),
- u'id': response.get(u'id'),
- u'name': response.get(u'name'),
- u'urlMap': response.get(u'urlMap'),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/global/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#targetHttpProxy')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_target_http_proxy_info.py b/lib/ansible/modules/cloud/google/gcp_compute_target_http_proxy_info.py
deleted file mode 100644
index 6d66927eab..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_target_http_proxy_info.py
+++ /dev/null
@@ -1,218 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_target_http_proxy_info
-description:
-- Gather info for GCP TargetHttpProxy
-short_description: Gather info for GCP TargetHttpProxy
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a target HTTP proxy
- gcp_compute_target_http_proxy_info:
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
- id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created.
- The name must be 1-63 characters long, and comply with RFC1035. Specifically,
- the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
- urlMap:
- description:
- - A reference to the UrlMap resource that defines the mapping from URL to the
- BackendService.
- returned: success
- type: dict
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/targetHttpProxies".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_target_https_proxy.py b/lib/ansible/modules/cloud/google/gcp_compute_target_https_proxy.py
deleted file mode 100644
index 514b581711..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_target_https_proxy.py
+++ /dev/null
@@ -1,547 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_target_https_proxy
-description:
-- Represents a TargetHttpsProxy resource, which is used by one or more global forwarding
- rule to route incoming HTTPS requests to a URL map.
-short_description: Creates a GCP TargetHttpsProxy
-version_added: '2.6'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- description:
- description:
- - An optional description of this resource.
- required: false
- type: str
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- required: true
- type: str
- quic_override:
- description:
- - Specifies the QUIC override policy for this resource. This determines whether
- the load balancer will attempt to negotiate QUIC with clients or not. Can specify
- one of NONE, ENABLE, or DISABLE. If NONE is specified, uses the QUIC policy
- with no user overrides, which is equivalent to DISABLE. Not specifying this
- field is equivalent to specifying NONE.
- - 'Some valid choices include: "NONE", "ENABLE", "DISABLE"'
- required: false
- type: str
- version_added: '2.7'
- ssl_certificates:
- description:
- - A list of SslCertificate resources that are used to authenticate connections
- between users and the load balancer. At least one SSL certificate must be specified.
- required: true
- type: list
- ssl_policy:
- description:
- - A reference to the SslPolicy resource that will be associated with the TargetHttpsProxy
- resource. If not set, the TargetHttpsProxy resource will not have any SSL policy
- configured.
- - 'This field represents a link to a SslPolicy resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''selfLink'' and value
- of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
- to a gcp_compute_ssl_policy task and then set this ssl_policy field to "{{ name-of-resource
- }}"'
- required: false
- type: dict
- version_added: '2.8'
- url_map:
- description:
- - A reference to the UrlMap resource that defines the mapping from URL to the
- BackendService.
- - 'This field represents a link to a UrlMap resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''selfLink'' and value
- of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
- to a gcp_compute_url_map task and then set this url_map field to "{{ name-of-resource
- }}"'
- required: true
- type: dict
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/compute/docs/reference/v1/targetHttpsProxies)'
-- 'Official Documentation: U(https://cloud.google.com/compute/docs/load-balancing/http/target-proxies)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a instance group
- gcp_compute_instance_group:
- name: instancegroup-targethttpsproxy
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: instancegroup
-
-- name: create a HTTP health check
- gcp_compute_http_health_check:
- name: httphealthcheck-targethttpsproxy
- healthy_threshold: 10
- port: 8080
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: healthcheck
-
-- name: create a backend service
- gcp_compute_backend_service:
- name: backendservice-targethttpsproxy
- backends:
- - group: "{{ instancegroup.selfLink }}"
- health_checks:
- - "{{ healthcheck.selfLink }}"
- enable_cdn: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: backendservice
-
-- name: create a URL map
- gcp_compute_url_map:
- name: urlmap-targethttpsproxy
- default_service: "{{ backendservice }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: urlmap
-
-- name: create a SSL certificate
- gcp_compute_ssl_certificate:
- name: sslcert-targethttpsproxy
- description: A certificate for testing. Do not use this certificate in production
- certificate: |-
- -----BEGIN CERTIFICATE-----
- MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG
- EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT
- BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm
- b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN
- AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2
- MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP
- BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM
- FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z
- aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH
- KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ
- 4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O
- BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn
- 0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O
- M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ
- zqGNhIPGq2ULqXKK8BY=
- -----END CERTIFICATE-----
- private_key: |-
- -----BEGIN EC PRIVATE KEY-----
- MHcCAQEEIObtRo8tkUqoMjeHhsOh2ouPpXCgBcP+EDxZCB/tws15oAoGCCqGSM49
- AwEHoUQDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ4mzkzTv0dXyB750f
- OGN02HtkpBOZzzvUARTR10JQoSe2/5PIwQ==
- -----END EC PRIVATE KEY-----
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: sslcert
-
-- name: create a target HTTPS proxy
- gcp_compute_target_https_proxy:
- name: test_object
- ssl_certificates:
- - "{{ sslcert }}"
- url_map: "{{ urlmap }}"
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
-id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
-name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
-quicOverride:
- description:
- - Specifies the QUIC override policy for this resource. This determines whether
- the load balancer will attempt to negotiate QUIC with clients or not. Can specify
- one of NONE, ENABLE, or DISABLE. If NONE is specified, uses the QUIC policy with
- no user overrides, which is equivalent to DISABLE. Not specifying this field is
- equivalent to specifying NONE.
- returned: success
- type: str
-sslCertificates:
- description:
- - A list of SslCertificate resources that are used to authenticate connections between
- users and the load balancer. At least one SSL certificate must be specified.
- returned: success
- type: list
-sslPolicy:
- description:
- - A reference to the SslPolicy resource that will be associated with the TargetHttpsProxy
- resource. If not set, the TargetHttpsProxy resource will not have any SSL policy
- configured.
- returned: success
- type: dict
-urlMap:
- description:
- - A reference to the UrlMap resource that defines the mapping from URL to the BackendService.
- returned: success
- type: dict
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- description=dict(type='str'),
- name=dict(required=True, type='str'),
- quic_override=dict(type='str'),
- ssl_certificates=dict(required=True, type='list', elements='dict'),
- ssl_policy=dict(type='dict'),
- url_map=dict(required=True, type='dict'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#targetHttpsProxy'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind, fetch)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind, fetch):
- update_fields(module, resource_to_request(module), response_to_hash(module, fetch))
- return fetch_resource(module, self_link(module), kind)
-
-
-def update_fields(module, request, response):
- if response.get('quicOverride') != request.get('quicOverride'):
- quic_override_update(module, request, response)
- if response.get('sslCertificates') != request.get('sslCertificates'):
- ssl_certificates_update(module, request, response)
- if response.get('sslPolicy') != request.get('sslPolicy'):
- ssl_policy_update(module, request, response)
- if response.get('urlMap') != request.get('urlMap'):
- url_map_update(module, request, response)
-
-
-def quic_override_update(module, request, response):
- auth = GcpSession(module, 'compute')
- auth.post(
- ''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/global/targetHttpsProxies/{name}/setQuicOverride"]).format(**module.params),
- {u'quicOverride': module.params.get('quic_override')},
- )
-
-
-def ssl_certificates_update(module, request, response):
- auth = GcpSession(module, 'compute')
- auth.post(
- ''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/targetHttpsProxies/{name}/setSslCertificates"]).format(**module.params),
- {u'sslCertificates': replace_resource_dict(module.params.get('ssl_certificates', []), 'selfLink')},
- )
-
-
-def ssl_policy_update(module, request, response):
- auth = GcpSession(module, 'compute')
- auth.post(
- ''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/global/targetHttpsProxies/{name}/setSslPolicy"]).format(**module.params),
- {u'sslPolicy': replace_resource_dict(module.params.get(u'ssl_policy', {}), 'selfLink')},
- )
-
-
-def url_map_update(module, request, response):
- auth = GcpSession(module, 'compute')
- auth.post(
- ''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/targetHttpsProxies/{name}/setUrlMap"]).format(**module.params),
- {u'urlMap': replace_resource_dict(module.params.get(u'url_map', {}), 'selfLink')},
- )
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#targetHttpsProxy',
- u'description': module.params.get('description'),
- u'name': module.params.get('name'),
- u'quicOverride': module.params.get('quic_override'),
- u'sslCertificates': replace_resource_dict(module.params.get('ssl_certificates', []), 'selfLink'),
- u'sslPolicy': replace_resource_dict(module.params.get(u'ssl_policy', {}), 'selfLink'),
- u'urlMap': replace_resource_dict(module.params.get(u'url_map', {}), 'selfLink'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/targetHttpsProxies/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/targetHttpsProxies".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'description': module.params.get('description'),
- u'id': response.get(u'id'),
- u'name': module.params.get('name'),
- u'quicOverride': response.get(u'quicOverride'),
- u'sslCertificates': response.get(u'sslCertificates'),
- u'sslPolicy': response.get(u'sslPolicy'),
- u'urlMap': response.get(u'urlMap'),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/global/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#targetHttpsProxy')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_target_https_proxy_info.py b/lib/ansible/modules/cloud/google/gcp_compute_target_https_proxy_info.py
deleted file mode 100644
index 7e93eb6431..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_target_https_proxy_info.py
+++ /dev/null
@@ -1,241 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_target_https_proxy_info
-description:
-- Gather info for GCP TargetHttpsProxy
-short_description: Gather info for GCP TargetHttpsProxy
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a target HTTPS proxy
- gcp_compute_target_https_proxy_info:
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
- id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created.
- The name must be 1-63 characters long, and comply with RFC1035. Specifically,
- the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
- quicOverride:
- description:
- - Specifies the QUIC override policy for this resource. This determines whether
- the load balancer will attempt to negotiate QUIC with clients or not. Can
- specify one of NONE, ENABLE, or DISABLE. If NONE is specified, uses the QUIC
- policy with no user overrides, which is equivalent to DISABLE. Not specifying
- this field is equivalent to specifying NONE.
- returned: success
- type: str
- sslCertificates:
- description:
- - A list of SslCertificate resources that are used to authenticate connections
- between users and the load balancer. At least one SSL certificate must be
- specified.
- returned: success
- type: list
- sslPolicy:
- description:
- - A reference to the SslPolicy resource that will be associated with the TargetHttpsProxy
- resource. If not set, the TargetHttpsProxy resource will not have any SSL
- policy configured.
- returned: success
- type: dict
- urlMap:
- description:
- - A reference to the UrlMap resource that defines the mapping from URL to the
- BackendService.
- returned: success
- type: dict
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/targetHttpsProxies".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_target_instance.py b/lib/ansible/modules/cloud/google/gcp_compute_target_instance.py
deleted file mode 100644
index 3ab28e5f96..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_target_instance.py
+++ /dev/null
@@ -1,419 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_target_instance
-description:
-- Represents a TargetInstance resource which defines an endpoint instance that terminates
- traffic of certain protocols. In particular, they are used in Protocol Forwarding,
- where forwarding rules can send packets to a non-NAT'ed target instance. Each target
- instance contains a single virtual machine instance that receives and handles traffic
- from the corresponding forwarding rules.
-short_description: Creates a GCP TargetInstance
-version_added: '2.10'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- required: true
- type: str
- description:
- description:
- - An optional description of this resource.
- required: false
- type: str
- instance:
- description:
- - A URL to the virtual machine instance that handles traffic for this target instance.
- Accepts self-links or the partial paths with format `projects/project/zones/zone/instances/instance'
- or `zones/zone/instances/instance` .
- - 'This field represents a link to a Instance resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''selfLink'' and value
- of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
- to a gcp_compute_instance task and then set this instance field to "{{ name-of-resource
- }}"'
- required: true
- type: dict
- nat_policy:
- description:
- - NAT option controlling how IPs are NAT'ed to the instance.
- - Currently only NO_NAT (default value) is supported.
- - 'Some valid choices include: "NO_NAT"'
- required: false
- default: NO_NAT
- type: str
- zone:
- description:
- - URL of the zone where the target instance resides.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/compute/docs/reference/v1/targetInstances)'
-- 'Using Protocol Forwarding: U(https://cloud.google.com/compute/docs/protocol-forwarding)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a network
- gcp_compute_network:
- name: network-instance
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: network
-
-- name: create a instance
- gcp_compute_instance:
- name: "{{ resource_name }}"
- machine_type: n1-standard-1
- disks:
- - auto_delete: 'true'
- boot: 'true'
- initialize_params:
- source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
- labels:
- environment: production
- network_interfaces:
- - network: "{{ network }}"
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: instance
-
-- name: create a target instance
- gcp_compute_target_instance:
- name: target
- instance: "{{ instance }}"
- zone: us-central1-a
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
-instance:
- description:
- - A URL to the virtual machine instance that handles traffic for this target instance.
- Accepts self-links or the partial paths with format `projects/project/zones/zone/instances/instance'
- or `zones/zone/instances/instance` .
- returned: success
- type: dict
-natPolicy:
- description:
- - NAT option controlling how IPs are NAT'ed to the instance.
- - Currently only NO_NAT (default value) is supported.
- returned: success
- type: str
-zone:
- description:
- - URL of the zone where the target instance resides.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- name=dict(required=True, type='str'),
- description=dict(type='str'),
- instance=dict(required=True, type='dict'),
- nat_policy=dict(default='NO_NAT', type='str'),
- zone=dict(required=True, type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#targetInstance'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind):
- delete(module, self_link(module), kind)
- create(module, collection(module), kind)
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#targetInstance',
- u'zone': module.params.get('zone'),
- u'name': module.params.get('name'),
- u'description': module.params.get('description'),
- u'instance': replace_resource_dict(module.params.get(u'instance', {}), 'selfLink'),
- u'natPolicy': module.params.get('nat_policy'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/targetInstances/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/targetInstances".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'name': response.get(u'name'),
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'description': response.get(u'description'),
- u'instance': replace_resource_dict(module.params.get(u'instance', {}), 'selfLink'),
- u'natPolicy': module.params.get('nat_policy'),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#targetInstance')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_target_instance_info.py b/lib/ansible/modules/cloud/google/gcp_compute_target_instance_info.py
deleted file mode 100644
index 5ceb6d66ef..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_target_instance_info.py
+++ /dev/null
@@ -1,231 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_target_instance_info
-description:
-- Gather info for GCP TargetInstance
-short_description: Gather info for GCP TargetInstance
-version_added: '2.10'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- zone:
- description:
- - URL of the zone where the target instance resides.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a target instance
- gcp_compute_target_instance_info:
- zone: us-central1-a
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created.
- The name must be 1-63 characters long, and comply with RFC1035. Specifically,
- the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
- instance:
- description:
- - A URL to the virtual machine instance that handles traffic for this target
- instance. Accepts self-links or the partial paths with format `projects/project/zones/zone/instances/instance'
- or `zones/zone/instances/instance` .
- returned: success
- type: dict
- natPolicy:
- description:
- - NAT option controlling how IPs are NAT'ed to the instance.
- - Currently only NO_NAT (default value) is supported.
- returned: success
- type: str
- zone:
- description:
- - URL of the zone where the target instance resides.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str'), zone=dict(required=True, type='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/zones/{zone}/targetInstances".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_target_pool.py b/lib/ansible/modules/cloud/google/gcp_compute_target_pool.py
deleted file mode 100644
index 329b6db536..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_target_pool.py
+++ /dev/null
@@ -1,521 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_target_pool
-description:
-- Represents a TargetPool resource, used for Load Balancing.
-short_description: Creates a GCP TargetPool
-version_added: '2.6'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- backup_pool:
- description:
- - This field is applicable only when the containing target pool is serving a forwarding
- rule as the primary pool, and its failoverRatio field is properly set to a value
- between [0, 1].
- - 'backupPool and failoverRatio together define the fallback behavior of the primary
- target pool: if the ratio of the healthy instances in the primary pool is at
- or below failoverRatio, traffic arriving at the load-balanced IP will be directed
- to the backup pool.'
- - In case where failoverRatio and backupPool are not set, or all the instances
- in the backup pool are unhealthy, the traffic will be directed back to the primary
- pool in the "force" mode, where traffic will be spread to the healthy instances
- with the best effort, or to all instances when no instance is healthy.
- - 'This field represents a link to a TargetPool resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''selfLink'' and value
- of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
- to a gcp_compute_target_pool task and then set this backup_pool field to "{{
- name-of-resource }}"'
- required: false
- type: dict
- description:
- description:
- - An optional description of this resource.
- required: false
- type: str
- failover_ratio:
- description:
- - This field is applicable only when the containing target pool is serving a forwarding
- rule as the primary pool (i.e., not as a backup pool to some other target pool).
- The value of the field must be in [0, 1].
- - 'If set, backupPool must also be set. They together define the fallback behavior
- of the primary target pool: if the ratio of the healthy instances in the primary
- pool is at or below this number, traffic arriving at the load-balanced IP will
- be directed to the backup pool.'
- - In case where failoverRatio is not set or all the instances in the backup pool
- are unhealthy, the traffic will be directed back to the primary pool in the
- "force" mode, where traffic will be spread to the healthy instances with the
- best effort, or to all instances when no instance is healthy.
- required: false
- type: str
- health_check:
- description:
- - A reference to a HttpHealthCheck resource.
- - A member instance in this pool is considered healthy if and only if the health
- checks pass. If not specified it means all member instances will be considered
- healthy at all times.
- - 'This field represents a link to a HttpHealthCheck resource in GCP. It can be
- specified in two ways. First, you can place a dictionary with key ''selfLink''
- and value of your resource''s selfLink Alternatively, you can add `register:
- name-of-resource` to a gcp_compute_http_health_check task and then set this
- health_check field to "{{ name-of-resource }}"'
- required: false
- type: dict
- instances:
- description:
- - A list of virtual machine instances serving this pool.
- - They must live in zones contained in the same region as this pool.
- required: false
- type: list
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- required: true
- type: str
- session_affinity:
- description:
- - 'Session affinity option. Must be one of these values: - NONE: Connections from
- the same client IP may go to any instance in the pool.'
- - "- CLIENT_IP: Connections from the same client IP will go to the same instance
- in the pool while that instance remains healthy."
- - "- CLIENT_IP_PROTO: Connections from the same client IP with the same IP protocol
- will go to the same instance in the pool while that instance remains healthy."
- - 'Some valid choices include: "NONE", "CLIENT_IP", "CLIENT_IP_PROTO"'
- required: false
- type: str
- region:
- description:
- - The region where the target pool resides.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/v1/targetPools)'
-- 'Official Documentation: U(https://cloud.google.com/compute/docs/load-balancing/network/target-pools)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a target pool
- gcp_compute_target_pool:
- name: test_object
- region: us-west1
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-backupPool:
- description:
- - This field is applicable only when the containing target pool is serving a forwarding
- rule as the primary pool, and its failoverRatio field is properly set to a value
- between [0, 1].
- - 'backupPool and failoverRatio together define the fallback behavior of the primary
- target pool: if the ratio of the healthy instances in the primary pool is at or
- below failoverRatio, traffic arriving at the load-balanced IP will be directed
- to the backup pool.'
- - In case where failoverRatio and backupPool are not set, or all the instances in
- the backup pool are unhealthy, the traffic will be directed back to the primary
- pool in the "force" mode, where traffic will be spread to the healthy instances
- with the best effort, or to all instances when no instance is healthy.
- returned: success
- type: dict
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
-failoverRatio:
- description:
- - This field is applicable only when the containing target pool is serving a forwarding
- rule as the primary pool (i.e., not as a backup pool to some other target pool).
- The value of the field must be in [0, 1].
- - 'If set, backupPool must also be set. They together define the fallback behavior
- of the primary target pool: if the ratio of the healthy instances in the primary
- pool is at or below this number, traffic arriving at the load-balanced IP will
- be directed to the backup pool.'
- - In case where failoverRatio is not set or all the instances in the backup pool
- are unhealthy, the traffic will be directed back to the primary pool in the "force"
- mode, where traffic will be spread to the healthy instances with the best effort,
- or to all instances when no instance is healthy.
- returned: success
- type: str
-healthCheck:
- description:
- - A reference to a HttpHealthCheck resource.
- - A member instance in this pool is considered healthy if and only if the health
- checks pass. If not specified it means all member instances will be considered
- healthy at all times.
- returned: success
- type: dict
-id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
-instances:
- description:
- - A list of virtual machine instances serving this pool.
- - They must live in zones contained in the same region as this pool.
- returned: success
- type: list
-name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
-sessionAffinity:
- description:
- - 'Session affinity option. Must be one of these values: - NONE: Connections from
- the same client IP may go to any instance in the pool.'
- - "- CLIENT_IP: Connections from the same client IP will go to the same instance
- in the pool while that instance remains healthy."
- - "- CLIENT_IP_PROTO: Connections from the same client IP with the same IP protocol
- will go to the same instance in the pool while that instance remains healthy."
- returned: success
- type: str
-region:
- description:
- - The region where the target pool resides.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- backup_pool=dict(type='dict'),
- description=dict(type='str'),
- failover_ratio=dict(type='str'),
- health_check=dict(type='dict'),
- instances=dict(type='list', elements='dict'),
- name=dict(required=True, type='str'),
- session_affinity=dict(type='str'),
- region=dict(required=True, type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#targetPool'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.put(link, resource_to_request(module)))
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#targetPool',
- u'backupPool': replace_resource_dict(module.params.get(u'backup_pool', {}), 'selfLink'),
- u'description': module.params.get('description'),
- u'failoverRatio': module.params.get('failover_ratio'),
- u'healthCheck': replace_resource_dict(module.params.get(u'health_check', {}), 'selfLink'),
- u'instances': replace_resource_dict(module.params.get('instances', []), 'selfLink'),
- u'name': module.params.get('name'),
- u'sessionAffinity': module.params.get('session_affinity'),
- }
- request = encode_request(request, module)
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/targetPools/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/targetPools".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- result = decode_response(result, module)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
- request = decode_response(request, module)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'backupPool': replace_resource_dict(module.params.get(u'backup_pool', {}), 'selfLink'),
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'description': response.get(u'description'),
- u'failoverRatio': response.get(u'failoverRatio'),
- u'healthCheck': response.get(u'healthCheck'),
- u'id': response.get(u'id'),
- u'instances': response.get(u'instances'),
- u'name': module.params.get('name'),
- u'sessionAffinity': module.params.get('session_affinity'),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- response = fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#targetPool')
- if response:
- return decode_response(response, module)
- else:
- return {}
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-# Mask the fact healthChecks array is actually a single object of type
-# HttpHealthCheck.
-#
-# Google Compute Engine API defines healthChecks as a list but it can only
-# take [0, 1] elements. To make it simpler to declare we'll map that to a
-# single object and encode/decode as appropriate.
-def encode_request(request, module):
- if 'healthCheck' in request:
- request['healthChecks'] = [request['healthCheck']]
- del request['healthCheck']
- return request
-
-
-# Mask healthChecks into a single element.
-# @see encode_request for details
-def decode_response(response, module):
- if response['kind'] != 'compute#targetPool':
- return response
-
- # Map healthChecks[0] => healthCheck
- if 'healthChecks' in response:
- if not response['healthChecks']:
- response['healthCheck'] = response['healthChecks'][0]
- del response['healthChecks']
-
- return response
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_target_pool_info.py b/lib/ansible/modules/cloud/google/gcp_compute_target_pool_info.py
deleted file mode 100644
index a89ce1bfe2..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_target_pool_info.py
+++ /dev/null
@@ -1,277 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_target_pool_info
-description:
-- Gather info for GCP TargetPool
-short_description: Gather info for GCP TargetPool
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- region:
- description:
- - The region where the target pool resides.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a target pool
- gcp_compute_target_pool_info:
- region: us-west1
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- backupPool:
- description:
- - This field is applicable only when the containing target pool is serving a
- forwarding rule as the primary pool, and its failoverRatio field is properly
- set to a value between [0, 1].
- - 'backupPool and failoverRatio together define the fallback behavior of the
- primary target pool: if the ratio of the healthy instances in the primary
- pool is at or below failoverRatio, traffic arriving at the load-balanced IP
- will be directed to the backup pool.'
- - In case where failoverRatio and backupPool are not set, or all the instances
- in the backup pool are unhealthy, the traffic will be directed back to the
- primary pool in the "force" mode, where traffic will be spread to the healthy
- instances with the best effort, or to all instances when no instance is healthy.
- returned: success
- type: dict
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
- failoverRatio:
- description:
- - This field is applicable only when the containing target pool is serving a
- forwarding rule as the primary pool (i.e., not as a backup pool to some other
- target pool). The value of the field must be in [0, 1].
- - 'If set, backupPool must also be set. They together define the fallback behavior
- of the primary target pool: if the ratio of the healthy instances in the primary
- pool is at or below this number, traffic arriving at the load-balanced IP
- will be directed to the backup pool.'
- - In case where failoverRatio is not set or all the instances in the backup
- pool are unhealthy, the traffic will be directed back to the primary pool
- in the "force" mode, where traffic will be spread to the healthy instances
- with the best effort, or to all instances when no instance is healthy.
- returned: success
- type: str
- healthCheck:
- description:
- - A reference to a HttpHealthCheck resource.
- - A member instance in this pool is considered healthy if and only if the health
- checks pass. If not specified it means all member instances will be considered
- healthy at all times.
- returned: success
- type: dict
- id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
- instances:
- description:
- - A list of virtual machine instances serving this pool.
- - They must live in zones contained in the same region as this pool.
- returned: success
- type: list
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created.
- The name must be 1-63 characters long, and comply with RFC1035. Specifically,
- the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
- sessionAffinity:
- description:
- - 'Session affinity option. Must be one of these values: - NONE: Connections
- from the same client IP may go to any instance in the pool.'
- - "- CLIENT_IP: Connections from the same client IP will go to the same instance
- in the pool while that instance remains healthy."
- - "- CLIENT_IP_PROTO: Connections from the same client IP with the same IP protocol
- will go to the same instance in the pool while that instance remains healthy."
- returned: success
- type: str
- region:
- description:
- - The region where the target pool resides.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str'), region=dict(required=True, type='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/targetPools".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_target_ssl_proxy.py b/lib/ansible/modules/cloud/google/gcp_compute_target_ssl_proxy.py
deleted file mode 100644
index 9e8e6bbbcd..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_target_ssl_proxy.py
+++ /dev/null
@@ -1,534 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_target_ssl_proxy
-description:
-- Represents a TargetSslProxy resource, which is used by one or more global forwarding
- rule to route incoming SSL requests to a backend service.
-short_description: Creates a GCP TargetSslProxy
-version_added: '2.6'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- description:
- description:
- - An optional description of this resource.
- required: false
- type: str
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- required: true
- type: str
- proxy_header:
- description:
- - Specifies the type of proxy header to append before sending data to the backend,
- either NONE or PROXY_V1. The default is NONE.
- - 'Some valid choices include: "NONE", "PROXY_V1"'
- required: false
- type: str
- service:
- description:
- - A reference to the BackendService resource.
- - 'This field represents a link to a BackendService resource in GCP. It can be
- specified in two ways. First, you can place a dictionary with key ''selfLink''
- and value of your resource''s selfLink Alternatively, you can add `register:
- name-of-resource` to a gcp_compute_backend_service task and then set this service
- field to "{{ name-of-resource }}"'
- required: true
- type: dict
- ssl_certificates:
- description:
- - A list of SslCertificate resources that are used to authenticate connections
- between users and the load balancer. Currently, exactly one SSL certificate
- must be specified.
- required: true
- type: list
- ssl_policy:
- description:
- - A reference to the SslPolicy resource that will be associated with the TargetSslProxy
- resource. If not set, the TargetSslProxy resource will not have any SSL policy
- configured.
- - 'This field represents a link to a SslPolicy resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''selfLink'' and value
- of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
- to a gcp_compute_ssl_policy task and then set this ssl_policy field to "{{ name-of-resource
- }}"'
- required: false
- type: dict
- version_added: '2.8'
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/compute/docs/reference/v1/targetSslProxies)'
-- 'Setting Up SSL proxy for Google Cloud Load Balancing: U(https://cloud.google.com/compute/docs/load-balancing/tcp-ssl/)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a instance group
- gcp_compute_instance_group:
- name: instancegroup-targetsslproxy
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: instancegroup
-
-- name: create a health check
- gcp_compute_health_check:
- name: healthcheck-targetsslproxy
- type: TCP
- tcp_health_check:
- port_name: service-health
- request: ping
- response: pong
- healthy_threshold: 10
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: healthcheck
-
-- name: create a backend service
- gcp_compute_backend_service:
- name: backendservice-targetsslproxy
- backends:
- - group: "{{ instancegroup.selfLink }}"
- health_checks:
- - "{{ healthcheck.selfLink }}"
- protocol: SSL
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: backendservice
-
-- name: create a SSL certificate
- gcp_compute_ssl_certificate:
- name: sslcert-targetsslproxy
- description: A certificate for testing. Do not use this certificate in production
- certificate: |-
- -----BEGIN CERTIFICATE-----
- MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG
- EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT
- BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm
- b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN
- AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2
- MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP
- BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM
- FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z
- aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH
- KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ
- 4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O
- BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn
- 0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O
- M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ
- zqGNhIPGq2ULqXKK8BY=
- -----END CERTIFICATE-----
- private_key: |-
- -----BEGIN EC PRIVATE KEY-----
- MHcCAQEEIObtRo8tkUqoMjeHhsOh2ouPpXCgBcP+EDxZCB/tws15oAoGCCqGSM49
- AwEHoUQDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ4mzkzTv0dXyB750f
- OGN02HtkpBOZzzvUARTR10JQoSe2/5PIwQ==
- -----END EC PRIVATE KEY-----
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: sslcert
-
-- name: create a target SSL proxy
- gcp_compute_target_ssl_proxy:
- name: test_object
- ssl_certificates:
- - "{{ sslcert }}"
- service: "{{ backendservice }}"
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
-id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
-name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
-proxyHeader:
- description:
- - Specifies the type of proxy header to append before sending data to the backend,
- either NONE or PROXY_V1. The default is NONE.
- returned: success
- type: str
-service:
- description:
- - A reference to the BackendService resource.
- returned: success
- type: dict
-sslCertificates:
- description:
- - A list of SslCertificate resources that are used to authenticate connections between
- users and the load balancer. Currently, exactly one SSL certificate must be specified.
- returned: success
- type: list
-sslPolicy:
- description:
- - A reference to the SslPolicy resource that will be associated with the TargetSslProxy
- resource. If not set, the TargetSslProxy resource will not have any SSL policy
- configured.
- returned: success
- type: dict
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- description=dict(type='str'),
- name=dict(required=True, type='str'),
- proxy_header=dict(type='str'),
- service=dict(required=True, type='dict'),
- ssl_certificates=dict(required=True, type='list', elements='dict'),
- ssl_policy=dict(type='dict'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#targetSslProxy'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind, fetch)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind, fetch):
- update_fields(module, resource_to_request(module), response_to_hash(module, fetch))
- return fetch_resource(module, self_link(module), kind)
-
-
-def update_fields(module, request, response):
- if response.get('proxyHeader') != request.get('proxyHeader'):
- proxy_header_update(module, request, response)
- if response.get('service') != request.get('service'):
- service_update(module, request, response)
- if response.get('sslCertificates') != request.get('sslCertificates'):
- ssl_certificates_update(module, request, response)
- if response.get('sslPolicy') != request.get('sslPolicy'):
- ssl_policy_update(module, request, response)
-
-
-def proxy_header_update(module, request, response):
- auth = GcpSession(module, 'compute')
- auth.post(
- ''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/global/targetSslProxies/{name}/setProxyHeader"]).format(**module.params),
- {u'proxyHeader': module.params.get('proxy_header')},
- )
-
-
-def service_update(module, request, response):
- auth = GcpSession(module, 'compute')
- auth.post(
- ''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/global/targetSslProxies/{name}/setBackendService"]).format(**module.params),
- {u'service': replace_resource_dict(module.params.get(u'service', {}), 'selfLink')},
- )
-
-
-def ssl_certificates_update(module, request, response):
- auth = GcpSession(module, 'compute')
- auth.post(
- ''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/global/targetSslProxies/{name}/setSslCertificates"]).format(**module.params),
- {u'sslCertificates': replace_resource_dict(module.params.get('ssl_certificates', []), 'selfLink')},
- )
-
-
-def ssl_policy_update(module, request, response):
- auth = GcpSession(module, 'compute')
- auth.post(
- ''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/global/targetSslProxies/{name}/setSslPolicy"]).format(**module.params),
- {u'sslPolicy': replace_resource_dict(module.params.get(u'ssl_policy', {}), 'selfLink')},
- )
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#targetSslProxy',
- u'description': module.params.get('description'),
- u'name': module.params.get('name'),
- u'proxyHeader': module.params.get('proxy_header'),
- u'service': replace_resource_dict(module.params.get(u'service', {}), 'selfLink'),
- u'sslCertificates': replace_resource_dict(module.params.get('ssl_certificates', []), 'selfLink'),
- u'sslPolicy': replace_resource_dict(module.params.get(u'ssl_policy', {}), 'selfLink'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/targetSslProxies/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/targetSslProxies".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'description': module.params.get('description'),
- u'id': response.get(u'id'),
- u'name': module.params.get('name'),
- u'proxyHeader': response.get(u'proxyHeader'),
- u'service': response.get(u'service'),
- u'sslCertificates': response.get(u'sslCertificates'),
- u'sslPolicy': response.get(u'sslPolicy'),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/global/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#targetSslProxy')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_target_ssl_proxy_info.py b/lib/ansible/modules/cloud/google/gcp_compute_target_ssl_proxy_info.py
deleted file mode 100644
index 38bac5100d..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_target_ssl_proxy_info.py
+++ /dev/null
@@ -1,237 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_target_ssl_proxy_info
-description:
-- Gather info for GCP TargetSslProxy
-short_description: Gather info for GCP TargetSslProxy
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a target SSL proxy
- gcp_compute_target_ssl_proxy_info:
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
- id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created.
- The name must be 1-63 characters long, and comply with RFC1035. Specifically,
- the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
- proxyHeader:
- description:
- - Specifies the type of proxy header to append before sending data to the backend,
- either NONE or PROXY_V1. The default is NONE.
- returned: success
- type: str
- service:
- description:
- - A reference to the BackendService resource.
- returned: success
- type: dict
- sslCertificates:
- description:
- - A list of SslCertificate resources that are used to authenticate connections
- between users and the load balancer. Currently, exactly one SSL certificate
- must be specified.
- returned: success
- type: list
- sslPolicy:
- description:
- - A reference to the SslPolicy resource that will be associated with the TargetSslProxy
- resource. If not set, the TargetSslProxy resource will not have any SSL policy
- configured.
- returned: success
- type: dict
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/targetSslProxies".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_target_tcp_proxy.py b/lib/ansible/modules/cloud/google/gcp_compute_target_tcp_proxy.py
deleted file mode 100644
index ee801df44d..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_target_tcp_proxy.py
+++ /dev/null
@@ -1,440 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_target_tcp_proxy
-description:
-- Represents a TargetTcpProxy resource, which is used by one or more global forwarding
- rule to route incoming TCP requests to a Backend service.
-short_description: Creates a GCP TargetTcpProxy
-version_added: '2.6'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- description:
- description:
- - An optional description of this resource.
- required: false
- type: str
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- required: true
- type: str
- proxy_header:
- description:
- - Specifies the type of proxy header to append before sending data to the backend,
- either NONE or PROXY_V1. The default is NONE.
- - 'Some valid choices include: "NONE", "PROXY_V1"'
- required: false
- type: str
- service:
- description:
- - A reference to the BackendService resource.
- - 'This field represents a link to a BackendService resource in GCP. It can be
- specified in two ways. First, you can place a dictionary with key ''selfLink''
- and value of your resource''s selfLink Alternatively, you can add `register:
- name-of-resource` to a gcp_compute_backend_service task and then set this service
- field to "{{ name-of-resource }}"'
- required: true
- type: dict
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/compute/docs/reference/v1/targetTcpProxies)'
-- 'Setting Up TCP proxy for Google Cloud Load Balancing: U(https://cloud.google.com/compute/docs/load-balancing/tcp-ssl/tcp-proxy)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a instance group
- gcp_compute_instance_group:
- name: instancegroup-targettcpproxy
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: instancegroup
-
-- name: create a health check
- gcp_compute_health_check:
- name: healthcheck-targettcpproxy
- type: TCP
- tcp_health_check:
- port_name: service-health
- request: ping
- response: pong
- healthy_threshold: 10
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: healthcheck
-
-- name: create a backend service
- gcp_compute_backend_service:
- name: backendservice-targettcpproxy
- backends:
- - group: "{{ instancegroup.selfLink }}"
- health_checks:
- - "{{ healthcheck.selfLink }}"
- protocol: TCP
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: backendservice
-
-- name: create a target TCP proxy
- gcp_compute_target_tcp_proxy:
- name: test_object
- proxy_header: PROXY_V1
- service: "{{ backendservice }}"
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
-id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
-name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
-proxyHeader:
- description:
- - Specifies the type of proxy header to append before sending data to the backend,
- either NONE or PROXY_V1. The default is NONE.
- returned: success
- type: str
-service:
- description:
- - A reference to the BackendService resource.
- returned: success
- type: dict
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- description=dict(type='str'),
- name=dict(required=True, type='str'),
- proxy_header=dict(type='str'),
- service=dict(required=True, type='dict'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#targetTcpProxy'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind, fetch)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind, fetch):
- update_fields(module, resource_to_request(module), response_to_hash(module, fetch))
- return fetch_resource(module, self_link(module), kind)
-
-
-def update_fields(module, request, response):
- if response.get('proxyHeader') != request.get('proxyHeader'):
- proxy_header_update(module, request, response)
- if response.get('service') != request.get('service'):
- service_update(module, request, response)
-
-
-def proxy_header_update(module, request, response):
- auth = GcpSession(module, 'compute')
- auth.post(
- ''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/global/targetTcpProxies/{name}/setProxyHeader"]).format(**module.params),
- {u'proxyHeader': module.params.get('proxy_header')},
- )
-
-
-def service_update(module, request, response):
- auth = GcpSession(module, 'compute')
- auth.post(
- ''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/global/targetTcpProxies/{name}/setBackendService"]).format(**module.params),
- {u'service': replace_resource_dict(module.params.get(u'service', {}), 'selfLink')},
- )
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#targetTcpProxy',
- u'description': module.params.get('description'),
- u'name': module.params.get('name'),
- u'proxyHeader': module.params.get('proxy_header'),
- u'service': replace_resource_dict(module.params.get(u'service', {}), 'selfLink'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/targetTcpProxies/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/targetTcpProxies".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'description': module.params.get('description'),
- u'id': response.get(u'id'),
- u'name': module.params.get('name'),
- u'proxyHeader': response.get(u'proxyHeader'),
- u'service': response.get(u'service'),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/global/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#targetTcpProxy')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_target_tcp_proxy_info.py b/lib/ansible/modules/cloud/google/gcp_compute_target_tcp_proxy_info.py
deleted file mode 100644
index fcb8f770d3..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_target_tcp_proxy_info.py
+++ /dev/null
@@ -1,223 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_target_tcp_proxy_info
-description:
-- Gather info for GCP TargetTcpProxy
-short_description: Gather info for GCP TargetTcpProxy
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a target TCP proxy
- gcp_compute_target_tcp_proxy_info:
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
- id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created.
- The name must be 1-63 characters long, and comply with RFC1035. Specifically,
- the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
- proxyHeader:
- description:
- - Specifies the type of proxy header to append before sending data to the backend,
- either NONE or PROXY_V1. The default is NONE.
- returned: success
- type: str
- service:
- description:
- - A reference to the BackendService resource.
- returned: success
- type: dict
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/targetTcpProxies".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_target_vpn_gateway.py b/lib/ansible/modules/cloud/google/gcp_compute_target_vpn_gateway.py
deleted file mode 100644
index e52014d932..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_target_vpn_gateway.py
+++ /dev/null
@@ -1,402 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_target_vpn_gateway
-description:
-- Represents a VPN gateway running in GCP. This virtual device is managed by Google,
- but used only by you.
-short_description: Creates a GCP TargetVpnGateway
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- description:
- description:
- - An optional description of this resource.
- required: false
- type: str
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- required: true
- type: str
- network:
- description:
- - The network this VPN gateway is accepting traffic for.
- - 'This field represents a link to a Network resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''selfLink'' and value
- of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
- to a gcp_compute_network task and then set this network field to "{{ name-of-resource
- }}"'
- required: true
- type: dict
- region:
- description:
- - The region this gateway should sit in.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/v1/targetVpnGateways)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a address
- gcp_compute_address:
- name: address-vpngateway
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: address
-
-- name: create a network
- gcp_compute_network:
- name: network-vpngateway
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: network
-
-- name: create a target vpn gateway
- gcp_compute_target_vpn_gateway:
- name: test_object
- region: us-west1
- network: "{{ network }}"
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
-name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
-id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
-network:
- description:
- - The network this VPN gateway is accepting traffic for.
- returned: success
- type: dict
-tunnels:
- description:
- - A list of references to VpnTunnel resources associated with this VPN gateway.
- returned: success
- type: list
-forwardingRules:
- description:
- - A list of references to the ForwardingRule resources associated with this VPN
- gateway.
- returned: success
- type: list
-region:
- description:
- - The region this gateway should sit in.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- description=dict(type='str'),
- name=dict(required=True, type='str'),
- network=dict(required=True, type='dict'),
- region=dict(required=True, type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#targetVpnGateway'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind):
- delete(module, self_link(module), kind)
- create(module, collection(module), kind)
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#targetVpnGateway',
- u'description': module.params.get('description'),
- u'name': module.params.get('name'),
- u'network': replace_resource_dict(module.params.get(u'network', {}), 'selfLink'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/targetVpnGateways/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/targetVpnGateways".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'description': module.params.get('description'),
- u'name': module.params.get('name'),
- u'id': response.get(u'id'),
- u'network': replace_resource_dict(module.params.get(u'network', {}), 'selfLink'),
- u'tunnels': response.get(u'tunnels'),
- u'forwardingRules': response.get(u'forwardingRules'),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#targetVpnGateway')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_target_vpn_gateway_info.py b/lib/ansible/modules/cloud/google/gcp_compute_target_vpn_gateway_info.py
deleted file mode 100644
index 2de42dcf37..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_target_vpn_gateway_info.py
+++ /dev/null
@@ -1,239 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_target_vpn_gateway_info
-description:
-- Gather info for GCP TargetVpnGateway
-short_description: Gather info for GCP TargetVpnGateway
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- region:
- description:
- - The region this gateway should sit in.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a target vpn gateway
- gcp_compute_target_vpn_gateway_info:
- region: us-west1
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created.
- The name must be 1-63 characters long, and comply with RFC1035. Specifically,
- the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
- id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
- network:
- description:
- - The network this VPN gateway is accepting traffic for.
- returned: success
- type: dict
- tunnels:
- description:
- - A list of references to VpnTunnel resources associated with this VPN gateway.
- returned: success
- type: list
- forwardingRules:
- description:
- - A list of references to the ForwardingRule resources associated with this
- VPN gateway.
- returned: success
- type: list
- region:
- description:
- - The region this gateway should sit in.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str'), region=dict(required=True, type='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/targetVpnGateways".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_url_map.py b/lib/ansible/modules/cloud/google/gcp_compute_url_map.py
deleted file mode 100644
index e8076392c8..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_url_map.py
+++ /dev/null
@@ -1,5077 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_url_map
-description:
-- UrlMaps are used to route requests to a backend service based on rules that you
- define for the host and path of an incoming URL.
-short_description: Creates a GCP UrlMap
-version_added: '2.6'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- default_service:
- description:
- - The BackendService resource to which traffic is directed if none of the hostRules
- match. If defaultRouteAction is additionally specified, advanced routing actions
- like URL Rewrites, etc. take effect prior to sending the request to the backend.
- However, if defaultService is specified, defaultRouteAction cannot contain any
- weightedBackendServices. Conversely, if routeAction specifies any weightedBackendServices,
- service must not be specified. Only one of defaultService, defaultUrlRedirect
- or defaultRouteAction.weightedBackendService must be set.
- - 'This field represents a link to a BackendService resource in GCP. It can be
- specified in two ways. First, you can place a dictionary with key ''selfLink''
- and value of your resource''s selfLink Alternatively, you can add `register:
- name-of-resource` to a gcp_compute_backend_service task and then set this default_service
- field to "{{ name-of-resource }}"'
- required: false
- type: dict
- description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- required: false
- type: str
- header_action:
- description:
- - Specifies changes to request and response headers that need to take effect for
- the selected backendService. The headerAction specified here take effect after
- headerAction specified under pathMatcher.
- required: false
- type: dict
- version_added: '2.10'
- suboptions:
- request_headers_to_add:
- description:
- - Headers to add to a matching request prior to forwarding the request to
- the backendService.
- required: false
- type: list
- suboptions:
- header_name:
- description:
- - The name of the header.
- required: true
- type: str
- header_value:
- description:
- - The value of the header to add.
- required: true
- type: str
- replace:
- description:
- - If false, headerValue is appended to any values that already exist for
- the header. If true, headerValue is set for the header, discarding any
- values that were set for that header.
- required: true
- type: bool
- request_headers_to_remove:
- description:
- - A list of header names for headers that need to be removed from the request
- prior to forwarding the request to the backendService.
- required: false
- type: list
- response_headers_to_add:
- description:
- - Headers to add the response prior to sending the response back to the client.
- required: false
- type: list
- suboptions:
- header_name:
- description:
- - The name of the header.
- required: true
- type: str
- header_value:
- description:
- - The value of the header to add.
- required: true
- type: str
- replace:
- description:
- - If false, headerValue is appended to any values that already exist for
- the header. If true, headerValue is set for the header, discarding any
- values that were set for that header.
- required: true
- type: bool
- response_headers_to_remove:
- description:
- - A list of header names for headers that need to be removed from the response
- prior to sending the response back to the client.
- required: false
- type: list
- host_rules:
- description:
- - The list of HostRules to use against the URL.
- required: false
- type: list
- suboptions:
- description:
- description:
- - An optional description of this resource. Provide this property when you
- create the resource.
- required: false
- type: str
- hosts:
- description:
- - The list of host patterns to match. They must be valid hostnames, except
- * will match any string of ([a-z0-9-.]*). In that case, * must be the first
- character and must be followed in the pattern by either - or .
- required: true
- type: list
- path_matcher:
- description:
- - The name of the PathMatcher to use to match the path portion of the URL
- if the hostRule matches the URL's host portion.
- required: true
- type: str
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- required: true
- type: str
- path_matchers:
- description:
- - The list of named PathMatchers to use against the URL.
- required: false
- type: list
- suboptions:
- default_service:
- description:
- - 'The BackendService resource. This will be used if none of the pathRules
- or routeRules defined by this PathMatcher are matched. For example, the
- following are all valid URLs to a BackendService resource: - U(https://www.googleapis.com/compute/v1/projects/project/global/backendServices/backen)
- dService - compute/v1/projects/project/global/backendServices/backendService
- - global/backendServices/backendService If defaultRouteAction is additionally
- specified, advanced routing actions like URL Rewrites, etc. take effect
- prior to sending the request to the backend. However, if defaultService
- is specified, defaultRouteAction cannot contain any weightedBackendServices.
- Conversely, if defaultRouteAction specifies any weightedBackendServices,
- defaultService must not be specified. Only one of defaultService, defaultUrlRedirect
- or defaultRouteAction.weightedBackendService must be set. Authorization
- requires one or more of the following Google IAM permissions on the specified
- resource default_service: - compute.backendBuckets.use - compute.backendServices.use
- .'
- - 'This field represents a link to a BackendService resource in GCP. It can
- be specified in two ways. First, you can place a dictionary with key ''selfLink''
- and value of your resource''s selfLink Alternatively, you can add `register:
- name-of-resource` to a gcp_compute_backend_service task and then set this
- default_service field to "{{ name-of-resource }}"'
- required: false
- type: dict
- description:
- description:
- - An optional description of this resource. Provide this property when you
- create the resource.
- required: false
- type: str
- header_action:
- description:
- - Specifies changes to request and response headers that need to take effect
- for the selected backendService. HeaderAction specified here are applied
- after the matching HttpRouteRule HeaderAction and before the HeaderAction
- in the UrlMap .
- required: false
- type: dict
- version_added: '2.10'
- suboptions:
- request_headers_to_add:
- description:
- - Headers to add to a matching request prior to forwarding the request
- to the backendService.
- required: false
- type: list
- suboptions:
- header_name:
- description:
- - The name of the header.
- required: true
- type: str
- header_value:
- description:
- - The value of the header to add.
- required: true
- type: str
- replace:
- description:
- - If false, headerValue is appended to any values that already exist
- for the header. If true, headerValue is set for the header, discarding
- any values that were set for that header.
- required: true
- type: bool
- request_headers_to_remove:
- description:
- - A list of header names for headers that need to be removed from the
- request prior to forwarding the request to the backendService.
- required: false
- type: list
- response_headers_to_add:
- description:
- - Headers to add the response prior to sending the response back to the
- client.
- required: false
- type: list
- suboptions:
- header_name:
- description:
- - The name of the header.
- required: true
- type: str
- header_value:
- description:
- - The value of the header to add.
- required: true
- type: str
- replace:
- description:
- - If false, headerValue is appended to any values that already exist
- for the header. If true, headerValue is set for the header, discarding
- any values that were set for that header.
- required: true
- type: bool
- response_headers_to_remove:
- description:
- - A list of header names for headers that need to be removed from the
- response prior to sending the response back to the client.
- required: false
- type: list
- name:
- description:
- - The name to which this PathMatcher is referred by the HostRule.
- required: true
- type: str
- path_rules:
- description:
- - 'The list of path rules. Use this list instead of routeRules when routing
- based on simple path matching is all that''s required. The order by which
- path rules are specified does not matter. Matches are always done on the
- longest-path-first basis. For example: a pathRule with a path /a/b/c/* will
- match before /a/b/* irrespective of the order in which those paths appear
- in this list. Within a given pathMatcher, only one of pathRules or routeRules
- must be set.'
- required: false
- type: list
- suboptions:
- service:
- description:
- - The backend service resource to which traffic is directed if this rule
- is matched. If routeAction is additionally specified, advanced routing
- actions like URL Rewrites, etc. take effect prior to sending the request
- to the backend. However, if service is specified, routeAction cannot
- contain any weightedBackendService s. Conversely, if routeAction specifies
- any weightedBackendServices, service must not be specified. Only one
- of urlRedirect, service or routeAction.weightedBackendService must be
- set.
- - 'This field represents a link to a BackendService resource in GCP. It
- can be specified in two ways. First, you can place a dictionary with
- key ''selfLink'' and value of your resource''s selfLink Alternatively,
- you can add `register: name-of-resource` to a gcp_compute_backend_service
- task and then set this service field to "{{ name-of-resource }}"'
- required: false
- type: dict
- paths:
- description:
- - 'The list of path patterns to match. Each must start with / and the
- only place a * is allowed is at the end following a /. The string fed
- to the path matcher does not include any text after the first ? or #,
- and those chars are not allowed here.'
- required: true
- type: list
- route_action:
- description:
- - In response to a matching path, the load balancer performs advanced
- routing actions like URL rewrites, header transformations, etc. prior
- to forwarding the request to the selected backend. If routeAction specifies
- any weightedBackendServices, service must not be set. Conversely if
- service is set, routeAction cannot contain any weightedBackendServices.
- Only one of routeAction or urlRedirect must be set.
- required: false
- type: dict
- version_added: '2.10'
- suboptions:
- cors_policy:
- description:
- - The specification for allowing client side cross-origin requests.
- Please see W3C Recommendation for Cross Origin Resource Sharing
- .
- required: false
- type: dict
- suboptions:
- allow_credentials:
- description:
- - In response to a preflight request, setting this to true indicates
- that the actual request can include user credentials. This translates
- to the Access- Control-Allow-Credentials header. Defaults to
- false.
- required: false
- default: 'false'
- type: bool
- allow_headers:
- description:
- - Specifies the content for the Access-Control-Allow-Headers header.
- required: false
- type: list
- allow_methods:
- description:
- - Specifies the content for the Access-Control-Allow-Methods header.
- required: false
- type: list
- allow_origin_regexes:
- description:
- - Specifies the regualar expression patterns that match allowed
- origins. For regular expression grammar please see en.cppreference.com/w/cpp/regex/ecmascript
- An origin is allowed if it matches either allow_origins or allow_origin_regex.
- required: false
- type: list
- allow_origins:
- description:
- - Specifies the list of origins that will be allowed to do CORS
- requests. An origin is allowed if it matches either allow_origins
- or allow_origin_regex.
- required: false
- type: list
- disabled:
- description:
- - If true, specifies the CORS policy is disabled.
- required: true
- type: bool
- expose_headers:
- description:
- - Specifies the content for the Access-Control-Expose-Headers
- header.
- required: false
- type: list
- max_age:
- description:
- - Specifies how long the results of a preflight request can be
- cached. This translates to the content for the Access-Control-Max-Age
- header.
- required: false
- type: int
- fault_injection_policy:
- description:
- - The specification for fault injection introduced into traffic to
- test the resiliency of clients to backend service failure. As part
- of fault injection, when clients send requests to a backend service,
- delays can be introduced by Loadbalancer on a percentage of requests
- before sending those request to the backend service. Similarly requests
- from clients can be aborted by the Loadbalancer for a percentage
- of requests. timeout and retry_policy will be ignored by clients
- that are configured with a fault_injection_policy.
- required: false
- type: dict
- suboptions:
- abort:
- description:
- - The specification for how client requests are aborted as part
- of fault injection.
- required: false
- type: dict
- suboptions:
- http_status:
- description:
- - The HTTP status code used to abort the request. The value
- must be between 200 and 599 inclusive.
- required: true
- type: int
- percentage:
- description:
- - The percentage of traffic (connections/operations/requests)
- which will be aborted as part of fault injection. The value
- must be between 0.0 and 100.0 inclusive.
- required: true
- type: str
- delay:
- description:
- - The specification for how client requests are delayed as part
- of fault injection, before being sent to a backend service.
- required: false
- type: dict
- suboptions:
- fixed_delay:
- description:
- - Specifies the value of the fixed delay interval.
- required: true
- type: dict
- suboptions:
- nanos:
- description:
- - Span of time that's a fraction of a second at nanosecond
- resolution. Durations less than one second are represented
- with a 0 `seconds` field and a positive `nanos` field.
- Must be from 0 to 999,999,999 inclusive.
- required: false
- type: int
- seconds:
- description:
- - Span of time at a resolution of a second. Must be from
- 0 to 315,576,000,000 inclusive.
- required: true
- type: str
- percentage:
- description:
- - The percentage of traffic (connections/operations/requests)
- on which delay will be introduced as part of fault injection.
- The value must be between 0.0 and 100.0 inclusive.
- required: true
- type: str
- request_mirror_policy:
- description:
- - Specifies the policy on how requests intended for the route's backends
- are shadowed to a separate mirrored backend service. Loadbalancer
- does not wait for responses from the shadow service. Prior to sending
- traffic to the shadow service, the host / authority header is suffixed
- with -shadow.
- required: false
- type: dict
- suboptions:
- backend_service:
- description:
- - The BackendService resource being mirrored to.
- - 'This field represents a link to a BackendService resource in
- GCP. It can be specified in two ways. First, you can place a
- dictionary with key ''selfLink'' and value of your resource''s
- selfLink Alternatively, you can add `register: name-of-resource`
- to a gcp_compute_backend_service task and then set this backend_service
- field to "{{ name-of-resource }}"'
- required: true
- type: dict
- retry_policy:
- description:
- - Specifies the retry policy associated with this route.
- required: false
- type: dict
- suboptions:
- num_retries:
- description:
- - Specifies the allowed number retries. This number must be >
- 0.
- required: false
- type: int
- per_try_timeout:
- description:
- - Specifies a non-zero timeout per retry attempt.
- required: false
- type: dict
- suboptions:
- nanos:
- description:
- - Span of time that's a fraction of a second at nanosecond
- resolution. Durations less than one second are represented
- with a 0 `seconds` field and a positive `nanos` field. Must
- be from 0 to 999,999,999 inclusive.
- required: false
- type: int
- seconds:
- description:
- - Span of time at a resolution of a second. Must be from 0
- to 315,576,000,000 inclusive.
- required: true
- type: str
- retry_conditions:
- description:
- - 'Specifies one or more conditions when this retry rule applies.
- Valid values are: - 5xx: Loadbalancer will attempt a retry if
- the backend service responds with any 5xx response code, or
- if the backend service does not respond at all, example: disconnects,
- reset, read timeout, connection failure, and refused streams.'
- - "- gateway-error: Similar to 5xx, but only applies to response
- codes 502, 503 or 504."
- - "- connect-failure: Loadbalancer will retry on failures connecting
- to backend services, for example due to connection timeouts."
- - "- retriable-4xx: Loadbalancer will retry for retriable 4xx
- response codes."
- - Currently the only retriable error supported is 409.
- - "- refused-stream: Loadbalancer will retry if the backend service
- resets the stream with a REFUSED_STREAM error code. This reset
- type indicates that it is safe to retry."
- - "- cancelled: Loadbalancer will retry if the gRPC status code
- in the response header is set to cancelled - deadline-exceeded:
- Loadbalancer will retry if the gRPC status code in the response
- header is set to deadline-exceeded - resource-exhausted: Loadbalancer
- will retry if the gRPC status code in the response header is
- set to resource-exhausted - unavailable: Loadbalancer will retry
- if the gRPC status code in the response header is set to unavailable
- ."
- required: false
- type: list
- timeout:
- description:
- - Specifies the timeout for the selected route. Timeout is computed
- from the time the request is has been fully processed (i.e. end-of-stream)
- up until the response has been completely processed. Timeout includes
- all retries. If not specified, the default value is 15 seconds.
- required: false
- type: dict
- suboptions:
- nanos:
- description:
- - Span of time that's a fraction of a second at nanosecond resolution.
- Durations less than one second are represented with a 0 `seconds`
- field and a positive `nanos` field. Must be from 0 to 999,999,999
- inclusive.
- required: false
- type: int
- seconds:
- description:
- - Span of time at a resolution of a second. Must be from 0 to
- 315,576,000,000 inclusive.
- required: true
- type: str
- url_rewrite:
- description:
- - The spec to modify the URL of the request, prior to forwarding the
- request to the matched service .
- required: false
- type: dict
- suboptions:
- host_rewrite:
- description:
- - Prior to forwarding the request to the selected service, the
- request's host header is replaced with contents of hostRewrite.
- The value must be between 1 and 255 characters.
- required: false
- type: str
- path_prefix_rewrite:
- description:
- - Prior to forwarding the request to the selected backend service,
- the matching portion of the request's path is replaced by pathPrefixRewrite.
- The value must be between 1 and 1024 characters.
- required: false
- type: str
- weighted_backend_services:
- description:
- - A list of weighted backend services to send traffic to when a route
- match occurs. The weights determine the fraction of traffic that
- flows to their corresponding backend service. If all traffic needs
- to go to a single backend service, there must be one weightedBackendService
- with weight set to a non 0 number. Once a backendService is identified
- and before forwarding the request to the backend service, advanced
- routing actions like Url rewrites and header transformations are
- applied depending on additional settings specified in this HttpRouteAction.
- required: false
- type: list
- suboptions:
- backend_service:
- description:
- - The default BackendService resource. Before forwarding the request
- to backendService, the loadbalancer applies any relevant headerActions
- specified as part of this backendServiceWeight.
- - 'This field represents a link to a BackendService resource in
- GCP. It can be specified in two ways. First, you can place a
- dictionary with key ''selfLink'' and value of your resource''s
- selfLink Alternatively, you can add `register: name-of-resource`
- to a gcp_compute_backend_service task and then set this backend_service
- field to "{{ name-of-resource }}"'
- required: true
- type: dict
- header_action:
- description:
- - Specifies changes to request and response headers that need
- to take effect for the selected backendService. headerAction
- specified here take effect before headerAction in the enclosing
- HttpRouteRule, PathMatcher and UrlMap.
- required: false
- type: dict
- suboptions:
- request_headers_to_add:
- description:
- - Headers to add to a matching request prior to forwarding
- the request to the backendService.
- required: false
- type: list
- suboptions:
- header_name:
- description:
- - The name of the header.
- required: true
- type: str
- header_value:
- description:
- - The value of the header to add.
- required: true
- type: str
- replace:
- description:
- - If false, headerValue is appended to any values that
- already exist for the header. If true, headerValue is
- set for the header, discarding any values that were
- set for that header.
- required: true
- type: bool
- request_headers_to_remove:
- description:
- - A list of header names for headers that need to be removed
- from the request prior to forwarding the request to the
- backendService.
- required: false
- type: list
- response_headers_to_add:
- description:
- - Headers to add the response prior to sending the response
- back to the client.
- required: false
- type: list
- suboptions:
- header_name:
- description:
- - The name of the header.
- required: true
- type: str
- header_value:
- description:
- - The value of the header to add.
- required: true
- type: str
- replace:
- description:
- - If false, headerValue is appended to any values that
- already exist for the header. If true, headerValue is
- set for the header, discarding any values that were
- set for that header.
- required: true
- type: bool
- response_headers_to_remove:
- description:
- - A list of header names for headers that need to be removed
- from the response prior to sending the response back to
- the client.
- required: false
- type: list
- weight:
- description:
- - Specifies the fraction of traffic sent to backendService, computed
- as weight / (sum of all weightedBackendService weights in routeAction)
- . The selection of a backend service is determined only for
- new traffic. Once a user's request has been directed to a backendService,
- subsequent requests will be sent to the same backendService
- as determined by the BackendService's session affinity policy.
- - The value must be between 0 and 1000 .
- required: true
- type: int
- url_redirect:
- description:
- - When a path pattern is matched, the request is redirected to a URL specified
- by urlRedirect. If urlRedirect is specified, service or routeAction
- must not be set.
- required: false
- type: dict
- version_added: '2.10'
- suboptions:
- host_redirect:
- description:
- - The host that will be used in the redirect response instead of the
- one that was supplied in the request. The value must be between
- 1 and 255 characters.
- required: false
- type: str
- https_redirect:
- description:
- - If set to true, the URL scheme in the redirected request is set
- to https. If set to false, the URL scheme of the redirected request
- will remain the same as that of the request. This must only be set
- for UrlMaps used in TargetHttpProxys.
- - Setting this true for TargetHttpsProxy is not permitted. Defaults
- to false.
- required: false
- default: 'false'
- type: bool
- path_redirect:
- description:
- - The path that will be used in the redirect response instead of the
- one that was supplied in the request. Only one of pathRedirect or
- prefixRedirect must be specified. The value must be between 1 and
- 1024 characters.
- required: false
- type: str
- prefix_redirect:
- description:
- - The prefix that replaces the prefixMatch specified in the HttpRouteRuleMatch,
- retaining the remaining portion of the URL before redirecting the
- request.
- required: false
- type: str
- redirect_response_code:
- description:
- - 'The HTTP Status code to use for this RedirectAction. Supported
- values are: - MOVED_PERMANENTLY_DEFAULT, which is the default value
- and corresponds to 301.'
- - "- FOUND, which corresponds to 302."
- - "- SEE_OTHER which corresponds to 303."
- - "- TEMPORARY_REDIRECT, which corresponds to 307. In this case, the
- request method will be retained."
- - "- PERMANENT_REDIRECT, which corresponds to 308. In this case, the
- request method will be retained."
- - 'Some valid choices include: "FOUND", "MOVED_PERMANENTLY_DEFAULT",
- "PERMANENT_REDIRECT", "SEE_OTHER", "TEMPORARY_REDIRECT"'
- required: false
- type: str
- strip_query:
- description:
- - If set to true, any accompanying query portion of the original URL
- is removed prior to redirecting the request. If set to false, the
- query portion of the original URL is retained.
- required: true
- type: bool
- route_rules:
- description:
- - 'The list of ordered HTTP route rules. Use this list instead of pathRules
- when advanced route matching and routing actions are desired. The order
- of specifying routeRules matters: the first rule that matches will cause
- its specified routing action to take effect. Within a given pathMatcher,
- only one of pathRules or routeRules must be set. routeRules are not supported
- in UrlMaps intended for External load balancers.'
- required: false
- type: list
- version_added: '2.10'
- suboptions:
- priority:
- description:
- - For routeRules within a given pathMatcher, priority determines the order
- in which load balancer will interpret routeRules. RouteRules are evaluated
- in order of priority, from the lowest to highest number. The priority
- of a rule decreases as its number increases (1, 2, 3, N+1). The first
- rule that matches the request is applied.
- - You cannot configure two or more routeRules with the same priority.
- - Priority for each rule must be set to a number between 0 and 2147483647
- inclusive.
- - Priority numbers can have gaps, which enable you to add or remove rules
- in the future without affecting the rest of the rules. For example,
- 1, 2, 3, 4, 5, 9, 12, 16 is a valid series of priority numbers to which
- you could add rules numbered from 6 to 8, 10 to 11, and 13 to 15 in
- the future without any impact on existing rules.
- required: true
- type: int
- service:
- description:
- - The backend service resource to which traffic is directed if this rule
- is matched. If routeAction is additionally specified, advanced routing
- actions like URL Rewrites, etc. take effect prior to sending the request
- to the backend. However, if service is specified, routeAction cannot
- contain any weightedBackendService s. Conversely, if routeAction specifies
- any weightedBackendServices, service must not be specified. Only one
- of urlRedirect, service or routeAction.weightedBackendService must be
- set.
- - 'This field represents a link to a BackendService resource in GCP. It
- can be specified in two ways. First, you can place a dictionary with
- key ''selfLink'' and value of your resource''s selfLink Alternatively,
- you can add `register: name-of-resource` to a gcp_compute_backend_service
- task and then set this service field to "{{ name-of-resource }}"'
- required: false
- type: dict
- header_action:
- description:
- - Specifies changes to request and response headers that need to take
- effect for the selected backendService. The headerAction specified here
- are applied before the matching pathMatchers[].headerAction and after
- pathMatchers[].routeRules[].r outeAction.weightedBackendService.backendServiceWeightAction[].headerAction
- .
- required: false
- type: dict
- suboptions:
- request_headers_to_add:
- description:
- - Headers to add to a matching request prior to forwarding the request
- to the backendService.
- required: false
- type: list
- suboptions:
- header_name:
- description:
- - The name of the header.
- required: true
- type: str
- header_value:
- description:
- - The value of the header to add.
- required: true
- type: str
- replace:
- description:
- - If false, headerValue is appended to any values that already
- exist for the header. If true, headerValue is set for the header,
- discarding any values that were set for that header.
- required: true
- type: bool
- request_headers_to_remove:
- description:
- - A list of header names for headers that need to be removed from
- the request prior to forwarding the request to the backendService.
- required: false
- type: list
- response_headers_to_add:
- description:
- - Headers to add the response prior to sending the response back to
- the client.
- required: false
- type: list
- suboptions:
- header_name:
- description:
- - The name of the header.
- required: true
- type: str
- header_value:
- description:
- - The value of the header to add.
- required: true
- type: str
- replace:
- description:
- - If false, headerValue is appended to any values that already
- exist for the header. If true, headerValue is set for the header,
- discarding any values that were set for that header.
- required: true
- type: bool
- response_headers_to_remove:
- description:
- - A list of header names for headers that need to be removed from
- the response prior to sending the response back to the client.
- required: false
- type: list
- match_rules:
- description:
- - The rules for determining a match.
- required: false
- type: list
- suboptions:
- full_path_match:
- description:
- - For satifying the matchRule condition, the path of the request must
- exactly match the value specified in fullPathMatch after removing
- any query parameters and anchor that may be part of the original
- URL. FullPathMatch must be between 1 and 1024 characters. Only one
- of prefixMatch, fullPathMatch or regexMatch must be specified.
- required: false
- type: str
- header_matches:
- description:
- - Specifies a list of header match criteria, all of which must match
- corresponding headers in the request.
- required: false
- type: list
- suboptions:
- exact_match:
- description:
- - The value should exactly match contents of exactMatch. Only
- one of exactMatch, prefixMatch, suffixMatch, regexMatch, presentMatch
- or rangeMatch must be set.
- required: false
- type: str
- header_name:
- description:
- - The name of the HTTP header to match. For matching against the
- HTTP request's authority, use a headerMatch with the header
- name ":authority". For matching a request's method, use the
- headerName ":method".
- required: true
- type: str
- invert_match:
- description:
- - If set to false, the headerMatch is considered a match if the
- match criteria above are met. If set to true, the headerMatch
- is considered a match if the match criteria above are NOT met.
- Defaults to false.
- required: false
- default: 'false'
- type: bool
- prefix_match:
- description:
- - The value of the header must start with the contents of prefixMatch.
- Only one of exactMatch, prefixMatch, suffixMatch, regexMatch,
- presentMatch or rangeMatch must be set.
- required: false
- type: str
- present_match:
- description:
- - A header with the contents of headerName must exist. The match
- takes place whether or not the request's header has a value
- or not. Only one of exactMatch, prefixMatch, suffixMatch, regexMatch,
- presentMatch or rangeMatch must be set.
- required: false
- type: bool
- range_match:
- description:
- - The header value must be an integer and its value must be in
- the range specified in rangeMatch. If the header does not contain
- an integer, number or is empty, the match fails. For example
- for a range [-5, 0] - -3 will match. - 0 will not match. - 0.25
- will not match. - -3someString will not match. Only one of exactMatch,
- prefixMatch, suffixMatch, regexMatch, presentMatch or rangeMatch
- must be set.
- required: false
- type: dict
- suboptions:
- range_end:
- description:
- - The end of the range (exclusive).
- required: true
- type: int
- range_start:
- description:
- - The start of the range (inclusive).
- required: true
- type: int
- regex_match:
- description:
- - 'The value of the header must match the regualar expression
- specified in regexMatch. For regular expression grammar, please
- see: en.cppreference.com/w/cpp/regex/ecmascript For matching
- against a port specified in the HTTP request, use a headerMatch
- with headerName set to PORT and a regular expression that satisfies
- the RFC2616 Host header''s port specifier.'
- - Only one of exactMatch, prefixMatch, suffixMatch, regexMatch,
- presentMatch or rangeMatch must be set.
- required: false
- type: str
- suffix_match:
- description:
- - The value of the header must end with the contents of suffixMatch.
- Only one of exactMatch, prefixMatch, suffixMatch, regexMatch,
- presentMatch or rangeMatch must be set.
- required: false
- type: str
- ignore_case:
- description:
- - Specifies that prefixMatch and fullPathMatch matches are case sensitive.
- - Defaults to false.
- required: false
- default: 'false'
- type: bool
- metadata_filters:
- description:
- - Opaque filter criteria used by Loadbalancer to restrict routing
- configuration to a limited set xDS compliant clients. In their xDS
- requests to Loadbalancer, xDS clients present node metadata. If
- a match takes place, the relevant routing configuration is made
- available to those proxies. For each metadataFilter in this list,
- if its filterMatchCriteria is set to MATCH_ANY, at least one of
- the filterLabels must match the corresponding label provided in
- the metadata. If its filterMatchCriteria is set to MATCH_ALL, then
- all of its filterLabels must match with corresponding labels in
- the provided metadata. metadataFilters specified here can be overrides
- those specified in ForwardingRule that refers to this UrlMap. metadataFilters
- only applies to Loadbalancers that have their loadBalancingScheme
- set to INTERNAL_SELF_MANAGED.
- required: false
- type: list
- suboptions:
- filter_labels:
- description:
- - The list of label value pairs that must match labels in the
- provided metadata based on filterMatchCriteria This list must
- not be empty and can have at the most 64 entries.
- required: true
- type: list
- suboptions:
- name:
- description:
- - Name of metadata label. The name can have a maximum length
- of 1024 characters and must be at least 1 character long.
- required: true
- type: str
- value:
- description:
- - The value of the label must match the specified value. value
- can have a maximum length of 1024 characters.
- required: true
- type: str
- filter_match_criteria:
- description:
- - 'Specifies how individual filterLabel matches within the list
- of filterLabels contribute towards the overall metadataFilter
- match. Supported values are: - MATCH_ANY: At least one of the
- filterLabels must have a matching label in the provided metadata.'
- - "- MATCH_ALL: All filterLabels must have matching labels in
- the provided metadata."
- - 'Some valid choices include: "MATCH_ALL", "MATCH_ANY"'
- required: true
- type: str
- prefix_match:
- description:
- - For satifying the matchRule condition, the request's path must begin
- with the specified prefixMatch. prefixMatch must begin with a /.
- The value must be between 1 and 1024 characters. Only one of prefixMatch,
- fullPathMatch or regexMatch must be specified.
- required: false
- type: str
- query_parameter_matches:
- description:
- - Specifies a list of query parameter match criteria, all of which
- must match corresponding query parameters in the request.
- required: false
- type: list
- suboptions:
- exact_match:
- description:
- - The queryParameterMatch matches if the value of the parameter
- exactly matches the contents of exactMatch. Only one of presentMatch,
- exactMatch and regexMatch must be set.
- required: false
- type: str
- name:
- description:
- - The name of the query parameter to match. The query parameter
- must exist in the request, in the absence of which the request
- match fails.
- required: true
- type: str
- present_match:
- description:
- - Specifies that the queryParameterMatch matches if the request
- contains the query parameter, irrespective of whether the parameter
- has a value or not. Only one of presentMatch, exactMatch and
- regexMatch must be set.
- required: false
- type: bool
- regex_match:
- description:
- - The queryParameterMatch matches if the value of the parameter
- matches the regular expression specified by regexMatch. For
- the regular expression grammar, please see en.cppreference.com/w/cpp/regex/ecmascript
- Only one of presentMatch, exactMatch and regexMatch must be
- set.
- required: false
- type: str
- regex_match:
- description:
- - For satifying the matchRule condition, the path of the request must
- satisfy the regular expression specified in regexMatch after removing
- any query parameters and anchor supplied with the original URL.
- For regular expression grammar please see en.cppreference.com/w/cpp/regex/ecmascript
- Only one of prefixMatch, fullPathMatch or regexMatch must be specified.
- required: false
- type: str
- route_action:
- description:
- - In response to a matching matchRule, the load balancer performs advanced
- routing actions like URL rewrites, header transformations, etc. prior
- to forwarding the request to the selected backend. If routeAction specifies
- any weightedBackendServices, service must not be set. Conversely if
- service is set, routeAction cannot contain any weightedBackendServices.
- Only one of routeAction or urlRedirect must be set.
- required: false
- type: dict
- suboptions:
- cors_policy:
- description:
- - The specification for allowing client side cross-origin requests.
- Please see W3C Recommendation for Cross Origin Resource Sharing
- .
- required: false
- type: dict
- suboptions:
- allow_credentials:
- description:
- - In response to a preflight request, setting this to true indicates
- that the actual request can include user credentials. This translates
- to the Access- Control-Allow-Credentials header. Defaults to
- false.
- required: false
- default: 'false'
- type: bool
- allow_headers:
- description:
- - Specifies the content for the Access-Control-Allow-Headers header.
- required: false
- type: list
- allow_methods:
- description:
- - Specifies the content for the Access-Control-Allow-Methods header.
- required: false
- type: list
- allow_origin_regexes:
- description:
- - Specifies the regualar expression patterns that match allowed
- origins. For regular expression grammar please see en.cppreference.com/w/cpp/regex/ecmascript
- An origin is allowed if it matches either allow_origins or allow_origin_regex.
- required: false
- type: list
- allow_origins:
- description:
- - Specifies the list of origins that will be allowed to do CORS
- requests. An origin is allowed if it matches either allow_origins
- or allow_origin_regex.
- required: false
- type: list
- disabled:
- description:
- - If true, specifies the CORS policy is disabled.
- - which indicates that the CORS policy is in effect. Defaults
- to false.
- required: false
- default: 'false'
- type: bool
- expose_headers:
- description:
- - Specifies the content for the Access-Control-Expose-Headers
- header.
- required: false
- type: list
- max_age:
- description:
- - Specifies how long the results of a preflight request can be
- cached. This translates to the content for the Access-Control-Max-Age
- header.
- required: false
- type: int
- fault_injection_policy:
- description:
- - The specification for fault injection introduced into traffic to
- test the resiliency of clients to backend service failure. As part
- of fault injection, when clients send requests to a backend service,
- delays can be introduced by Loadbalancer on a percentage of requests
- before sending those request to the backend service. Similarly requests
- from clients can be aborted by the Loadbalancer for a percentage
- of requests. timeout and retry_policy will be ignored by clients
- that are configured with a fault_injection_policy.
- required: false
- type: dict
- suboptions:
- abort:
- description:
- - The specification for how client requests are aborted as part
- of fault injection.
- required: false
- type: dict
- suboptions:
- http_status:
- description:
- - The HTTP status code used to abort the request. The value
- must be between 200 and 599 inclusive.
- required: false
- type: int
- percentage:
- description:
- - The percentage of traffic (connections/operations/requests)
- which will be aborted as part of fault injection. The value
- must be between 0.0 and 100.0 inclusive.
- required: false
- type: str
- delay:
- description:
- - The specification for how client requests are delayed as part
- of fault injection, before being sent to a backend service.
- required: false
- type: dict
- suboptions:
- fixed_delay:
- description:
- - Specifies the value of the fixed delay interval.
- required: false
- type: dict
- suboptions:
- nanos:
- description:
- - Span of time that's a fraction of a second at nanosecond
- resolution. Durations less than one second are represented
- with a 0 `seconds` field and a positive `nanos` field.
- Must be from 0 to 999,999,999 inclusive.
- required: false
- type: int
- seconds:
- description:
- - Span of time at a resolution of a second. Must be from
- 0 to 315,576,000,000 inclusive.
- required: true
- type: str
- percentage:
- description:
- - The percentage of traffic (connections/operations/requests)
- on which delay will be introduced as part of fault injection.
- The value must be between 0.0 and 100.0 inclusive.
- required: false
- type: str
- request_mirror_policy:
- description:
- - Specifies the policy on how requests intended for the route's backends
- are shadowed to a separate mirrored backend service. Loadbalancer
- does not wait for responses from the shadow service. Prior to sending
- traffic to the shadow service, the host / authority header is suffixed
- with -shadow.
- required: false
- type: dict
- suboptions:
- backend_service:
- description:
- - The BackendService resource being mirrored to.
- - 'This field represents a link to a BackendService resource in
- GCP. It can be specified in two ways. First, you can place a
- dictionary with key ''selfLink'' and value of your resource''s
- selfLink Alternatively, you can add `register: name-of-resource`
- to a gcp_compute_backend_service task and then set this backend_service
- field to "{{ name-of-resource }}"'
- required: true
- type: dict
- retry_policy:
- description:
- - Specifies the retry policy associated with this route.
- required: false
- type: dict
- suboptions:
- num_retries:
- description:
- - Specifies the allowed number retries. This number must be >
- 0.
- required: true
- type: int
- per_try_timeout:
- description:
- - Specifies a non-zero timeout per retry attempt.
- - If not specified, will use the timeout set in HttpRouteAction.
- If timeout in HttpRouteAction is not set, will use the largest
- timeout among all backend services associated with the route.
- required: false
- type: dict
- suboptions:
- nanos:
- description:
- - Span of time that's a fraction of a second at nanosecond
- resolution. Durations less than one second are represented
- with a 0 `seconds` field and a positive `nanos` field. Must
- be from 0 to 999,999,999 inclusive.
- required: false
- type: int
- seconds:
- description:
- - Span of time at a resolution of a second. Must be from 0
- to 315,576,000,000 inclusive.
- required: true
- type: str
- retry_conditions:
- description:
- - 'Specfies one or more conditions when this retry rule applies.
- Valid values are: - 5xx: Loadbalancer will attempt a retry if
- the backend service responds with any 5xx response code, or
- if the backend service does not respond at all, example: disconnects,
- reset, read timeout, connection failure, and refused streams.'
- - "- gateway-error: Similar to 5xx, but only applies to response
- codes 502, 503 or 504."
- - "- connect-failure: Loadbalancer will retry on failures connecting
- to backend services, for example due to connection timeouts."
- - "- retriable-4xx: Loadbalancer will retry for retriable 4xx
- response codes."
- - Currently the only retriable error supported is 409.
- - "- refused-stream: Loadbalancer will retry if the backend service
- resets the stream with a REFUSED_STREAM error code. This reset
- type indicates that it is safe to retry."
- - "- cancelled: Loadbalancer will retry if the gRPC status code
- in the response header is set to cancelled - deadline-exceeded:
- Loadbalancer will retry if the gRPC status code in the response
- header is set to deadline-exceeded - resource-exhausted: Loadbalancer
- will retry if the gRPC status code in the response header is
- set to resource-exhausted - unavailable: Loadbalancer will retry
- if the gRPC status code in the response header is set to unavailable
- ."
- required: false
- type: list
- timeout:
- description:
- - Specifies the timeout for the selected route. Timeout is computed
- from the time the request is has been fully processed (i.e. end-of-stream)
- up until the response has been completely processed. Timeout includes
- all retries. If not specified, the default value is 15 seconds.
- required: false
- type: dict
- suboptions:
- nanos:
- description:
- - Span of time that's a fraction of a second at nanosecond resolution.
- Durations less than one second are represented with a 0 `seconds`
- field and a positive `nanos` field. Must be from 0 to 999,999,999
- inclusive.
- required: false
- type: int
- seconds:
- description:
- - Span of time at a resolution of a second. Must be from 0 to
- 315,576,000,000 inclusive.
- required: true
- type: str
- url_rewrite:
- description:
- - The spec to modify the URL of the request, prior to forwarding the
- request to the matched service .
- required: false
- type: dict
- suboptions:
- host_rewrite:
- description:
- - Prior to forwarding the request to the selected service, the
- request's host header is replaced with contents of hostRewrite.
- The value must be between 1 and 255 characters.
- required: false
- type: str
- path_prefix_rewrite:
- description:
- - Prior to forwarding the request to the selected backend service,
- the matching portion of the request's path is replaced by pathPrefixRewrite.
- The value must be between 1 and 1024 characters.
- required: false
- type: str
- weighted_backend_services:
- description:
- - A list of weighted backend services to send traffic to when a route
- match occurs. The weights determine the fraction of traffic that
- flows to their corresponding backend service. If all traffic needs
- to go to a single backend service, there must be one weightedBackendService
- with weight set to a non 0 number. Once a backendService is identified
- and before forwarding the request to the backend service, advanced
- routing actions like Url rewrites and header transformations are
- applied depending on additional settings specified in this HttpRouteAction.
- required: false
- type: list
- suboptions:
- backend_service:
- description:
- - The default BackendService resource. Before forwarding the request
- to backendService, the loadbalancer applies any relevant headerActions
- specified as part of this backendServiceWeight.
- - 'This field represents a link to a BackendService resource in
- GCP. It can be specified in two ways. First, you can place a
- dictionary with key ''selfLink'' and value of your resource''s
- selfLink Alternatively, you can add `register: name-of-resource`
- to a gcp_compute_backend_service task and then set this backend_service
- field to "{{ name-of-resource }}"'
- required: true
- type: dict
- header_action:
- description:
- - Specifies changes to request and response headers that need
- to take effect for the selected backendService. headerAction
- specified here take effect before headerAction in the enclosing
- HttpRouteRule, PathMatcher and UrlMap.
- required: false
- type: dict
- suboptions:
- request_headers_to_add:
- description:
- - Headers to add to a matching request prior to forwarding
- the request to the backendService.
- required: false
- type: list
- suboptions:
- header_name:
- description:
- - The name of the header.
- required: true
- type: str
- header_value:
- description:
- - The value of the header to add.
- required: true
- type: str
- replace:
- description:
- - If false, headerValue is appended to any values that
- already exist for the header. If true, headerValue is
- set for the header, discarding any values that were
- set for that header.
- required: true
- type: bool
- request_headers_to_remove:
- description:
- - A list of header names for headers that need to be removed
- from the request prior to forwarding the request to the
- backendService.
- required: false
- type: list
- response_headers_to_add:
- description:
- - Headers to add the response prior to sending the response
- back to the client.
- required: false
- type: list
- suboptions:
- header_name:
- description:
- - The name of the header.
- required: true
- type: str
- header_value:
- description:
- - The value of the header to add.
- required: true
- type: str
- replace:
- description:
- - If false, headerValue is appended to any values that
- already exist for the header. If true, headerValue is
- set for the header, discarding any values that were
- set for that header.
- required: true
- type: bool
- response_headers_to_remove:
- description:
- - A list of header names for headers that need to be removed
- from the response prior to sending the response back to
- the client.
- required: false
- type: list
- weight:
- description:
- - Specifies the fraction of traffic sent to backendService, computed
- as weight / (sum of all weightedBackendService weights in routeAction)
- . The selection of a backend service is determined only for
- new traffic. Once a user's request has been directed to a backendService,
- subsequent requests will be sent to the same backendService
- as determined by the BackendService's session affinity policy.
- - The value must be between 0 and 1000 .
- required: true
- type: int
- url_redirect:
- description:
- - When this rule is matched, the request is redirected to a URL specified
- by urlRedirect. If urlRedirect is specified, service or routeAction
- must not be set.
- required: false
- type: dict
- suboptions:
- host_redirect:
- description:
- - The host that will be used in the redirect response instead of the
- one that was supplied in the request. The value must be between
- 1 and 255 characters.
- required: false
- type: str
- https_redirect:
- description:
- - If set to true, the URL scheme in the redirected request is set
- to https. If set to false, the URL scheme of the redirected request
- will remain the same as that of the request. This must only be set
- for UrlMaps used in TargetHttpProxys.
- - Setting this true for TargetHttpsProxy is not permitted. Defaults
- to false.
- required: false
- default: 'false'
- type: bool
- path_redirect:
- description:
- - The path that will be used in the redirect response instead of the
- one that was supplied in the request. Only one of pathRedirect or
- prefixRedirect must be specified. The value must be between 1 and
- 1024 characters.
- required: false
- type: str
- prefix_redirect:
- description:
- - The prefix that replaces the prefixMatch specified in the HttpRouteRuleMatch,
- retaining the remaining portion of the URL before redirecting the
- request.
- required: false
- type: str
- redirect_response_code:
- description:
- - 'The HTTP Status code to use for this RedirectAction. Supported
- values are: - MOVED_PERMANENTLY_DEFAULT, which is the default value
- and corresponds to 301. - FOUND, which corresponds to 302. - SEE_OTHER
- which corresponds to 303. - TEMPORARY_REDIRECT, which corresponds
- to 307. In this case, the request method will be retained. - PERMANENT_REDIRECT,
- which corresponds to 308. In this case, the request method will
- be retained.'
- - 'Some valid choices include: "FOUND", "MOVED_PERMANENTLY_DEFAULT",
- "PERMANENT_REDIRECT", "SEE_OTHER", "TEMPORARY_REDIRECT"'
- required: false
- type: str
- strip_query:
- description:
- - If set to true, any accompanying query portion of the original URL
- is removed prior to redirecting the request. If set to false, the
- query portion of the original URL is retained. Defaults to false.
- required: false
- default: 'false'
- type: bool
- tests:
- description:
- - The list of expected URL mapping tests. Request to update this UrlMap will succeed
- only if all of the test cases pass. You can specify a maximum of 100 tests per
- UrlMap.
- required: false
- type: list
- suboptions:
- description:
- description:
- - Description of this test case.
- required: false
- type: str
- host:
- description:
- - Host portion of the URL.
- required: true
- type: str
- path:
- description:
- - Path portion of the URL.
- required: true
- type: str
- service:
- description:
- - Expected BackendService resource the given URL should be mapped to.
- - 'This field represents a link to a BackendService resource in GCP. It can
- be specified in two ways. First, you can place a dictionary with key ''selfLink''
- and value of your resource''s selfLink Alternatively, you can add `register:
- name-of-resource` to a gcp_compute_backend_service task and then set this
- service field to "{{ name-of-resource }}"'
- required: true
- type: dict
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/v1/urlMaps)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a instance group
- gcp_compute_instance_group:
- name: instancegroup-urlmap
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: instancegroup
-
-- name: create a HTTP health check
- gcp_compute_http_health_check:
- name: httphealthcheck-urlmap
- healthy_threshold: 10
- port: 8080
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: healthcheck
-
-- name: create a backend service
- gcp_compute_backend_service:
- name: backendservice-urlmap
- backends:
- - group: "{{ instancegroup.selfLink }}"
- health_checks:
- - "{{ healthcheck.selfLink }}"
- enable_cdn: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: backendservice
-
-- name: create a URL map
- gcp_compute_url_map:
- name: test_object
- default_service: "{{ backendservice }}"
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-defaultService:
- description:
- - The BackendService resource to which traffic is directed if none of the hostRules
- match. If defaultRouteAction is additionally specified, advanced routing actions
- like URL Rewrites, etc. take effect prior to sending the request to the backend.
- However, if defaultService is specified, defaultRouteAction cannot contain any
- weightedBackendServices. Conversely, if routeAction specifies any weightedBackendServices,
- service must not be specified. Only one of defaultService, defaultUrlRedirect
- or defaultRouteAction.weightedBackendService must be set.
- returned: success
- type: dict
-description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- returned: success
- type: str
-id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
-fingerprint:
- description:
- - Fingerprint of this resource. A hash of the contents stored in this object. This
- field is used in optimistic locking.
- returned: success
- type: str
-headerAction:
- description:
- - Specifies changes to request and response headers that need to take effect for
- the selected backendService. The headerAction specified here take effect after
- headerAction specified under pathMatcher.
- returned: success
- type: complex
- contains:
- requestHeadersToAdd:
- description:
- - Headers to add to a matching request prior to forwarding the request to the
- backendService.
- returned: success
- type: complex
- contains:
- headerName:
- description:
- - The name of the header.
- returned: success
- type: str
- headerValue:
- description:
- - The value of the header to add.
- returned: success
- type: str
- replace:
- description:
- - If false, headerValue is appended to any values that already exist for
- the header. If true, headerValue is set for the header, discarding any
- values that were set for that header.
- returned: success
- type: bool
- requestHeadersToRemove:
- description:
- - A list of header names for headers that need to be removed from the request
- prior to forwarding the request to the backendService.
- returned: success
- type: list
- responseHeadersToAdd:
- description:
- - Headers to add the response prior to sending the response back to the client.
- returned: success
- type: complex
- contains:
- headerName:
- description:
- - The name of the header.
- returned: success
- type: str
- headerValue:
- description:
- - The value of the header to add.
- returned: success
- type: str
- replace:
- description:
- - If false, headerValue is appended to any values that already exist for
- the header. If true, headerValue is set for the header, discarding any
- values that were set for that header.
- returned: success
- type: bool
- responseHeadersToRemove:
- description:
- - A list of header names for headers that need to be removed from the response
- prior to sending the response back to the client.
- returned: success
- type: list
-hostRules:
- description:
- - The list of HostRules to use against the URL.
- returned: success
- type: complex
- contains:
- description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- returned: success
- type: str
- hosts:
- description:
- - The list of host patterns to match. They must be valid hostnames, except *
- will match any string of ([a-z0-9-.]*). In that case, * must be the first
- character and must be followed in the pattern by either - or .
- returned: success
- type: list
- pathMatcher:
- description:
- - The name of the PathMatcher to use to match the path portion of the URL if
- the hostRule matches the URL's host portion.
- returned: success
- type: str
-name:
- description:
- - Name of the resource. Provided by the client when the resource is created. The
- name must be 1-63 characters long, and comply with RFC1035. Specifically, the
- name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
-pathMatchers:
- description:
- - The list of named PathMatchers to use against the URL.
- returned: success
- type: complex
- contains:
- defaultService:
- description:
- - 'The BackendService resource. This will be used if none of the pathRules or
- routeRules defined by this PathMatcher are matched. For example, the following
- are all valid URLs to a BackendService resource: - U(https://www.googleapis.com/compute/v1/projects/project/global/backendServices/backen)
- dService - compute/v1/projects/project/global/backendServices/backendService
- - global/backendServices/backendService If defaultRouteAction is additionally
- specified, advanced routing actions like URL Rewrites, etc. take effect prior
- to sending the request to the backend. However, if defaultService is specified,
- defaultRouteAction cannot contain any weightedBackendServices. Conversely,
- if defaultRouteAction specifies any weightedBackendServices, defaultService
- must not be specified. Only one of defaultService, defaultUrlRedirect or defaultRouteAction.weightedBackendService
- must be set. Authorization requires one or more of the following Google IAM
- permissions on the specified resource default_service: - compute.backendBuckets.use
- - compute.backendServices.use .'
- returned: success
- type: dict
- description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- returned: success
- type: str
- headerAction:
- description:
- - Specifies changes to request and response headers that need to take effect
- for the selected backendService. HeaderAction specified here are applied after
- the matching HttpRouteRule HeaderAction and before the HeaderAction in the
- UrlMap .
- returned: success
- type: complex
- contains:
- requestHeadersToAdd:
- description:
- - Headers to add to a matching request prior to forwarding the request to
- the backendService.
- returned: success
- type: complex
- contains:
- headerName:
- description:
- - The name of the header.
- returned: success
- type: str
- headerValue:
- description:
- - The value of the header to add.
- returned: success
- type: str
- replace:
- description:
- - If false, headerValue is appended to any values that already exist
- for the header. If true, headerValue is set for the header, discarding
- any values that were set for that header.
- returned: success
- type: bool
- requestHeadersToRemove:
- description:
- - A list of header names for headers that need to be removed from the request
- prior to forwarding the request to the backendService.
- returned: success
- type: list
- responseHeadersToAdd:
- description:
- - Headers to add the response prior to sending the response back to the
- client.
- returned: success
- type: complex
- contains:
- headerName:
- description:
- - The name of the header.
- returned: success
- type: str
- headerValue:
- description:
- - The value of the header to add.
- returned: success
- type: str
- replace:
- description:
- - If false, headerValue is appended to any values that already exist
- for the header. If true, headerValue is set for the header, discarding
- any values that were set for that header.
- returned: success
- type: bool
- responseHeadersToRemove:
- description:
- - A list of header names for headers that need to be removed from the response
- prior to sending the response back to the client.
- returned: success
- type: list
- name:
- description:
- - The name to which this PathMatcher is referred by the HostRule.
- returned: success
- type: str
- pathRules:
- description:
- - 'The list of path rules. Use this list instead of routeRules when routing
- based on simple path matching is all that''s required. The order by which
- path rules are specified does not matter. Matches are always done on the longest-path-first
- basis. For example: a pathRule with a path /a/b/c/* will match before /a/b/*
- irrespective of the order in which those paths appear in this list. Within
- a given pathMatcher, only one of pathRules or routeRules must be set.'
- returned: success
- type: complex
- contains:
- service:
- description:
- - The backend service resource to which traffic is directed if this rule
- is matched. If routeAction is additionally specified, advanced routing
- actions like URL Rewrites, etc. take effect prior to sending the request
- to the backend. However, if service is specified, routeAction cannot contain
- any weightedBackendService s. Conversely, if routeAction specifies any
- weightedBackendServices, service must not be specified. Only one of urlRedirect,
- service or routeAction.weightedBackendService must be set.
- returned: success
- type: dict
- paths:
- description:
- - 'The list of path patterns to match. Each must start with / and the only
- place a * is allowed is at the end following a /. The string fed to the
- path matcher does not include any text after the first ? or #, and those
- chars are not allowed here.'
- returned: success
- type: list
- routeAction:
- description:
- - In response to a matching path, the load balancer performs advanced routing
- actions like URL rewrites, header transformations, etc. prior to forwarding
- the request to the selected backend. If routeAction specifies any weightedBackendServices,
- service must not be set. Conversely if service is set, routeAction cannot
- contain any weightedBackendServices. Only one of routeAction or urlRedirect
- must be set.
- returned: success
- type: complex
- contains:
- corsPolicy:
- description:
- - The specification for allowing client side cross-origin requests.
- Please see W3C Recommendation for Cross Origin Resource Sharing .
- returned: success
- type: complex
- contains:
- allowCredentials:
- description:
- - In response to a preflight request, setting this to true indicates
- that the actual request can include user credentials. This translates
- to the Access- Control-Allow-Credentials header. Defaults to false.
- returned: success
- type: bool
- allowHeaders:
- description:
- - Specifies the content for the Access-Control-Allow-Headers header.
- returned: success
- type: list
- allowMethods:
- description:
- - Specifies the content for the Access-Control-Allow-Methods header.
- returned: success
- type: list
- allowOriginRegexes:
- description:
- - Specifies the regualar expression patterns that match allowed
- origins. For regular expression grammar please see en.cppreference.com/w/cpp/regex/ecmascript
- An origin is allowed if it matches either allow_origins or allow_origin_regex.
- returned: success
- type: list
- allowOrigins:
- description:
- - Specifies the list of origins that will be allowed to do CORS
- requests. An origin is allowed if it matches either allow_origins
- or allow_origin_regex.
- returned: success
- type: list
- disabled:
- description:
- - If true, specifies the CORS policy is disabled.
- returned: success
- type: bool
- exposeHeaders:
- description:
- - Specifies the content for the Access-Control-Expose-Headers header.
- returned: success
- type: list
- maxAge:
- description:
- - Specifies how long the results of a preflight request can be cached.
- This translates to the content for the Access-Control-Max-Age
- header.
- returned: success
- type: int
- faultInjectionPolicy:
- description:
- - The specification for fault injection introduced into traffic to test
- the resiliency of clients to backend service failure. As part of fault
- injection, when clients send requests to a backend service, delays
- can be introduced by Loadbalancer on a percentage of requests before
- sending those request to the backend service. Similarly requests from
- clients can be aborted by the Loadbalancer for a percentage of requests.
- timeout and retry_policy will be ignored by clients that are configured
- with a fault_injection_policy.
- returned: success
- type: complex
- contains:
- abort:
- description:
- - The specification for how client requests are aborted as part
- of fault injection.
- returned: success
- type: complex
- contains:
- httpStatus:
- description:
- - The HTTP status code used to abort the request. The value
- must be between 200 and 599 inclusive.
- returned: success
- type: int
- percentage:
- description:
- - The percentage of traffic (connections/operations/requests)
- which will be aborted as part of fault injection. The value
- must be between 0.0 and 100.0 inclusive.
- returned: success
- type: str
- delay:
- description:
- - The specification for how client requests are delayed as part
- of fault injection, before being sent to a backend service.
- returned: success
- type: complex
- contains:
- fixedDelay:
- description:
- - Specifies the value of the fixed delay interval.
- returned: success
- type: complex
- contains:
- nanos:
- description:
- - Span of time that's a fraction of a second at nanosecond
- resolution. Durations less than one second are represented
- with a 0 `seconds` field and a positive `nanos` field.
- Must be from 0 to 999,999,999 inclusive.
- returned: success
- type: int
- seconds:
- description:
- - Span of time at a resolution of a second. Must be from
- 0 to 315,576,000,000 inclusive.
- returned: success
- type: str
- percentage:
- description:
- - The percentage of traffic (connections/operations/requests)
- on which delay will be introduced as part of fault injection.
- The value must be between 0.0 and 100.0 inclusive.
- returned: success
- type: str
- requestMirrorPolicy:
- description:
- - Specifies the policy on how requests intended for the route's backends
- are shadowed to a separate mirrored backend service. Loadbalancer
- does not wait for responses from the shadow service. Prior to sending
- traffic to the shadow service, the host / authority header is suffixed
- with -shadow.
- returned: success
- type: complex
- contains:
- backendService:
- description:
- - The BackendService resource being mirrored to.
- returned: success
- type: dict
- retryPolicy:
- description:
- - Specifies the retry policy associated with this route.
- returned: success
- type: complex
- contains:
- numRetries:
- description:
- - Specifies the allowed number retries. This number must be > 0.
- returned: success
- type: int
- perTryTimeout:
- description:
- - Specifies a non-zero timeout per retry attempt.
- returned: success
- type: complex
- contains:
- nanos:
- description:
- - Span of time that's a fraction of a second at nanosecond resolution.
- Durations less than one second are represented with a 0 `seconds`
- field and a positive `nanos` field. Must be from 0 to 999,999,999
- inclusive.
- returned: success
- type: int
- seconds:
- description:
- - Span of time at a resolution of a second. Must be from 0 to
- 315,576,000,000 inclusive.
- returned: success
- type: str
- retryConditions:
- description:
- - 'Specifies one or more conditions when this retry rule applies.
- Valid values are: - 5xx: Loadbalancer will attempt a retry if
- the backend service responds with any 5xx response code, or if
- the backend service does not respond at all, example: disconnects,
- reset, read timeout, connection failure, and refused streams.'
- - "- gateway-error: Similar to 5xx, but only applies to response
- codes 502, 503 or 504."
- - "- connect-failure: Loadbalancer will retry on failures connecting
- to backend services, for example due to connection timeouts."
- - "- retriable-4xx: Loadbalancer will retry for retriable 4xx response
- codes."
- - Currently the only retriable error supported is 409.
- - "- refused-stream: Loadbalancer will retry if the backend service
- resets the stream with a REFUSED_STREAM error code. This reset
- type indicates that it is safe to retry."
- - "- cancelled: Loadbalancer will retry if the gRPC status code
- in the response header is set to cancelled - deadline-exceeded:
- Loadbalancer will retry if the gRPC status code in the response
- header is set to deadline-exceeded - resource-exhausted: Loadbalancer
- will retry if the gRPC status code in the response header is set
- to resource-exhausted - unavailable: Loadbalancer will retry if
- the gRPC status code in the response header is set to unavailable
- ."
- returned: success
- type: list
- timeout:
- description:
- - Specifies the timeout for the selected route. Timeout is computed
- from the time the request is has been fully processed (i.e. end-of-stream)
- up until the response has been completely processed. Timeout includes
- all retries. If not specified, the default value is 15 seconds.
- returned: success
- type: complex
- contains:
- nanos:
- description:
- - Span of time that's a fraction of a second at nanosecond resolution.
- Durations less than one second are represented with a 0 `seconds`
- field and a positive `nanos` field. Must be from 0 to 999,999,999
- inclusive.
- returned: success
- type: int
- seconds:
- description:
- - Span of time at a resolution of a second. Must be from 0 to 315,576,000,000
- inclusive.
- returned: success
- type: str
- urlRewrite:
- description:
- - The spec to modify the URL of the request, prior to forwarding the
- request to the matched service .
- returned: success
- type: complex
- contains:
- hostRewrite:
- description:
- - Prior to forwarding the request to the selected service, the request's
- host header is replaced with contents of hostRewrite. The value
- must be between 1 and 255 characters.
- returned: success
- type: str
- pathPrefixRewrite:
- description:
- - Prior to forwarding the request to the selected backend service,
- the matching portion of the request's path is replaced by pathPrefixRewrite.
- The value must be between 1 and 1024 characters.
- returned: success
- type: str
- weightedBackendServices:
- description:
- - A list of weighted backend services to send traffic to when a route
- match occurs. The weights determine the fraction of traffic that flows
- to their corresponding backend service. If all traffic needs to go
- to a single backend service, there must be one weightedBackendService
- with weight set to a non 0 number. Once a backendService is identified
- and before forwarding the request to the backend service, advanced
- routing actions like Url rewrites and header transformations are applied
- depending on additional settings specified in this HttpRouteAction.
- returned: success
- type: complex
- contains:
- backendService:
- description:
- - The default BackendService resource. Before forwarding the request
- to backendService, the loadbalancer applies any relevant headerActions
- specified as part of this backendServiceWeight.
- returned: success
- type: dict
- headerAction:
- description:
- - Specifies changes to request and response headers that need to
- take effect for the selected backendService. headerAction specified
- here take effect before headerAction in the enclosing HttpRouteRule,
- PathMatcher and UrlMap.
- returned: success
- type: complex
- contains:
- requestHeadersToAdd:
- description:
- - Headers to add to a matching request prior to forwarding the
- request to the backendService.
- returned: success
- type: complex
- contains:
- headerName:
- description:
- - The name of the header.
- returned: success
- type: str
- headerValue:
- description:
- - The value of the header to add.
- returned: success
- type: str
- replace:
- description:
- - If false, headerValue is appended to any values that already
- exist for the header. If true, headerValue is set for
- the header, discarding any values that were set for that
- header.
- returned: success
- type: bool
- requestHeadersToRemove:
- description:
- - A list of header names for headers that need to be removed
- from the request prior to forwarding the request to the backendService.
- returned: success
- type: list
- responseHeadersToAdd:
- description:
- - Headers to add the response prior to sending the response
- back to the client.
- returned: success
- type: complex
- contains:
- headerName:
- description:
- - The name of the header.
- returned: success
- type: str
- headerValue:
- description:
- - The value of the header to add.
- returned: success
- type: str
- replace:
- description:
- - If false, headerValue is appended to any values that already
- exist for the header. If true, headerValue is set for
- the header, discarding any values that were set for that
- header.
- returned: success
- type: bool
- responseHeadersToRemove:
- description:
- - A list of header names for headers that need to be removed
- from the response prior to sending the response back to the
- client.
- returned: success
- type: list
- weight:
- description:
- - Specifies the fraction of traffic sent to backendService, computed
- as weight / (sum of all weightedBackendService weights in routeAction)
- . The selection of a backend service is determined only for new
- traffic. Once a user's request has been directed to a backendService,
- subsequent requests will be sent to the same backendService as
- determined by the BackendService's session affinity policy.
- - The value must be between 0 and 1000 .
- returned: success
- type: int
- urlRedirect:
- description:
- - When a path pattern is matched, the request is redirected to a URL specified
- by urlRedirect. If urlRedirect is specified, service or routeAction must
- not be set.
- returned: success
- type: complex
- contains:
- hostRedirect:
- description:
- - The host that will be used in the redirect response instead of the
- one that was supplied in the request. The value must be between 1
- and 255 characters.
- returned: success
- type: str
- httpsRedirect:
- description:
- - If set to true, the URL scheme in the redirected request is set to
- https. If set to false, the URL scheme of the redirected request will
- remain the same as that of the request. This must only be set for
- UrlMaps used in TargetHttpProxys.
- - Setting this true for TargetHttpsProxy is not permitted. Defaults
- to false.
- returned: success
- type: bool
- pathRedirect:
- description:
- - The path that will be used in the redirect response instead of the
- one that was supplied in the request. Only one of pathRedirect or
- prefixRedirect must be specified. The value must be between 1 and
- 1024 characters.
- returned: success
- type: str
- prefixRedirect:
- description:
- - The prefix that replaces the prefixMatch specified in the HttpRouteRuleMatch,
- retaining the remaining portion of the URL before redirecting the
- request.
- returned: success
- type: str
- redirectResponseCode:
- description:
- - 'The HTTP Status code to use for this RedirectAction. Supported values
- are: - MOVED_PERMANENTLY_DEFAULT, which is the default value and corresponds
- to 301.'
- - "- FOUND, which corresponds to 302."
- - "- SEE_OTHER which corresponds to 303."
- - "- TEMPORARY_REDIRECT, which corresponds to 307. In this case, the
- request method will be retained."
- - "- PERMANENT_REDIRECT, which corresponds to 308. In this case, the
- request method will be retained."
- returned: success
- type: str
- stripQuery:
- description:
- - If set to true, any accompanying query portion of the original URL
- is removed prior to redirecting the request. If set to false, the
- query portion of the original URL is retained.
- returned: success
- type: bool
- routeRules:
- description:
- - 'The list of ordered HTTP route rules. Use this list instead of pathRules
- when advanced route matching and routing actions are desired. The order of
- specifying routeRules matters: the first rule that matches will cause its
- specified routing action to take effect. Within a given pathMatcher, only
- one of pathRules or routeRules must be set. routeRules are not supported in
- UrlMaps intended for External load balancers.'
- returned: success
- type: complex
- contains:
- priority:
- description:
- - For routeRules within a given pathMatcher, priority determines the order
- in which load balancer will interpret routeRules. RouteRules are evaluated
- in order of priority, from the lowest to highest number. The priority
- of a rule decreases as its number increases (1, 2, 3, N+1). The first
- rule that matches the request is applied.
- - You cannot configure two or more routeRules with the same priority.
- - Priority for each rule must be set to a number between 0 and 2147483647
- inclusive.
- - Priority numbers can have gaps, which enable you to add or remove rules
- in the future without affecting the rest of the rules. For example, 1,
- 2, 3, 4, 5, 9, 12, 16 is a valid series of priority numbers to which you
- could add rules numbered from 6 to 8, 10 to 11, and 13 to 15 in the future
- without any impact on existing rules.
- returned: success
- type: int
- service:
- description:
- - The backend service resource to which traffic is directed if this rule
- is matched. If routeAction is additionally specified, advanced routing
- actions like URL Rewrites, etc. take effect prior to sending the request
- to the backend. However, if service is specified, routeAction cannot contain
- any weightedBackendService s. Conversely, if routeAction specifies any
- weightedBackendServices, service must not be specified. Only one of urlRedirect,
- service or routeAction.weightedBackendService must be set.
- returned: success
- type: dict
- headerAction:
- description:
- - Specifies changes to request and response headers that need to take effect
- for the selected backendService. The headerAction specified here are applied
- before the matching pathMatchers[].headerAction and after pathMatchers[].routeRules[].r
- outeAction.weightedBackendService.backendServiceWeightAction[].headerAction
- .
- returned: success
- type: complex
- contains:
- requestHeadersToAdd:
- description:
- - Headers to add to a matching request prior to forwarding the request
- to the backendService.
- returned: success
- type: complex
- contains:
- headerName:
- description:
- - The name of the header.
- returned: success
- type: str
- headerValue:
- description:
- - The value of the header to add.
- returned: success
- type: str
- replace:
- description:
- - If false, headerValue is appended to any values that already exist
- for the header. If true, headerValue is set for the header, discarding
- any values that were set for that header.
- returned: success
- type: bool
- requestHeadersToRemove:
- description:
- - A list of header names for headers that need to be removed from the
- request prior to forwarding the request to the backendService.
- returned: success
- type: list
- responseHeadersToAdd:
- description:
- - Headers to add the response prior to sending the response back to
- the client.
- returned: success
- type: complex
- contains:
- headerName:
- description:
- - The name of the header.
- returned: success
- type: str
- headerValue:
- description:
- - The value of the header to add.
- returned: success
- type: str
- replace:
- description:
- - If false, headerValue is appended to any values that already exist
- for the header. If true, headerValue is set for the header, discarding
- any values that were set for that header.
- returned: success
- type: bool
- responseHeadersToRemove:
- description:
- - A list of header names for headers that need to be removed from the
- response prior to sending the response back to the client.
- returned: success
- type: list
- matchRules:
- description:
- - The rules for determining a match.
- returned: success
- type: complex
- contains:
- fullPathMatch:
- description:
- - For satifying the matchRule condition, the path of the request must
- exactly match the value specified in fullPathMatch after removing
- any query parameters and anchor that may be part of the original URL.
- FullPathMatch must be between 1 and 1024 characters. Only one of prefixMatch,
- fullPathMatch or regexMatch must be specified.
- returned: success
- type: str
- headerMatches:
- description:
- - Specifies a list of header match criteria, all of which must match
- corresponding headers in the request.
- returned: success
- type: complex
- contains:
- exactMatch:
- description:
- - The value should exactly match contents of exactMatch. Only one
- of exactMatch, prefixMatch, suffixMatch, regexMatch, presentMatch
- or rangeMatch must be set.
- returned: success
- type: str
- headerName:
- description:
- - The name of the HTTP header to match. For matching against the
- HTTP request's authority, use a headerMatch with the header name
- ":authority". For matching a request's method, use the headerName
- ":method".
- returned: success
- type: str
- invertMatch:
- description:
- - If set to false, the headerMatch is considered a match if the
- match criteria above are met. If set to true, the headerMatch
- is considered a match if the match criteria above are NOT met.
- Defaults to false.
- returned: success
- type: bool
- prefixMatch:
- description:
- - The value of the header must start with the contents of prefixMatch.
- Only one of exactMatch, prefixMatch, suffixMatch, regexMatch,
- presentMatch or rangeMatch must be set.
- returned: success
- type: str
- presentMatch:
- description:
- - A header with the contents of headerName must exist. The match
- takes place whether or not the request's header has a value or
- not. Only one of exactMatch, prefixMatch, suffixMatch, regexMatch,
- presentMatch or rangeMatch must be set.
- returned: success
- type: bool
- rangeMatch:
- description:
- - The header value must be an integer and its value must be in the
- range specified in rangeMatch. If the header does not contain
- an integer, number or is empty, the match fails. For example for
- a range [-5, 0] - -3 will match. - 0 will not match. - 0.25 will
- not match. - -3someString will not match. Only one of exactMatch,
- prefixMatch, suffixMatch, regexMatch, presentMatch or rangeMatch
- must be set.
- returned: success
- type: complex
- contains:
- rangeEnd:
- description:
- - The end of the range (exclusive).
- returned: success
- type: int
- rangeStart:
- description:
- - The start of the range (inclusive).
- returned: success
- type: int
- regexMatch:
- description:
- - 'The value of the header must match the regualar expression specified
- in regexMatch. For regular expression grammar, please see: en.cppreference.com/w/cpp/regex/ecmascript
- For matching against a port specified in the HTTP request, use
- a headerMatch with headerName set to PORT and a regular expression
- that satisfies the RFC2616 Host header''s port specifier.'
- - Only one of exactMatch, prefixMatch, suffixMatch, regexMatch,
- presentMatch or rangeMatch must be set.
- returned: success
- type: str
- suffixMatch:
- description:
- - The value of the header must end with the contents of suffixMatch.
- Only one of exactMatch, prefixMatch, suffixMatch, regexMatch,
- presentMatch or rangeMatch must be set.
- returned: success
- type: str
- ignoreCase:
- description:
- - Specifies that prefixMatch and fullPathMatch matches are case sensitive.
- - Defaults to false.
- returned: success
- type: bool
- metadataFilters:
- description:
- - Opaque filter criteria used by Loadbalancer to restrict routing configuration
- to a limited set xDS compliant clients. In their xDS requests to Loadbalancer,
- xDS clients present node metadata. If a match takes place, the relevant
- routing configuration is made available to those proxies. For each
- metadataFilter in this list, if its filterMatchCriteria is set to
- MATCH_ANY, at least one of the filterLabels must match the corresponding
- label provided in the metadata. If its filterMatchCriteria is set
- to MATCH_ALL, then all of its filterLabels must match with corresponding
- labels in the provided metadata. metadataFilters specified here can
- be overrides those specified in ForwardingRule that refers to this
- UrlMap. metadataFilters only applies to Loadbalancers that have their
- loadBalancingScheme set to INTERNAL_SELF_MANAGED.
- returned: success
- type: complex
- contains:
- filterLabels:
- description:
- - The list of label value pairs that must match labels in the provided
- metadata based on filterMatchCriteria This list must not be empty
- and can have at the most 64 entries.
- returned: success
- type: complex
- contains:
- name:
- description:
- - Name of metadata label. The name can have a maximum length
- of 1024 characters and must be at least 1 character long.
- returned: success
- type: str
- value:
- description:
- - The value of the label must match the specified value. value
- can have a maximum length of 1024 characters.
- returned: success
- type: str
- filterMatchCriteria:
- description:
- - 'Specifies how individual filterLabel matches within the list
- of filterLabels contribute towards the overall metadataFilter
- match. Supported values are: - MATCH_ANY: At least one of the
- filterLabels must have a matching label in the provided metadata.'
- - "- MATCH_ALL: All filterLabels must have matching labels in the
- provided metadata."
- returned: success
- type: str
- prefixMatch:
- description:
- - For satifying the matchRule condition, the request's path must begin
- with the specified prefixMatch. prefixMatch must begin with a /. The
- value must be between 1 and 1024 characters. Only one of prefixMatch,
- fullPathMatch or regexMatch must be specified.
- returned: success
- type: str
- queryParameterMatches:
- description:
- - Specifies a list of query parameter match criteria, all of which must
- match corresponding query parameters in the request.
- returned: success
- type: complex
- contains:
- exactMatch:
- description:
- - The queryParameterMatch matches if the value of the parameter
- exactly matches the contents of exactMatch. Only one of presentMatch,
- exactMatch and regexMatch must be set.
- returned: success
- type: str
- name:
- description:
- - The name of the query parameter to match. The query parameter
- must exist in the request, in the absence of which the request
- match fails.
- returned: success
- type: str
- presentMatch:
- description:
- - Specifies that the queryParameterMatch matches if the request
- contains the query parameter, irrespective of whether the parameter
- has a value or not. Only one of presentMatch, exactMatch and regexMatch
- must be set.
- returned: success
- type: bool
- regexMatch:
- description:
- - The queryParameterMatch matches if the value of the parameter
- matches the regular expression specified by regexMatch. For the
- regular expression grammar, please see en.cppreference.com/w/cpp/regex/ecmascript
- Only one of presentMatch, exactMatch and regexMatch must be set.
- returned: success
- type: str
- regexMatch:
- description:
- - For satifying the matchRule condition, the path of the request must
- satisfy the regular expression specified in regexMatch after removing
- any query parameters and anchor supplied with the original URL. For
- regular expression grammar please see en.cppreference.com/w/cpp/regex/ecmascript
- Only one of prefixMatch, fullPathMatch or regexMatch must be specified.
- returned: success
- type: str
- routeAction:
- description:
- - In response to a matching matchRule, the load balancer performs advanced
- routing actions like URL rewrites, header transformations, etc. prior
- to forwarding the request to the selected backend. If routeAction specifies
- any weightedBackendServices, service must not be set. Conversely if service
- is set, routeAction cannot contain any weightedBackendServices. Only one
- of routeAction or urlRedirect must be set.
- returned: success
- type: complex
- contains:
- corsPolicy:
- description:
- - The specification for allowing client side cross-origin requests.
- Please see W3C Recommendation for Cross Origin Resource Sharing .
- returned: success
- type: complex
- contains:
- allowCredentials:
- description:
- - In response to a preflight request, setting this to true indicates
- that the actual request can include user credentials. This translates
- to the Access- Control-Allow-Credentials header. Defaults to false.
- returned: success
- type: bool
- allowHeaders:
- description:
- - Specifies the content for the Access-Control-Allow-Headers header.
- returned: success
- type: list
- allowMethods:
- description:
- - Specifies the content for the Access-Control-Allow-Methods header.
- returned: success
- type: list
- allowOriginRegexes:
- description:
- - Specifies the regualar expression patterns that match allowed
- origins. For regular expression grammar please see en.cppreference.com/w/cpp/regex/ecmascript
- An origin is allowed if it matches either allow_origins or allow_origin_regex.
- returned: success
- type: list
- allowOrigins:
- description:
- - Specifies the list of origins that will be allowed to do CORS
- requests. An origin is allowed if it matches either allow_origins
- or allow_origin_regex.
- returned: success
- type: list
- disabled:
- description:
- - If true, specifies the CORS policy is disabled.
- - which indicates that the CORS policy is in effect. Defaults to
- false.
- returned: success
- type: bool
- exposeHeaders:
- description:
- - Specifies the content for the Access-Control-Expose-Headers header.
- returned: success
- type: list
- maxAge:
- description:
- - Specifies how long the results of a preflight request can be cached.
- This translates to the content for the Access-Control-Max-Age
- header.
- returned: success
- type: int
- faultInjectionPolicy:
- description:
- - The specification for fault injection introduced into traffic to test
- the resiliency of clients to backend service failure. As part of fault
- injection, when clients send requests to a backend service, delays
- can be introduced by Loadbalancer on a percentage of requests before
- sending those request to the backend service. Similarly requests from
- clients can be aborted by the Loadbalancer for a percentage of requests.
- timeout and retry_policy will be ignored by clients that are configured
- with a fault_injection_policy.
- returned: success
- type: complex
- contains:
- abort:
- description:
- - The specification for how client requests are aborted as part
- of fault injection.
- returned: success
- type: complex
- contains:
- httpStatus:
- description:
- - The HTTP status code used to abort the request. The value
- must be between 200 and 599 inclusive.
- returned: success
- type: int
- percentage:
- description:
- - The percentage of traffic (connections/operations/requests)
- which will be aborted as part of fault injection. The value
- must be between 0.0 and 100.0 inclusive.
- returned: success
- type: str
- delay:
- description:
- - The specification for how client requests are delayed as part
- of fault injection, before being sent to a backend service.
- returned: success
- type: complex
- contains:
- fixedDelay:
- description:
- - Specifies the value of the fixed delay interval.
- returned: success
- type: complex
- contains:
- nanos:
- description:
- - Span of time that's a fraction of a second at nanosecond
- resolution. Durations less than one second are represented
- with a 0 `seconds` field and a positive `nanos` field.
- Must be from 0 to 999,999,999 inclusive.
- returned: success
- type: int
- seconds:
- description:
- - Span of time at a resolution of a second. Must be from
- 0 to 315,576,000,000 inclusive.
- returned: success
- type: str
- percentage:
- description:
- - The percentage of traffic (connections/operations/requests)
- on which delay will be introduced as part of fault injection.
- The value must be between 0.0 and 100.0 inclusive.
- returned: success
- type: str
- requestMirrorPolicy:
- description:
- - Specifies the policy on how requests intended for the route's backends
- are shadowed to a separate mirrored backend service. Loadbalancer
- does not wait for responses from the shadow service. Prior to sending
- traffic to the shadow service, the host / authority header is suffixed
- with -shadow.
- returned: success
- type: complex
- contains:
- backendService:
- description:
- - The BackendService resource being mirrored to.
- returned: success
- type: dict
- retryPolicy:
- description:
- - Specifies the retry policy associated with this route.
- returned: success
- type: complex
- contains:
- numRetries:
- description:
- - Specifies the allowed number retries. This number must be > 0.
- returned: success
- type: int
- perTryTimeout:
- description:
- - Specifies a non-zero timeout per retry attempt.
- - If not specified, will use the timeout set in HttpRouteAction.
- If timeout in HttpRouteAction is not set, will use the largest
- timeout among all backend services associated with the route.
- returned: success
- type: complex
- contains:
- nanos:
- description:
- - Span of time that's a fraction of a second at nanosecond resolution.
- Durations less than one second are represented with a 0 `seconds`
- field and a positive `nanos` field. Must be from 0 to 999,999,999
- inclusive.
- returned: success
- type: int
- seconds:
- description:
- - Span of time at a resolution of a second. Must be from 0 to
- 315,576,000,000 inclusive.
- returned: success
- type: str
- retryConditions:
- description:
- - 'Specfies one or more conditions when this retry rule applies.
- Valid values are: - 5xx: Loadbalancer will attempt a retry if
- the backend service responds with any 5xx response code, or if
- the backend service does not respond at all, example: disconnects,
- reset, read timeout, connection failure, and refused streams.'
- - "- gateway-error: Similar to 5xx, but only applies to response
- codes 502, 503 or 504."
- - "- connect-failure: Loadbalancer will retry on failures connecting
- to backend services, for example due to connection timeouts."
- - "- retriable-4xx: Loadbalancer will retry for retriable 4xx response
- codes."
- - Currently the only retriable error supported is 409.
- - "- refused-stream: Loadbalancer will retry if the backend service
- resets the stream with a REFUSED_STREAM error code. This reset
- type indicates that it is safe to retry."
- - "- cancelled: Loadbalancer will retry if the gRPC status code
- in the response header is set to cancelled - deadline-exceeded:
- Loadbalancer will retry if the gRPC status code in the response
- header is set to deadline-exceeded - resource-exhausted: Loadbalancer
- will retry if the gRPC status code in the response header is set
- to resource-exhausted - unavailable: Loadbalancer will retry if
- the gRPC status code in the response header is set to unavailable
- ."
- returned: success
- type: list
- timeout:
- description:
- - Specifies the timeout for the selected route. Timeout is computed
- from the time the request is has been fully processed (i.e. end-of-stream)
- up until the response has been completely processed. Timeout includes
- all retries. If not specified, the default value is 15 seconds.
- returned: success
- type: complex
- contains:
- nanos:
- description:
- - Span of time that's a fraction of a second at nanosecond resolution.
- Durations less than one second are represented with a 0 `seconds`
- field and a positive `nanos` field. Must be from 0 to 999,999,999
- inclusive.
- returned: success
- type: int
- seconds:
- description:
- - Span of time at a resolution of a second. Must be from 0 to 315,576,000,000
- inclusive.
- returned: success
- type: str
- urlRewrite:
- description:
- - The spec to modify the URL of the request, prior to forwarding the
- request to the matched service .
- returned: success
- type: complex
- contains:
- hostRewrite:
- description:
- - Prior to forwarding the request to the selected service, the request's
- host header is replaced with contents of hostRewrite. The value
- must be between 1 and 255 characters.
- returned: success
- type: str
- pathPrefixRewrite:
- description:
- - Prior to forwarding the request to the selected backend service,
- the matching portion of the request's path is replaced by pathPrefixRewrite.
- The value must be between 1 and 1024 characters.
- returned: success
- type: str
- weightedBackendServices:
- description:
- - A list of weighted backend services to send traffic to when a route
- match occurs. The weights determine the fraction of traffic that flows
- to their corresponding backend service. If all traffic needs to go
- to a single backend service, there must be one weightedBackendService
- with weight set to a non 0 number. Once a backendService is identified
- and before forwarding the request to the backend service, advanced
- routing actions like Url rewrites and header transformations are applied
- depending on additional settings specified in this HttpRouteAction.
- returned: success
- type: complex
- contains:
- backendService:
- description:
- - The default BackendService resource. Before forwarding the request
- to backendService, the loadbalancer applies any relevant headerActions
- specified as part of this backendServiceWeight.
- returned: success
- type: dict
- headerAction:
- description:
- - Specifies changes to request and response headers that need to
- take effect for the selected backendService. headerAction specified
- here take effect before headerAction in the enclosing HttpRouteRule,
- PathMatcher and UrlMap.
- returned: success
- type: complex
- contains:
- requestHeadersToAdd:
- description:
- - Headers to add to a matching request prior to forwarding the
- request to the backendService.
- returned: success
- type: complex
- contains:
- headerName:
- description:
- - The name of the header.
- returned: success
- type: str
- headerValue:
- description:
- - The value of the header to add.
- returned: success
- type: str
- replace:
- description:
- - If false, headerValue is appended to any values that already
- exist for the header. If true, headerValue is set for
- the header, discarding any values that were set for that
- header.
- returned: success
- type: bool
- requestHeadersToRemove:
- description:
- - A list of header names for headers that need to be removed
- from the request prior to forwarding the request to the backendService.
- returned: success
- type: list
- responseHeadersToAdd:
- description:
- - Headers to add the response prior to sending the response
- back to the client.
- returned: success
- type: complex
- contains:
- headerName:
- description:
- - The name of the header.
- returned: success
- type: str
- headerValue:
- description:
- - The value of the header to add.
- returned: success
- type: str
- replace:
- description:
- - If false, headerValue is appended to any values that already
- exist for the header. If true, headerValue is set for
- the header, discarding any values that were set for that
- header.
- returned: success
- type: bool
- responseHeadersToRemove:
- description:
- - A list of header names for headers that need to be removed
- from the response prior to sending the response back to the
- client.
- returned: success
- type: list
- weight:
- description:
- - Specifies the fraction of traffic sent to backendService, computed
- as weight / (sum of all weightedBackendService weights in routeAction)
- . The selection of a backend service is determined only for new
- traffic. Once a user's request has been directed to a backendService,
- subsequent requests will be sent to the same backendService as
- determined by the BackendService's session affinity policy.
- - The value must be between 0 and 1000 .
- returned: success
- type: int
- urlRedirect:
- description:
- - When this rule is matched, the request is redirected to a URL specified
- by urlRedirect. If urlRedirect is specified, service or routeAction must
- not be set.
- returned: success
- type: complex
- contains:
- hostRedirect:
- description:
- - The host that will be used in the redirect response instead of the
- one that was supplied in the request. The value must be between 1
- and 255 characters.
- returned: success
- type: str
- httpsRedirect:
- description:
- - If set to true, the URL scheme in the redirected request is set to
- https. If set to false, the URL scheme of the redirected request will
- remain the same as that of the request. This must only be set for
- UrlMaps used in TargetHttpProxys.
- - Setting this true for TargetHttpsProxy is not permitted. Defaults
- to false.
- returned: success
- type: bool
- pathRedirect:
- description:
- - The path that will be used in the redirect response instead of the
- one that was supplied in the request. Only one of pathRedirect or
- prefixRedirect must be specified. The value must be between 1 and
- 1024 characters.
- returned: success
- type: str
- prefixRedirect:
- description:
- - The prefix that replaces the prefixMatch specified in the HttpRouteRuleMatch,
- retaining the remaining portion of the URL before redirecting the
- request.
- returned: success
- type: str
- redirectResponseCode:
- description:
- - 'The HTTP Status code to use for this RedirectAction. Supported values
- are: - MOVED_PERMANENTLY_DEFAULT, which is the default value and corresponds
- to 301. - FOUND, which corresponds to 302. - SEE_OTHER which corresponds
- to 303. - TEMPORARY_REDIRECT, which corresponds to 307. In this case,
- the request method will be retained. - PERMANENT_REDIRECT, which corresponds
- to 308. In this case, the request method will be retained.'
- returned: success
- type: str
- stripQuery:
- description:
- - If set to true, any accompanying query portion of the original URL
- is removed prior to redirecting the request. If set to false, the
- query portion of the original URL is retained. Defaults to false.
- returned: success
- type: bool
-tests:
- description:
- - The list of expected URL mapping tests. Request to update this UrlMap will succeed
- only if all of the test cases pass. You can specify a maximum of 100 tests per
- UrlMap.
- returned: success
- type: complex
- contains:
- description:
- description:
- - Description of this test case.
- returned: success
- type: str
- host:
- description:
- - Host portion of the URL.
- returned: success
- type: str
- path:
- description:
- - Path portion of the URL.
- returned: success
- type: str
- service:
- description:
- - Expected BackendService resource the given URL should be mapped to.
- returned: success
- type: dict
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- default_service=dict(type='dict'),
- description=dict(type='str'),
- header_action=dict(
- type='dict',
- options=dict(
- request_headers_to_add=dict(
- type='list',
- elements='dict',
- options=dict(
- header_name=dict(required=True, type='str'), header_value=dict(required=True, type='str'), replace=dict(required=True, type='bool')
- ),
- ),
- request_headers_to_remove=dict(type='list', elements='str'),
- response_headers_to_add=dict(
- type='list',
- elements='dict',
- options=dict(
- header_name=dict(required=True, type='str'), header_value=dict(required=True, type='str'), replace=dict(required=True, type='bool')
- ),
- ),
- response_headers_to_remove=dict(type='list', elements='str'),
- ),
- ),
- host_rules=dict(
- type='list',
- elements='dict',
- options=dict(
- description=dict(type='str'), hosts=dict(required=True, type='list', elements='str'), path_matcher=dict(required=True, type='str')
- ),
- ),
- name=dict(required=True, type='str'),
- path_matchers=dict(
- type='list',
- elements='dict',
- options=dict(
- default_service=dict(type='dict'),
- description=dict(type='str'),
- header_action=dict(
- type='dict',
- options=dict(
- request_headers_to_add=dict(
- type='list',
- elements='dict',
- options=dict(
- header_name=dict(required=True, type='str'),
- header_value=dict(required=True, type='str'),
- replace=dict(required=True, type='bool'),
- ),
- ),
- request_headers_to_remove=dict(type='list', elements='str'),
- response_headers_to_add=dict(
- type='list',
- elements='dict',
- options=dict(
- header_name=dict(required=True, type='str'),
- header_value=dict(required=True, type='str'),
- replace=dict(required=True, type='bool'),
- ),
- ),
- response_headers_to_remove=dict(type='list', elements='str'),
- ),
- ),
- name=dict(required=True, type='str'),
- path_rules=dict(
- type='list',
- elements='dict',
- options=dict(
- service=dict(type='dict'),
- paths=dict(required=True, type='list', elements='str'),
- route_action=dict(
- type='dict',
- options=dict(
- cors_policy=dict(
- type='dict',
- options=dict(
- allow_credentials=dict(type='bool'),
- allow_headers=dict(type='list', elements='str'),
- allow_methods=dict(type='list', elements='str'),
- allow_origin_regexes=dict(type='list', elements='str'),
- allow_origins=dict(type='list', elements='str'),
- disabled=dict(required=True, type='bool'),
- expose_headers=dict(type='list', elements='str'),
- max_age=dict(type='int'),
- ),
- ),
- fault_injection_policy=dict(
- type='dict',
- options=dict(
- abort=dict(
- type='dict',
- options=dict(http_status=dict(required=True, type='int'), percentage=dict(required=True, type='str')),
- ),
- delay=dict(
- type='dict',
- options=dict(
- fixed_delay=dict(
- required=True,
- type='dict',
- options=dict(nanos=dict(type='int'), seconds=dict(required=True, type='str')),
- ),
- percentage=dict(required=True, type='str'),
- ),
- ),
- ),
- ),
- request_mirror_policy=dict(type='dict', options=dict(backend_service=dict(required=True, type='dict'))),
- retry_policy=dict(
- type='dict',
- options=dict(
- num_retries=dict(type='int'),
- per_try_timeout=dict(type='dict', options=dict(nanos=dict(type='int'), seconds=dict(required=True, type='str'))),
- retry_conditions=dict(type='list', elements='str'),
- ),
- ),
- timeout=dict(type='dict', options=dict(nanos=dict(type='int'), seconds=dict(required=True, type='str'))),
- url_rewrite=dict(type='dict', options=dict(host_rewrite=dict(type='str'), path_prefix_rewrite=dict(type='str'))),
- weighted_backend_services=dict(
- type='list',
- elements='dict',
- options=dict(
- backend_service=dict(required=True, type='dict'),
- header_action=dict(
- type='dict',
- options=dict(
- request_headers_to_add=dict(
- type='list',
- elements='dict',
- options=dict(
- header_name=dict(required=True, type='str'),
- header_value=dict(required=True, type='str'),
- replace=dict(required=True, type='bool'),
- ),
- ),
- request_headers_to_remove=dict(type='list', elements='str'),
- response_headers_to_add=dict(
- type='list',
- elements='dict',
- options=dict(
- header_name=dict(required=True, type='str'),
- header_value=dict(required=True, type='str'),
- replace=dict(required=True, type='bool'),
- ),
- ),
- response_headers_to_remove=dict(type='list', elements='str'),
- ),
- ),
- weight=dict(required=True, type='int'),
- ),
- ),
- ),
- ),
- url_redirect=dict(
- type='dict',
- options=dict(
- host_redirect=dict(type='str'),
- https_redirect=dict(type='bool'),
- path_redirect=dict(type='str'),
- prefix_redirect=dict(type='str'),
- redirect_response_code=dict(type='str'),
- strip_query=dict(required=True, type='bool'),
- ),
- ),
- ),
- ),
- route_rules=dict(
- type='list',
- elements='dict',
- options=dict(
- priority=dict(required=True, type='int'),
- service=dict(type='dict'),
- header_action=dict(
- type='dict',
- options=dict(
- request_headers_to_add=dict(
- type='list',
- elements='dict',
- options=dict(
- header_name=dict(required=True, type='str'),
- header_value=dict(required=True, type='str'),
- replace=dict(required=True, type='bool'),
- ),
- ),
- request_headers_to_remove=dict(type='list', elements='str'),
- response_headers_to_add=dict(
- type='list',
- elements='dict',
- options=dict(
- header_name=dict(required=True, type='str'),
- header_value=dict(required=True, type='str'),
- replace=dict(required=True, type='bool'),
- ),
- ),
- response_headers_to_remove=dict(type='list', elements='str'),
- ),
- ),
- match_rules=dict(
- type='list',
- elements='dict',
- options=dict(
- full_path_match=dict(type='str'),
- header_matches=dict(
- type='list',
- elements='dict',
- options=dict(
- exact_match=dict(type='str'),
- header_name=dict(required=True, type='str'),
- invert_match=dict(type='bool'),
- prefix_match=dict(type='str'),
- present_match=dict(type='bool'),
- range_match=dict(
- type='dict',
- options=dict(range_end=dict(required=True, type='int'), range_start=dict(required=True, type='int')),
- ),
- regex_match=dict(type='str'),
- suffix_match=dict(type='str'),
- ),
- ),
- ignore_case=dict(type='bool'),
- metadata_filters=dict(
- type='list',
- elements='dict',
- options=dict(
- filter_labels=dict(
- required=True,
- type='list',
- elements='dict',
- options=dict(name=dict(required=True, type='str'), value=dict(required=True, type='str')),
- ),
- filter_match_criteria=dict(required=True, type='str'),
- ),
- ),
- prefix_match=dict(type='str'),
- query_parameter_matches=dict(
- type='list',
- elements='dict',
- options=dict(
- exact_match=dict(type='str'),
- name=dict(required=True, type='str'),
- present_match=dict(type='bool'),
- regex_match=dict(type='str'),
- ),
- ),
- regex_match=dict(type='str'),
- ),
- ),
- route_action=dict(
- type='dict',
- options=dict(
- cors_policy=dict(
- type='dict',
- options=dict(
- allow_credentials=dict(type='bool'),
- allow_headers=dict(type='list', elements='str'),
- allow_methods=dict(type='list', elements='str'),
- allow_origin_regexes=dict(type='list', elements='str'),
- allow_origins=dict(type='list', elements='str'),
- disabled=dict(type='bool'),
- expose_headers=dict(type='list', elements='str'),
- max_age=dict(type='int'),
- ),
- ),
- fault_injection_policy=dict(
- type='dict',
- options=dict(
- abort=dict(type='dict', options=dict(http_status=dict(type='int'), percentage=dict(type='str'))),
- delay=dict(
- type='dict',
- options=dict(
- fixed_delay=dict(
- type='dict', options=dict(nanos=dict(type='int'), seconds=dict(required=True, type='str'))
- ),
- percentage=dict(type='str'),
- ),
- ),
- ),
- ),
- request_mirror_policy=dict(type='dict', options=dict(backend_service=dict(required=True, type='dict'))),
- retry_policy=dict(
- type='dict',
- options=dict(
- num_retries=dict(required=True, type='int'),
- per_try_timeout=dict(type='dict', options=dict(nanos=dict(type='int'), seconds=dict(required=True, type='str'))),
- retry_conditions=dict(type='list', elements='str'),
- ),
- ),
- timeout=dict(type='dict', options=dict(nanos=dict(type='int'), seconds=dict(required=True, type='str'))),
- url_rewrite=dict(type='dict', options=dict(host_rewrite=dict(type='str'), path_prefix_rewrite=dict(type='str'))),
- weighted_backend_services=dict(
- type='list',
- elements='dict',
- options=dict(
- backend_service=dict(required=True, type='dict'),
- header_action=dict(
- type='dict',
- options=dict(
- request_headers_to_add=dict(
- type='list',
- elements='dict',
- options=dict(
- header_name=dict(required=True, type='str'),
- header_value=dict(required=True, type='str'),
- replace=dict(required=True, type='bool'),
- ),
- ),
- request_headers_to_remove=dict(type='list', elements='str'),
- response_headers_to_add=dict(
- type='list',
- elements='dict',
- options=dict(
- header_name=dict(required=True, type='str'),
- header_value=dict(required=True, type='str'),
- replace=dict(required=True, type='bool'),
- ),
- ),
- response_headers_to_remove=dict(type='list', elements='str'),
- ),
- ),
- weight=dict(required=True, type='int'),
- ),
- ),
- ),
- ),
- url_redirect=dict(
- type='dict',
- options=dict(
- host_redirect=dict(type='str'),
- https_redirect=dict(type='bool'),
- path_redirect=dict(type='str'),
- prefix_redirect=dict(type='str'),
- redirect_response_code=dict(type='str'),
- strip_query=dict(type='bool'),
- ),
- ),
- ),
- ),
- ),
- ),
- tests=dict(
- type='list',
- elements='dict',
- options=dict(
- description=dict(type='str'),
- host=dict(required=True, type='str'),
- path=dict(required=True, type='str'),
- service=dict(required=True, type='dict'),
- ),
- ),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#urlMap'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.put(link, resource_to_request(module)))
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#urlMap',
- u'defaultService': replace_resource_dict(module.params.get(u'default_service', {}), 'selfLink'),
- u'description': module.params.get('description'),
- u'headerAction': UrlMapHeaderaction(module.params.get('header_action', {}), module).to_request(),
- u'hostRules': UrlMapHostrulesArray(module.params.get('host_rules', []), module).to_request(),
- u'name': module.params.get('name'),
- u'pathMatchers': UrlMapPathmatchersArray(module.params.get('path_matchers', []), module).to_request(),
- u'tests': UrlMapTestsArray(module.params.get('tests', []), module).to_request(),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/urlMaps/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/urlMaps".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'defaultService': response.get(u'defaultService'),
- u'description': response.get(u'description'),
- u'id': response.get(u'id'),
- u'fingerprint': response.get(u'fingerprint'),
- u'headerAction': UrlMapHeaderaction(response.get(u'headerAction', {}), module).from_response(),
- u'hostRules': UrlMapHostrulesArray(response.get(u'hostRules', []), module).from_response(),
- u'name': module.params.get('name'),
- u'pathMatchers': UrlMapPathmatchersArray(response.get(u'pathMatchers', []), module).from_response(),
- u'tests': UrlMapTestsArray(response.get(u'tests', []), module).from_response(),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/global/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#urlMap')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-class UrlMapHeaderaction(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'requestHeadersToAdd': UrlMapRequestheaderstoaddArray(self.request.get('request_headers_to_add', []), self.module).to_request(),
- u'requestHeadersToRemove': self.request.get('request_headers_to_remove'),
- u'responseHeadersToAdd': UrlMapResponseheaderstoaddArray(self.request.get('response_headers_to_add', []), self.module).to_request(),
- u'responseHeadersToRemove': self.request.get('response_headers_to_remove'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'requestHeadersToAdd': UrlMapRequestheaderstoaddArray(self.request.get(u'requestHeadersToAdd', []), self.module).from_response(),
- u'requestHeadersToRemove': self.request.get(u'requestHeadersToRemove'),
- u'responseHeadersToAdd': UrlMapResponseheaderstoaddArray(self.request.get(u'responseHeadersToAdd', []), self.module).from_response(),
- u'responseHeadersToRemove': self.request.get(u'responseHeadersToRemove'),
- }
- )
-
-
-class UrlMapRequestheaderstoaddArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'headerName': item.get('header_name'), u'headerValue': item.get('header_value'), u'replace': item.get('replace')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'headerName': item.get(u'headerName'), u'headerValue': item.get(u'headerValue'), u'replace': item.get(u'replace')})
-
-
-class UrlMapResponseheaderstoaddArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'headerName': item.get('header_name'), u'headerValue': item.get('header_value'), u'replace': item.get('replace')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'headerName': item.get(u'headerName'), u'headerValue': item.get(u'headerValue'), u'replace': item.get(u'replace')})
-
-
-class UrlMapHostrulesArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'description': item.get('description'), u'hosts': item.get('hosts'), u'pathMatcher': item.get('path_matcher')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'description': item.get(u'description'), u'hosts': item.get(u'hosts'), u'pathMatcher': item.get(u'pathMatcher')})
-
-
-class UrlMapPathmatchersArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict(
- {
- u'defaultService': replace_resource_dict(item.get(u'default_service', {}), 'selfLink'),
- u'description': item.get('description'),
- u'headerAction': UrlMapHeaderaction(item.get('header_action', {}), self.module).to_request(),
- u'name': item.get('name'),
- u'pathRules': UrlMapPathrulesArray(item.get('path_rules', []), self.module).to_request(),
- u'routeRules': UrlMapRouterulesArray(item.get('route_rules', []), self.module).to_request(),
- }
- )
-
- def _response_from_item(self, item):
- return remove_nones_from_dict(
- {
- u'defaultService': item.get(u'defaultService'),
- u'description': item.get(u'description'),
- u'headerAction': UrlMapHeaderaction(item.get(u'headerAction', {}), self.module).from_response(),
- u'name': item.get(u'name'),
- u'pathRules': UrlMapPathrulesArray(item.get(u'pathRules', []), self.module).from_response(),
- u'routeRules': UrlMapRouterulesArray(item.get(u'routeRules', []), self.module).from_response(),
- }
- )
-
-
-class UrlMapHeaderaction(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'requestHeadersToAdd': UrlMapRequestheaderstoaddArray(self.request.get('request_headers_to_add', []), self.module).to_request(),
- u'requestHeadersToRemove': self.request.get('request_headers_to_remove'),
- u'responseHeadersToAdd': UrlMapResponseheaderstoaddArray(self.request.get('response_headers_to_add', []), self.module).to_request(),
- u'responseHeadersToRemove': self.request.get('response_headers_to_remove'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'requestHeadersToAdd': UrlMapRequestheaderstoaddArray(self.request.get(u'requestHeadersToAdd', []), self.module).from_response(),
- u'requestHeadersToRemove': self.request.get(u'requestHeadersToRemove'),
- u'responseHeadersToAdd': UrlMapResponseheaderstoaddArray(self.request.get(u'responseHeadersToAdd', []), self.module).from_response(),
- u'responseHeadersToRemove': self.request.get(u'responseHeadersToRemove'),
- }
- )
-
-
-class UrlMapRequestheaderstoaddArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'headerName': item.get('header_name'), u'headerValue': item.get('header_value'), u'replace': item.get('replace')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'headerName': item.get(u'headerName'), u'headerValue': item.get(u'headerValue'), u'replace': item.get(u'replace')})
-
-
-class UrlMapResponseheaderstoaddArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'headerName': item.get('header_name'), u'headerValue': item.get('header_value'), u'replace': item.get('replace')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'headerName': item.get(u'headerName'), u'headerValue': item.get(u'headerValue'), u'replace': item.get(u'replace')})
-
-
-class UrlMapPathrulesArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict(
- {
- u'service': replace_resource_dict(item.get(u'service', {}), 'selfLink'),
- u'paths': item.get('paths'),
- u'routeAction': UrlMapRouteaction(item.get('route_action', {}), self.module).to_request(),
- u'urlRedirect': UrlMapUrlredirect(item.get('url_redirect', {}), self.module).to_request(),
- }
- )
-
- def _response_from_item(self, item):
- return remove_nones_from_dict(
- {
- u'service': item.get(u'service'),
- u'paths': item.get(u'paths'),
- u'routeAction': UrlMapRouteaction(item.get(u'routeAction', {}), self.module).from_response(),
- u'urlRedirect': UrlMapUrlredirect(item.get(u'urlRedirect', {}), self.module).from_response(),
- }
- )
-
-
-class UrlMapRouteaction(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'corsPolicy': UrlMapCorspolicy(self.request.get('cors_policy', {}), self.module).to_request(),
- u'faultInjectionPolicy': UrlMapFaultinjectionpolicy(self.request.get('fault_injection_policy', {}), self.module).to_request(),
- u'requestMirrorPolicy': UrlMapRequestmirrorpolicy(self.request.get('request_mirror_policy', {}), self.module).to_request(),
- u'retryPolicy': UrlMapRetrypolicy(self.request.get('retry_policy', {}), self.module).to_request(),
- u'timeout': UrlMapTimeout(self.request.get('timeout', {}), self.module).to_request(),
- u'urlRewrite': UrlMapUrlrewrite(self.request.get('url_rewrite', {}), self.module).to_request(),
- u'weightedBackendServices': UrlMapWeightedbackendservicesArray(self.request.get('weighted_backend_services', []), self.module).to_request(),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'corsPolicy': UrlMapCorspolicy(self.request.get(u'corsPolicy', {}), self.module).from_response(),
- u'faultInjectionPolicy': UrlMapFaultinjectionpolicy(self.request.get(u'faultInjectionPolicy', {}), self.module).from_response(),
- u'requestMirrorPolicy': UrlMapRequestmirrorpolicy(self.request.get(u'requestMirrorPolicy', {}), self.module).from_response(),
- u'retryPolicy': UrlMapRetrypolicy(self.request.get(u'retryPolicy', {}), self.module).from_response(),
- u'timeout': UrlMapTimeout(self.request.get(u'timeout', {}), self.module).from_response(),
- u'urlRewrite': UrlMapUrlrewrite(self.request.get(u'urlRewrite', {}), self.module).from_response(),
- u'weightedBackendServices': UrlMapWeightedbackendservicesArray(self.request.get(u'weightedBackendServices', []), self.module).from_response(),
- }
- )
-
-
-class UrlMapCorspolicy(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'allowCredentials': self.request.get('allow_credentials'),
- u'allowHeaders': self.request.get('allow_headers'),
- u'allowMethods': self.request.get('allow_methods'),
- u'allowOriginRegexes': self.request.get('allow_origin_regexes'),
- u'allowOrigins': self.request.get('allow_origins'),
- u'disabled': self.request.get('disabled'),
- u'exposeHeaders': self.request.get('expose_headers'),
- u'maxAge': self.request.get('max_age'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'allowCredentials': self.request.get(u'allowCredentials'),
- u'allowHeaders': self.request.get(u'allowHeaders'),
- u'allowMethods': self.request.get(u'allowMethods'),
- u'allowOriginRegexes': self.request.get(u'allowOriginRegexes'),
- u'allowOrigins': self.request.get(u'allowOrigins'),
- u'disabled': self.request.get(u'disabled'),
- u'exposeHeaders': self.request.get(u'exposeHeaders'),
- u'maxAge': self.request.get(u'maxAge'),
- }
- )
-
-
-class UrlMapFaultinjectionpolicy(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'abort': UrlMapAbort(self.request.get('abort', {}), self.module).to_request(),
- u'delay': UrlMapDelay(self.request.get('delay', {}), self.module).to_request(),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'abort': UrlMapAbort(self.request.get(u'abort', {}), self.module).from_response(),
- u'delay': UrlMapDelay(self.request.get(u'delay', {}), self.module).from_response(),
- }
- )
-
-
-class UrlMapAbort(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'httpStatus': self.request.get('http_status'), u'percentage': self.request.get('percentage')})
-
- def from_response(self):
- return remove_nones_from_dict({u'httpStatus': self.request.get(u'httpStatus'), u'percentage': self.request.get(u'percentage')})
-
-
-class UrlMapDelay(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {u'fixedDelay': UrlMapFixeddelay(self.request.get('fixed_delay', {}), self.module).to_request(), u'percentage': self.request.get('percentage')}
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {u'fixedDelay': UrlMapFixeddelay(self.request.get(u'fixedDelay', {}), self.module).from_response(), u'percentage': self.request.get(u'percentage')}
- )
-
-
-class UrlMapFixeddelay(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'nanos': self.request.get('nanos'), u'seconds': self.request.get('seconds')})
-
- def from_response(self):
- return remove_nones_from_dict({u'nanos': self.request.get(u'nanos'), u'seconds': self.request.get(u'seconds')})
-
-
-class UrlMapRequestmirrorpolicy(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'backendService': replace_resource_dict(self.request.get(u'backend_service', {}), 'selfLink')})
-
- def from_response(self):
- return remove_nones_from_dict({u'backendService': self.request.get(u'backendService')})
-
-
-class UrlMapRetrypolicy(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'numRetries': self.request.get('num_retries'),
- u'perTryTimeout': UrlMapPertrytimeout(self.request.get('per_try_timeout', {}), self.module).to_request(),
- u'retryConditions': self.request.get('retry_conditions'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'numRetries': self.request.get(u'numRetries'),
- u'perTryTimeout': UrlMapPertrytimeout(self.request.get(u'perTryTimeout', {}), self.module).from_response(),
- u'retryConditions': self.request.get(u'retryConditions'),
- }
- )
-
-
-class UrlMapPertrytimeout(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'nanos': self.request.get('nanos'), u'seconds': self.request.get('seconds')})
-
- def from_response(self):
- return remove_nones_from_dict({u'nanos': self.request.get(u'nanos'), u'seconds': self.request.get(u'seconds')})
-
-
-class UrlMapTimeout(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'nanos': self.request.get('nanos'), u'seconds': self.request.get('seconds')})
-
- def from_response(self):
- return remove_nones_from_dict({u'nanos': self.request.get(u'nanos'), u'seconds': self.request.get(u'seconds')})
-
-
-class UrlMapUrlrewrite(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'hostRewrite': self.request.get('host_rewrite'), u'pathPrefixRewrite': self.request.get('path_prefix_rewrite')})
-
- def from_response(self):
- return remove_nones_from_dict({u'hostRewrite': self.request.get(u'hostRewrite'), u'pathPrefixRewrite': self.request.get(u'pathPrefixRewrite')})
-
-
-class UrlMapWeightedbackendservicesArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict(
- {
- u'backendService': replace_resource_dict(item.get(u'backend_service', {}), 'selfLink'),
- u'headerAction': UrlMapHeaderaction(item.get('header_action', {}), self.module).to_request(),
- u'weight': item.get('weight'),
- }
- )
-
- def _response_from_item(self, item):
- return remove_nones_from_dict(
- {
- u'backendService': item.get(u'backendService'),
- u'headerAction': UrlMapHeaderaction(item.get(u'headerAction', {}), self.module).from_response(),
- u'weight': item.get(u'weight'),
- }
- )
-
-
-class UrlMapHeaderaction(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'requestHeadersToAdd': UrlMapRequestheaderstoaddArray(self.request.get('request_headers_to_add', []), self.module).to_request(),
- u'requestHeadersToRemove': self.request.get('request_headers_to_remove'),
- u'responseHeadersToAdd': UrlMapResponseheaderstoaddArray(self.request.get('response_headers_to_add', []), self.module).to_request(),
- u'responseHeadersToRemove': self.request.get('response_headers_to_remove'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'requestHeadersToAdd': UrlMapRequestheaderstoaddArray(self.request.get(u'requestHeadersToAdd', []), self.module).from_response(),
- u'requestHeadersToRemove': self.request.get(u'requestHeadersToRemove'),
- u'responseHeadersToAdd': UrlMapResponseheaderstoaddArray(self.request.get(u'responseHeadersToAdd', []), self.module).from_response(),
- u'responseHeadersToRemove': self.request.get(u'responseHeadersToRemove'),
- }
- )
-
-
-class UrlMapRequestheaderstoaddArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'headerName': item.get('header_name'), u'headerValue': item.get('header_value'), u'replace': item.get('replace')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'headerName': item.get(u'headerName'), u'headerValue': item.get(u'headerValue'), u'replace': item.get(u'replace')})
-
-
-class UrlMapResponseheaderstoaddArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'headerName': item.get('header_name'), u'headerValue': item.get('header_value'), u'replace': item.get('replace')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'headerName': item.get(u'headerName'), u'headerValue': item.get(u'headerValue'), u'replace': item.get(u'replace')})
-
-
-class UrlMapUrlredirect(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'hostRedirect': self.request.get('host_redirect'),
- u'httpsRedirect': self.request.get('https_redirect'),
- u'pathRedirect': self.request.get('path_redirect'),
- u'prefixRedirect': self.request.get('prefix_redirect'),
- u'redirectResponseCode': self.request.get('redirect_response_code'),
- u'stripQuery': self.request.get('strip_query'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'hostRedirect': self.request.get(u'hostRedirect'),
- u'httpsRedirect': self.request.get(u'httpsRedirect'),
- u'pathRedirect': self.request.get(u'pathRedirect'),
- u'prefixRedirect': self.request.get(u'prefixRedirect'),
- u'redirectResponseCode': self.request.get(u'redirectResponseCode'),
- u'stripQuery': self.request.get(u'stripQuery'),
- }
- )
-
-
-class UrlMapRouterulesArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict(
- {
- u'priority': item.get('priority'),
- u'service': replace_resource_dict(item.get(u'service', {}), 'selfLink'),
- u'headerAction': UrlMapHeaderaction(item.get('header_action', {}), self.module).to_request(),
- u'matchRules': UrlMapMatchrulesArray(item.get('match_rules', []), self.module).to_request(),
- u'routeAction': UrlMapRouteaction(item.get('route_action', {}), self.module).to_request(),
- u'urlRedirect': UrlMapUrlredirect(item.get('url_redirect', {}), self.module).to_request(),
- }
- )
-
- def _response_from_item(self, item):
- return remove_nones_from_dict(
- {
- u'priority': item.get(u'priority'),
- u'service': item.get(u'service'),
- u'headerAction': UrlMapHeaderaction(item.get(u'headerAction', {}), self.module).from_response(),
- u'matchRules': UrlMapMatchrulesArray(item.get(u'matchRules', []), self.module).from_response(),
- u'routeAction': UrlMapRouteaction(item.get(u'routeAction', {}), self.module).from_response(),
- u'urlRedirect': UrlMapUrlredirect(item.get(u'urlRedirect', {}), self.module).from_response(),
- }
- )
-
-
-class UrlMapHeaderaction(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'requestHeadersToAdd': UrlMapRequestheaderstoaddArray(self.request.get('request_headers_to_add', []), self.module).to_request(),
- u'requestHeadersToRemove': self.request.get('request_headers_to_remove'),
- u'responseHeadersToAdd': UrlMapResponseheaderstoaddArray(self.request.get('response_headers_to_add', []), self.module).to_request(),
- u'responseHeadersToRemove': self.request.get('response_headers_to_remove'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'requestHeadersToAdd': UrlMapRequestheaderstoaddArray(self.request.get(u'requestHeadersToAdd', []), self.module).from_response(),
- u'requestHeadersToRemove': self.request.get(u'requestHeadersToRemove'),
- u'responseHeadersToAdd': UrlMapResponseheaderstoaddArray(self.request.get(u'responseHeadersToAdd', []), self.module).from_response(),
- u'responseHeadersToRemove': self.request.get(u'responseHeadersToRemove'),
- }
- )
-
-
-class UrlMapRequestheaderstoaddArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'headerName': item.get('header_name'), u'headerValue': item.get('header_value'), u'replace': item.get('replace')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'headerName': item.get(u'headerName'), u'headerValue': item.get(u'headerValue'), u'replace': item.get(u'replace')})
-
-
-class UrlMapResponseheaderstoaddArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'headerName': item.get('header_name'), u'headerValue': item.get('header_value'), u'replace': item.get('replace')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'headerName': item.get(u'headerName'), u'headerValue': item.get(u'headerValue'), u'replace': item.get(u'replace')})
-
-
-class UrlMapMatchrulesArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict(
- {
- u'fullPathMatch': item.get('full_path_match'),
- u'headerMatches': UrlMapHeadermatchesArray(item.get('header_matches', []), self.module).to_request(),
- u'ignoreCase': item.get('ignore_case'),
- u'metadataFilters': UrlMapMetadatafiltersArray(item.get('metadata_filters', []), self.module).to_request(),
- u'prefixMatch': item.get('prefix_match'),
- u'queryParameterMatches': UrlMapQueryparametermatchesArray(item.get('query_parameter_matches', []), self.module).to_request(),
- u'regexMatch': item.get('regex_match'),
- }
- )
-
- def _response_from_item(self, item):
- return remove_nones_from_dict(
- {
- u'fullPathMatch': item.get(u'fullPathMatch'),
- u'headerMatches': UrlMapHeadermatchesArray(item.get(u'headerMatches', []), self.module).from_response(),
- u'ignoreCase': item.get(u'ignoreCase'),
- u'metadataFilters': UrlMapMetadatafiltersArray(item.get(u'metadataFilters', []), self.module).from_response(),
- u'prefixMatch': item.get(u'prefixMatch'),
- u'queryParameterMatches': UrlMapQueryparametermatchesArray(item.get(u'queryParameterMatches', []), self.module).from_response(),
- u'regexMatch': item.get(u'regexMatch'),
- }
- )
-
-
-class UrlMapHeadermatchesArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict(
- {
- u'exactMatch': item.get('exact_match'),
- u'headerName': item.get('header_name'),
- u'invertMatch': item.get('invert_match'),
- u'prefixMatch': item.get('prefix_match'),
- u'presentMatch': item.get('present_match'),
- u'rangeMatch': UrlMapRangematch(item.get('range_match', {}), self.module).to_request(),
- u'regexMatch': item.get('regex_match'),
- u'suffixMatch': item.get('suffix_match'),
- }
- )
-
- def _response_from_item(self, item):
- return remove_nones_from_dict(
- {
- u'exactMatch': item.get(u'exactMatch'),
- u'headerName': item.get(u'headerName'),
- u'invertMatch': item.get(u'invertMatch'),
- u'prefixMatch': item.get(u'prefixMatch'),
- u'presentMatch': item.get(u'presentMatch'),
- u'rangeMatch': UrlMapRangematch(item.get(u'rangeMatch', {}), self.module).from_response(),
- u'regexMatch': item.get(u'regexMatch'),
- u'suffixMatch': item.get(u'suffixMatch'),
- }
- )
-
-
-class UrlMapRangematch(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'rangeEnd': self.request.get('range_end'), u'rangeStart': self.request.get('range_start')})
-
- def from_response(self):
- return remove_nones_from_dict({u'rangeEnd': self.request.get(u'rangeEnd'), u'rangeStart': self.request.get(u'rangeStart')})
-
-
-class UrlMapMetadatafiltersArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict(
- {
- u'filterLabels': UrlMapFilterlabelsArray(item.get('filter_labels', []), self.module).to_request(),
- u'filterMatchCriteria': item.get('filter_match_criteria'),
- }
- )
-
- def _response_from_item(self, item):
- return remove_nones_from_dict(
- {
- u'filterLabels': UrlMapFilterlabelsArray(item.get(u'filterLabels', []), self.module).from_response(),
- u'filterMatchCriteria': item.get(u'filterMatchCriteria'),
- }
- )
-
-
-class UrlMapFilterlabelsArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'name': item.get('name'), u'value': item.get('value')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'name': item.get(u'name'), u'value': item.get(u'value')})
-
-
-class UrlMapQueryparametermatchesArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict(
- {
- u'exactMatch': item.get('exact_match'),
- u'name': item.get('name'),
- u'presentMatch': item.get('present_match'),
- u'regexMatch': item.get('regex_match'),
- }
- )
-
- def _response_from_item(self, item):
- return remove_nones_from_dict(
- {
- u'exactMatch': item.get(u'exactMatch'),
- u'name': item.get(u'name'),
- u'presentMatch': item.get(u'presentMatch'),
- u'regexMatch': item.get(u'regexMatch'),
- }
- )
-
-
-class UrlMapRouteaction(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'corsPolicy': UrlMapCorspolicy(self.request.get('cors_policy', {}), self.module).to_request(),
- u'faultInjectionPolicy': UrlMapFaultinjectionpolicy(self.request.get('fault_injection_policy', {}), self.module).to_request(),
- u'requestMirrorPolicy': UrlMapRequestmirrorpolicy(self.request.get('request_mirror_policy', {}), self.module).to_request(),
- u'retryPolicy': UrlMapRetrypolicy(self.request.get('retry_policy', {}), self.module).to_request(),
- u'timeout': UrlMapTimeout(self.request.get('timeout', {}), self.module).to_request(),
- u'urlRewrite': UrlMapUrlrewrite(self.request.get('url_rewrite', {}), self.module).to_request(),
- u'weightedBackendServices': UrlMapWeightedbackendservicesArray(self.request.get('weighted_backend_services', []), self.module).to_request(),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'corsPolicy': UrlMapCorspolicy(self.request.get(u'corsPolicy', {}), self.module).from_response(),
- u'faultInjectionPolicy': UrlMapFaultinjectionpolicy(self.request.get(u'faultInjectionPolicy', {}), self.module).from_response(),
- u'requestMirrorPolicy': UrlMapRequestmirrorpolicy(self.request.get(u'requestMirrorPolicy', {}), self.module).from_response(),
- u'retryPolicy': UrlMapRetrypolicy(self.request.get(u'retryPolicy', {}), self.module).from_response(),
- u'timeout': UrlMapTimeout(self.request.get(u'timeout', {}), self.module).from_response(),
- u'urlRewrite': UrlMapUrlrewrite(self.request.get(u'urlRewrite', {}), self.module).from_response(),
- u'weightedBackendServices': UrlMapWeightedbackendservicesArray(self.request.get(u'weightedBackendServices', []), self.module).from_response(),
- }
- )
-
-
-class UrlMapCorspolicy(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'allowCredentials': self.request.get('allow_credentials'),
- u'allowHeaders': self.request.get('allow_headers'),
- u'allowMethods': self.request.get('allow_methods'),
- u'allowOriginRegexes': self.request.get('allow_origin_regexes'),
- u'allowOrigins': self.request.get('allow_origins'),
- u'disabled': self.request.get('disabled'),
- u'exposeHeaders': self.request.get('expose_headers'),
- u'maxAge': self.request.get('max_age'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'allowCredentials': self.request.get(u'allowCredentials'),
- u'allowHeaders': self.request.get(u'allowHeaders'),
- u'allowMethods': self.request.get(u'allowMethods'),
- u'allowOriginRegexes': self.request.get(u'allowOriginRegexes'),
- u'allowOrigins': self.request.get(u'allowOrigins'),
- u'disabled': self.request.get(u'disabled'),
- u'exposeHeaders': self.request.get(u'exposeHeaders'),
- u'maxAge': self.request.get(u'maxAge'),
- }
- )
-
-
-class UrlMapFaultinjectionpolicy(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'abort': UrlMapAbort(self.request.get('abort', {}), self.module).to_request(),
- u'delay': UrlMapDelay(self.request.get('delay', {}), self.module).to_request(),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'abort': UrlMapAbort(self.request.get(u'abort', {}), self.module).from_response(),
- u'delay': UrlMapDelay(self.request.get(u'delay', {}), self.module).from_response(),
- }
- )
-
-
-class UrlMapAbort(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'httpStatus': self.request.get('http_status'), u'percentage': self.request.get('percentage')})
-
- def from_response(self):
- return remove_nones_from_dict({u'httpStatus': self.request.get(u'httpStatus'), u'percentage': self.request.get(u'percentage')})
-
-
-class UrlMapDelay(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {u'fixedDelay': UrlMapFixeddelay(self.request.get('fixed_delay', {}), self.module).to_request(), u'percentage': self.request.get('percentage')}
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {u'fixedDelay': UrlMapFixeddelay(self.request.get(u'fixedDelay', {}), self.module).from_response(), u'percentage': self.request.get(u'percentage')}
- )
-
-
-class UrlMapFixeddelay(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'nanos': self.request.get('nanos'), u'seconds': self.request.get('seconds')})
-
- def from_response(self):
- return remove_nones_from_dict({u'nanos': self.request.get(u'nanos'), u'seconds': self.request.get(u'seconds')})
-
-
-class UrlMapRequestmirrorpolicy(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'backendService': replace_resource_dict(self.request.get(u'backend_service', {}), 'selfLink')})
-
- def from_response(self):
- return remove_nones_from_dict({u'backendService': self.request.get(u'backendService')})
-
-
-class UrlMapRetrypolicy(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'numRetries': self.request.get('num_retries'),
- u'perTryTimeout': UrlMapPertrytimeout(self.request.get('per_try_timeout', {}), self.module).to_request(),
- u'retryConditions': self.request.get('retry_conditions'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'numRetries': self.request.get(u'numRetries'),
- u'perTryTimeout': UrlMapPertrytimeout(self.request.get(u'perTryTimeout', {}), self.module).from_response(),
- u'retryConditions': self.request.get(u'retryConditions'),
- }
- )
-
-
-class UrlMapPertrytimeout(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'nanos': self.request.get('nanos'), u'seconds': self.request.get('seconds')})
-
- def from_response(self):
- return remove_nones_from_dict({u'nanos': self.request.get(u'nanos'), u'seconds': self.request.get(u'seconds')})
-
-
-class UrlMapTimeout(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'nanos': self.request.get('nanos'), u'seconds': self.request.get('seconds')})
-
- def from_response(self):
- return remove_nones_from_dict({u'nanos': self.request.get(u'nanos'), u'seconds': self.request.get(u'seconds')})
-
-
-class UrlMapUrlrewrite(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'hostRewrite': self.request.get('host_rewrite'), u'pathPrefixRewrite': self.request.get('path_prefix_rewrite')})
-
- def from_response(self):
- return remove_nones_from_dict({u'hostRewrite': self.request.get(u'hostRewrite'), u'pathPrefixRewrite': self.request.get(u'pathPrefixRewrite')})
-
-
-class UrlMapWeightedbackendservicesArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict(
- {
- u'backendService': replace_resource_dict(item.get(u'backend_service', {}), 'selfLink'),
- u'headerAction': UrlMapHeaderaction(item.get('header_action', {}), self.module).to_request(),
- u'weight': item.get('weight'),
- }
- )
-
- def _response_from_item(self, item):
- return remove_nones_from_dict(
- {
- u'backendService': item.get(u'backendService'),
- u'headerAction': UrlMapHeaderaction(item.get(u'headerAction', {}), self.module).from_response(),
- u'weight': item.get(u'weight'),
- }
- )
-
-
-class UrlMapHeaderaction(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'requestHeadersToAdd': UrlMapRequestheaderstoaddArray(self.request.get('request_headers_to_add', []), self.module).to_request(),
- u'requestHeadersToRemove': self.request.get('request_headers_to_remove'),
- u'responseHeadersToAdd': UrlMapResponseheaderstoaddArray(self.request.get('response_headers_to_add', []), self.module).to_request(),
- u'responseHeadersToRemove': self.request.get('response_headers_to_remove'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'requestHeadersToAdd': UrlMapRequestheaderstoaddArray(self.request.get(u'requestHeadersToAdd', []), self.module).from_response(),
- u'requestHeadersToRemove': self.request.get(u'requestHeadersToRemove'),
- u'responseHeadersToAdd': UrlMapResponseheaderstoaddArray(self.request.get(u'responseHeadersToAdd', []), self.module).from_response(),
- u'responseHeadersToRemove': self.request.get(u'responseHeadersToRemove'),
- }
- )
-
-
-class UrlMapRequestheaderstoaddArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'headerName': item.get('header_name'), u'headerValue': item.get('header_value'), u'replace': item.get('replace')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'headerName': item.get(u'headerName'), u'headerValue': item.get(u'headerValue'), u'replace': item.get(u'replace')})
-
-
-class UrlMapResponseheaderstoaddArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'headerName': item.get('header_name'), u'headerValue': item.get('header_value'), u'replace': item.get('replace')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'headerName': item.get(u'headerName'), u'headerValue': item.get(u'headerValue'), u'replace': item.get(u'replace')})
-
-
-class UrlMapUrlredirect(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'hostRedirect': self.request.get('host_redirect'),
- u'httpsRedirect': self.request.get('https_redirect'),
- u'pathRedirect': self.request.get('path_redirect'),
- u'prefixRedirect': self.request.get('prefix_redirect'),
- u'redirectResponseCode': self.request.get('redirect_response_code'),
- u'stripQuery': self.request.get('strip_query'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'hostRedirect': self.request.get(u'hostRedirect'),
- u'httpsRedirect': self.request.get(u'httpsRedirect'),
- u'pathRedirect': self.request.get(u'pathRedirect'),
- u'prefixRedirect': self.request.get(u'prefixRedirect'),
- u'redirectResponseCode': self.request.get(u'redirectResponseCode'),
- u'stripQuery': self.request.get(u'stripQuery'),
- }
- )
-
-
-class UrlMapTestsArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict(
- {
- u'description': item.get('description'),
- u'host': item.get('host'),
- u'path': item.get('path'),
- u'service': replace_resource_dict(item.get(u'service', {}), 'selfLink'),
- }
- )
-
- def _response_from_item(self, item):
- return remove_nones_from_dict(
- {u'description': item.get(u'description'), u'host': item.get(u'host'), u'path': item.get(u'path'), u'service': item.get(u'service')}
- )
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_url_map_info.py b/lib/ansible/modules/cloud/google/gcp_compute_url_map_info.py
deleted file mode 100644
index f1965b33c5..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_url_map_info.py
+++ /dev/null
@@ -1,1659 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_url_map_info
-description:
-- Gather info for GCP UrlMap
-short_description: Gather info for GCP UrlMap
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on an URL map
- gcp_compute_url_map_info:
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- defaultService:
- description:
- - The BackendService resource to which traffic is directed if none of the hostRules
- match. If defaultRouteAction is additionally specified, advanced routing actions
- like URL Rewrites, etc. take effect prior to sending the request to the backend.
- However, if defaultService is specified, defaultRouteAction cannot contain
- any weightedBackendServices. Conversely, if routeAction specifies any weightedBackendServices,
- service must not be specified. Only one of defaultService, defaultUrlRedirect
- or defaultRouteAction.weightedBackendService must be set.
- returned: success
- type: dict
- description:
- description:
- - An optional description of this resource. Provide this property when you create
- the resource.
- returned: success
- type: str
- id:
- description:
- - The unique identifier for the resource.
- returned: success
- type: int
- fingerprint:
- description:
- - Fingerprint of this resource. A hash of the contents stored in this object.
- This field is used in optimistic locking.
- returned: success
- type: str
- headerAction:
- description:
- - Specifies changes to request and response headers that need to take effect
- for the selected backendService. The headerAction specified here take effect
- after headerAction specified under pathMatcher.
- returned: success
- type: complex
- contains:
- requestHeadersToAdd:
- description:
- - Headers to add to a matching request prior to forwarding the request to
- the backendService.
- returned: success
- type: complex
- contains:
- headerName:
- description:
- - The name of the header.
- returned: success
- type: str
- headerValue:
- description:
- - The value of the header to add.
- returned: success
- type: str
- replace:
- description:
- - If false, headerValue is appended to any values that already exist
- for the header. If true, headerValue is set for the header, discarding
- any values that were set for that header.
- returned: success
- type: bool
- requestHeadersToRemove:
- description:
- - A list of header names for headers that need to be removed from the request
- prior to forwarding the request to the backendService.
- returned: success
- type: list
- responseHeadersToAdd:
- description:
- - Headers to add the response prior to sending the response back to the
- client.
- returned: success
- type: complex
- contains:
- headerName:
- description:
- - The name of the header.
- returned: success
- type: str
- headerValue:
- description:
- - The value of the header to add.
- returned: success
- type: str
- replace:
- description:
- - If false, headerValue is appended to any values that already exist
- for the header. If true, headerValue is set for the header, discarding
- any values that were set for that header.
- returned: success
- type: bool
- responseHeadersToRemove:
- description:
- - A list of header names for headers that need to be removed from the response
- prior to sending the response back to the client.
- returned: success
- type: list
- hostRules:
- description:
- - The list of HostRules to use against the URL.
- returned: success
- type: complex
- contains:
- description:
- description:
- - An optional description of this resource. Provide this property when you
- create the resource.
- returned: success
- type: str
- hosts:
- description:
- - The list of host patterns to match. They must be valid hostnames, except
- * will match any string of ([a-z0-9-.]*). In that case, * must be the
- first character and must be followed in the pattern by either - or .
- returned: success
- type: list
- pathMatcher:
- description:
- - The name of the PathMatcher to use to match the path portion of the URL
- if the hostRule matches the URL's host portion.
- returned: success
- type: str
- name:
- description:
- - Name of the resource. Provided by the client when the resource is created.
- The name must be 1-63 characters long, and comply with RFC1035. Specifically,
- the name must be 1-63 characters long and match the regular expression `[a-z]([-a-z0-9]*[a-z0-9])?`
- which means the first character must be a lowercase letter, and all following
- characters must be a dash, lowercase letter, or digit, except the last character,
- which cannot be a dash.
- returned: success
- type: str
- pathMatchers:
- description:
- - The list of named PathMatchers to use against the URL.
- returned: success
- type: complex
- contains:
- defaultService:
- description:
- - 'The BackendService resource. This will be used if none of the pathRules
- or routeRules defined by this PathMatcher are matched. For example, the
- following are all valid URLs to a BackendService resource: - U(https://www.googleapis.com/compute/v1/projects/project/global/backendServices/backen)
- dService - compute/v1/projects/project/global/backendServices/backendService
- - global/backendServices/backendService If defaultRouteAction is additionally
- specified, advanced routing actions like URL Rewrites, etc. take effect
- prior to sending the request to the backend. However, if defaultService
- is specified, defaultRouteAction cannot contain any weightedBackendServices.
- Conversely, if defaultRouteAction specifies any weightedBackendServices,
- defaultService must not be specified. Only one of defaultService, defaultUrlRedirect
- or defaultRouteAction.weightedBackendService must be set. Authorization
- requires one or more of the following Google IAM permissions on the specified
- resource default_service: - compute.backendBuckets.use - compute.backendServices.use
- .'
- returned: success
- type: dict
- description:
- description:
- - An optional description of this resource. Provide this property when you
- create the resource.
- returned: success
- type: str
- headerAction:
- description:
- - Specifies changes to request and response headers that need to take effect
- for the selected backendService. HeaderAction specified here are applied
- after the matching HttpRouteRule HeaderAction and before the HeaderAction
- in the UrlMap .
- returned: success
- type: complex
- contains:
- requestHeadersToAdd:
- description:
- - Headers to add to a matching request prior to forwarding the request
- to the backendService.
- returned: success
- type: complex
- contains:
- headerName:
- description:
- - The name of the header.
- returned: success
- type: str
- headerValue:
- description:
- - The value of the header to add.
- returned: success
- type: str
- replace:
- description:
- - If false, headerValue is appended to any values that already exist
- for the header. If true, headerValue is set for the header, discarding
- any values that were set for that header.
- returned: success
- type: bool
- requestHeadersToRemove:
- description:
- - A list of header names for headers that need to be removed from the
- request prior to forwarding the request to the backendService.
- returned: success
- type: list
- responseHeadersToAdd:
- description:
- - Headers to add the response prior to sending the response back to
- the client.
- returned: success
- type: complex
- contains:
- headerName:
- description:
- - The name of the header.
- returned: success
- type: str
- headerValue:
- description:
- - The value of the header to add.
- returned: success
- type: str
- replace:
- description:
- - If false, headerValue is appended to any values that already exist
- for the header. If true, headerValue is set for the header, discarding
- any values that were set for that header.
- returned: success
- type: bool
- responseHeadersToRemove:
- description:
- - A list of header names for headers that need to be removed from the
- response prior to sending the response back to the client.
- returned: success
- type: list
- name:
- description:
- - The name to which this PathMatcher is referred by the HostRule.
- returned: success
- type: str
- pathRules:
- description:
- - 'The list of path rules. Use this list instead of routeRules when routing
- based on simple path matching is all that''s required. The order by which
- path rules are specified does not matter. Matches are always done on the
- longest-path-first basis. For example: a pathRule with a path /a/b/c/*
- will match before /a/b/* irrespective of the order in which those paths
- appear in this list. Within a given pathMatcher, only one of pathRules
- or routeRules must be set.'
- returned: success
- type: complex
- contains:
- service:
- description:
- - The backend service resource to which traffic is directed if this
- rule is matched. If routeAction is additionally specified, advanced
- routing actions like URL Rewrites, etc. take effect prior to sending
- the request to the backend. However, if service is specified, routeAction
- cannot contain any weightedBackendService s. Conversely, if routeAction
- specifies any weightedBackendServices, service must not be specified.
- Only one of urlRedirect, service or routeAction.weightedBackendService
- must be set.
- returned: success
- type: dict
- paths:
- description:
- - 'The list of path patterns to match. Each must start with / and the
- only place a * is allowed is at the end following a /. The string
- fed to the path matcher does not include any text after the first
- ? or #, and those chars are not allowed here.'
- returned: success
- type: list
- routeAction:
- description:
- - In response to a matching path, the load balancer performs advanced
- routing actions like URL rewrites, header transformations, etc. prior
- to forwarding the request to the selected backend. If routeAction
- specifies any weightedBackendServices, service must not be set. Conversely
- if service is set, routeAction cannot contain any weightedBackendServices.
- Only one of routeAction or urlRedirect must be set.
- returned: success
- type: complex
- contains:
- corsPolicy:
- description:
- - The specification for allowing client side cross-origin requests.
- Please see W3C Recommendation for Cross Origin Resource Sharing
- .
- returned: success
- type: complex
- contains:
- allowCredentials:
- description:
- - In response to a preflight request, setting this to true indicates
- that the actual request can include user credentials. This
- translates to the Access- Control-Allow-Credentials header.
- Defaults to false.
- returned: success
- type: bool
- allowHeaders:
- description:
- - Specifies the content for the Access-Control-Allow-Headers
- header.
- returned: success
- type: list
- allowMethods:
- description:
- - Specifies the content for the Access-Control-Allow-Methods
- header.
- returned: success
- type: list
- allowOriginRegexes:
- description:
- - Specifies the regualar expression patterns that match allowed
- origins. For regular expression grammar please see en.cppreference.com/w/cpp/regex/ecmascript
- An origin is allowed if it matches either allow_origins or
- allow_origin_regex.
- returned: success
- type: list
- allowOrigins:
- description:
- - Specifies the list of origins that will be allowed to do CORS
- requests. An origin is allowed if it matches either allow_origins
- or allow_origin_regex.
- returned: success
- type: list
- disabled:
- description:
- - If true, specifies the CORS policy is disabled.
- returned: success
- type: bool
- exposeHeaders:
- description:
- - Specifies the content for the Access-Control-Expose-Headers
- header.
- returned: success
- type: list
- maxAge:
- description:
- - Specifies how long the results of a preflight request can
- be cached. This translates to the content for the Access-Control-Max-Age
- header.
- returned: success
- type: int
- faultInjectionPolicy:
- description:
- - The specification for fault injection introduced into traffic
- to test the resiliency of clients to backend service failure.
- As part of fault injection, when clients send requests to a backend
- service, delays can be introduced by Loadbalancer on a percentage
- of requests before sending those request to the backend service.
- Similarly requests from clients can be aborted by the Loadbalancer
- for a percentage of requests. timeout and retry_policy will be
- ignored by clients that are configured with a fault_injection_policy.
- returned: success
- type: complex
- contains:
- abort:
- description:
- - The specification for how client requests are aborted as part
- of fault injection.
- returned: success
- type: complex
- contains:
- httpStatus:
- description:
- - The HTTP status code used to abort the request. The value
- must be between 200 and 599 inclusive.
- returned: success
- type: int
- percentage:
- description:
- - The percentage of traffic (connections/operations/requests)
- which will be aborted as part of fault injection. The
- value must be between 0.0 and 100.0 inclusive.
- returned: success
- type: str
- delay:
- description:
- - The specification for how client requests are delayed as part
- of fault injection, before being sent to a backend service.
- returned: success
- type: complex
- contains:
- fixedDelay:
- description:
- - Specifies the value of the fixed delay interval.
- returned: success
- type: complex
- contains:
- nanos:
- description:
- - Span of time that's a fraction of a second at nanosecond
- resolution. Durations less than one second are represented
- with a 0 `seconds` field and a positive `nanos` field.
- Must be from 0 to 999,999,999 inclusive.
- returned: success
- type: int
- seconds:
- description:
- - Span of time at a resolution of a second. Must be
- from 0 to 315,576,000,000 inclusive.
- returned: success
- type: str
- percentage:
- description:
- - The percentage of traffic (connections/operations/requests)
- on which delay will be introduced as part of fault injection.
- The value must be between 0.0 and 100.0 inclusive.
- returned: success
- type: str
- requestMirrorPolicy:
- description:
- - Specifies the policy on how requests intended for the route's
- backends are shadowed to a separate mirrored backend service.
- Loadbalancer does not wait for responses from the shadow service.
- Prior to sending traffic to the shadow service, the host / authority
- header is suffixed with -shadow.
- returned: success
- type: complex
- contains:
- backendService:
- description:
- - The BackendService resource being mirrored to.
- returned: success
- type: dict
- retryPolicy:
- description:
- - Specifies the retry policy associated with this route.
- returned: success
- type: complex
- contains:
- numRetries:
- description:
- - Specifies the allowed number retries. This number must be
- > 0.
- returned: success
- type: int
- perTryTimeout:
- description:
- - Specifies a non-zero timeout per retry attempt.
- returned: success
- type: complex
- contains:
- nanos:
- description:
- - Span of time that's a fraction of a second at nanosecond
- resolution. Durations less than one second are represented
- with a 0 `seconds` field and a positive `nanos` field.
- Must be from 0 to 999,999,999 inclusive.
- returned: success
- type: int
- seconds:
- description:
- - Span of time at a resolution of a second. Must be from
- 0 to 315,576,000,000 inclusive.
- returned: success
- type: str
- retryConditions:
- description:
- - 'Specifies one or more conditions when this retry rule applies.
- Valid values are: - 5xx: Loadbalancer will attempt a retry
- if the backend service responds with any 5xx response code,
- or if the backend service does not respond at all, example:
- disconnects, reset, read timeout, connection failure, and
- refused streams.'
- - "- gateway-error: Similar to 5xx, but only applies to response
- codes 502, 503 or 504."
- - "- connect-failure: Loadbalancer will retry on failures connecting
- to backend services, for example due to connection timeouts."
- - "- retriable-4xx: Loadbalancer will retry for retriable 4xx
- response codes."
- - Currently the only retriable error supported is 409.
- - "- refused-stream: Loadbalancer will retry if the backend
- service resets the stream with a REFUSED_STREAM error code.
- This reset type indicates that it is safe to retry."
- - "- cancelled: Loadbalancer will retry if the gRPC status code
- in the response header is set to cancelled - deadline-exceeded:
- Loadbalancer will retry if the gRPC status code in the response
- header is set to deadline-exceeded - resource-exhausted: Loadbalancer
- will retry if the gRPC status code in the response header
- is set to resource-exhausted - unavailable: Loadbalancer will
- retry if the gRPC status code in the response header is set
- to unavailable ."
- returned: success
- type: list
- timeout:
- description:
- - Specifies the timeout for the selected route. Timeout is computed
- from the time the request is has been fully processed (i.e. end-of-stream)
- up until the response has been completely processed. Timeout includes
- all retries. If not specified, the default value is 15 seconds.
- returned: success
- type: complex
- contains:
- nanos:
- description:
- - Span of time that's a fraction of a second at nanosecond resolution.
- Durations less than one second are represented with a 0 `seconds`
- field and a positive `nanos` field. Must be from 0 to 999,999,999
- inclusive.
- returned: success
- type: int
- seconds:
- description:
- - Span of time at a resolution of a second. Must be from 0 to
- 315,576,000,000 inclusive.
- returned: success
- type: str
- urlRewrite:
- description:
- - The spec to modify the URL of the request, prior to forwarding
- the request to the matched service .
- returned: success
- type: complex
- contains:
- hostRewrite:
- description:
- - Prior to forwarding the request to the selected service, the
- request's host header is replaced with contents of hostRewrite.
- The value must be between 1 and 255 characters.
- returned: success
- type: str
- pathPrefixRewrite:
- description:
- - Prior to forwarding the request to the selected backend service,
- the matching portion of the request's path is replaced by
- pathPrefixRewrite. The value must be between 1 and 1024 characters.
- returned: success
- type: str
- weightedBackendServices:
- description:
- - A list of weighted backend services to send traffic to when a
- route match occurs. The weights determine the fraction of traffic
- that flows to their corresponding backend service. If all traffic
- needs to go to a single backend service, there must be one weightedBackendService
- with weight set to a non 0 number. Once a backendService is identified
- and before forwarding the request to the backend service, advanced
- routing actions like Url rewrites and header transformations are
- applied depending on additional settings specified in this HttpRouteAction.
- returned: success
- type: complex
- contains:
- backendService:
- description:
- - The default BackendService resource. Before forwarding the
- request to backendService, the loadbalancer applies any relevant
- headerActions specified as part of this backendServiceWeight.
- returned: success
- type: dict
- headerAction:
- description:
- - Specifies changes to request and response headers that need
- to take effect for the selected backendService. headerAction
- specified here take effect before headerAction in the enclosing
- HttpRouteRule, PathMatcher and UrlMap.
- returned: success
- type: complex
- contains:
- requestHeadersToAdd:
- description:
- - Headers to add to a matching request prior to forwarding
- the request to the backendService.
- returned: success
- type: complex
- contains:
- headerName:
- description:
- - The name of the header.
- returned: success
- type: str
- headerValue:
- description:
- - The value of the header to add.
- returned: success
- type: str
- replace:
- description:
- - If false, headerValue is appended to any values that
- already exist for the header. If true, headerValue
- is set for the header, discarding any values that
- were set for that header.
- returned: success
- type: bool
- requestHeadersToRemove:
- description:
- - A list of header names for headers that need to be removed
- from the request prior to forwarding the request to the
- backendService.
- returned: success
- type: list
- responseHeadersToAdd:
- description:
- - Headers to add the response prior to sending the response
- back to the client.
- returned: success
- type: complex
- contains:
- headerName:
- description:
- - The name of the header.
- returned: success
- type: str
- headerValue:
- description:
- - The value of the header to add.
- returned: success
- type: str
- replace:
- description:
- - If false, headerValue is appended to any values that
- already exist for the header. If true, headerValue
- is set for the header, discarding any values that
- were set for that header.
- returned: success
- type: bool
- responseHeadersToRemove:
- description:
- - A list of header names for headers that need to be removed
- from the response prior to sending the response back to
- the client.
- returned: success
- type: list
- weight:
- description:
- - Specifies the fraction of traffic sent to backendService,
- computed as weight / (sum of all weightedBackendService weights
- in routeAction) . The selection of a backend service is determined
- only for new traffic. Once a user's request has been directed
- to a backendService, subsequent requests will be sent to the
- same backendService as determined by the BackendService's
- session affinity policy.
- - The value must be between 0 and 1000 .
- returned: success
- type: int
- urlRedirect:
- description:
- - When a path pattern is matched, the request is redirected to a URL
- specified by urlRedirect. If urlRedirect is specified, service or
- routeAction must not be set.
- returned: success
- type: complex
- contains:
- hostRedirect:
- description:
- - The host that will be used in the redirect response instead of
- the one that was supplied in the request. The value must be between
- 1 and 255 characters.
- returned: success
- type: str
- httpsRedirect:
- description:
- - If set to true, the URL scheme in the redirected request is set
- to https. If set to false, the URL scheme of the redirected request
- will remain the same as that of the request. This must only be
- set for UrlMaps used in TargetHttpProxys.
- - Setting this true for TargetHttpsProxy is not permitted. Defaults
- to false.
- returned: success
- type: bool
- pathRedirect:
- description:
- - The path that will be used in the redirect response instead of
- the one that was supplied in the request. Only one of pathRedirect
- or prefixRedirect must be specified. The value must be between
- 1 and 1024 characters.
- returned: success
- type: str
- prefixRedirect:
- description:
- - The prefix that replaces the prefixMatch specified in the HttpRouteRuleMatch,
- retaining the remaining portion of the URL before redirecting
- the request.
- returned: success
- type: str
- redirectResponseCode:
- description:
- - 'The HTTP Status code to use for this RedirectAction. Supported
- values are: - MOVED_PERMANENTLY_DEFAULT, which is the default
- value and corresponds to 301.'
- - "- FOUND, which corresponds to 302."
- - "- SEE_OTHER which corresponds to 303."
- - "- TEMPORARY_REDIRECT, which corresponds to 307. In this case,
- the request method will be retained."
- - "- PERMANENT_REDIRECT, which corresponds to 308. In this case,
- the request method will be retained."
- returned: success
- type: str
- stripQuery:
- description:
- - If set to true, any accompanying query portion of the original
- URL is removed prior to redirecting the request. If set to false,
- the query portion of the original URL is retained.
- returned: success
- type: bool
- routeRules:
- description:
- - 'The list of ordered HTTP route rules. Use this list instead of pathRules
- when advanced route matching and routing actions are desired. The order
- of specifying routeRules matters: the first rule that matches will cause
- its specified routing action to take effect. Within a given pathMatcher,
- only one of pathRules or routeRules must be set. routeRules are not supported
- in UrlMaps intended for External load balancers.'
- returned: success
- type: complex
- contains:
- priority:
- description:
- - For routeRules within a given pathMatcher, priority determines the
- order in which load balancer will interpret routeRules. RouteRules
- are evaluated in order of priority, from the lowest to highest number.
- The priority of a rule decreases as its number increases (1, 2, 3,
- N+1). The first rule that matches the request is applied.
- - You cannot configure two or more routeRules with the same priority.
- - Priority for each rule must be set to a number between 0 and 2147483647
- inclusive.
- - Priority numbers can have gaps, which enable you to add or remove
- rules in the future without affecting the rest of the rules. For example,
- 1, 2, 3, 4, 5, 9, 12, 16 is a valid series of priority numbers to
- which you could add rules numbered from 6 to 8, 10 to 11, and 13 to
- 15 in the future without any impact on existing rules.
- returned: success
- type: int
- service:
- description:
- - The backend service resource to which traffic is directed if this
- rule is matched. If routeAction is additionally specified, advanced
- routing actions like URL Rewrites, etc. take effect prior to sending
- the request to the backend. However, if service is specified, routeAction
- cannot contain any weightedBackendService s. Conversely, if routeAction
- specifies any weightedBackendServices, service must not be specified.
- Only one of urlRedirect, service or routeAction.weightedBackendService
- must be set.
- returned: success
- type: dict
- headerAction:
- description:
- - Specifies changes to request and response headers that need to take
- effect for the selected backendService. The headerAction specified
- here are applied before the matching pathMatchers[].headerAction and
- after pathMatchers[].routeRules[].r outeAction.weightedBackendService.backendServiceWeightAction[].headerAction
- .
- returned: success
- type: complex
- contains:
- requestHeadersToAdd:
- description:
- - Headers to add to a matching request prior to forwarding the request
- to the backendService.
- returned: success
- type: complex
- contains:
- headerName:
- description:
- - The name of the header.
- returned: success
- type: str
- headerValue:
- description:
- - The value of the header to add.
- returned: success
- type: str
- replace:
- description:
- - If false, headerValue is appended to any values that already
- exist for the header. If true, headerValue is set for the
- header, discarding any values that were set for that header.
- returned: success
- type: bool
- requestHeadersToRemove:
- description:
- - A list of header names for headers that need to be removed from
- the request prior to forwarding the request to the backendService.
- returned: success
- type: list
- responseHeadersToAdd:
- description:
- - Headers to add the response prior to sending the response back
- to the client.
- returned: success
- type: complex
- contains:
- headerName:
- description:
- - The name of the header.
- returned: success
- type: str
- headerValue:
- description:
- - The value of the header to add.
- returned: success
- type: str
- replace:
- description:
- - If false, headerValue is appended to any values that already
- exist for the header. If true, headerValue is set for the
- header, discarding any values that were set for that header.
- returned: success
- type: bool
- responseHeadersToRemove:
- description:
- - A list of header names for headers that need to be removed from
- the response prior to sending the response back to the client.
- returned: success
- type: list
- matchRules:
- description:
- - The rules for determining a match.
- returned: success
- type: complex
- contains:
- fullPathMatch:
- description:
- - For satifying the matchRule condition, the path of the request
- must exactly match the value specified in fullPathMatch after
- removing any query parameters and anchor that may be part of the
- original URL. FullPathMatch must be between 1 and 1024 characters.
- Only one of prefixMatch, fullPathMatch or regexMatch must be specified.
- returned: success
- type: str
- headerMatches:
- description:
- - Specifies a list of header match criteria, all of which must match
- corresponding headers in the request.
- returned: success
- type: complex
- contains:
- exactMatch:
- description:
- - The value should exactly match contents of exactMatch. Only
- one of exactMatch, prefixMatch, suffixMatch, regexMatch, presentMatch
- or rangeMatch must be set.
- returned: success
- type: str
- headerName:
- description:
- - The name of the HTTP header to match. For matching against
- the HTTP request's authority, use a headerMatch with the header
- name ":authority". For matching a request's method, use the
- headerName ":method".
- returned: success
- type: str
- invertMatch:
- description:
- - If set to false, the headerMatch is considered a match if
- the match criteria above are met. If set to true, the headerMatch
- is considered a match if the match criteria above are NOT
- met. Defaults to false.
- returned: success
- type: bool
- prefixMatch:
- description:
- - The value of the header must start with the contents of prefixMatch.
- Only one of exactMatch, prefixMatch, suffixMatch, regexMatch,
- presentMatch or rangeMatch must be set.
- returned: success
- type: str
- presentMatch:
- description:
- - A header with the contents of headerName must exist. The match
- takes place whether or not the request's header has a value
- or not. Only one of exactMatch, prefixMatch, suffixMatch,
- regexMatch, presentMatch or rangeMatch must be set.
- returned: success
- type: bool
- rangeMatch:
- description:
- - The header value must be an integer and its value must be
- in the range specified in rangeMatch. If the header does not
- contain an integer, number or is empty, the match fails. For
- example for a range [-5, 0] - -3 will match. - 0 will not
- match. - 0.25 will not match. - -3someString will not match.
- Only one of exactMatch, prefixMatch, suffixMatch, regexMatch,
- presentMatch or rangeMatch must be set.
- returned: success
- type: complex
- contains:
- rangeEnd:
- description:
- - The end of the range (exclusive).
- returned: success
- type: int
- rangeStart:
- description:
- - The start of the range (inclusive).
- returned: success
- type: int
- regexMatch:
- description:
- - 'The value of the header must match the regualar expression
- specified in regexMatch. For regular expression grammar, please
- see: en.cppreference.com/w/cpp/regex/ecmascript For matching
- against a port specified in the HTTP request, use a headerMatch
- with headerName set to PORT and a regular expression that
- satisfies the RFC2616 Host header''s port specifier.'
- - Only one of exactMatch, prefixMatch, suffixMatch, regexMatch,
- presentMatch or rangeMatch must be set.
- returned: success
- type: str
- suffixMatch:
- description:
- - The value of the header must end with the contents of suffixMatch.
- Only one of exactMatch, prefixMatch, suffixMatch, regexMatch,
- presentMatch or rangeMatch must be set.
- returned: success
- type: str
- ignoreCase:
- description:
- - Specifies that prefixMatch and fullPathMatch matches are case
- sensitive.
- - Defaults to false.
- returned: success
- type: bool
- metadataFilters:
- description:
- - Opaque filter criteria used by Loadbalancer to restrict routing
- configuration to a limited set xDS compliant clients. In their
- xDS requests to Loadbalancer, xDS clients present node metadata.
- If a match takes place, the relevant routing configuration is
- made available to those proxies. For each metadataFilter in this
- list, if its filterMatchCriteria is set to MATCH_ANY, at least
- one of the filterLabels must match the corresponding label provided
- in the metadata. If its filterMatchCriteria is set to MATCH_ALL,
- then all of its filterLabels must match with corresponding labels
- in the provided metadata. metadataFilters specified here can be
- overrides those specified in ForwardingRule that refers to this
- UrlMap. metadataFilters only applies to Loadbalancers that have
- their loadBalancingScheme set to INTERNAL_SELF_MANAGED.
- returned: success
- type: complex
- contains:
- filterLabels:
- description:
- - The list of label value pairs that must match labels in the
- provided metadata based on filterMatchCriteria This list must
- not be empty and can have at the most 64 entries.
- returned: success
- type: complex
- contains:
- name:
- description:
- - Name of metadata label. The name can have a maximum length
- of 1024 characters and must be at least 1 character long.
- returned: success
- type: str
- value:
- description:
- - The value of the label must match the specified value.
- value can have a maximum length of 1024 characters.
- returned: success
- type: str
- filterMatchCriteria:
- description:
- - 'Specifies how individual filterLabel matches within the list
- of filterLabels contribute towards the overall metadataFilter
- match. Supported values are: - MATCH_ANY: At least one of
- the filterLabels must have a matching label in the provided
- metadata.'
- - "- MATCH_ALL: All filterLabels must have matching labels in
- the provided metadata."
- returned: success
- type: str
- prefixMatch:
- description:
- - For satifying the matchRule condition, the request's path must
- begin with the specified prefixMatch. prefixMatch must begin with
- a /. The value must be between 1 and 1024 characters. Only one
- of prefixMatch, fullPathMatch or regexMatch must be specified.
- returned: success
- type: str
- queryParameterMatches:
- description:
- - Specifies a list of query parameter match criteria, all of which
- must match corresponding query parameters in the request.
- returned: success
- type: complex
- contains:
- exactMatch:
- description:
- - The queryParameterMatch matches if the value of the parameter
- exactly matches the contents of exactMatch. Only one of presentMatch,
- exactMatch and regexMatch must be set.
- returned: success
- type: str
- name:
- description:
- - The name of the query parameter to match. The query parameter
- must exist in the request, in the absence of which the request
- match fails.
- returned: success
- type: str
- presentMatch:
- description:
- - Specifies that the queryParameterMatch matches if the request
- contains the query parameter, irrespective of whether the
- parameter has a value or not. Only one of presentMatch, exactMatch
- and regexMatch must be set.
- returned: success
- type: bool
- regexMatch:
- description:
- - The queryParameterMatch matches if the value of the parameter
- matches the regular expression specified by regexMatch. For
- the regular expression grammar, please see en.cppreference.com/w/cpp/regex/ecmascript
- Only one of presentMatch, exactMatch and regexMatch must be
- set.
- returned: success
- type: str
- regexMatch:
- description:
- - For satifying the matchRule condition, the path of the request
- must satisfy the regular expression specified in regexMatch after
- removing any query parameters and anchor supplied with the original
- URL. For regular expression grammar please see en.cppreference.com/w/cpp/regex/ecmascript
- Only one of prefixMatch, fullPathMatch or regexMatch must be specified.
- returned: success
- type: str
- routeAction:
- description:
- - In response to a matching matchRule, the load balancer performs advanced
- routing actions like URL rewrites, header transformations, etc. prior
- to forwarding the request to the selected backend. If routeAction
- specifies any weightedBackendServices, service must not be set. Conversely
- if service is set, routeAction cannot contain any weightedBackendServices.
- Only one of routeAction or urlRedirect must be set.
- returned: success
- type: complex
- contains:
- corsPolicy:
- description:
- - The specification for allowing client side cross-origin requests.
- Please see W3C Recommendation for Cross Origin Resource Sharing
- .
- returned: success
- type: complex
- contains:
- allowCredentials:
- description:
- - In response to a preflight request, setting this to true indicates
- that the actual request can include user credentials. This
- translates to the Access- Control-Allow-Credentials header.
- Defaults to false.
- returned: success
- type: bool
- allowHeaders:
- description:
- - Specifies the content for the Access-Control-Allow-Headers
- header.
- returned: success
- type: list
- allowMethods:
- description:
- - Specifies the content for the Access-Control-Allow-Methods
- header.
- returned: success
- type: list
- allowOriginRegexes:
- description:
- - Specifies the regualar expression patterns that match allowed
- origins. For regular expression grammar please see en.cppreference.com/w/cpp/regex/ecmascript
- An origin is allowed if it matches either allow_origins or
- allow_origin_regex.
- returned: success
- type: list
- allowOrigins:
- description:
- - Specifies the list of origins that will be allowed to do CORS
- requests. An origin is allowed if it matches either allow_origins
- or allow_origin_regex.
- returned: success
- type: list
- disabled:
- description:
- - If true, specifies the CORS policy is disabled.
- - which indicates that the CORS policy is in effect. Defaults
- to false.
- returned: success
- type: bool
- exposeHeaders:
- description:
- - Specifies the content for the Access-Control-Expose-Headers
- header.
- returned: success
- type: list
- maxAge:
- description:
- - Specifies how long the results of a preflight request can
- be cached. This translates to the content for the Access-Control-Max-Age
- header.
- returned: success
- type: int
- faultInjectionPolicy:
- description:
- - The specification for fault injection introduced into traffic
- to test the resiliency of clients to backend service failure.
- As part of fault injection, when clients send requests to a backend
- service, delays can be introduced by Loadbalancer on a percentage
- of requests before sending those request to the backend service.
- Similarly requests from clients can be aborted by the Loadbalancer
- for a percentage of requests. timeout and retry_policy will be
- ignored by clients that are configured with a fault_injection_policy.
- returned: success
- type: complex
- contains:
- abort:
- description:
- - The specification for how client requests are aborted as part
- of fault injection.
- returned: success
- type: complex
- contains:
- httpStatus:
- description:
- - The HTTP status code used to abort the request. The value
- must be between 200 and 599 inclusive.
- returned: success
- type: int
- percentage:
- description:
- - The percentage of traffic (connections/operations/requests)
- which will be aborted as part of fault injection. The
- value must be between 0.0 and 100.0 inclusive.
- returned: success
- type: str
- delay:
- description:
- - The specification for how client requests are delayed as part
- of fault injection, before being sent to a backend service.
- returned: success
- type: complex
- contains:
- fixedDelay:
- description:
- - Specifies the value of the fixed delay interval.
- returned: success
- type: complex
- contains:
- nanos:
- description:
- - Span of time that's a fraction of a second at nanosecond
- resolution. Durations less than one second are represented
- with a 0 `seconds` field and a positive `nanos` field.
- Must be from 0 to 999,999,999 inclusive.
- returned: success
- type: int
- seconds:
- description:
- - Span of time at a resolution of a second. Must be
- from 0 to 315,576,000,000 inclusive.
- returned: success
- type: str
- percentage:
- description:
- - The percentage of traffic (connections/operations/requests)
- on which delay will be introduced as part of fault injection.
- The value must be between 0.0 and 100.0 inclusive.
- returned: success
- type: str
- requestMirrorPolicy:
- description:
- - Specifies the policy on how requests intended for the route's
- backends are shadowed to a separate mirrored backend service.
- Loadbalancer does not wait for responses from the shadow service.
- Prior to sending traffic to the shadow service, the host / authority
- header is suffixed with -shadow.
- returned: success
- type: complex
- contains:
- backendService:
- description:
- - The BackendService resource being mirrored to.
- returned: success
- type: dict
- retryPolicy:
- description:
- - Specifies the retry policy associated with this route.
- returned: success
- type: complex
- contains:
- numRetries:
- description:
- - Specifies the allowed number retries. This number must be
- > 0.
- returned: success
- type: int
- perTryTimeout:
- description:
- - Specifies a non-zero timeout per retry attempt.
- - If not specified, will use the timeout set in HttpRouteAction.
- If timeout in HttpRouteAction is not set, will use the largest
- timeout among all backend services associated with the route.
- returned: success
- type: complex
- contains:
- nanos:
- description:
- - Span of time that's a fraction of a second at nanosecond
- resolution. Durations less than one second are represented
- with a 0 `seconds` field and a positive `nanos` field.
- Must be from 0 to 999,999,999 inclusive.
- returned: success
- type: int
- seconds:
- description:
- - Span of time at a resolution of a second. Must be from
- 0 to 315,576,000,000 inclusive.
- returned: success
- type: str
- retryConditions:
- description:
- - 'Specfies one or more conditions when this retry rule applies.
- Valid values are: - 5xx: Loadbalancer will attempt a retry
- if the backend service responds with any 5xx response code,
- or if the backend service does not respond at all, example:
- disconnects, reset, read timeout, connection failure, and
- refused streams.'
- - "- gateway-error: Similar to 5xx, but only applies to response
- codes 502, 503 or 504."
- - "- connect-failure: Loadbalancer will retry on failures connecting
- to backend services, for example due to connection timeouts."
- - "- retriable-4xx: Loadbalancer will retry for retriable 4xx
- response codes."
- - Currently the only retriable error supported is 409.
- - "- refused-stream: Loadbalancer will retry if the backend
- service resets the stream with a REFUSED_STREAM error code.
- This reset type indicates that it is safe to retry."
- - "- cancelled: Loadbalancer will retry if the gRPC status code
- in the response header is set to cancelled - deadline-exceeded:
- Loadbalancer will retry if the gRPC status code in the response
- header is set to deadline-exceeded - resource-exhausted: Loadbalancer
- will retry if the gRPC status code in the response header
- is set to resource-exhausted - unavailable: Loadbalancer will
- retry if the gRPC status code in the response header is set
- to unavailable ."
- returned: success
- type: list
- timeout:
- description:
- - Specifies the timeout for the selected route. Timeout is computed
- from the time the request is has been fully processed (i.e. end-of-stream)
- up until the response has been completely processed. Timeout includes
- all retries. If not specified, the default value is 15 seconds.
- returned: success
- type: complex
- contains:
- nanos:
- description:
- - Span of time that's a fraction of a second at nanosecond resolution.
- Durations less than one second are represented with a 0 `seconds`
- field and a positive `nanos` field. Must be from 0 to 999,999,999
- inclusive.
- returned: success
- type: int
- seconds:
- description:
- - Span of time at a resolution of a second. Must be from 0 to
- 315,576,000,000 inclusive.
- returned: success
- type: str
- urlRewrite:
- description:
- - The spec to modify the URL of the request, prior to forwarding
- the request to the matched service .
- returned: success
- type: complex
- contains:
- hostRewrite:
- description:
- - Prior to forwarding the request to the selected service, the
- request's host header is replaced with contents of hostRewrite.
- The value must be between 1 and 255 characters.
- returned: success
- type: str
- pathPrefixRewrite:
- description:
- - Prior to forwarding the request to the selected backend service,
- the matching portion of the request's path is replaced by
- pathPrefixRewrite. The value must be between 1 and 1024 characters.
- returned: success
- type: str
- weightedBackendServices:
- description:
- - A list of weighted backend services to send traffic to when a
- route match occurs. The weights determine the fraction of traffic
- that flows to their corresponding backend service. If all traffic
- needs to go to a single backend service, there must be one weightedBackendService
- with weight set to a non 0 number. Once a backendService is identified
- and before forwarding the request to the backend service, advanced
- routing actions like Url rewrites and header transformations are
- applied depending on additional settings specified in this HttpRouteAction.
- returned: success
- type: complex
- contains:
- backendService:
- description:
- - The default BackendService resource. Before forwarding the
- request to backendService, the loadbalancer applies any relevant
- headerActions specified as part of this backendServiceWeight.
- returned: success
- type: dict
- headerAction:
- description:
- - Specifies changes to request and response headers that need
- to take effect for the selected backendService. headerAction
- specified here take effect before headerAction in the enclosing
- HttpRouteRule, PathMatcher and UrlMap.
- returned: success
- type: complex
- contains:
- requestHeadersToAdd:
- description:
- - Headers to add to a matching request prior to forwarding
- the request to the backendService.
- returned: success
- type: complex
- contains:
- headerName:
- description:
- - The name of the header.
- returned: success
- type: str
- headerValue:
- description:
- - The value of the header to add.
- returned: success
- type: str
- replace:
- description:
- - If false, headerValue is appended to any values that
- already exist for the header. If true, headerValue
- is set for the header, discarding any values that
- were set for that header.
- returned: success
- type: bool
- requestHeadersToRemove:
- description:
- - A list of header names for headers that need to be removed
- from the request prior to forwarding the request to the
- backendService.
- returned: success
- type: list
- responseHeadersToAdd:
- description:
- - Headers to add the response prior to sending the response
- back to the client.
- returned: success
- type: complex
- contains:
- headerName:
- description:
- - The name of the header.
- returned: success
- type: str
- headerValue:
- description:
- - The value of the header to add.
- returned: success
- type: str
- replace:
- description:
- - If false, headerValue is appended to any values that
- already exist for the header. If true, headerValue
- is set for the header, discarding any values that
- were set for that header.
- returned: success
- type: bool
- responseHeadersToRemove:
- description:
- - A list of header names for headers that need to be removed
- from the response prior to sending the response back to
- the client.
- returned: success
- type: list
- weight:
- description:
- - Specifies the fraction of traffic sent to backendService,
- computed as weight / (sum of all weightedBackendService weights
- in routeAction) . The selection of a backend service is determined
- only for new traffic. Once a user's request has been directed
- to a backendService, subsequent requests will be sent to the
- same backendService as determined by the BackendService's
- session affinity policy.
- - The value must be between 0 and 1000 .
- returned: success
- type: int
- urlRedirect:
- description:
- - When this rule is matched, the request is redirected to a URL specified
- by urlRedirect. If urlRedirect is specified, service or routeAction
- must not be set.
- returned: success
- type: complex
- contains:
- hostRedirect:
- description:
- - The host that will be used in the redirect response instead of
- the one that was supplied in the request. The value must be between
- 1 and 255 characters.
- returned: success
- type: str
- httpsRedirect:
- description:
- - If set to true, the URL scheme in the redirected request is set
- to https. If set to false, the URL scheme of the redirected request
- will remain the same as that of the request. This must only be
- set for UrlMaps used in TargetHttpProxys.
- - Setting this true for TargetHttpsProxy is not permitted. Defaults
- to false.
- returned: success
- type: bool
- pathRedirect:
- description:
- - The path that will be used in the redirect response instead of
- the one that was supplied in the request. Only one of pathRedirect
- or prefixRedirect must be specified. The value must be between
- 1 and 1024 characters.
- returned: success
- type: str
- prefixRedirect:
- description:
- - The prefix that replaces the prefixMatch specified in the HttpRouteRuleMatch,
- retaining the remaining portion of the URL before redirecting
- the request.
- returned: success
- type: str
- redirectResponseCode:
- description:
- - 'The HTTP Status code to use for this RedirectAction. Supported
- values are: - MOVED_PERMANENTLY_DEFAULT, which is the default
- value and corresponds to 301. - FOUND, which corresponds to 302.
- - SEE_OTHER which corresponds to 303. - TEMPORARY_REDIRECT, which
- corresponds to 307. In this case, the request method will be retained.
- - PERMANENT_REDIRECT, which corresponds to 308. In this case,
- the request method will be retained.'
- returned: success
- type: str
- stripQuery:
- description:
- - If set to true, any accompanying query portion of the original
- URL is removed prior to redirecting the request. If set to false,
- the query portion of the original URL is retained. Defaults to
- false.
- returned: success
- type: bool
- tests:
- description:
- - The list of expected URL mapping tests. Request to update this UrlMap will
- succeed only if all of the test cases pass. You can specify a maximum of 100
- tests per UrlMap.
- returned: success
- type: complex
- contains:
- description:
- description:
- - Description of this test case.
- returned: success
- type: str
- host:
- description:
- - Host portion of the URL.
- returned: success
- type: str
- path:
- description:
- - Path portion of the URL.
- returned: success
- type: str
- service:
- description:
- - Expected BackendService resource the given URL should be mapped to.
- returned: success
- type: dict
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/global/urlMaps".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_vpn_tunnel.py b/lib/ansible/modules/cloud/google/gcp_compute_vpn_tunnel.py
deleted file mode 100644
index a74075e654..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_vpn_tunnel.py
+++ /dev/null
@@ -1,516 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_vpn_tunnel
-description:
-- VPN tunnel resource.
-short_description: Creates a GCP VpnTunnel
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- name:
- description:
- - Name of the resource. The name must be 1-63 characters long, and comply with
- RFC1035. Specifically, the name must be 1-63 characters long and match the regular
- expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must
- be a lowercase letter, and all following characters must be a dash, lowercase
- letter, or digit, except the last character, which cannot be a dash.
- required: true
- type: str
- description:
- description:
- - An optional description of this resource.
- required: false
- type: str
- target_vpn_gateway:
- description:
- - URL of the Target VPN gateway with which this VPN tunnel is associated.
- - 'This field represents a link to a TargetVpnGateway resource in GCP. It can
- be specified in two ways. First, you can place a dictionary with key ''selfLink''
- and value of your resource''s selfLink Alternatively, you can add `register:
- name-of-resource` to a gcp_compute_target_vpn_gateway task and then set this
- target_vpn_gateway field to "{{ name-of-resource }}"'
- required: false
- type: dict
- router:
- description:
- - URL of router resource to be used for dynamic routing.
- - 'This field represents a link to a Router resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''selfLink'' and value
- of your resource''s selfLink Alternatively, you can add `register: name-of-resource`
- to a gcp_compute_router task and then set this router field to "{{ name-of-resource
- }}"'
- required: false
- type: dict
- peer_ip:
- description:
- - IP address of the peer VPN gateway. Only IPv4 is supported.
- required: false
- type: str
- shared_secret:
- description:
- - Shared secret used to set the secure session between the Cloud VPN gateway and
- the peer VPN gateway.
- required: true
- type: str
- ike_version:
- description:
- - IKE protocol version to use when establishing the VPN tunnel with peer VPN gateway.
- - Acceptable IKE versions are 1 or 2. Default version is 2.
- required: false
- default: '2'
- type: int
- local_traffic_selector:
- description:
- - Local traffic selector to use when establishing the VPN tunnel with peer VPN
- gateway. The value should be a CIDR formatted string, for example `192.168.0.0/16`.
- The ranges should be disjoint.
- - Only IPv4 is supported.
- required: false
- type: list
- remote_traffic_selector:
- description:
- - Remote traffic selector to use when establishing the VPN tunnel with peer VPN
- gateway. The value should be a CIDR formatted string, for example `192.168.0.0/16`.
- The ranges should be disjoint.
- - Only IPv4 is supported.
- required: false
- type: list
- region:
- description:
- - The region where the tunnel is located.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/compute/docs/reference/rest/v1/vpnTunnels)'
-- 'Cloud VPN Overview: U(https://cloud.google.com/vpn/docs/concepts/overview)'
-- 'Networks and Tunnel Routing: U(https://cloud.google.com/vpn/docs/concepts/choosing-networks-routing)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a network
- gcp_compute_network:
- name: network-vpn-tunnel
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: network
-
-- name: create a router
- gcp_compute_router:
- name: router-vpn-tunnel
- network: "{{ network }}"
- bgp:
- asn: 64514
- advertise_mode: CUSTOM
- advertised_groups:
- - ALL_SUBNETS
- advertised_ip_ranges:
- - range: 1.2.3.4
- - range: 6.7.0.0/16
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: router
-
-- name: create a target vpn gateway
- gcp_compute_target_vpn_gateway:
- name: gateway-vpn-tunnel
- region: us-west1
- network: "{{ network }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: gateway
-
-- name: create a vpn tunnel
- gcp_compute_vpn_tunnel:
- name: test_object
- region: us-west1
- target_vpn_gateway: "{{ gateway }}"
- router: "{{ router }}"
- shared_secret: super secret
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-id:
- description:
- - The unique identifier for the resource. This identifier is defined by the server.
- returned: success
- type: str
-creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-name:
- description:
- - Name of the resource. The name must be 1-63 characters long, and comply with RFC1035.
- Specifically, the name must be 1-63 characters long and match the regular expression
- `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character must be a lowercase
- letter, and all following characters must be a dash, lowercase letter, or digit,
- except the last character, which cannot be a dash.
- returned: success
- type: str
-description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
-targetVpnGateway:
- description:
- - URL of the Target VPN gateway with which this VPN tunnel is associated.
- returned: success
- type: dict
-router:
- description:
- - URL of router resource to be used for dynamic routing.
- returned: success
- type: dict
-peerIp:
- description:
- - IP address of the peer VPN gateway. Only IPv4 is supported.
- returned: success
- type: str
-sharedSecret:
- description:
- - Shared secret used to set the secure session between the Cloud VPN gateway and
- the peer VPN gateway.
- returned: success
- type: str
-sharedSecretHash:
- description:
- - Hash of the shared secret.
- returned: success
- type: str
-ikeVersion:
- description:
- - IKE protocol version to use when establishing the VPN tunnel with peer VPN gateway.
- - Acceptable IKE versions are 1 or 2. Default version is 2.
- returned: success
- type: int
-localTrafficSelector:
- description:
- - Local traffic selector to use when establishing the VPN tunnel with peer VPN gateway.
- The value should be a CIDR formatted string, for example `192.168.0.0/16`. The
- ranges should be disjoint.
- - Only IPv4 is supported.
- returned: success
- type: list
-remoteTrafficSelector:
- description:
- - Remote traffic selector to use when establishing the VPN tunnel with peer VPN
- gateway. The value should be a CIDR formatted string, for example `192.168.0.0/16`.
- The ranges should be disjoint.
- - Only IPv4 is supported.
- returned: success
- type: list
-region:
- description:
- - The region where the tunnel is located.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- name=dict(required=True, type='str'),
- description=dict(type='str'),
- target_vpn_gateway=dict(type='dict'),
- router=dict(type='dict'),
- peer_ip=dict(type='str'),
- shared_secret=dict(required=True, type='str'),
- ike_version=dict(default=2, type='int'),
- local_traffic_selector=dict(type='list', elements='str'),
- remote_traffic_selector=dict(type='list', elements='str'),
- region=dict(required=True, type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- state = module.params['state']
- kind = 'compute#vpnTunnel'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind):
- delete(module, self_link(module), kind)
- create(module, collection(module), kind)
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'compute')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'compute#vpnTunnel',
- u'name': module.params.get('name'),
- u'description': module.params.get('description'),
- u'targetVpnGateway': replace_resource_dict(module.params.get(u'target_vpn_gateway', {}), 'selfLink'),
- u'router': replace_resource_dict(module.params.get(u'router', {}), 'selfLink'),
- u'peerIp': module.params.get('peer_ip'),
- u'sharedSecret': module.params.get('shared_secret'),
- u'ikeVersion': module.params.get('ike_version'),
- u'localTrafficSelector': module.params.get('local_traffic_selector'),
- u'remoteTrafficSelector': module.params.get('remote_traffic_selector'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'compute')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/vpnTunnels/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/vpnTunnels".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'id': response.get(u'id'),
- u'creationTimestamp': response.get(u'creationTimestamp'),
- u'name': response.get(u'name'),
- u'description': module.params.get('description'),
- u'targetVpnGateway': replace_resource_dict(module.params.get(u'target_vpn_gateway', {}), 'selfLink'),
- u'router': replace_resource_dict(module.params.get(u'router', {}), 'selfLink'),
- u'peerIp': response.get(u'peerIp'),
- u'sharedSecret': response.get(u'sharedSecret'),
- u'sharedSecretHash': response.get(u'sharedSecretHash'),
- u'ikeVersion': response.get(u'ikeVersion'),
- u'localTrafficSelector': response.get(u'localTrafficSelector'),
- u'remoteTrafficSelector': response.get(u'remoteTrafficSelector'),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'compute#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'compute#vpnTunnel')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'compute#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_compute_vpn_tunnel_info.py b/lib/ansible/modules/cloud/google/gcp_compute_vpn_tunnel_info.py
deleted file mode 100644
index 4077f3f0d2..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_compute_vpn_tunnel_info.py
+++ /dev/null
@@ -1,272 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_compute_vpn_tunnel_info
-description:
-- Gather info for GCP VpnTunnel
-short_description: Gather info for GCP VpnTunnel
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- filters:
- description:
- - A list of filter value pairs. Available filters are listed here U(https://cloud.google.com/sdk/gcloud/reference/topic/filters).
- - Each additional filter in the list will act be added as an AND condition (filter1
- and filter2) .
- type: list
- region:
- description:
- - The region where the tunnel is located.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a vpn tunnel
- gcp_compute_vpn_tunnel_info:
- region: us-west1
- filters:
- - name = test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- id:
- description:
- - The unique identifier for the resource. This identifier is defined by the
- server.
- returned: success
- type: str
- creationTimestamp:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- name:
- description:
- - Name of the resource. The name must be 1-63 characters long, and comply with
- RFC1035. Specifically, the name must be 1-63 characters long and match the
- regular expression `[a-z]([-a-z0-9]*[a-z0-9])?` which means the first character
- must be a lowercase letter, and all following characters must be a dash, lowercase
- letter, or digit, except the last character, which cannot be a dash.
- returned: success
- type: str
- description:
- description:
- - An optional description of this resource.
- returned: success
- type: str
- targetVpnGateway:
- description:
- - URL of the Target VPN gateway with which this VPN tunnel is associated.
- returned: success
- type: dict
- router:
- description:
- - URL of router resource to be used for dynamic routing.
- returned: success
- type: dict
- peerIp:
- description:
- - IP address of the peer VPN gateway. Only IPv4 is supported.
- returned: success
- type: str
- sharedSecret:
- description:
- - Shared secret used to set the secure session between the Cloud VPN gateway
- and the peer VPN gateway.
- returned: success
- type: str
- sharedSecretHash:
- description:
- - Hash of the shared secret.
- returned: success
- type: str
- ikeVersion:
- description:
- - IKE protocol version to use when establishing the VPN tunnel with peer VPN
- gateway.
- - Acceptable IKE versions are 1 or 2. Default version is 2.
- returned: success
- type: int
- localTrafficSelector:
- description:
- - Local traffic selector to use when establishing the VPN tunnel with peer VPN
- gateway. The value should be a CIDR formatted string, for example `192.168.0.0/16`.
- The ranges should be disjoint.
- - Only IPv4 is supported.
- returned: success
- type: list
- remoteTrafficSelector:
- description:
- - Remote traffic selector to use when establishing the VPN tunnel with peer
- VPN gateway. The value should be a CIDR formatted string, for example `192.168.0.0/16`.
- The ranges should be disjoint.
- - Only IPv4 is supported.
- returned: success
- type: list
- region:
- description:
- - The region where the tunnel is located.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(filters=dict(type='list', elements='str'), region=dict(required=True, type='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/compute']
-
- return_value = {'resources': fetch_list(module, collection(module), query_options(module.params['filters']))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/vpnTunnels".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'compute')
- return auth.list(link, return_if_object, array_name='items', params={'filter': query})
-
-
-def query_options(filters):
- if not filters:
- return ''
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != '(' and f[-1] != ')':
- queries.append("(%s)" % ''.join(f))
- else:
- queries.append(f)
-
- return ' '.join(queries)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_container_cluster.py b/lib/ansible/modules/cloud/google/gcp_container_cluster.py
deleted file mode 100644
index b89962306a..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_container_cluster.py
+++ /dev/null
@@ -1,2055 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_container_cluster
-description:
-- A Google Container Engine cluster.
-short_description: Creates a GCP Cluster
-version_added: '2.6'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- name:
- description:
- - The name of this cluster. The name must be unique within this project and location,
- and can be up to 40 characters. Must be Lowercase letters, numbers, and hyphens
- only. Must start with a letter. Must end with a number or a letter.
- required: false
- type: str
- description:
- description:
- - An optional description of this cluster.
- required: false
- type: str
- initial_node_count:
- description:
- - The number of nodes to create in this cluster. You must ensure that your Compute
- Engine resource quota is sufficient for this number of instances. You must also
- have available firewall and routes quota. For requests, this field should only
- be used in lieu of a "nodePool" object, since this configuration (along with
- the "nodeConfig") will be used to create a "NodePool" object with an auto-generated
- name. Do not use this and a nodePool at the same time.
- - This field has been deprecated. Please use nodePool.initial_node_count instead.
- required: false
- type: int
- node_config:
- description:
- - Parameters used in creating the cluster's nodes.
- - For requests, this field should only be used in lieu of a "nodePool" object,
- since this configuration (along with the "initialNodeCount") will be used to
- create a "NodePool" object with an auto-generated name. Do not use this and
- a nodePool at the same time. For responses, this field will be populated with
- the node configuration of the first node pool. If unspecified, the defaults
- are used.
- required: false
- type: dict
- suboptions:
- machine_type:
- description:
- - The name of a Google Compute Engine machine type (e.g.
- - n1-standard-1). If unspecified, the default machine type is n1-standard-1.
- required: false
- type: str
- disk_size_gb:
- description:
- - Size of the disk attached to each node, specified in GB. The smallest allowed
- disk size is 10GB. If unspecified, the default disk size is 100GB.
- required: false
- type: int
- oauth_scopes:
- description:
- - The set of Google API scopes to be made available on all of the node VMs
- under the "default" service account.
- - 'The following scopes are recommended, but not required, and by default
- are not included: U(https://www.googleapis.com/auth/compute) is required
- for mounting persistent storage on your nodes.'
- - U(https://www.googleapis.com/auth/devstorage.read_only) is required for
- communicating with gcr.io (the Google Container Registry).
- - If unspecified, no scopes are added, unless Cloud Logging or Cloud Monitoring
- are enabled, in which case their required scopes will be added.
- required: false
- type: list
- service_account:
- description:
- - The Google Cloud Platform Service Account to be used by the node VMs. If
- no Service Account is specified, the "default" service account is used.
- required: false
- type: str
- metadata:
- description:
- - The metadata key/value pairs assigned to instances in the cluster.
- - 'Keys must conform to the regexp [a-zA-Z0-9-_]+ and be less than 128 bytes
- in length. These are reflected as part of a URL in the metadata server.
- Additionally, to avoid ambiguity, keys must not conflict with any other
- metadata keys for the project or be one of the four reserved keys: "instance-template",
- "kube-env", "startup-script", and "user-data" Values are free-form strings,
- and only have meaning as interpreted by the image running in the instance.
- The only restriction placed on them is that each value''s size must be less
- than or equal to 32 KB.'
- - The total size of all keys and values must be less than 512 KB.
- - 'An object containing a list of "key": value pairs.'
- - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.'
- required: false
- type: dict
- image_type:
- description:
- - The image type to use for this node. Note that for a given image type, the
- latest version of it will be used.
- required: false
- type: str
- labels:
- description:
- - 'The map of Kubernetes labels (key/value pairs) to be applied to each node.
- These will added in addition to any default label(s) that Kubernetes may
- apply to the node. In case of conflict in label keys, the applied set may
- differ depending on the Kubernetes version -- it''s best to assume the behavior
- is undefined and conflicts should be avoided. For more information, including
- usage and the valid values, see: U(http://kubernetes.io/v1.1/docs/user-guide/labels.html)
- An object containing a list of "key": value pairs.'
- - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.'
- required: false
- type: dict
- local_ssd_count:
- description:
- - The number of local SSD disks to be attached to the node.
- - 'The limit for this value is dependant upon the maximum number of disks
- available on a machine per zone. See: U(https://cloud.google.com/compute/docs/disks/local-ssd#local_ssd_limits)
- for more information.'
- required: false
- type: int
- tags:
- description:
- - The list of instance tags applied to all nodes. Tags are used to identify
- valid sources or targets for network firewalls and are specified by the
- client during cluster or node pool creation. Each tag within the list must
- comply with RFC1035.
- required: false
- type: list
- preemptible:
- description:
- - 'Whether the nodes are created as preemptible VM instances. See: U(https://cloud.google.com/compute/docs/instances/preemptible)
- for more information about preemptible VM instances.'
- required: false
- type: bool
- accelerators:
- description:
- - A list of hardware accelerators to be attached to each node. See U(https://cloud.google.com/compute/docs/gpus)
- for more information about support for GPUs.
- required: false
- type: list
- version_added: '2.9'
- suboptions:
- accelerator_count:
- description:
- - The number of accelerator cards exposed to an instance.
- required: false
- type: str
- accelerator_type:
- description:
- - The accelerator type resource name.
- required: false
- type: str
- disk_type:
- description:
- - Type of the disk attached to each node (e.g. 'pd-standard' or 'pd-ssd')
- If unspecified, the default disk type is 'pd-standard' .
- required: false
- type: str
- version_added: '2.9'
- min_cpu_platform:
- description:
- - Minimum CPU platform to be used by this instance. The instance may be scheduled
- on the specified or newer CPU platform.
- required: false
- type: str
- version_added: '2.9'
- taints:
- description:
- - List of kubernetes taints to be applied to each node.
- - 'For more information, including usage and the valid values, see: U(https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/)
- .'
- required: false
- type: list
- version_added: '2.9'
- suboptions:
- key:
- description:
- - Key for taint.
- required: false
- type: str
- value:
- description:
- - Value for taint.
- required: false
- type: str
- effect:
- description:
- - Effect for taint.
- - 'Some valid choices include: "EFFECT_UNSPECIFIED", "NO_SCHEDULE", "PREFER_NO_SCHEDULE",
- "NO_EXECUTE"'
- required: false
- type: str
- master_auth:
- description:
- - The authentication information for accessing the master endpoint.
- required: false
- type: dict
- suboptions:
- username:
- description:
- - The username to use for HTTP basic authentication to the master endpoint.
- required: false
- type: str
- password:
- description:
- - The password to use for HTTP basic authentication to the master endpoint.
- Because the master endpoint is open to the Internet, you should create a
- strong password with a minimum of 16 characters.
- required: false
- type: str
- client_certificate_config:
- description:
- - Configuration for client certificate authentication on the cluster. For
- clusters before v1.12, if no configuration is specified, a client certificate
- is issued.
- required: false
- type: dict
- version_added: '2.9'
- suboptions:
- issue_client_certificate:
- description:
- - Issue a client certificate.
- required: false
- type: bool
- logging_service:
- description:
- - 'The logging service the cluster should use to write logs. Currently available
- options: logging.googleapis.com - the Google Cloud Logging service.'
- - none - no logs will be exported from the cluster.
- - if left as an empty string,logging.googleapis.com will be used.
- - 'Some valid choices include: "logging.googleapis.com", "none"'
- required: false
- type: str
- monitoring_service:
- description:
- - The monitoring service the cluster should use to write metrics.
- - 'Currently available options: monitoring.googleapis.com - the Google Cloud Monitoring
- service.'
- - none - no metrics will be exported from the cluster.
- - if left as an empty string, monitoring.googleapis.com will be used.
- - 'Some valid choices include: "monitoring.googleapis.com", "none"'
- required: false
- type: str
- network:
- description:
- - The name of the Google Compute Engine network to which the cluster is connected.
- If left unspecified, the default network will be used.
- required: false
- type: str
- private_cluster_config:
- description:
- - Configuration for a private cluster.
- required: false
- type: dict
- version_added: '2.8'
- suboptions:
- enable_private_nodes:
- description:
- - Whether nodes have internal IP addresses only. If enabled, all nodes are
- given only RFC 1918 private addresses and communicate with the master via
- private networking.
- required: false
- type: bool
- enable_private_endpoint:
- description:
- - Whether the master's internal IP address is used as the cluster endpoint.
- required: false
- type: bool
- master_ipv4_cidr_block:
- description:
- - The IP range in CIDR notation to use for the hosted master network. This
- range will be used for assigning internal IP addresses to the master or
- set of masters, as well as the ILB VIP. This range must not overlap with
- any other ranges in use within the cluster's network.
- required: false
- type: str
- cluster_ipv4_cidr:
- description:
- - The IP address range of the container pods in this cluster, in CIDR notation
- (e.g. 10.96.0.0/14). Leave blank to have one automatically chosen or specify
- a /14 block in 10.0.0.0/8.
- required: false
- type: str
- addons_config:
- description:
- - Configurations for the various addons available to run in the cluster.
- required: false
- type: dict
- suboptions:
- http_load_balancing:
- description:
- - Configuration for the HTTP (L7) load balancing controller addon, which makes
- it easy to set up HTTP load balancers for services in a cluster.
- required: false
- type: dict
- suboptions:
- disabled:
- description:
- - Whether the HTTP Load Balancing controller is enabled in the cluster.
- When enabled, it runs a small pod in the cluster that manages the load
- balancers.
- required: false
- type: bool
- horizontal_pod_autoscaling:
- description:
- - Configuration for the horizontal pod autoscaling feature, which increases
- or decreases the number of replica pods a replication controller has based
- on the resource usage of the existing pods.
- required: false
- type: dict
- suboptions:
- disabled:
- description:
- - Whether the Horizontal Pod Autoscaling feature is enabled in the cluster.
- When enabled, it ensures that a Heapster pod is running in the cluster,
- which is also used by the Cloud Monitoring service.
- required: false
- type: bool
- network_policy_config:
- description:
- - Configuration for NetworkPolicy. This only tracks whether the addon is enabled
- or not on the Master, it does not track whether network policy is enabled
- for the nodes.
- required: false
- type: dict
- version_added: '2.9'
- suboptions:
- disabled:
- description:
- - Whether NetworkPolicy is enabled for this cluster.
- required: false
- type: bool
- subnetwork:
- description:
- - The name of the Google Compute Engine subnetwork to which the cluster is connected.
- required: false
- type: str
- locations:
- description:
- - The list of Google Compute Engine zones in which the cluster's nodes should
- be located.
- required: false
- type: list
- aliases:
- - nodeLocations
- version_added: '2.9'
- resource_labels:
- description:
- - The resource labels for the cluster to use to annotate any related Google Compute
- Engine resources.
- required: false
- type: dict
- version_added: '2.9'
- legacy_abac:
- description:
- - Configuration for the legacy ABAC authorization mode.
- required: false
- type: dict
- version_added: '2.9'
- suboptions:
- enabled:
- description:
- - Whether the ABAC authorizer is enabled for this cluster. When enabled, identities
- in the system, including service accounts, nodes, and controllers, will
- have statically granted permissions beyond those provided by the RBAC configuration
- or IAM.
- required: false
- type: bool
- network_policy:
- description:
- - Configuration options for the NetworkPolicy feature.
- required: false
- type: dict
- version_added: '2.9'
- suboptions:
- provider:
- description:
- - The selected network policy provider.
- - 'Some valid choices include: "PROVIDER_UNSPECIFIED", "CALICO"'
- required: false
- type: str
- enabled:
- description:
- - Whether network policy is enabled on the cluster.
- required: false
- type: bool
- default_max_pods_constraint:
- description:
- - The default constraint on the maximum number of pods that can be run simultaneously
- on a node in the node pool of this cluster.
- - Only honored if cluster created with IP Alias support.
- required: false
- type: dict
- version_added: '2.9'
- suboptions:
- max_pods_per_node:
- description:
- - Constraint enforced on the max num of pods per node.
- required: false
- type: str
- ip_allocation_policy:
- description:
- - Configuration for controlling how IPs are allocated in the cluster.
- required: false
- type: dict
- version_added: '2.9'
- suboptions:
- use_ip_aliases:
- description:
- - Whether alias IPs will be used for pod IPs in the cluster.
- required: false
- type: bool
- create_subnetwork:
- description:
- - Whether a new subnetwork will be created automatically for the cluster.
- required: false
- type: bool
- subnetwork_name:
- description:
- - A custom subnetwork name to be used if createSubnetwork is true.
- - If this field is empty, then an automatic name will be chosen for the new
- subnetwork.
- required: false
- type: str
- cluster_secondary_range_name:
- description:
- - The name of the secondary range to be used for the cluster CIDR block. The
- secondary range will be used for pod IP addresses.
- - This must be an existing secondary range associated with the cluster subnetwork
- .
- required: false
- type: str
- services_secondary_range_name:
- description:
- - The name of the secondary range to be used as for the services CIDR block.
- The secondary range will be used for service ClusterIPs. This must be an
- existing secondary range associated with the cluster subnetwork.
- required: false
- type: str
- cluster_ipv4_cidr_block:
- description:
- - The IP address range for the cluster pod IPs. If this field is set, then
- cluster.cluster_ipv4_cidr must be left blank.
- - This field is only applicable when useIpAliases is true.
- - Set to blank to have a range chosen with the default size.
- - Set to /netmask (e.g. /14) to have a range chosen with a specific netmask.
- required: false
- type: str
- node_ipv4_cidr_block:
- description:
- - The IP address range of the instance IPs in this cluster.
- - This is applicable only if createSubnetwork is true.
- - Set to blank to have a range chosen with the default size.
- - Set to /netmask (e.g. /14) to have a range chosen with a specific netmask.
- required: false
- type: str
- services_ipv4_cidr_block:
- description:
- - The IP address range of the services IPs in this cluster. If blank, a range
- will be automatically chosen with the default size.
- - This field is only applicable when useIpAliases is true.
- - Set to blank to have a range chosen with the default size.
- - Set to /netmask (e.g. /14) to have a range chosen with a specific netmask.
- required: false
- type: str
- tpu_ipv4_cidr_block:
- description:
- - The IP address range of the Cloud TPUs in this cluster. If unspecified,
- a range will be automatically chosen with the default size.
- - This field is only applicable when useIpAliases is true.
- - If unspecified, the range will use the default size.
- - Set to /netmask (e.g. /14) to have a range chosen with a specific netmask.
- required: false
- type: str
- enable_tpu:
- description:
- - Enable the ability to use Cloud TPUs in this cluster.
- required: false
- type: bool
- version_added: '2.9'
- tpu_ipv4_cidr_block:
- description:
- - The IP address range of the Cloud TPUs in this cluster, in CIDR notation.
- required: false
- type: str
- version_added: '2.9'
- master_authorized_networks_config:
- description:
- - Configuration for controlling how IPs are allocated in the cluster.
- required: false
- type: dict
- version_added: '2.10'
- suboptions:
- enabled:
- description:
- - Whether or not master authorized networks is enabled.
- required: false
- type: bool
- cidr_blocks:
- description:
- - Define up to 50 external networks that could access Kubernetes master through
- HTTPS.
- required: false
- type: list
- suboptions:
- display_name:
- description:
- - Optional field used to identify cidr blocks.
- required: false
- type: str
- cidr_block:
- description:
- - Block specified in CIDR notation.
- required: false
- type: str
- location:
- description:
- - The location where the cluster is deployed.
- required: true
- type: str
- aliases:
- - zone
- version_added: '2.8'
- kubectl_path:
- description:
- - The path that the kubectl config file will be written to.
- - The file will not be created if this path is unset.
- - Any existing file at this path will be completely overwritten.
- - This requires the PyYaml library.
- required: false
- type: str
- version_added: '2.9'
- kubectl_context:
- description:
- - The name of the context for the kubectl config file. Will default to the cluster
- name.
- required: false
- type: str
- version_added: '2.9'
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-'''
-
-EXAMPLES = '''
-- name: create a cluster
- gcp_container_cluster:
- name: my-cluster
- initial_node_count: 2
- master_auth:
- username: cluster_admin
- password: my-secret-password
- node_config:
- machine_type: n1-standard-4
- disk_size_gb: 500
- location: us-central1-a
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-name:
- description:
- - The name of this cluster. The name must be unique within this project and location,
- and can be up to 40 characters. Must be Lowercase letters, numbers, and hyphens
- only. Must start with a letter. Must end with a number or a letter.
- returned: success
- type: str
-description:
- description:
- - An optional description of this cluster.
- returned: success
- type: str
-initialNodeCount:
- description:
- - The number of nodes to create in this cluster. You must ensure that your Compute
- Engine resource quota is sufficient for this number of instances. You must also
- have available firewall and routes quota. For requests, this field should only
- be used in lieu of a "nodePool" object, since this configuration (along with the
- "nodeConfig") will be used to create a "NodePool" object with an auto-generated
- name. Do not use this and a nodePool at the same time.
- - This field has been deprecated. Please use nodePool.initial_node_count instead.
- returned: success
- type: int
-nodeConfig:
- description:
- - Parameters used in creating the cluster's nodes.
- - For requests, this field should only be used in lieu of a "nodePool" object, since
- this configuration (along with the "initialNodeCount") will be used to create
- a "NodePool" object with an auto-generated name. Do not use this and a nodePool
- at the same time. For responses, this field will be populated with the node configuration
- of the first node pool. If unspecified, the defaults are used.
- returned: success
- type: complex
- contains:
- machineType:
- description:
- - The name of a Google Compute Engine machine type (e.g.
- - n1-standard-1). If unspecified, the default machine type is n1-standard-1.
- returned: success
- type: str
- diskSizeGb:
- description:
- - Size of the disk attached to each node, specified in GB. The smallest allowed
- disk size is 10GB. If unspecified, the default disk size is 100GB.
- returned: success
- type: int
- oauthScopes:
- description:
- - The set of Google API scopes to be made available on all of the node VMs under
- the "default" service account.
- - 'The following scopes are recommended, but not required, and by default are
- not included: U(https://www.googleapis.com/auth/compute) is required for mounting
- persistent storage on your nodes.'
- - U(https://www.googleapis.com/auth/devstorage.read_only) is required for communicating
- with gcr.io (the Google Container Registry).
- - If unspecified, no scopes are added, unless Cloud Logging or Cloud Monitoring
- are enabled, in which case their required scopes will be added.
- returned: success
- type: list
- serviceAccount:
- description:
- - The Google Cloud Platform Service Account to be used by the node VMs. If no
- Service Account is specified, the "default" service account is used.
- returned: success
- type: str
- metadata:
- description:
- - The metadata key/value pairs assigned to instances in the cluster.
- - 'Keys must conform to the regexp [a-zA-Z0-9-_]+ and be less than 128 bytes
- in length. These are reflected as part of a URL in the metadata server. Additionally,
- to avoid ambiguity, keys must not conflict with any other metadata keys for
- the project or be one of the four reserved keys: "instance-template", "kube-env",
- "startup-script", and "user-data" Values are free-form strings, and only have
- meaning as interpreted by the image running in the instance. The only restriction
- placed on them is that each value''s size must be less than or equal to 32
- KB.'
- - The total size of all keys and values must be less than 512 KB.
- - 'An object containing a list of "key": value pairs.'
- - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.'
- returned: success
- type: dict
- imageType:
- description:
- - The image type to use for this node. Note that for a given image type, the
- latest version of it will be used.
- returned: success
- type: str
- labels:
- description:
- - 'The map of Kubernetes labels (key/value pairs) to be applied to each node.
- These will added in addition to any default label(s) that Kubernetes may apply
- to the node. In case of conflict in label keys, the applied set may differ
- depending on the Kubernetes version -- it''s best to assume the behavior is
- undefined and conflicts should be avoided. For more information, including
- usage and the valid values, see: U(http://kubernetes.io/v1.1/docs/user-guide/labels.html)
- An object containing a list of "key": value pairs.'
- - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.'
- returned: success
- type: dict
- localSsdCount:
- description:
- - The number of local SSD disks to be attached to the node.
- - 'The limit for this value is dependant upon the maximum number of disks available
- on a machine per zone. See: U(https://cloud.google.com/compute/docs/disks/local-ssd#local_ssd_limits)
- for more information.'
- returned: success
- type: int
- tags:
- description:
- - The list of instance tags applied to all nodes. Tags are used to identify
- valid sources or targets for network firewalls and are specified by the client
- during cluster or node pool creation. Each tag within the list must comply
- with RFC1035.
- returned: success
- type: list
- preemptible:
- description:
- - 'Whether the nodes are created as preemptible VM instances. See: U(https://cloud.google.com/compute/docs/instances/preemptible)
- for more information about preemptible VM instances.'
- returned: success
- type: bool
- accelerators:
- description:
- - A list of hardware accelerators to be attached to each node. See U(https://cloud.google.com/compute/docs/gpus)
- for more information about support for GPUs.
- returned: success
- type: complex
- contains:
- acceleratorCount:
- description:
- - The number of accelerator cards exposed to an instance.
- returned: success
- type: str
- acceleratorType:
- description:
- - The accelerator type resource name.
- returned: success
- type: str
- diskType:
- description:
- - Type of the disk attached to each node (e.g. 'pd-standard' or 'pd-ssd') If
- unspecified, the default disk type is 'pd-standard' .
- returned: success
- type: str
- minCpuPlatform:
- description:
- - Minimum CPU platform to be used by this instance. The instance may be scheduled
- on the specified or newer CPU platform.
- returned: success
- type: str
- taints:
- description:
- - List of kubernetes taints to be applied to each node.
- - 'For more information, including usage and the valid values, see: U(https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/)
- .'
- returned: success
- type: complex
- contains:
- key:
- description:
- - Key for taint.
- returned: success
- type: str
- value:
- description:
- - Value for taint.
- returned: success
- type: str
- effect:
- description:
- - Effect for taint.
- returned: success
- type: str
-masterAuth:
- description:
- - The authentication information for accessing the master endpoint.
- returned: success
- type: complex
- contains:
- username:
- description:
- - The username to use for HTTP basic authentication to the master endpoint.
- returned: success
- type: str
- password:
- description:
- - The password to use for HTTP basic authentication to the master endpoint.
- Because the master endpoint is open to the Internet, you should create a strong
- password with a minimum of 16 characters.
- returned: success
- type: str
- clientCertificateConfig:
- description:
- - Configuration for client certificate authentication on the cluster. For clusters
- before v1.12, if no configuration is specified, a client certificate is issued.
- returned: success
- type: complex
- contains:
- issueClientCertificate:
- description:
- - Issue a client certificate.
- returned: success
- type: bool
- clusterCaCertificate:
- description:
- - Base64-encoded public certificate that is the root of trust for the cluster.
- returned: success
- type: str
- clientCertificate:
- description:
- - Base64-encoded public certificate used by clients to authenticate to the cluster
- endpoint.
- returned: success
- type: str
- clientKey:
- description:
- - Base64-encoded private key used by clients to authenticate to the cluster
- endpoint.
- returned: success
- type: str
-loggingService:
- description:
- - 'The logging service the cluster should use to write logs. Currently available
- options: logging.googleapis.com - the Google Cloud Logging service.'
- - none - no logs will be exported from the cluster.
- - if left as an empty string,logging.googleapis.com will be used.
- returned: success
- type: str
-monitoringService:
- description:
- - The monitoring service the cluster should use to write metrics.
- - 'Currently available options: monitoring.googleapis.com - the Google Cloud Monitoring
- service.'
- - none - no metrics will be exported from the cluster.
- - if left as an empty string, monitoring.googleapis.com will be used.
- returned: success
- type: str
-network:
- description:
- - The name of the Google Compute Engine network to which the cluster is connected.
- If left unspecified, the default network will be used.
- returned: success
- type: str
-privateClusterConfig:
- description:
- - Configuration for a private cluster.
- returned: success
- type: complex
- contains:
- enablePrivateNodes:
- description:
- - Whether nodes have internal IP addresses only. If enabled, all nodes are given
- only RFC 1918 private addresses and communicate with the master via private
- networking.
- returned: success
- type: bool
- enablePrivateEndpoint:
- description:
- - Whether the master's internal IP address is used as the cluster endpoint.
- returned: success
- type: bool
- masterIpv4CidrBlock:
- description:
- - The IP range in CIDR notation to use for the hosted master network. This range
- will be used for assigning internal IP addresses to the master or set of masters,
- as well as the ILB VIP. This range must not overlap with any other ranges
- in use within the cluster's network.
- returned: success
- type: str
- privateEndpoint:
- description:
- - The internal IP address of this cluster's master endpoint.
- returned: success
- type: str
- publicEndpoint:
- description:
- - The external IP address of this cluster's master endpoint.
- returned: success
- type: str
-clusterIpv4Cidr:
- description:
- - The IP address range of the container pods in this cluster, in CIDR notation (e.g.
- 10.96.0.0/14). Leave blank to have one automatically chosen or specify a /14 block
- in 10.0.0.0/8.
- returned: success
- type: str
-addonsConfig:
- description:
- - Configurations for the various addons available to run in the cluster.
- returned: success
- type: complex
- contains:
- httpLoadBalancing:
- description:
- - Configuration for the HTTP (L7) load balancing controller addon, which makes
- it easy to set up HTTP load balancers for services in a cluster.
- returned: success
- type: complex
- contains:
- disabled:
- description:
- - Whether the HTTP Load Balancing controller is enabled in the cluster.
- When enabled, it runs a small pod in the cluster that manages the load
- balancers.
- returned: success
- type: bool
- horizontalPodAutoscaling:
- description:
- - Configuration for the horizontal pod autoscaling feature, which increases
- or decreases the number of replica pods a replication controller has based
- on the resource usage of the existing pods.
- returned: success
- type: complex
- contains:
- disabled:
- description:
- - Whether the Horizontal Pod Autoscaling feature is enabled in the cluster.
- When enabled, it ensures that a Heapster pod is running in the cluster,
- which is also used by the Cloud Monitoring service.
- returned: success
- type: bool
- networkPolicyConfig:
- description:
- - Configuration for NetworkPolicy. This only tracks whether the addon is enabled
- or not on the Master, it does not track whether network policy is enabled
- for the nodes.
- returned: success
- type: complex
- contains:
- disabled:
- description:
- - Whether NetworkPolicy is enabled for this cluster.
- returned: success
- type: bool
-subnetwork:
- description:
- - The name of the Google Compute Engine subnetwork to which the cluster is connected.
- returned: success
- type: str
-locations:
- description:
- - The list of Google Compute Engine zones in which the cluster's nodes should be
- located.
- returned: success
- type: list
-resourceLabels:
- description:
- - The resource labels for the cluster to use to annotate any related Google Compute
- Engine resources.
- returned: success
- type: dict
-labelFingerprint:
- description:
- - The fingerprint of the set of labels for this cluster.
- returned: success
- type: str
-legacyAbac:
- description:
- - Configuration for the legacy ABAC authorization mode.
- returned: success
- type: complex
- contains:
- enabled:
- description:
- - Whether the ABAC authorizer is enabled for this cluster. When enabled, identities
- in the system, including service accounts, nodes, and controllers, will have
- statically granted permissions beyond those provided by the RBAC configuration
- or IAM.
- returned: success
- type: bool
-networkPolicy:
- description:
- - Configuration options for the NetworkPolicy feature.
- returned: success
- type: complex
- contains:
- provider:
- description:
- - The selected network policy provider.
- returned: success
- type: str
- enabled:
- description:
- - Whether network policy is enabled on the cluster.
- returned: success
- type: bool
-defaultMaxPodsConstraint:
- description:
- - The default constraint on the maximum number of pods that can be run simultaneously
- on a node in the node pool of this cluster.
- - Only honored if cluster created with IP Alias support.
- returned: success
- type: complex
- contains:
- maxPodsPerNode:
- description:
- - Constraint enforced on the max num of pods per node.
- returned: success
- type: str
-ipAllocationPolicy:
- description:
- - Configuration for controlling how IPs are allocated in the cluster.
- returned: success
- type: complex
- contains:
- useIpAliases:
- description:
- - Whether alias IPs will be used for pod IPs in the cluster.
- returned: success
- type: bool
- createSubnetwork:
- description:
- - Whether a new subnetwork will be created automatically for the cluster.
- returned: success
- type: bool
- subnetworkName:
- description:
- - A custom subnetwork name to be used if createSubnetwork is true.
- - If this field is empty, then an automatic name will be chosen for the new
- subnetwork.
- returned: success
- type: str
- clusterSecondaryRangeName:
- description:
- - The name of the secondary range to be used for the cluster CIDR block. The
- secondary range will be used for pod IP addresses.
- - This must be an existing secondary range associated with the cluster subnetwork
- .
- returned: success
- type: str
- servicesSecondaryRangeName:
- description:
- - The name of the secondary range to be used as for the services CIDR block.
- The secondary range will be used for service ClusterIPs. This must be an existing
- secondary range associated with the cluster subnetwork.
- returned: success
- type: str
- clusterIpv4CidrBlock:
- description:
- - The IP address range for the cluster pod IPs. If this field is set, then cluster.cluster_ipv4_cidr
- must be left blank.
- - This field is only applicable when useIpAliases is true.
- - Set to blank to have a range chosen with the default size.
- - Set to /netmask (e.g. /14) to have a range chosen with a specific netmask.
- returned: success
- type: str
- nodeIpv4CidrBlock:
- description:
- - The IP address range of the instance IPs in this cluster.
- - This is applicable only if createSubnetwork is true.
- - Set to blank to have a range chosen with the default size.
- - Set to /netmask (e.g. /14) to have a range chosen with a specific netmask.
- returned: success
- type: str
- servicesIpv4CidrBlock:
- description:
- - The IP address range of the services IPs in this cluster. If blank, a range
- will be automatically chosen with the default size.
- - This field is only applicable when useIpAliases is true.
- - Set to blank to have a range chosen with the default size.
- - Set to /netmask (e.g. /14) to have a range chosen with a specific netmask.
- returned: success
- type: str
- tpuIpv4CidrBlock:
- description:
- - The IP address range of the Cloud TPUs in this cluster. If unspecified, a
- range will be automatically chosen with the default size.
- - This field is only applicable when useIpAliases is true.
- - If unspecified, the range will use the default size.
- - Set to /netmask (e.g. /14) to have a range chosen with a specific netmask.
- returned: success
- type: str
-endpoint:
- description:
- - The IP address of this cluster's master endpoint.
- - The endpoint can be accessed from the internet at https://username:password@endpoint/
- See the masterAuth property of this resource for username and password information.
- returned: success
- type: str
-initialClusterVersion:
- description:
- - The software version of the master endpoint and kubelets used in the cluster when
- it was first created. The version can be upgraded over time.
- returned: success
- type: str
-currentMasterVersion:
- description:
- - The current software version of the master endpoint.
- returned: success
- type: str
-currentNodeVersion:
- description:
- - The current version of the node software components. If they are currently at
- multiple versions because they're in the process of being upgraded, this reflects
- the minimum version of all nodes.
- returned: success
- type: str
-createTime:
- description:
- - The time the cluster was created, in RFC3339 text format.
- returned: success
- type: str
-status:
- description:
- - The current status of this cluster.
- returned: success
- type: str
-statusMessage:
- description:
- - Additional information about the current status of this cluster, if available.
- returned: success
- type: str
-nodeIpv4CidrSize:
- description:
- - The size of the address space on each node for hosting containers.
- - This is provisioned from within the container_ipv4_cidr range.
- returned: success
- type: int
-servicesIpv4Cidr:
- description:
- - The IP address range of the Kubernetes services in this cluster, in CIDR notation
- (e.g. 1.2.3.4/29). Service addresses are typically put in the last /16 from the
- container CIDR.
- returned: success
- type: str
-currentNodeCount:
- description:
- - The number of nodes currently in the cluster.
- returned: success
- type: int
-expireTime:
- description:
- - The time the cluster will be automatically deleted in RFC3339 text format.
- returned: success
- type: str
-enableTpu:
- description:
- - Enable the ability to use Cloud TPUs in this cluster.
- returned: success
- type: bool
-tpuIpv4CidrBlock:
- description:
- - The IP address range of the Cloud TPUs in this cluster, in CIDR notation.
- returned: success
- type: str
-conditions:
- description:
- - Which conditions caused the current cluster state.
- returned: success
- type: complex
- contains:
- code:
- description:
- - Machine-friendly representation of the condition.
- returned: success
- type: str
- message:
- description:
- - Human-friendly representation of the condition.
- returned: success
- type: str
-masterAuthorizedNetworksConfig:
- description:
- - Configuration for controlling how IPs are allocated in the cluster.
- returned: success
- type: complex
- contains:
- enabled:
- description:
- - Whether or not master authorized networks is enabled.
- returned: success
- type: bool
- cidrBlocks:
- description:
- - Define up to 50 external networks that could access Kubernetes master through
- HTTPS.
- returned: success
- type: complex
- contains:
- displayName:
- description:
- - Optional field used to identify cidr blocks.
- returned: success
- type: str
- cidrBlock:
- description:
- - Block specified in CIDR notation.
- returned: success
- type: str
-location:
- description:
- - The location where the cluster is deployed.
- returned: success
- type: str
-kubectlPath:
- description:
- - The path that the kubectl config file will be written to.
- - The file will not be created if this path is unset.
- - Any existing file at this path will be completely overwritten.
- - This requires the PyYaml library.
- returned: success
- type: str
-kubectlContext:
- description:
- - The name of the context for the kubectl config file. Will default to the cluster
- name.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- name=dict(type='str'),
- description=dict(type='str'),
- initial_node_count=dict(type='int'),
- node_config=dict(
- type='dict',
- options=dict(
- machine_type=dict(type='str'),
- disk_size_gb=dict(type='int'),
- oauth_scopes=dict(type='list', elements='str'),
- service_account=dict(type='str'),
- metadata=dict(type='dict'),
- image_type=dict(type='str'),
- labels=dict(type='dict'),
- local_ssd_count=dict(type='int'),
- tags=dict(type='list', elements='str'),
- preemptible=dict(type='bool'),
- accelerators=dict(type='list', elements='dict', options=dict(accelerator_count=dict(type='str'), accelerator_type=dict(type='str'))),
- disk_type=dict(type='str'),
- min_cpu_platform=dict(type='str'),
- taints=dict(type='list', elements='dict', options=dict(key=dict(type='str'), value=dict(type='str'), effect=dict(type='str'))),
- ),
- ),
- master_auth=dict(
- type='dict',
- options=dict(
- username=dict(type='str'),
- password=dict(type='str'),
- client_certificate_config=dict(type='dict', options=dict(issue_client_certificate=dict(type='bool'))),
- ),
- ),
- logging_service=dict(type='str'),
- monitoring_service=dict(type='str'),
- network=dict(type='str'),
- private_cluster_config=dict(
- type='dict',
- options=dict(enable_private_nodes=dict(type='bool'), enable_private_endpoint=dict(type='bool'), master_ipv4_cidr_block=dict(type='str')),
- ),
- cluster_ipv4_cidr=dict(type='str'),
- addons_config=dict(
- type='dict',
- options=dict(
- http_load_balancing=dict(type='dict', options=dict(disabled=dict(type='bool'))),
- horizontal_pod_autoscaling=dict(type='dict', options=dict(disabled=dict(type='bool'))),
- network_policy_config=dict(type='dict', options=dict(disabled=dict(type='bool'))),
- ),
- ),
- subnetwork=dict(type='str'),
- locations=dict(type='list', elements='str', aliases=['nodeLocations']),
- resource_labels=dict(type='dict'),
- legacy_abac=dict(type='dict', options=dict(enabled=dict(type='bool'))),
- network_policy=dict(type='dict', options=dict(provider=dict(type='str'), enabled=dict(type='bool'))),
- default_max_pods_constraint=dict(type='dict', options=dict(max_pods_per_node=dict(type='str'))),
- ip_allocation_policy=dict(
- type='dict',
- options=dict(
- use_ip_aliases=dict(type='bool'),
- create_subnetwork=dict(type='bool'),
- subnetwork_name=dict(type='str'),
- cluster_secondary_range_name=dict(type='str'),
- services_secondary_range_name=dict(type='str'),
- cluster_ipv4_cidr_block=dict(type='str'),
- node_ipv4_cidr_block=dict(type='str'),
- services_ipv4_cidr_block=dict(type='str'),
- tpu_ipv4_cidr_block=dict(type='str'),
- ),
- ),
- enable_tpu=dict(type='bool'),
- tpu_ipv4_cidr_block=dict(type='str'),
- master_authorized_networks_config=dict(
- type='dict',
- options=dict(
- enabled=dict(type='bool'),
- cidr_blocks=dict(type='list', elements='dict', options=dict(display_name=dict(type='str'), cidr_block=dict(type='str'))),
- ),
- ),
- location=dict(required=True, type='str', aliases=['zone']),
- kubectl_path=dict(type='str'),
- kubectl_context=dict(type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
-
- state = module.params['state']
-
- fetch = fetch_resource(module, self_link(module))
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module))
- fetch = fetch_resource(module, self_link(module))
- changed = True
- else:
- delete(module, self_link(module))
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module))
- delete_default_node_pool(module)
- changed = True
- else:
- fetch = {}
-
- if module.params.get('kubectl_path'):
- Kubectl(module).write_file()
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link):
- auth = GcpSession(module, 'container')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link):
- auth = GcpSession(module, 'container')
- return wait_for_operation(module, auth.put(link, resource_to_request(module)))
-
-
-def delete(module, link):
- auth = GcpSession(module, 'container')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'name': module.params.get('name'),
- u'description': module.params.get('description'),
- u'initialNodeCount': module.params.get('initial_node_count'),
- u'nodeConfig': ClusterNodeconfig(module.params.get('node_config', {}), module).to_request(),
- u'masterAuth': ClusterMasterauth(module.params.get('master_auth', {}), module).to_request(),
- u'loggingService': module.params.get('logging_service'),
- u'monitoringService': module.params.get('monitoring_service'),
- u'network': module.params.get('network'),
- u'privateClusterConfig': ClusterPrivateclusterconfig(module.params.get('private_cluster_config', {}), module).to_request(),
- u'clusterIpv4Cidr': module.params.get('cluster_ipv4_cidr'),
- u'addonsConfig': ClusterAddonsconfig(module.params.get('addons_config', {}), module).to_request(),
- u'subnetwork': module.params.get('subnetwork'),
- u'locations': module.params.get('locations'),
- u'resourceLabels': module.params.get('resource_labels'),
- u'legacyAbac': ClusterLegacyabac(module.params.get('legacy_abac', {}), module).to_request(),
- u'networkPolicy': ClusterNetworkpolicy(module.params.get('network_policy', {}), module).to_request(),
- u'defaultMaxPodsConstraint': ClusterDefaultmaxpodsconstraint(module.params.get('default_max_pods_constraint', {}), module).to_request(),
- u'ipAllocationPolicy': ClusterIpallocationpolicy(module.params.get('ip_allocation_policy', {}), module).to_request(),
- u'enableTpu': module.params.get('enable_tpu'),
- u'tpuIpv4CidrBlock': module.params.get('tpu_ipv4_cidr_block'),
- u'masterAuthorizedNetworksConfig': ClusterMasterauthorizednetworksconfig(
- module.params.get('master_authorized_networks_config', {}), module
- ).to_request(),
- }
- request = encode_request(request, module)
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, allow_not_found=True):
- auth = GcpSession(module, 'container')
- return return_if_object(module, auth.get(link), allow_not_found)
-
-
-def self_link(module):
- return "https://container.googleapis.com/v1/projects/{project}/locations/{location}/clusters/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://container.googleapis.com/v1/projects/{project}/locations/{location}/clusters".format(**module.params)
-
-
-def return_if_object(module, response, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'name': response.get(u'name'),
- u'description': response.get(u'description'),
- u'initialNodeCount': module.params.get('initial_node_count'),
- u'nodeConfig': ClusterNodeconfig(module.params.get('node_config', {}), module).to_request(),
- u'masterAuth': ClusterMasterauth(response.get(u'masterAuth', {}), module).from_response(),
- u'loggingService': response.get(u'loggingService'),
- u'monitoringService': response.get(u'monitoringService'),
- u'network': response.get(u'network'),
- u'privateClusterConfig': ClusterPrivateclusterconfig(response.get(u'privateClusterConfig', {}), module).from_response(),
- u'clusterIpv4Cidr': response.get(u'clusterIpv4Cidr'),
- u'addonsConfig': ClusterAddonsconfig(response.get(u'addonsConfig', {}), module).from_response(),
- u'subnetwork': response.get(u'subnetwork'),
- u'locations': response.get(u'locations'),
- u'resourceLabels': response.get(u'resourceLabels'),
- u'labelFingerprint': response.get(u'labelFingerprint'),
- u'legacyAbac': ClusterLegacyabac(response.get(u'legacyAbac', {}), module).from_response(),
- u'networkPolicy': ClusterNetworkpolicy(response.get(u'networkPolicy', {}), module).from_response(),
- u'defaultMaxPodsConstraint': ClusterDefaultmaxpodsconstraint(response.get(u'defaultMaxPodsConstraint', {}), module).from_response(),
- u'ipAllocationPolicy': ClusterIpallocationpolicy(response.get(u'ipAllocationPolicy', {}), module).from_response(),
- u'endpoint': response.get(u'endpoint'),
- u'initialClusterVersion': response.get(u'initialClusterVersion'),
- u'currentMasterVersion': response.get(u'currentMasterVersion'),
- u'currentNodeVersion': response.get(u'currentNodeVersion'),
- u'createTime': response.get(u'createTime'),
- u'status': response.get(u'status'),
- u'statusMessage': response.get(u'statusMessage'),
- u'nodeIpv4CidrSize': response.get(u'nodeIpv4CidrSize'),
- u'servicesIpv4Cidr': response.get(u'servicesIpv4Cidr'),
- u'currentNodeCount': response.get(u'currentNodeCount'),
- u'expireTime': response.get(u'expireTime'),
- u'enableTpu': response.get(u'enableTpu'),
- u'tpuIpv4CidrBlock': response.get(u'tpuIpv4CidrBlock'),
- u'conditions': ClusterConditionsArray(response.get(u'conditions', []), module).from_response(),
- u'masterAuthorizedNetworksConfig': ClusterMasterauthorizednetworksconfig(response.get(u'masterAuthorizedNetworksConfig', {}), module).from_response(),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://container.googleapis.com/v1/projects/{project}/locations/{location}/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response)
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']))
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-# Google Container Engine API has its own layout for the create method,
-# defined like this:
-#
-# {
-# 'cluster': {
-# ... cluster data
-# }
-# }
-#
-# Format the request to match the expected input by the API
-def encode_request(resource_request, module):
- return {'cluster': resource_request}
-
-
-# Deletes the default node pool on default creation.
-def delete_default_node_pool(module):
- auth = GcpSession(module, 'container')
- link = "https://container.googleapis.com/v1/projects/%s/locations/%s/clusters/%s/nodePools/default-pool" % (
- module.params['project'],
- module.params['location'],
- module.params['name'],
- )
- return wait_for_operation(module, auth.delete(link))
-
-
-class Kubectl(object):
- def __init__(self, module):
- self.module = module
-
- """
- Writes a kubectl config file
- kubectl_path must be set or this will fail.
- """
-
- def write_file(self):
- try:
- import yaml
- except ImportError:
- self.module.fail_json(msg="Please install the pyyaml module")
-
- with open(self.module.params['kubectl_path'], 'w') as f:
- f.write(yaml.dump(self._contents()))
-
- """
- Returns the contents of a kubectl file
- """
-
- def _contents(self):
- token = self._auth_token()
- endpoint = "https://%s" % self.fetch["endpoint"]
- context = self.module.params.get('kubectl_context')
- if not context:
- context = self.module.params['name']
-
- return {
- 'apiVersion': 'v1',
- 'clusters': [
- {'name': context, 'cluster': {'certificate-authority-data': str(self.fetch['masterAuth']['clusterCaCertificate']), 'server': endpoint}}
- ],
- 'contexts': [{'name': context, 'context': {'cluster': context, 'user': context}}],
- 'current-context': context,
- 'kind': 'Config',
- 'preferences': {},
- 'users': [
- {
- 'name': context,
- 'user': {
- 'auth-provider': {
- 'config': {
- 'access-token': token,
- 'cmd-args': 'config config-helper --format=json',
- 'cmd-path': '/usr/lib64/google-cloud-sdk/bin/gcloud',
- 'expiry-key': '{.credential.token_expiry}',
- 'token-key': '{.credential.access_token}',
- },
- 'name': 'gcp',
- },
- 'username': str(self.fetch['masterAuth']['username']),
- 'password': str(self.fetch['masterAuth']['password']),
- },
- }
- ],
- }
-
- """
- Returns the auth token used in kubectl
- This also sets the 'fetch' variable used in creating the kubectl
- """
-
- def _auth_token(self):
- auth = GcpSession(self.module, 'auth')
- response = auth.get(self_link(self.module))
- self.fetch = response.json()
- return response.request.headers['authorization'].split(' ')[1]
-
-
-class ClusterNodeconfig(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'machineType': self.request.get('machine_type'),
- u'diskSizeGb': self.request.get('disk_size_gb'),
- u'oauthScopes': self.request.get('oauth_scopes'),
- u'serviceAccount': self.request.get('service_account'),
- u'metadata': self.request.get('metadata'),
- u'imageType': self.request.get('image_type'),
- u'labels': self.request.get('labels'),
- u'localSsdCount': self.request.get('local_ssd_count'),
- u'tags': self.request.get('tags'),
- u'preemptible': self.request.get('preemptible'),
- u'accelerators': ClusterAcceleratorsArray(self.request.get('accelerators', []), self.module).to_request(),
- u'diskType': self.request.get('disk_type'),
- u'minCpuPlatform': self.request.get('min_cpu_platform'),
- u'taints': ClusterTaintsArray(self.request.get('taints', []), self.module).to_request(),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'machineType': self.request.get(u'machineType'),
- u'diskSizeGb': self.request.get(u'diskSizeGb'),
- u'oauthScopes': self.request.get(u'oauthScopes'),
- u'serviceAccount': self.request.get(u'serviceAccount'),
- u'metadata': self.request.get(u'metadata'),
- u'imageType': self.request.get(u'imageType'),
- u'labels': self.request.get(u'labels'),
- u'localSsdCount': self.request.get(u'localSsdCount'),
- u'tags': self.request.get(u'tags'),
- u'preemptible': self.request.get(u'preemptible'),
- u'accelerators': ClusterAcceleratorsArray(self.request.get(u'accelerators', []), self.module).from_response(),
- u'diskType': self.request.get(u'diskType'),
- u'minCpuPlatform': self.request.get(u'minCpuPlatform'),
- u'taints': ClusterTaintsArray(self.request.get(u'taints', []), self.module).from_response(),
- }
- )
-
-
-class ClusterAcceleratorsArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'acceleratorCount': item.get('accelerator_count'), u'acceleratorType': item.get('accelerator_type')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'acceleratorCount': item.get(u'acceleratorCount'), u'acceleratorType': item.get(u'acceleratorType')})
-
-
-class ClusterTaintsArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'key': item.get('key'), u'value': item.get('value'), u'effect': item.get('effect')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'key': item.get(u'key'), u'value': item.get(u'value'), u'effect': item.get(u'effect')})
-
-
-class ClusterMasterauth(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'username': self.request.get('username'),
- u'password': self.request.get('password'),
- u'clientCertificateConfig': ClusterClientcertificateconfig(self.request.get('client_certificate_config', {}), self.module).to_request(),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'username': self.request.get(u'username'),
- u'password': self.request.get(u'password'),
- u'clientCertificateConfig': ClusterClientcertificateconfig(self.request.get(u'clientCertificateConfig', {}), self.module).from_response(),
- }
- )
-
-
-class ClusterClientcertificateconfig(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'issueClientCertificate': self.request.get('issue_client_certificate')})
-
- def from_response(self):
- return remove_nones_from_dict({u'issueClientCertificate': self.request.get(u'issueClientCertificate')})
-
-
-class ClusterPrivateclusterconfig(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'enablePrivateNodes': self.request.get('enable_private_nodes'),
- u'enablePrivateEndpoint': self.request.get('enable_private_endpoint'),
- u'masterIpv4CidrBlock': self.request.get('master_ipv4_cidr_block'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'enablePrivateNodes': self.request.get(u'enablePrivateNodes'),
- u'enablePrivateEndpoint': self.request.get(u'enablePrivateEndpoint'),
- u'masterIpv4CidrBlock': self.request.get(u'masterIpv4CidrBlock'),
- }
- )
-
-
-class ClusterAddonsconfig(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'httpLoadBalancing': ClusterHttploadbalancing(self.request.get('http_load_balancing', {}), self.module).to_request(),
- u'horizontalPodAutoscaling': ClusterHorizontalpodautoscaling(self.request.get('horizontal_pod_autoscaling', {}), self.module).to_request(),
- u'networkPolicyConfig': ClusterNetworkpolicyconfig(self.request.get('network_policy_config', {}), self.module).to_request(),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'httpLoadBalancing': ClusterHttploadbalancing(self.request.get(u'httpLoadBalancing', {}), self.module).from_response(),
- u'horizontalPodAutoscaling': ClusterHorizontalpodautoscaling(self.request.get(u'horizontalPodAutoscaling', {}), self.module).from_response(),
- u'networkPolicyConfig': ClusterNetworkpolicyconfig(self.request.get(u'networkPolicyConfig', {}), self.module).from_response(),
- }
- )
-
-
-class ClusterHttploadbalancing(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'disabled': self.request.get('disabled')})
-
- def from_response(self):
- return remove_nones_from_dict({u'disabled': self.request.get(u'disabled')})
-
-
-class ClusterHorizontalpodautoscaling(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'disabled': self.request.get('disabled')})
-
- def from_response(self):
- return remove_nones_from_dict({u'disabled': self.request.get(u'disabled')})
-
-
-class ClusterNetworkpolicyconfig(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'disabled': self.request.get('disabled')})
-
- def from_response(self):
- return remove_nones_from_dict({u'disabled': self.request.get(u'disabled')})
-
-
-class ClusterLegacyabac(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'enabled': self.request.get('enabled')})
-
- def from_response(self):
- return remove_nones_from_dict({u'enabled': self.request.get(u'enabled')})
-
-
-class ClusterNetworkpolicy(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'provider': self.request.get('provider'), u'enabled': self.request.get('enabled')})
-
- def from_response(self):
- return remove_nones_from_dict({u'provider': self.request.get(u'provider'), u'enabled': self.request.get(u'enabled')})
-
-
-class ClusterDefaultmaxpodsconstraint(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'maxPodsPerNode': self.request.get('max_pods_per_node')})
-
- def from_response(self):
- return remove_nones_from_dict({u'maxPodsPerNode': self.request.get(u'maxPodsPerNode')})
-
-
-class ClusterIpallocationpolicy(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'useIpAliases': self.request.get('use_ip_aliases'),
- u'createSubnetwork': self.request.get('create_subnetwork'),
- u'subnetworkName': self.request.get('subnetwork_name'),
- u'clusterSecondaryRangeName': self.request.get('cluster_secondary_range_name'),
- u'servicesSecondaryRangeName': self.request.get('services_secondary_range_name'),
- u'clusterIpv4CidrBlock': self.request.get('cluster_ipv4_cidr_block'),
- u'nodeIpv4CidrBlock': self.request.get('node_ipv4_cidr_block'),
- u'servicesIpv4CidrBlock': self.request.get('services_ipv4_cidr_block'),
- u'tpuIpv4CidrBlock': self.request.get('tpu_ipv4_cidr_block'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'useIpAliases': self.request.get(u'useIpAliases'),
- u'createSubnetwork': self.request.get(u'createSubnetwork'),
- u'subnetworkName': self.request.get(u'subnetworkName'),
- u'clusterSecondaryRangeName': self.request.get(u'clusterSecondaryRangeName'),
- u'servicesSecondaryRangeName': self.request.get(u'servicesSecondaryRangeName'),
- u'clusterIpv4CidrBlock': self.request.get(u'clusterIpv4CidrBlock'),
- u'nodeIpv4CidrBlock': self.request.get(u'nodeIpv4CidrBlock'),
- u'servicesIpv4CidrBlock': self.request.get(u'servicesIpv4CidrBlock'),
- u'tpuIpv4CidrBlock': self.request.get(u'tpuIpv4CidrBlock'),
- }
- )
-
-
-class ClusterConditionsArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'code': item.get('code'), u'message': item.get('message')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'code': item.get(u'code'), u'message': item.get(u'message')})
-
-
-class ClusterMasterauthorizednetworksconfig(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {u'enabled': self.request.get('enabled'), u'cidrBlocks': ClusterCidrblocksArray(self.request.get('cidr_blocks', []), self.module).to_request()}
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {u'enabled': self.request.get(u'enabled'), u'cidrBlocks': ClusterCidrblocksArray(self.request.get(u'cidrBlocks', []), self.module).from_response()}
- )
-
-
-class ClusterCidrblocksArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'displayName': item.get('display_name'), u'cidrBlock': item.get('cidr_block')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'displayName': item.get(u'displayName'), u'cidrBlock': item.get(u'cidrBlock')})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_container_cluster_info.py b/lib/ansible/modules/cloud/google/gcp_container_cluster_info.py
deleted file mode 100644
index f489c36670..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_container_cluster_info.py
+++ /dev/null
@@ -1,767 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_container_cluster_info
-description:
-- Gather info for GCP Cluster
-short_description: Gather info for GCP Cluster
-version_added: '2.8'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- location:
- description:
- - The location where the cluster is deployed.
- required: true
- type: str
- aliases:
- - region
- - zone
- version_added: '2.8'
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a cluster
- gcp_container_cluster_info:
- location: us-central1-a
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- name:
- description:
- - The name of this cluster. The name must be unique within this project and
- location, and can be up to 40 characters. Must be Lowercase letters, numbers,
- and hyphens only. Must start with a letter. Must end with a number or a letter.
- returned: success
- type: str
- description:
- description:
- - An optional description of this cluster.
- returned: success
- type: str
- initialNodeCount:
- description:
- - The number of nodes to create in this cluster. You must ensure that your Compute
- Engine resource quota is sufficient for this number of instances. You must
- also have available firewall and routes quota. For requests, this field should
- only be used in lieu of a "nodePool" object, since this configuration (along
- with the "nodeConfig") will be used to create a "NodePool" object with an
- auto-generated name. Do not use this and a nodePool at the same time.
- - This field has been deprecated. Please use nodePool.initial_node_count instead.
- returned: success
- type: int
- nodeConfig:
- description:
- - Parameters used in creating the cluster's nodes.
- - For requests, this field should only be used in lieu of a "nodePool" object,
- since this configuration (along with the "initialNodeCount") will be used
- to create a "NodePool" object with an auto-generated name. Do not use this
- and a nodePool at the same time. For responses, this field will be populated
- with the node configuration of the first node pool. If unspecified, the defaults
- are used.
- returned: success
- type: complex
- contains:
- machineType:
- description:
- - The name of a Google Compute Engine machine type (e.g.
- - n1-standard-1). If unspecified, the default machine type is n1-standard-1.
- returned: success
- type: str
- diskSizeGb:
- description:
- - Size of the disk attached to each node, specified in GB. The smallest
- allowed disk size is 10GB. If unspecified, the default disk size is 100GB.
- returned: success
- type: int
- oauthScopes:
- description:
- - The set of Google API scopes to be made available on all of the node VMs
- under the "default" service account.
- - 'The following scopes are recommended, but not required, and by default
- are not included: U(https://www.googleapis.com/auth/compute) is required
- for mounting persistent storage on your nodes.'
- - U(https://www.googleapis.com/auth/devstorage.read_only) is required for
- communicating with gcr.io (the Google Container Registry).
- - If unspecified, no scopes are added, unless Cloud Logging or Cloud Monitoring
- are enabled, in which case their required scopes will be added.
- returned: success
- type: list
- serviceAccount:
- description:
- - The Google Cloud Platform Service Account to be used by the node VMs.
- If no Service Account is specified, the "default" service account is used.
- returned: success
- type: str
- metadata:
- description:
- - The metadata key/value pairs assigned to instances in the cluster.
- - 'Keys must conform to the regexp [a-zA-Z0-9-_]+ and be less than 128 bytes
- in length. These are reflected as part of a URL in the metadata server.
- Additionally, to avoid ambiguity, keys must not conflict with any other
- metadata keys for the project or be one of the four reserved keys: "instance-template",
- "kube-env", "startup-script", and "user-data" Values are free-form strings,
- and only have meaning as interpreted by the image running in the instance.
- The only restriction placed on them is that each value''s size must be
- less than or equal to 32 KB.'
- - The total size of all keys and values must be less than 512 KB.
- - 'An object containing a list of "key": value pairs.'
- - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.'
- returned: success
- type: dict
- imageType:
- description:
- - The image type to use for this node. Note that for a given image type,
- the latest version of it will be used.
- returned: success
- type: str
- labels:
- description:
- - 'The map of Kubernetes labels (key/value pairs) to be applied to each
- node. These will added in addition to any default label(s) that Kubernetes
- may apply to the node. In case of conflict in label keys, the applied
- set may differ depending on the Kubernetes version -- it''s best to assume
- the behavior is undefined and conflicts should be avoided. For more information,
- including usage and the valid values, see: U(http://kubernetes.io/v1.1/docs/user-guide/labels.html)
- An object containing a list of "key": value pairs.'
- - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.'
- returned: success
- type: dict
- localSsdCount:
- description:
- - The number of local SSD disks to be attached to the node.
- - 'The limit for this value is dependant upon the maximum number of disks
- available on a machine per zone. See: U(https://cloud.google.com/compute/docs/disks/local-ssd#local_ssd_limits)
- for more information.'
- returned: success
- type: int
- tags:
- description:
- - The list of instance tags applied to all nodes. Tags are used to identify
- valid sources or targets for network firewalls and are specified by the
- client during cluster or node pool creation. Each tag within the list
- must comply with RFC1035.
- returned: success
- type: list
- preemptible:
- description:
- - 'Whether the nodes are created as preemptible VM instances. See: U(https://cloud.google.com/compute/docs/instances/preemptible)
- for more information about preemptible VM instances.'
- returned: success
- type: bool
- accelerators:
- description:
- - A list of hardware accelerators to be attached to each node. See U(https://cloud.google.com/compute/docs/gpus)
- for more information about support for GPUs.
- returned: success
- type: complex
- contains:
- acceleratorCount:
- description:
- - The number of accelerator cards exposed to an instance.
- returned: success
- type: str
- acceleratorType:
- description:
- - The accelerator type resource name.
- returned: success
- type: str
- diskType:
- description:
- - Type of the disk attached to each node (e.g. 'pd-standard' or 'pd-ssd')
- If unspecified, the default disk type is 'pd-standard' .
- returned: success
- type: str
- minCpuPlatform:
- description:
- - Minimum CPU platform to be used by this instance. The instance may be
- scheduled on the specified or newer CPU platform.
- returned: success
- type: str
- taints:
- description:
- - List of kubernetes taints to be applied to each node.
- - 'For more information, including usage and the valid values, see: U(https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/)
- .'
- returned: success
- type: complex
- contains:
- key:
- description:
- - Key for taint.
- returned: success
- type: str
- value:
- description:
- - Value for taint.
- returned: success
- type: str
- effect:
- description:
- - Effect for taint.
- returned: success
- type: str
- masterAuth:
- description:
- - The authentication information for accessing the master endpoint.
- returned: success
- type: complex
- contains:
- username:
- description:
- - The username to use for HTTP basic authentication to the master endpoint.
- returned: success
- type: str
- password:
- description:
- - The password to use for HTTP basic authentication to the master endpoint.
- Because the master endpoint is open to the Internet, you should create
- a strong password with a minimum of 16 characters.
- returned: success
- type: str
- clientCertificateConfig:
- description:
- - Configuration for client certificate authentication on the cluster. For
- clusters before v1.12, if no configuration is specified, a client certificate
- is issued.
- returned: success
- type: complex
- contains:
- issueClientCertificate:
- description:
- - Issue a client certificate.
- returned: success
- type: bool
- clusterCaCertificate:
- description:
- - Base64-encoded public certificate that is the root of trust for the cluster.
- returned: success
- type: str
- clientCertificate:
- description:
- - Base64-encoded public certificate used by clients to authenticate to the
- cluster endpoint.
- returned: success
- type: str
- clientKey:
- description:
- - Base64-encoded private key used by clients to authenticate to the cluster
- endpoint.
- returned: success
- type: str
- loggingService:
- description:
- - 'The logging service the cluster should use to write logs. Currently available
- options: logging.googleapis.com - the Google Cloud Logging service.'
- - none - no logs will be exported from the cluster.
- - if left as an empty string,logging.googleapis.com will be used.
- returned: success
- type: str
- monitoringService:
- description:
- - The monitoring service the cluster should use to write metrics.
- - 'Currently available options: monitoring.googleapis.com - the Google Cloud
- Monitoring service.'
- - none - no metrics will be exported from the cluster.
- - if left as an empty string, monitoring.googleapis.com will be used.
- returned: success
- type: str
- network:
- description:
- - The name of the Google Compute Engine network to which the cluster is connected.
- If left unspecified, the default network will be used.
- returned: success
- type: str
- privateClusterConfig:
- description:
- - Configuration for a private cluster.
- returned: success
- type: complex
- contains:
- enablePrivateNodes:
- description:
- - Whether nodes have internal IP addresses only. If enabled, all nodes are
- given only RFC 1918 private addresses and communicate with the master
- via private networking.
- returned: success
- type: bool
- enablePrivateEndpoint:
- description:
- - Whether the master's internal IP address is used as the cluster endpoint.
- returned: success
- type: bool
- masterIpv4CidrBlock:
- description:
- - The IP range in CIDR notation to use for the hosted master network. This
- range will be used for assigning internal IP addresses to the master or
- set of masters, as well as the ILB VIP. This range must not overlap with
- any other ranges in use within the cluster's network.
- returned: success
- type: str
- privateEndpoint:
- description:
- - The internal IP address of this cluster's master endpoint.
- returned: success
- type: str
- publicEndpoint:
- description:
- - The external IP address of this cluster's master endpoint.
- returned: success
- type: str
- clusterIpv4Cidr:
- description:
- - The IP address range of the container pods in this cluster, in CIDR notation
- (e.g. 10.96.0.0/14). Leave blank to have one automatically chosen or specify
- a /14 block in 10.0.0.0/8.
- returned: success
- type: str
- addonsConfig:
- description:
- - Configurations for the various addons available to run in the cluster.
- returned: success
- type: complex
- contains:
- httpLoadBalancing:
- description:
- - Configuration for the HTTP (L7) load balancing controller addon, which
- makes it easy to set up HTTP load balancers for services in a cluster.
- returned: success
- type: complex
- contains:
- disabled:
- description:
- - Whether the HTTP Load Balancing controller is enabled in the cluster.
- When enabled, it runs a small pod in the cluster that manages the
- load balancers.
- returned: success
- type: bool
- horizontalPodAutoscaling:
- description:
- - Configuration for the horizontal pod autoscaling feature, which increases
- or decreases the number of replica pods a replication controller has based
- on the resource usage of the existing pods.
- returned: success
- type: complex
- contains:
- disabled:
- description:
- - Whether the Horizontal Pod Autoscaling feature is enabled in the cluster.
- When enabled, it ensures that a Heapster pod is running in the cluster,
- which is also used by the Cloud Monitoring service.
- returned: success
- type: bool
- networkPolicyConfig:
- description:
- - Configuration for NetworkPolicy. This only tracks whether the addon is
- enabled or not on the Master, it does not track whether network policy
- is enabled for the nodes.
- returned: success
- type: complex
- contains:
- disabled:
- description:
- - Whether NetworkPolicy is enabled for this cluster.
- returned: success
- type: bool
- subnetwork:
- description:
- - The name of the Google Compute Engine subnetwork to which the cluster is connected.
- returned: success
- type: str
- locations:
- description:
- - The list of Google Compute Engine zones in which the cluster's nodes should
- be located.
- returned: success
- type: list
- resourceLabels:
- description:
- - The resource labels for the cluster to use to annotate any related Google
- Compute Engine resources.
- returned: success
- type: dict
- labelFingerprint:
- description:
- - The fingerprint of the set of labels for this cluster.
- returned: success
- type: str
- legacyAbac:
- description:
- - Configuration for the legacy ABAC authorization mode.
- returned: success
- type: complex
- contains:
- enabled:
- description:
- - Whether the ABAC authorizer is enabled for this cluster. When enabled,
- identities in the system, including service accounts, nodes, and controllers,
- will have statically granted permissions beyond those provided by the
- RBAC configuration or IAM.
- returned: success
- type: bool
- networkPolicy:
- description:
- - Configuration options for the NetworkPolicy feature.
- returned: success
- type: complex
- contains:
- provider:
- description:
- - The selected network policy provider.
- returned: success
- type: str
- enabled:
- description:
- - Whether network policy is enabled on the cluster.
- returned: success
- type: bool
- defaultMaxPodsConstraint:
- description:
- - The default constraint on the maximum number of pods that can be run simultaneously
- on a node in the node pool of this cluster.
- - Only honored if cluster created with IP Alias support.
- returned: success
- type: complex
- contains:
- maxPodsPerNode:
- description:
- - Constraint enforced on the max num of pods per node.
- returned: success
- type: str
- ipAllocationPolicy:
- description:
- - Configuration for controlling how IPs are allocated in the cluster.
- returned: success
- type: complex
- contains:
- useIpAliases:
- description:
- - Whether alias IPs will be used for pod IPs in the cluster.
- returned: success
- type: bool
- createSubnetwork:
- description:
- - Whether a new subnetwork will be created automatically for the cluster.
- returned: success
- type: bool
- subnetworkName:
- description:
- - A custom subnetwork name to be used if createSubnetwork is true.
- - If this field is empty, then an automatic name will be chosen for the
- new subnetwork.
- returned: success
- type: str
- clusterSecondaryRangeName:
- description:
- - The name of the secondary range to be used for the cluster CIDR block.
- The secondary range will be used for pod IP addresses.
- - This must be an existing secondary range associated with the cluster subnetwork
- .
- returned: success
- type: str
- servicesSecondaryRangeName:
- description:
- - The name of the secondary range to be used as for the services CIDR block.
- The secondary range will be used for service ClusterIPs. This must be
- an existing secondary range associated with the cluster subnetwork.
- returned: success
- type: str
- clusterIpv4CidrBlock:
- description:
- - The IP address range for the cluster pod IPs. If this field is set, then
- cluster.cluster_ipv4_cidr must be left blank.
- - This field is only applicable when useIpAliases is true.
- - Set to blank to have a range chosen with the default size.
- - Set to /netmask (e.g. /14) to have a range chosen with a specific netmask.
- returned: success
- type: str
- nodeIpv4CidrBlock:
- description:
- - The IP address range of the instance IPs in this cluster.
- - This is applicable only if createSubnetwork is true.
- - Set to blank to have a range chosen with the default size.
- - Set to /netmask (e.g. /14) to have a range chosen with a specific netmask.
- returned: success
- type: str
- servicesIpv4CidrBlock:
- description:
- - The IP address range of the services IPs in this cluster. If blank, a
- range will be automatically chosen with the default size.
- - This field is only applicable when useIpAliases is true.
- - Set to blank to have a range chosen with the default size.
- - Set to /netmask (e.g. /14) to have a range chosen with a specific netmask.
- returned: success
- type: str
- tpuIpv4CidrBlock:
- description:
- - The IP address range of the Cloud TPUs in this cluster. If unspecified,
- a range will be automatically chosen with the default size.
- - This field is only applicable when useIpAliases is true.
- - If unspecified, the range will use the default size.
- - Set to /netmask (e.g. /14) to have a range chosen with a specific netmask.
- returned: success
- type: str
- endpoint:
- description:
- - The IP address of this cluster's master endpoint.
- - The endpoint can be accessed from the internet at https://username:password@endpoint/
- See the masterAuth property of this resource for username and password information.
- returned: success
- type: str
- initialClusterVersion:
- description:
- - The software version of the master endpoint and kubelets used in the cluster
- when it was first created. The version can be upgraded over time.
- returned: success
- type: str
- currentMasterVersion:
- description:
- - The current software version of the master endpoint.
- returned: success
- type: str
- currentNodeVersion:
- description:
- - The current version of the node software components. If they are currently
- at multiple versions because they're in the process of being upgraded, this
- reflects the minimum version of all nodes.
- returned: success
- type: str
- createTime:
- description:
- - The time the cluster was created, in RFC3339 text format.
- returned: success
- type: str
- status:
- description:
- - The current status of this cluster.
- returned: success
- type: str
- statusMessage:
- description:
- - Additional information about the current status of this cluster, if available.
- returned: success
- type: str
- nodeIpv4CidrSize:
- description:
- - The size of the address space on each node for hosting containers.
- - This is provisioned from within the container_ipv4_cidr range.
- returned: success
- type: int
- servicesIpv4Cidr:
- description:
- - The IP address range of the Kubernetes services in this cluster, in CIDR notation
- (e.g. 1.2.3.4/29). Service addresses are typically put in the last /16 from
- the container CIDR.
- returned: success
- type: str
- currentNodeCount:
- description:
- - The number of nodes currently in the cluster.
- returned: success
- type: int
- expireTime:
- description:
- - The time the cluster will be automatically deleted in RFC3339 text format.
- returned: success
- type: str
- enableTpu:
- description:
- - Enable the ability to use Cloud TPUs in this cluster.
- returned: success
- type: bool
- tpuIpv4CidrBlock:
- description:
- - The IP address range of the Cloud TPUs in this cluster, in CIDR notation.
- returned: success
- type: str
- conditions:
- description:
- - Which conditions caused the current cluster state.
- returned: success
- type: complex
- contains:
- code:
- description:
- - Machine-friendly representation of the condition.
- returned: success
- type: str
- message:
- description:
- - Human-friendly representation of the condition.
- returned: success
- type: str
- masterAuthorizedNetworksConfig:
- description:
- - Configuration for controlling how IPs are allocated in the cluster.
- returned: success
- type: complex
- contains:
- enabled:
- description:
- - Whether or not master authorized networks is enabled.
- returned: success
- type: bool
- cidrBlocks:
- description:
- - Define up to 50 external networks that could access Kubernetes master
- through HTTPS.
- returned: success
- type: complex
- contains:
- displayName:
- description:
- - Optional field used to identify cidr blocks.
- returned: success
- type: str
- cidrBlock:
- description:
- - Block specified in CIDR notation.
- returned: success
- type: str
- location:
- description:
- - The location where the cluster is deployed.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(location=dict(required=True, type='str', aliases=['region', 'zone'])))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
-
- return_value = {'resources': fetch_list(module, collection(module))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://container.googleapis.com/v1/projects/{project}/locations/{location}/clusters".format(**module.params)
-
-
-def fetch_list(module, link):
- auth = GcpSession(module, 'container')
- return auth.list(link, return_if_object, array_name='clusters')
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_container_node_pool.py b/lib/ansible/modules/cloud/google/gcp_container_node_pool.py
deleted file mode 100644
index 76f6f456fb..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_container_node_pool.py
+++ /dev/null
@@ -1,1099 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_container_node_pool
-description:
-- NodePool contains the name and configuration for a cluster's node pool.
-- Node pools are a set of nodes (i.e. VM's), with a common configuration and specification,
- under the control of the cluster master. They may have a set of Kubernetes labels
- applied to them, which may be used to reference them during pod scheduling. They
- may also be resized up or down, to accommodate the workload.
-short_description: Creates a GCP NodePool
-version_added: '2.6'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- name:
- description:
- - The name of the node pool.
- required: false
- type: str
- config:
- description:
- - The node configuration of the pool.
- required: false
- type: dict
- suboptions:
- machine_type:
- description:
- - The name of a Google Compute Engine machine type (e.g.
- - n1-standard-1). If unspecified, the default machine type is n1-standard-1.
- required: false
- type: str
- disk_size_gb:
- description:
- - Size of the disk attached to each node, specified in GB. The smallest allowed
- disk size is 10GB. If unspecified, the default disk size is 100GB.
- required: false
- type: int
- oauth_scopes:
- description:
- - The set of Google API scopes to be made available on all of the node VMs
- under the "default" service account.
- - 'The following scopes are recommended, but not required, and by default
- are not included: U(https://www.googleapis.com/auth/compute) is required
- for mounting persistent storage on your nodes.'
- - U(https://www.googleapis.com/auth/devstorage.read_only) is required for
- communicating with gcr.io (the Google Container Registry).
- - If unspecified, no scopes are added, unless Cloud Logging or Cloud Monitoring
- are enabled, in which case their required scopes will be added.
- required: false
- type: list
- service_account:
- description:
- - The Google Cloud Platform Service Account to be used by the node VMs. If
- no Service Account is specified, the "default" service account is used.
- required: false
- type: str
- metadata:
- description:
- - The metadata key/value pairs assigned to instances in the cluster.
- - 'Keys must conform to the regexp [a-zA-Z0-9-_]+ and be less than 128 bytes
- in length. These are reflected as part of a URL in the metadata server.
- Additionally, to avoid ambiguity, keys must not conflict with any other
- metadata keys for the project or be one of the four reserved keys: "instance-template",
- "kube-env", "startup-script", and "user-data" Values are free-form strings,
- and only have meaning as interpreted by the image running in the instance.
- The only restriction placed on them is that each value''s size must be less
- than or equal to 32 KB.'
- - The total size of all keys and values must be less than 512 KB.
- - 'An object containing a list of "key": value pairs.'
- - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.'
- required: false
- type: dict
- image_type:
- description:
- - The image type to use for this node. Note that for a given image type, the
- latest version of it will be used.
- required: false
- type: str
- labels:
- description:
- - 'The map of Kubernetes labels (key/value pairs) to be applied to each node.
- These will added in addition to any default label(s) that Kubernetes may
- apply to the node. In case of conflict in label keys, the applied set may
- differ depending on the Kubernetes version -- it''s best to assume the behavior
- is undefined and conflicts should be avoided. For more information, including
- usage and the valid values, see: U(http://kubernetes.io/v1.1/docs/user-guide/labels.html)
- An object containing a list of "key": value pairs.'
- - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.'
- required: false
- type: dict
- local_ssd_count:
- description:
- - The number of local SSD disks to be attached to the node.
- - 'The limit for this value is dependant upon the maximum number of disks
- available on a machine per zone. See: U(https://cloud.google.com/compute/docs/disks/local-ssd#local_ssd_limits)
- for more information.'
- required: false
- type: int
- tags:
- description:
- - The list of instance tags applied to all nodes. Tags are used to identify
- valid sources or targets for network firewalls and are specified by the
- client during cluster or node pool creation. Each tag within the list must
- comply with RFC1035.
- required: false
- type: list
- preemptible:
- description:
- - 'Whether the nodes are created as preemptible VM instances. See: U(https://cloud.google.com/compute/docs/instances/preemptible)
- for more information about preemptible VM instances.'
- required: false
- type: bool
- accelerators:
- description:
- - A list of hardware accelerators to be attached to each node.
- required: false
- type: list
- version_added: '2.9'
- suboptions:
- accelerator_count:
- description:
- - The number of the accelerator cards exposed to an instance.
- required: false
- type: int
- accelerator_type:
- description:
- - The accelerator type resource name.
- required: false
- type: str
- disk_type:
- description:
- - Type of the disk attached to each node (e.g. 'pd-standard' or 'pd-ssd')
- If unspecified, the default disk type is 'pd-standard' .
- required: false
- type: str
- version_added: '2.9'
- min_cpu_platform:
- description:
- - Minimum CPU platform to be used by this instance. The instance may be scheduled
- on the specified or newer CPU platform .
- required: false
- type: str
- version_added: '2.9'
- taints:
- description:
- - List of kubernetes taints to be applied to each node.
- required: false
- type: list
- version_added: '2.9'
- suboptions:
- key:
- description:
- - Key for taint.
- required: false
- type: str
- value:
- description:
- - Value for taint.
- required: false
- type: str
- effect:
- description:
- - Effect for taint.
- required: false
- type: str
- initial_node_count:
- description:
- - The initial node count for the pool. You must ensure that your Compute Engine
- resource quota is sufficient for this number of instances. You must also have
- available firewall and routes quota.
- required: true
- type: int
- version:
- description:
- - The version of the Kubernetes of this node.
- required: false
- type: str
- version_added: '2.8'
- autoscaling:
- description:
- - Autoscaler configuration for this NodePool. Autoscaler is enabled only if a
- valid configuration is present.
- required: false
- type: dict
- suboptions:
- enabled:
- description:
- - Is autoscaling enabled for this node pool.
- required: false
- type: bool
- min_node_count:
- description:
- - Minimum number of nodes in the NodePool. Must be >= 1 and <= maxNodeCount.
- required: false
- type: int
- max_node_count:
- description:
- - Maximum number of nodes in the NodePool. Must be >= minNodeCount.
- - There has to enough quota to scale up the cluster.
- required: false
- type: int
- management:
- description:
- - Management configuration for this NodePool.
- required: false
- type: dict
- suboptions:
- auto_upgrade:
- description:
- - A flag that specifies whether node auto-upgrade is enabled for the node
- pool. If enabled, node auto-upgrade helps keep the nodes in your node pool
- up to date with the latest release version of Kubernetes.
- required: false
- type: bool
- auto_repair:
- description:
- - A flag that specifies whether the node auto-repair is enabled for the node
- pool. If enabled, the nodes in this node pool will be monitored and, if
- they fail health checks too many times, an automatic repair action will
- be triggered.
- required: false
- type: bool
- upgrade_options:
- description:
- - Specifies the Auto Upgrade knobs for the node pool.
- required: false
- type: dict
- suboptions: {}
- max_pods_constraint:
- description:
- - The constraint on the maximum number of pods that can be run simultaneously
- on a node in the node pool.
- required: false
- type: dict
- version_added: '2.9'
- suboptions:
- max_pods_per_node:
- description:
- - Constraint enforced on the max num of pods per node.
- required: false
- type: int
- conditions:
- description:
- - Which conditions caused the current node pool state.
- required: false
- type: list
- version_added: '2.9'
- suboptions:
- code:
- description:
- - Machine-friendly representation of the condition.
- - 'Some valid choices include: "UNKNOWN", "GCE_STOCKOUT", "GKE_SERVICE_ACCOUNT_DELETED",
- "GCE_QUOTA_EXCEEDED", "SET_BY_OPERATOR"'
- required: false
- type: str
- cluster:
- description:
- - The cluster this node pool belongs to.
- - 'This field represents a link to a Cluster resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''name'' and value of
- your resource''s name Alternatively, you can add `register: name-of-resource`
- to a gcp_container_cluster task and then set this cluster field to "{{ name-of-resource
- }}"'
- required: true
- type: dict
- location:
- description:
- - The location where the node pool is deployed.
- required: true
- type: str
- aliases:
- - region
- - zone
- version_added: '2.8'
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-'''
-
-EXAMPLES = '''
-- name: create a cluster
- gcp_container_cluster:
- name: cluster-nodepool
- initial_node_count: 4
- location: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: cluster
-
-- name: create a node pool
- gcp_container_node_pool:
- name: my-pool
- initial_node_count: 4
- cluster: "{{ cluster }}"
- location: us-central1-a
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-name:
- description:
- - The name of the node pool.
- returned: success
- type: str
-config:
- description:
- - The node configuration of the pool.
- returned: success
- type: complex
- contains:
- machineType:
- description:
- - The name of a Google Compute Engine machine type (e.g.
- - n1-standard-1). If unspecified, the default machine type is n1-standard-1.
- returned: success
- type: str
- diskSizeGb:
- description:
- - Size of the disk attached to each node, specified in GB. The smallest allowed
- disk size is 10GB. If unspecified, the default disk size is 100GB.
- returned: success
- type: int
- oauthScopes:
- description:
- - The set of Google API scopes to be made available on all of the node VMs under
- the "default" service account.
- - 'The following scopes are recommended, but not required, and by default are
- not included: U(https://www.googleapis.com/auth/compute) is required for mounting
- persistent storage on your nodes.'
- - U(https://www.googleapis.com/auth/devstorage.read_only) is required for communicating
- with gcr.io (the Google Container Registry).
- - If unspecified, no scopes are added, unless Cloud Logging or Cloud Monitoring
- are enabled, in which case their required scopes will be added.
- returned: success
- type: list
- serviceAccount:
- description:
- - The Google Cloud Platform Service Account to be used by the node VMs. If no
- Service Account is specified, the "default" service account is used.
- returned: success
- type: str
- metadata:
- description:
- - The metadata key/value pairs assigned to instances in the cluster.
- - 'Keys must conform to the regexp [a-zA-Z0-9-_]+ and be less than 128 bytes
- in length. These are reflected as part of a URL in the metadata server. Additionally,
- to avoid ambiguity, keys must not conflict with any other metadata keys for
- the project or be one of the four reserved keys: "instance-template", "kube-env",
- "startup-script", and "user-data" Values are free-form strings, and only have
- meaning as interpreted by the image running in the instance. The only restriction
- placed on them is that each value''s size must be less than or equal to 32
- KB.'
- - The total size of all keys and values must be less than 512 KB.
- - 'An object containing a list of "key": value pairs.'
- - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.'
- returned: success
- type: dict
- imageType:
- description:
- - The image type to use for this node. Note that for a given image type, the
- latest version of it will be used.
- returned: success
- type: str
- labels:
- description:
- - 'The map of Kubernetes labels (key/value pairs) to be applied to each node.
- These will added in addition to any default label(s) that Kubernetes may apply
- to the node. In case of conflict in label keys, the applied set may differ
- depending on the Kubernetes version -- it''s best to assume the behavior is
- undefined and conflicts should be avoided. For more information, including
- usage and the valid values, see: U(http://kubernetes.io/v1.1/docs/user-guide/labels.html)
- An object containing a list of "key": value pairs.'
- - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.'
- returned: success
- type: dict
- localSsdCount:
- description:
- - The number of local SSD disks to be attached to the node.
- - 'The limit for this value is dependant upon the maximum number of disks available
- on a machine per zone. See: U(https://cloud.google.com/compute/docs/disks/local-ssd#local_ssd_limits)
- for more information.'
- returned: success
- type: int
- tags:
- description:
- - The list of instance tags applied to all nodes. Tags are used to identify
- valid sources or targets for network firewalls and are specified by the client
- during cluster or node pool creation. Each tag within the list must comply
- with RFC1035.
- returned: success
- type: list
- preemptible:
- description:
- - 'Whether the nodes are created as preemptible VM instances. See: U(https://cloud.google.com/compute/docs/instances/preemptible)
- for more information about preemptible VM instances.'
- returned: success
- type: bool
- accelerators:
- description:
- - A list of hardware accelerators to be attached to each node.
- returned: success
- type: complex
- contains:
- acceleratorCount:
- description:
- - The number of the accelerator cards exposed to an instance.
- returned: success
- type: int
- acceleratorType:
- description:
- - The accelerator type resource name.
- returned: success
- type: str
- diskType:
- description:
- - Type of the disk attached to each node (e.g. 'pd-standard' or 'pd-ssd') If
- unspecified, the default disk type is 'pd-standard' .
- returned: success
- type: str
- minCpuPlatform:
- description:
- - Minimum CPU platform to be used by this instance. The instance may be scheduled
- on the specified or newer CPU platform .
- returned: success
- type: str
- taints:
- description:
- - List of kubernetes taints to be applied to each node.
- returned: success
- type: complex
- contains:
- key:
- description:
- - Key for taint.
- returned: success
- type: str
- value:
- description:
- - Value for taint.
- returned: success
- type: str
- effect:
- description:
- - Effect for taint.
- returned: success
- type: str
-initialNodeCount:
- description:
- - The initial node count for the pool. You must ensure that your Compute Engine
- resource quota is sufficient for this number of instances. You must also have
- available firewall and routes quota.
- returned: success
- type: int
-status:
- description:
- - Status of nodes in this pool instance.
- returned: success
- type: str
-statusMessage:
- description:
- - Additional information about the current status of this node pool instance.
- returned: success
- type: str
-version:
- description:
- - The version of the Kubernetes of this node.
- returned: success
- type: str
-autoscaling:
- description:
- - Autoscaler configuration for this NodePool. Autoscaler is enabled only if a valid
- configuration is present.
- returned: success
- type: complex
- contains:
- enabled:
- description:
- - Is autoscaling enabled for this node pool.
- returned: success
- type: bool
- minNodeCount:
- description:
- - Minimum number of nodes in the NodePool. Must be >= 1 and <= maxNodeCount.
- returned: success
- type: int
- maxNodeCount:
- description:
- - Maximum number of nodes in the NodePool. Must be >= minNodeCount.
- - There has to enough quota to scale up the cluster.
- returned: success
- type: int
-management:
- description:
- - Management configuration for this NodePool.
- returned: success
- type: complex
- contains:
- autoUpgrade:
- description:
- - A flag that specifies whether node auto-upgrade is enabled for the node pool.
- If enabled, node auto-upgrade helps keep the nodes in your node pool up to
- date with the latest release version of Kubernetes.
- returned: success
- type: bool
- autoRepair:
- description:
- - A flag that specifies whether the node auto-repair is enabled for the node
- pool. If enabled, the nodes in this node pool will be monitored and, if they
- fail health checks too many times, an automatic repair action will be triggered.
- returned: success
- type: bool
- upgradeOptions:
- description:
- - Specifies the Auto Upgrade knobs for the node pool.
- returned: success
- type: complex
- contains:
- autoUpgradeStartTime:
- description:
- - This field is set when upgrades are about to commence with the approximate
- start time for the upgrades, in RFC3339 text format.
- returned: success
- type: str
- description:
- description:
- - This field is set when upgrades are about to commence with the description
- of the upgrade.
- returned: success
- type: str
-maxPodsConstraint:
- description:
- - The constraint on the maximum number of pods that can be run simultaneously on
- a node in the node pool.
- returned: success
- type: complex
- contains:
- maxPodsPerNode:
- description:
- - Constraint enforced on the max num of pods per node.
- returned: success
- type: int
-conditions:
- description:
- - Which conditions caused the current node pool state.
- returned: success
- type: complex
- contains:
- code:
- description:
- - Machine-friendly representation of the condition.
- returned: success
- type: str
-podIpv4CidrSize:
- description:
- - The pod CIDR block size per node in this node pool.
- returned: success
- type: int
-cluster:
- description:
- - The cluster this node pool belongs to.
- returned: success
- type: dict
-location:
- description:
- - The location where the node pool is deployed.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- name=dict(type='str'),
- config=dict(
- type='dict',
- options=dict(
- machine_type=dict(type='str'),
- disk_size_gb=dict(type='int'),
- oauth_scopes=dict(type='list', elements='str'),
- service_account=dict(type='str'),
- metadata=dict(type='dict'),
- image_type=dict(type='str'),
- labels=dict(type='dict'),
- local_ssd_count=dict(type='int'),
- tags=dict(type='list', elements='str'),
- preemptible=dict(type='bool'),
- accelerators=dict(type='list', elements='dict', options=dict(accelerator_count=dict(type='int'), accelerator_type=dict(type='str'))),
- disk_type=dict(type='str'),
- min_cpu_platform=dict(type='str'),
- taints=dict(type='list', elements='dict', options=dict(key=dict(type='str'), value=dict(type='str'), effect=dict(type='str'))),
- ),
- ),
- initial_node_count=dict(required=True, type='int'),
- version=dict(type='str'),
- autoscaling=dict(type='dict', options=dict(enabled=dict(type='bool'), min_node_count=dict(type='int'), max_node_count=dict(type='int'))),
- management=dict(
- type='dict', options=dict(auto_upgrade=dict(type='bool'), auto_repair=dict(type='bool'), upgrade_options=dict(type='dict', options=dict()))
- ),
- max_pods_constraint=dict(type='dict', options=dict(max_pods_per_node=dict(type='int'))),
- conditions=dict(type='list', elements='dict', options=dict(code=dict(type='str'))),
- cluster=dict(required=True, type='dict'),
- location=dict(required=True, type='str', aliases=['region', 'zone']),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
-
- state = module.params['state']
-
- fetch = fetch_resource(module, self_link(module))
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module))
- fetch = fetch_resource(module, self_link(module))
- changed = True
- else:
- delete(module, self_link(module))
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module))
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link):
- auth = GcpSession(module, 'container')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link):
- auth = GcpSession(module, 'container')
- return wait_for_operation(module, auth.put(link, resource_to_request(module)))
-
-
-def delete(module, link):
- auth = GcpSession(module, 'container')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'name': module.params.get('name'),
- u'config': NodePoolConfig(module.params.get('config', {}), module).to_request(),
- u'initialNodeCount': module.params.get('initial_node_count'),
- u'version': module.params.get('version'),
- u'autoscaling': NodePoolAutoscaling(module.params.get('autoscaling', {}), module).to_request(),
- u'management': NodePoolManagement(module.params.get('management', {}), module).to_request(),
- u'maxPodsConstraint': NodePoolMaxpodsconstraint(module.params.get('max_pods_constraint', {}), module).to_request(),
- u'conditions': NodePoolConditionsArray(module.params.get('conditions', []), module).to_request(),
- }
- request = encode_request(request, module)
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, allow_not_found=True):
- auth = GcpSession(module, 'container')
- return return_if_object(module, auth.get(link), allow_not_found)
-
-
-def self_link(module):
- res = {
- 'project': module.params['project'],
- 'location': module.params['location'],
- 'cluster': replace_resource_dict(module.params['cluster'], 'name'),
- 'name': module.params['name'],
- }
- return "https://container.googleapis.com/v1/projects/{project}/locations/{location}/clusters/{cluster}/nodePools/{name}".format(**res)
-
-
-def collection(module):
- res = {'project': module.params['project'], 'location': module.params['location'], 'cluster': replace_resource_dict(module.params['cluster'], 'name')}
- return "https://container.googleapis.com/v1/projects/{project}/locations/{location}/clusters/{cluster}/nodePools".format(**res)
-
-
-def return_if_object(module, response, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'name': response.get(u'name'),
- u'config': NodePoolConfig(response.get(u'config', {}), module).from_response(),
- u'initialNodeCount': module.params.get('initial_node_count'),
- u'status': response.get(u'status'),
- u'statusMessage': response.get(u'statusMessage'),
- u'version': module.params.get('version'),
- u'autoscaling': NodePoolAutoscaling(response.get(u'autoscaling', {}), module).from_response(),
- u'management': NodePoolManagement(response.get(u'management', {}), module).from_response(),
- u'maxPodsConstraint': NodePoolMaxpodsconstraint(response.get(u'maxPodsConstraint', {}), module).from_response(),
- u'conditions': NodePoolConditionsArray(response.get(u'conditions', []), module).from_response(),
- u'podIpv4CidrSize': response.get(u'podIpv4CidrSize'),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://container.googleapis.com/v1/projects/{project}/locations/{location}/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response)
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']))
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-# Google Container Engine API has its own layout for the create method,
-# defined like this:
-#
-# {
-# 'nodePool': {
-# ... node pool data
-# }
-# }
-#
-# Format the request to match the expected input by the API
-def encode_request(resource_request, module):
- return {'nodePool': resource_request}
-
-
-class NodePoolConfig(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'machineType': self.request.get('machine_type'),
- u'diskSizeGb': self.request.get('disk_size_gb'),
- u'oauthScopes': self.request.get('oauth_scopes'),
- u'serviceAccount': self.request.get('service_account'),
- u'metadata': self.request.get('metadata'),
- u'imageType': self.request.get('image_type'),
- u'labels': self.request.get('labels'),
- u'localSsdCount': self.request.get('local_ssd_count'),
- u'tags': self.request.get('tags'),
- u'preemptible': self.request.get('preemptible'),
- u'accelerators': NodePoolAcceleratorsArray(self.request.get('accelerators', []), self.module).to_request(),
- u'diskType': self.request.get('disk_type'),
- u'minCpuPlatform': self.request.get('min_cpu_platform'),
- u'taints': NodePoolTaintsArray(self.request.get('taints', []), self.module).to_request(),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'machineType': self.request.get(u'machineType'),
- u'diskSizeGb': self.request.get(u'diskSizeGb'),
- u'oauthScopes': self.request.get(u'oauthScopes'),
- u'serviceAccount': self.request.get(u'serviceAccount'),
- u'metadata': self.request.get(u'metadata'),
- u'imageType': self.request.get(u'imageType'),
- u'labels': self.request.get(u'labels'),
- u'localSsdCount': self.request.get(u'localSsdCount'),
- u'tags': self.request.get(u'tags'),
- u'preemptible': self.request.get(u'preemptible'),
- u'accelerators': NodePoolAcceleratorsArray(self.request.get(u'accelerators', []), self.module).from_response(),
- u'diskType': self.request.get(u'diskType'),
- u'minCpuPlatform': self.request.get(u'minCpuPlatform'),
- u'taints': NodePoolTaintsArray(self.request.get(u'taints', []), self.module).from_response(),
- }
- )
-
-
-class NodePoolAcceleratorsArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'acceleratorCount': item.get('accelerator_count'), u'acceleratorType': item.get('accelerator_type')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'acceleratorCount': item.get(u'acceleratorCount'), u'acceleratorType': item.get(u'acceleratorType')})
-
-
-class NodePoolTaintsArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'key': item.get('key'), u'value': item.get('value'), u'effect': item.get('effect')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'key': item.get(u'key'), u'value': item.get(u'value'), u'effect': item.get(u'effect')})
-
-
-class NodePoolAutoscaling(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {u'enabled': self.request.get('enabled'), u'minNodeCount': self.request.get('min_node_count'), u'maxNodeCount': self.request.get('max_node_count')}
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {u'enabled': self.request.get(u'enabled'), u'minNodeCount': self.request.get(u'minNodeCount'), u'maxNodeCount': self.request.get(u'maxNodeCount')}
- )
-
-
-class NodePoolManagement(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'autoUpgrade': self.request.get('auto_upgrade'),
- u'autoRepair': self.request.get('auto_repair'),
- u'upgradeOptions': NodePoolUpgradeoptions(self.request.get('upgrade_options', {}), self.module).to_request(),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'autoUpgrade': self.request.get(u'autoUpgrade'),
- u'autoRepair': self.request.get(u'autoRepair'),
- u'upgradeOptions': NodePoolUpgradeoptions(self.request.get(u'upgradeOptions', {}), self.module).from_response(),
- }
- )
-
-
-class NodePoolUpgradeoptions(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({})
-
- def from_response(self):
- return remove_nones_from_dict({})
-
-
-class NodePoolMaxpodsconstraint(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'maxPodsPerNode': self.request.get('max_pods_per_node')})
-
- def from_response(self):
- return remove_nones_from_dict({u'maxPodsPerNode': self.request.get(u'maxPodsPerNode')})
-
-
-class NodePoolConditionsArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'code': item.get('code')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'code': item.get(u'code')})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_container_node_pool_info.py b/lib/ansible/modules/cloud/google/gcp_container_node_pool_info.py
deleted file mode 100644
index 03914bb5e0..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_container_node_pool_info.py
+++ /dev/null
@@ -1,452 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_container_node_pool_info
-description:
-- Gather info for GCP NodePool
-short_description: Gather info for GCP NodePool
-version_added: '2.8'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- location:
- description:
- - The location where the node pool is deployed.
- required: true
- type: str
- aliases:
- - region
- - zone
- version_added: '2.8'
- cluster:
- description:
- - The cluster this node pool belongs to.
- - 'This field represents a link to a Cluster resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''name'' and value of
- your resource''s name Alternatively, you can add `register: name-of-resource`
- to a gcp_container_cluster task and then set this cluster field to "{{ name-of-resource
- }}"'
- required: true
- type: dict
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a node pool
- gcp_container_node_pool_info:
- cluster: "{{ cluster }}"
- location: us-central1-a
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- name:
- description:
- - The name of the node pool.
- returned: success
- type: str
- config:
- description:
- - The node configuration of the pool.
- returned: success
- type: complex
- contains:
- machineType:
- description:
- - The name of a Google Compute Engine machine type (e.g.
- - n1-standard-1). If unspecified, the default machine type is n1-standard-1.
- returned: success
- type: str
- diskSizeGb:
- description:
- - Size of the disk attached to each node, specified in GB. The smallest
- allowed disk size is 10GB. If unspecified, the default disk size is 100GB.
- returned: success
- type: int
- oauthScopes:
- description:
- - The set of Google API scopes to be made available on all of the node VMs
- under the "default" service account.
- - 'The following scopes are recommended, but not required, and by default
- are not included: U(https://www.googleapis.com/auth/compute) is required
- for mounting persistent storage on your nodes.'
- - U(https://www.googleapis.com/auth/devstorage.read_only) is required for
- communicating with gcr.io (the Google Container Registry).
- - If unspecified, no scopes are added, unless Cloud Logging or Cloud Monitoring
- are enabled, in which case their required scopes will be added.
- returned: success
- type: list
- serviceAccount:
- description:
- - The Google Cloud Platform Service Account to be used by the node VMs.
- If no Service Account is specified, the "default" service account is used.
- returned: success
- type: str
- metadata:
- description:
- - The metadata key/value pairs assigned to instances in the cluster.
- - 'Keys must conform to the regexp [a-zA-Z0-9-_]+ and be less than 128 bytes
- in length. These are reflected as part of a URL in the metadata server.
- Additionally, to avoid ambiguity, keys must not conflict with any other
- metadata keys for the project or be one of the four reserved keys: "instance-template",
- "kube-env", "startup-script", and "user-data" Values are free-form strings,
- and only have meaning as interpreted by the image running in the instance.
- The only restriction placed on them is that each value''s size must be
- less than or equal to 32 KB.'
- - The total size of all keys and values must be less than 512 KB.
- - 'An object containing a list of "key": value pairs.'
- - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.'
- returned: success
- type: dict
- imageType:
- description:
- - The image type to use for this node. Note that for a given image type,
- the latest version of it will be used.
- returned: success
- type: str
- labels:
- description:
- - 'The map of Kubernetes labels (key/value pairs) to be applied to each
- node. These will added in addition to any default label(s) that Kubernetes
- may apply to the node. In case of conflict in label keys, the applied
- set may differ depending on the Kubernetes version -- it''s best to assume
- the behavior is undefined and conflicts should be avoided. For more information,
- including usage and the valid values, see: U(http://kubernetes.io/v1.1/docs/user-guide/labels.html)
- An object containing a list of "key": value pairs.'
- - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.'
- returned: success
- type: dict
- localSsdCount:
- description:
- - The number of local SSD disks to be attached to the node.
- - 'The limit for this value is dependant upon the maximum number of disks
- available on a machine per zone. See: U(https://cloud.google.com/compute/docs/disks/local-ssd#local_ssd_limits)
- for more information.'
- returned: success
- type: int
- tags:
- description:
- - The list of instance tags applied to all nodes. Tags are used to identify
- valid sources or targets for network firewalls and are specified by the
- client during cluster or node pool creation. Each tag within the list
- must comply with RFC1035.
- returned: success
- type: list
- preemptible:
- description:
- - 'Whether the nodes are created as preemptible VM instances. See: U(https://cloud.google.com/compute/docs/instances/preemptible)
- for more information about preemptible VM instances.'
- returned: success
- type: bool
- accelerators:
- description:
- - A list of hardware accelerators to be attached to each node.
- returned: success
- type: complex
- contains:
- acceleratorCount:
- description:
- - The number of the accelerator cards exposed to an instance.
- returned: success
- type: int
- acceleratorType:
- description:
- - The accelerator type resource name.
- returned: success
- type: str
- diskType:
- description:
- - Type of the disk attached to each node (e.g. 'pd-standard' or 'pd-ssd')
- If unspecified, the default disk type is 'pd-standard' .
- returned: success
- type: str
- minCpuPlatform:
- description:
- - Minimum CPU platform to be used by this instance. The instance may be
- scheduled on the specified or newer CPU platform .
- returned: success
- type: str
- taints:
- description:
- - List of kubernetes taints to be applied to each node.
- returned: success
- type: complex
- contains:
- key:
- description:
- - Key for taint.
- returned: success
- type: str
- value:
- description:
- - Value for taint.
- returned: success
- type: str
- effect:
- description:
- - Effect for taint.
- returned: success
- type: str
- initialNodeCount:
- description:
- - The initial node count for the pool. You must ensure that your Compute Engine
- resource quota is sufficient for this number of instances. You must also have
- available firewall and routes quota.
- returned: success
- type: int
- status:
- description:
- - Status of nodes in this pool instance.
- returned: success
- type: str
- statusMessage:
- description:
- - Additional information about the current status of this node pool instance.
- returned: success
- type: str
- version:
- description:
- - The version of the Kubernetes of this node.
- returned: success
- type: str
- autoscaling:
- description:
- - Autoscaler configuration for this NodePool. Autoscaler is enabled only if
- a valid configuration is present.
- returned: success
- type: complex
- contains:
- enabled:
- description:
- - Is autoscaling enabled for this node pool.
- returned: success
- type: bool
- minNodeCount:
- description:
- - Minimum number of nodes in the NodePool. Must be >= 1 and <= maxNodeCount.
- returned: success
- type: int
- maxNodeCount:
- description:
- - Maximum number of nodes in the NodePool. Must be >= minNodeCount.
- - There has to enough quota to scale up the cluster.
- returned: success
- type: int
- management:
- description:
- - Management configuration for this NodePool.
- returned: success
- type: complex
- contains:
- autoUpgrade:
- description:
- - A flag that specifies whether node auto-upgrade is enabled for the node
- pool. If enabled, node auto-upgrade helps keep the nodes in your node
- pool up to date with the latest release version of Kubernetes.
- returned: success
- type: bool
- autoRepair:
- description:
- - A flag that specifies whether the node auto-repair is enabled for the
- node pool. If enabled, the nodes in this node pool will be monitored and,
- if they fail health checks too many times, an automatic repair action
- will be triggered.
- returned: success
- type: bool
- upgradeOptions:
- description:
- - Specifies the Auto Upgrade knobs for the node pool.
- returned: success
- type: complex
- contains:
- autoUpgradeStartTime:
- description:
- - This field is set when upgrades are about to commence with the approximate
- start time for the upgrades, in RFC3339 text format.
- returned: success
- type: str
- description:
- description:
- - This field is set when upgrades are about to commence with the description
- of the upgrade.
- returned: success
- type: str
- maxPodsConstraint:
- description:
- - The constraint on the maximum number of pods that can be run simultaneously
- on a node in the node pool.
- returned: success
- type: complex
- contains:
- maxPodsPerNode:
- description:
- - Constraint enforced on the max num of pods per node.
- returned: success
- type: int
- conditions:
- description:
- - Which conditions caused the current node pool state.
- returned: success
- type: complex
- contains:
- code:
- description:
- - Machine-friendly representation of the condition.
- returned: success
- type: str
- podIpv4CidrSize:
- description:
- - The pod CIDR block size per node in this node pool.
- returned: success
- type: int
- cluster:
- description:
- - The cluster this node pool belongs to.
- returned: success
- type: dict
- location:
- description:
- - The location where the node pool is deployed.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(location=dict(required=True, type='str', aliases=['region', 'zone']), cluster=dict(required=True, type='dict')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
-
- return_value = {'resources': fetch_list(module, collection(module))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- res = {'project': module.params['project'], 'location': module.params['location'], 'cluster': replace_resource_dict(module.params['cluster'], 'name')}
- return "https://container.googleapis.com/v1/projects/{project}/locations/{location}/clusters/{cluster}/nodePools".format(**res)
-
-
-def fetch_list(module, link):
- auth = GcpSession(module, 'container')
- return auth.list(link, return_if_object, array_name='nodePools')
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_dns_managed_zone.py b/lib/ansible/modules/cloud/google/gcp_dns_managed_zone.py
deleted file mode 100644
index b4a63c4fc6..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_dns_managed_zone.py
+++ /dev/null
@@ -1,674 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_dns_managed_zone
-description:
-- A zone is a subtree of the DNS namespace under one administrative responsibility.
- A ManagedZone is a resource that represents a DNS zone hosted by the Cloud DNS service.
-short_description: Creates a GCP ManagedZone
-version_added: '2.5'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- description:
- description:
- - A mutable string of at most 1024 characters associated with this resource for
- the user's convenience. Has no effect on the managed zone's function.
- required: true
- type: str
- dns_name:
- description:
- - The DNS name of this managed zone, for instance "example.com.".
- required: true
- type: str
- dnssec_config:
- description:
- - DNSSEC configuration.
- required: false
- type: dict
- version_added: '2.9'
- suboptions:
- kind:
- description:
- - Identifies what kind of resource this is.
- required: false
- default: dns#managedZoneDnsSecConfig
- type: str
- non_existence:
- description:
- - Specifies the mechanism used to provide authenticated denial-of-existence
- responses.
- - 'Some valid choices include: "nsec", "nsec3"'
- required: false
- type: str
- state:
- description:
- - Specifies whether DNSSEC is enabled, and what mode it is in.
- - 'Some valid choices include: "off", "on", "transfer"'
- required: false
- type: str
- default_key_specs:
- description:
- - Specifies parameters that will be used for generating initial DnsKeys for
- this ManagedZone. If you provide a spec for keySigning or zoneSigning, you
- must also provide one for the other.
- required: false
- type: list
- suboptions:
- algorithm:
- description:
- - String mnemonic specifying the DNSSEC algorithm of this key.
- - 'Some valid choices include: "ecdsap256sha256", "ecdsap384sha384", "rsasha1",
- "rsasha256", "rsasha512"'
- required: false
- type: str
- key_length:
- description:
- - Length of the keys in bits.
- required: false
- type: int
- key_type:
- description:
- - Specifies whether this is a key signing key (KSK) or a zone signing
- key (ZSK). Key signing keys have the Secure Entry Point flag set and,
- when active, will only be used to sign resource record sets of type
- DNSKEY. Zone signing keys do not have the Secure Entry Point flag set
- and will be used to sign all other types of resource record sets. .
- - 'Some valid choices include: "keySigning", "zoneSigning"'
- required: false
- type: str
- kind:
- description:
- - Identifies what kind of resource this is.
- required: false
- default: dns#dnsKeySpec
- type: str
- name:
- description:
- - User assigned name for this resource.
- - Must be unique within the project.
- required: true
- type: str
- name_server_set:
- description:
- - Optionally specifies the NameServerSet for this ManagedZone. A NameServerSet
- is a set of DNS name servers that all host the same ManagedZones. Most users
- will leave this field unset.
- required: false
- type: str
- labels:
- description:
- - A set of key/value label pairs to assign to this ManagedZone.
- required: false
- type: dict
- version_added: '2.8'
- visibility:
- description:
- - 'The zone''s visibility: public zones are exposed to the Internet, while private
- zones are visible only to Virtual Private Cloud resources.'
- - 'Must be one of: `public`, `private`.'
- - 'Some valid choices include: "private", "public"'
- required: false
- default: public
- type: str
- version_added: '2.8'
- private_visibility_config:
- description:
- - For privately visible zones, the set of Virtual Private Cloud resources that
- the zone is visible from.
- required: false
- type: dict
- version_added: '2.8'
- suboptions:
- networks:
- description:
- - The list of VPC networks that can see this zone.
- required: true
- type: list
- suboptions:
- network_url:
- description:
- - The fully qualified URL of the VPC network to bind to.
- - This should be formatted like `U(https://www.googleapis.com/compute/v1/projects/{project}/global/networks/{network}`)
- .
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/dns/api/v1/managedZones)'
-- 'Managing Zones: U(https://cloud.google.com/dns/zones/)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a managed zone
- gcp_dns_managed_zone:
- name: test_object
- dns_name: test.somewild2.example.com.
- description: test zone
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-description:
- description:
- - A mutable string of at most 1024 characters associated with this resource for
- the user's convenience. Has no effect on the managed zone's function.
- returned: success
- type: str
-dnsName:
- description:
- - The DNS name of this managed zone, for instance "example.com.".
- returned: success
- type: str
-dnssecConfig:
- description:
- - DNSSEC configuration.
- returned: success
- type: complex
- contains:
- kind:
- description:
- - Identifies what kind of resource this is.
- returned: success
- type: str
- nonExistence:
- description:
- - Specifies the mechanism used to provide authenticated denial-of-existence
- responses.
- returned: success
- type: str
- state:
- description:
- - Specifies whether DNSSEC is enabled, and what mode it is in.
- returned: success
- type: str
- defaultKeySpecs:
- description:
- - Specifies parameters that will be used for generating initial DnsKeys for
- this ManagedZone. If you provide a spec for keySigning or zoneSigning, you
- must also provide one for the other.
- returned: success
- type: complex
- contains:
- algorithm:
- description:
- - String mnemonic specifying the DNSSEC algorithm of this key.
- returned: success
- type: str
- keyLength:
- description:
- - Length of the keys in bits.
- returned: success
- type: int
- keyType:
- description:
- - Specifies whether this is a key signing key (KSK) or a zone signing key
- (ZSK). Key signing keys have the Secure Entry Point flag set and, when
- active, will only be used to sign resource record sets of type DNSKEY.
- Zone signing keys do not have the Secure Entry Point flag set and will
- be used to sign all other types of resource record sets. .
- returned: success
- type: str
- kind:
- description:
- - Identifies what kind of resource this is.
- returned: success
- type: str
-id:
- description:
- - Unique identifier for the resource; defined by the server.
- returned: success
- type: int
-name:
- description:
- - User assigned name for this resource.
- - Must be unique within the project.
- returned: success
- type: str
-nameServers:
- description:
- - Delegate your managed_zone to these virtual name servers; defined by the server
- .
- returned: success
- type: list
-nameServerSet:
- description:
- - Optionally specifies the NameServerSet for this ManagedZone. A NameServerSet is
- a set of DNS name servers that all host the same ManagedZones. Most users will
- leave this field unset.
- returned: success
- type: str
-creationTime:
- description:
- - The time that this resource was created on the server.
- - This is in RFC3339 text format.
- returned: success
- type: str
-labels:
- description:
- - A set of key/value label pairs to assign to this ManagedZone.
- returned: success
- type: dict
-visibility:
- description:
- - 'The zone''s visibility: public zones are exposed to the Internet, while private
- zones are visible only to Virtual Private Cloud resources.'
- - 'Must be one of: `public`, `private`.'
- returned: success
- type: str
-privateVisibilityConfig:
- description:
- - For privately visible zones, the set of Virtual Private Cloud resources that the
- zone is visible from.
- returned: success
- type: complex
- contains:
- networks:
- description:
- - The list of VPC networks that can see this zone.
- returned: success
- type: complex
- contains:
- networkUrl:
- description:
- - The fully qualified URL of the VPC network to bind to.
- - This should be formatted like `U(https://www.googleapis.com/compute/v1/projects/{project}/global/networks/{network}`)
- .
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- description=dict(required=True, type='str'),
- dns_name=dict(required=True, type='str'),
- dnssec_config=dict(
- type='dict',
- options=dict(
- kind=dict(default='dns#managedZoneDnsSecConfig', type='str'),
- non_existence=dict(type='str'),
- state=dict(type='str'),
- default_key_specs=dict(
- type='list',
- elements='dict',
- options=dict(
- algorithm=dict(type='str'), key_length=dict(type='int'), key_type=dict(type='str'), kind=dict(default='dns#dnsKeySpec', type='str')
- ),
- ),
- ),
- ),
- name=dict(required=True, type='str'),
- name_server_set=dict(type='str'),
- labels=dict(type='dict'),
- visibility=dict(default='public', type='str'),
- private_visibility_config=dict(
- type='dict', options=dict(networks=dict(required=True, type='list', elements='dict', options=dict(network_url=dict(required=True, type='str'))))
- ),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/ndev.clouddns.readwrite']
-
- state = module.params['state']
- kind = 'dns#managedZone'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind, fetch)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'dns')
- return return_if_object(module, auth.post(link, resource_to_request(module)), kind)
-
-
-def update(module, link, kind, fetch):
- update_fields(module, resource_to_request(module), response_to_hash(module, fetch))
- return fetch_resource(module, self_link(module), kind)
-
-
-def update_fields(module, request, response):
- if (
- response.get('description') != request.get('description')
- or response.get('labels') != request.get('labels')
- or response.get('privateVisibilityConfig') != request.get('privateVisibilityConfig')
- ):
- description_update(module, request, response)
-
-
-def description_update(module, request, response):
- auth = GcpSession(module, 'dns')
- auth.patch(
- ''.join(["https://www.googleapis.com/dns/v1/", "projects/{project}/managedZones/{name}"]).format(**module.params),
- {
- u'description': module.params.get('description'),
- u'labels': module.params.get('labels'),
- u'privateVisibilityConfig': ManagedZonePrivatevisibilityconfig(module.params.get('private_visibility_config', {}), module).to_request(),
- },
- )
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'dns')
- return return_if_object(module, auth.delete(link), kind)
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'dns#managedZone',
- u'description': module.params.get('description'),
- u'dnsName': module.params.get('dns_name'),
- u'dnssecConfig': ManagedZoneDnssecconfig(module.params.get('dnssec_config', {}), module).to_request(),
- u'name': module.params.get('name'),
- u'nameServerSet': module.params.get('name_server_set'),
- u'labels': module.params.get('labels'),
- u'visibility': module.params.get('visibility'),
- u'privateVisibilityConfig': ManagedZonePrivatevisibilityconfig(module.params.get('private_visibility_config', {}), module).to_request(),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'dns')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/dns/v1/projects/{project}/managedZones/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/dns/v1/projects/{project}/managedZones".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'description': response.get(u'description'),
- u'dnsName': response.get(u'dnsName'),
- u'dnssecConfig': ManagedZoneDnssecconfig(response.get(u'dnssecConfig', {}), module).from_response(),
- u'id': response.get(u'id'),
- u'name': response.get(u'name'),
- u'nameServers': response.get(u'nameServers'),
- u'nameServerSet': response.get(u'nameServerSet'),
- u'creationTime': response.get(u'creationTime'),
- u'labels': response.get(u'labels'),
- u'visibility': response.get(u'visibility'),
- u'privateVisibilityConfig': ManagedZonePrivatevisibilityconfig(response.get(u'privateVisibilityConfig', {}), module).from_response(),
- }
-
-
-class ManagedZoneDnssecconfig(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'kind': self.request.get('kind'),
- u'nonExistence': self.request.get('non_existence'),
- u'state': self.request.get('state'),
- u'defaultKeySpecs': ManagedZoneDefaultkeyspecsArray(self.request.get('default_key_specs', []), self.module).to_request(),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'kind': self.request.get(u'kind'),
- u'nonExistence': self.request.get(u'nonExistence'),
- u'state': self.request.get(u'state'),
- u'defaultKeySpecs': ManagedZoneDefaultkeyspecsArray(self.request.get(u'defaultKeySpecs', []), self.module).from_response(),
- }
- )
-
-
-class ManagedZoneDefaultkeyspecsArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict(
- {u'algorithm': item.get('algorithm'), u'keyLength': item.get('key_length'), u'keyType': item.get('key_type'), u'kind': item.get('kind')}
- )
-
- def _response_from_item(self, item):
- return remove_nones_from_dict(
- {u'algorithm': item.get(u'algorithm'), u'keyLength': item.get(u'keyLength'), u'keyType': item.get(u'keyType'), u'kind': item.get(u'kind')}
- )
-
-
-class ManagedZonePrivatevisibilityconfig(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'networks': ManagedZoneNetworksArray(self.request.get('networks', []), self.module).to_request()})
-
- def from_response(self):
- return remove_nones_from_dict({u'networks': ManagedZoneNetworksArray(self.request.get(u'networks', []), self.module).from_response()})
-
-
-class ManagedZoneNetworksArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'networkUrl': item.get('network_url')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'networkUrl': item.get(u'networkUrl')})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_dns_managed_zone_info.py b/lib/ansible/modules/cloud/google/gcp_dns_managed_zone_info.py
deleted file mode 100644
index 09571a530d..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_dns_managed_zone_info.py
+++ /dev/null
@@ -1,294 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_dns_managed_zone_info
-description:
-- Gather info for GCP ManagedZone
-short_description: Gather info for GCP ManagedZone
-version_added: '2.8'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- dns_name:
- description:
- - Restricts the list to return only zones with this domain name.
- type: list
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a managed zone
- gcp_dns_managed_zone_info:
- dns_name: test.somewild2.example.com.
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- description:
- description:
- - A mutable string of at most 1024 characters associated with this resource
- for the user's convenience. Has no effect on the managed zone's function.
- returned: success
- type: str
- dnsName:
- description:
- - The DNS name of this managed zone, for instance "example.com.".
- returned: success
- type: str
- dnssecConfig:
- description:
- - DNSSEC configuration.
- returned: success
- type: complex
- contains:
- kind:
- description:
- - Identifies what kind of resource this is.
- returned: success
- type: str
- nonExistence:
- description:
- - Specifies the mechanism used to provide authenticated denial-of-existence
- responses.
- returned: success
- type: str
- state:
- description:
- - Specifies whether DNSSEC is enabled, and what mode it is in.
- returned: success
- type: str
- defaultKeySpecs:
- description:
- - Specifies parameters that will be used for generating initial DnsKeys
- for this ManagedZone. If you provide a spec for keySigning or zoneSigning,
- you must also provide one for the other.
- returned: success
- type: complex
- contains:
- algorithm:
- description:
- - String mnemonic specifying the DNSSEC algorithm of this key.
- returned: success
- type: str
- keyLength:
- description:
- - Length of the keys in bits.
- returned: success
- type: int
- keyType:
- description:
- - Specifies whether this is a key signing key (KSK) or a zone signing
- key (ZSK). Key signing keys have the Secure Entry Point flag set and,
- when active, will only be used to sign resource record sets of type
- DNSKEY. Zone signing keys do not have the Secure Entry Point flag
- set and will be used to sign all other types of resource record sets.
- .
- returned: success
- type: str
- kind:
- description:
- - Identifies what kind of resource this is.
- returned: success
- type: str
- id:
- description:
- - Unique identifier for the resource; defined by the server.
- returned: success
- type: int
- name:
- description:
- - User assigned name for this resource.
- - Must be unique within the project.
- returned: success
- type: str
- nameServers:
- description:
- - Delegate your managed_zone to these virtual name servers; defined by the server
- .
- returned: success
- type: list
- nameServerSet:
- description:
- - Optionally specifies the NameServerSet for this ManagedZone. A NameServerSet
- is a set of DNS name servers that all host the same ManagedZones. Most users
- will leave this field unset.
- returned: success
- type: str
- creationTime:
- description:
- - The time that this resource was created on the server.
- - This is in RFC3339 text format.
- returned: success
- type: str
- labels:
- description:
- - A set of key/value label pairs to assign to this ManagedZone.
- returned: success
- type: dict
- visibility:
- description:
- - 'The zone''s visibility: public zones are exposed to the Internet, while private
- zones are visible only to Virtual Private Cloud resources.'
- - 'Must be one of: `public`, `private`.'
- returned: success
- type: str
- privateVisibilityConfig:
- description:
- - For privately visible zones, the set of Virtual Private Cloud resources that
- the zone is visible from.
- returned: success
- type: complex
- contains:
- networks:
- description:
- - The list of VPC networks that can see this zone.
- returned: success
- type: complex
- contains:
- networkUrl:
- description:
- - The fully qualified URL of the VPC network to bind to.
- - This should be formatted like `U(https://www.googleapis.com/compute/v1/projects/{project}/global/networks/{network}`)
- .
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(dns_name=dict(type='list', elements='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/ndev.clouddns.readwrite']
-
- return_value = {'resources': fetch_list(module, collection(module), module.params['dns_name'])}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/dns/v1/projects/{project}/managedZones".format(**module.params)
-
-
-def fetch_list(module, link, query):
- auth = GcpSession(module, 'dns')
- return auth.list(link, return_if_object, array_name='managedZones', params={'dnsName': query})
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_dns_resource_record_set.py b/lib/ansible/modules/cloud/google/gcp_dns_resource_record_set.py
deleted file mode 100644
index c409fe7701..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_dns_resource_record_set.py
+++ /dev/null
@@ -1,497 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_dns_resource_record_set
-description:
-- A single DNS record that exists on a domain name (i.e. in a managed zone).
-- This record defines the information about the domain and where the domain / subdomains
- direct to.
-- The record will include the domain/subdomain name, a type (i.e. A, AAA, CAA, MX,
- CNAME, NS, etc) .
-short_description: Creates a GCP ResourceRecordSet
-version_added: '2.6'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- name:
- description:
- - For example, U(www.example.com).
- required: true
- type: str
- type:
- description:
- - One of valid DNS resource types.
- - 'Some valid choices include: "A", "AAAA", "CAA", "CNAME", "MX", "NAPTR", "NS",
- "PTR", "SOA", "SPF", "SRV", "TLSA", "TXT"'
- required: true
- type: str
- ttl:
- description:
- - Number of seconds that this ResourceRecordSet can be cached by resolvers.
- required: false
- type: int
- target:
- description:
- - As defined in RFC 1035 (section 5) and RFC 1034 (section 3.6.1) .
- required: false
- type: list
- managed_zone:
- description:
- - Identifies the managed zone addressed by this request. This must be a dictionary
- that contains both a 'name' key and a 'dnsName' key. You can pass in the results
- of the gcp_dns_managed_zone module, which will contain both.
- required: true
- type: dict
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-'''
-
-EXAMPLES = '''
-- name: create a managed zone
- gcp_dns_managed_zone:
- name: managedzone-rrs
- dns_name: testzone-4.com.
- description: test zone
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: managed_zone
-
-- name: create a resource record set
- gcp_dns_resource_record_set:
- name: www.testzone-4.com.
- managed_zone: "{{ managed_zone }}"
- type: A
- ttl: 600
- target:
- - 10.1.2.3
- - 40.5.6.7
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-name:
- description:
- - For example, U(www.example.com).
- returned: success
- type: str
-type:
- description:
- - One of valid DNS resource types.
- returned: success
- type: str
-ttl:
- description:
- - Number of seconds that this ResourceRecordSet can be cached by resolvers.
- returned: success
- type: int
-target:
- description:
- - As defined in RFC 1035 (section 5) and RFC 1034 (section 3.6.1) .
- returned: success
- type: list
-managed_zone:
- description:
- - Identifies the managed zone addressed by this request. This must be a dictionary
- that contains both a 'name' key and a 'dnsName' key. You can pass in the results
- of the gcp_dns_managed_zone module, which will contain both.
- returned: success
- type: dict
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-import copy
-import datetime
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- name=dict(required=True, type='str'),
- type=dict(required=True, type='str'),
- ttl=dict(type='int'),
- target=dict(type='list', elements='str'),
- managed_zone=dict(required=True, type='dict'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/ndev.clouddns.readwrite']
-
- state = module.params['state']
- kind = 'dns#resourceRecordSet'
-
- fetch = fetch_wrapped_resource(module, 'dns#resourceRecordSet', 'dns#resourceRecordSetsListResponse', 'rrsets')
- changed = False
-
- if 'dnsName' not in module.params.get('managed_zone') or 'name' not in module.params.get('managed_zone'):
- module.fail_json(msg="managed_zone dictionary must contain both the name of the zone and the dns name of the zone")
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind, fetch)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind, fetch)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- change = create_change(None, updated_record(module), module)
- change_id = int(change['id'])
- if change['status'] == 'pending':
- wait_for_change_to_complete(change_id, module)
- return fetch_wrapped_resource(module, 'dns#resourceRecordSet', 'dns#resourceRecordSetsListResponse', 'rrsets')
-
-
-def update(module, link, kind, fetch):
- change = create_change(fetch, updated_record(module), module)
- change_id = int(change['id'])
- if change['status'] == 'pending':
- wait_for_change_to_complete(change_id, module)
- return fetch_wrapped_resource(module, 'dns#resourceRecordSet', 'dns#resourceRecordSetsListResponse', 'rrsets')
-
-
-def delete(module, link, kind, fetch):
- change = create_change(fetch, None, module)
- change_id = int(change['id'])
- if change['status'] == 'pending':
- wait_for_change_to_complete(change_id, module)
- return fetch_wrapped_resource(module, 'dns#resourceRecordSet', 'dns#resourceRecordSetsListResponse', 'rrsets')
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'dns#resourceRecordSet',
- u'name': module.params.get('name'),
- u'type': module.params.get('type'),
- u'ttl': module.params.get('ttl'),
- u'rrdatas': module.params.get('target'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'dns')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def fetch_wrapped_resource(module, kind, wrap_kind, wrap_path):
- result = fetch_resource(module, self_link(module), wrap_kind)
- if result is None or wrap_path not in result:
- return None
-
- result = unwrap_resource(result[wrap_path], module)
-
- if result is None:
- return None
-
- if result['kind'] != kind:
- module.fail_json(msg="Incorrect result: {kind}".format(**result))
-
- return result
-
-
-def self_link(module):
- res = {
- 'project': module.params['project'],
- 'managed_zone': replace_resource_dict(module.params['managed_zone'], 'name'),
- 'name': module.params['name'],
- 'type': module.params['type'],
- }
- return "https://www.googleapis.com/dns/v1/projects/{project}/managedZones/{managed_zone}/rrsets?name={name}&type={type}".format(**res)
-
-
-def collection(module):
- res = {'project': module.params['project'], 'managed_zone': replace_resource_dict(module.params['managed_zone'], 'name')}
- return "https://www.googleapis.com/dns/v1/projects/{project}/managedZones/{managed_zone}/changes".format(**res)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {u'name': response.get(u'name'), u'type': response.get(u'type'), u'ttl': response.get(u'ttl'), u'rrdatas': response.get(u'rrdatas')}
-
-
-def updated_record(module):
- return {
- 'kind': 'dns#resourceRecordSet',
- 'name': module.params['name'],
- 'type': module.params['type'],
- 'ttl': module.params['ttl'] if module.params['ttl'] else 900,
- 'rrdatas': module.params['target'],
- }
-
-
-def unwrap_resource(result, module):
- if not result:
- return None
- return result[0]
-
-
-class SOAForwardable(object):
- def __init__(self, params, module):
- self.params = params
- self.module = module
-
- def fail_json(self, *args, **kwargs):
- self.module.fail_json(*args, **kwargs)
-
- def raise_for_status(self, *args, **kwargs):
- self.module.raise_for_status(*args, **kwargs)
-
-
-def prefetch_soa_resource(module):
-
- resource = SOAForwardable(
- {
- 'type': 'SOA',
- 'managed_zone': module.params['managed_zone'],
- 'name': replace_resource_dict(module.params['managed_zone'], 'dnsName'),
- 'project': module.params['project'],
- 'scopes': module.params['scopes'],
- 'service_account_file': module.params.get('service_account_file'),
- 'auth_kind': module.params['auth_kind'],
- 'service_account_email': module.params.get('service_account_email'),
- 'service_account_contents': module.params.get('service_account_contents'),
- },
- module,
- )
-
- result = fetch_wrapped_resource(resource, 'dns#resourceRecordSet', 'dns#resourceRecordSetsListResponse', 'rrsets')
- if not result:
- raise ValueError("Google DNS Managed Zone %s not found" % replace_resource_dict(module.params['managed_zone'], 'name'))
- return result
-
-
-def create_change(original, updated, module):
- auth = GcpSession(module, 'dns')
- return return_if_change_object(module, auth.post(collection(module), resource_to_change_request(original, updated, module)))
-
-
-# Fetch current SOA. We need the last SOA so we can increment its serial
-def update_soa(module):
- original_soa = prefetch_soa_resource(module)
-
- # Create a clone of the SOA record so we can update it
- updated_soa = copy.deepcopy(original_soa)
-
- soa_parts = updated_soa['rrdatas'][0].split(' ')
- soa_parts[2] = str(int(soa_parts[2]) + 1)
- updated_soa['rrdatas'][0] = ' '.join(soa_parts)
- return [original_soa, updated_soa]
-
-
-def resource_to_change_request(original_record, updated_record, module):
- original_soa, updated_soa = update_soa(module)
- result = new_change_request()
- add_additions(result, updated_soa, updated_record)
- add_deletions(result, original_soa, original_record)
- return result
-
-
-def add_additions(result, updated_soa, updated_record):
- if updated_soa:
- result['additions'].append(updated_soa)
- if updated_record:
- result['additions'].append(updated_record)
-
-
-def add_deletions(result, original_soa, original_record):
- if original_soa:
- result['deletions'].append(original_soa)
-
- if original_record:
- result['deletions'].append(original_record)
-
-
-# TODO(nelsonjr): Merge and delete this code once async operation
-# declared in api.yaml
-def wait_for_change_to_complete(change_id, module):
- status = 'pending'
- while status == 'pending':
- status = get_change_status(change_id, module)
- if status != 'done':
- time.sleep(0.5)
-
-
-def get_change_status(change_id, module):
- auth = GcpSession(module, 'dns')
- link = collection(module) + "/%s" % change_id
- return return_if_change_object(module, auth.get(link))['status']
-
-
-def new_change_request():
- return {'kind': 'dns#change', 'additions': [], 'deletions': [], 'start_time': datetime.datetime.now().isoformat()}
-
-
-def return_if_change_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- if response.status_code == 204:
- return None
-
- try:
- response.raise_for_status()
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if result['kind'] != 'dns#change':
- module.fail_json(msg="Invalid result: %s" % result['kind'])
-
- return result
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_dns_resource_record_set_info.py b/lib/ansible/modules/cloud/google/gcp_dns_resource_record_set_info.py
deleted file mode 100644
index a63519ca55..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_dns_resource_record_set_info.py
+++ /dev/null
@@ -1,197 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_dns_resource_record_set_info
-description:
-- Gather info for GCP ResourceRecordSet
-short_description: Gather info for GCP ResourceRecordSet
-version_added: '2.8'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- managed_zone:
- description:
- - Identifies the managed zone addressed by this request. This must be a dictionary
- that contains both a 'name' key and a 'dnsName' key. You can pass in the results
- of the gcp_dns_managed_zone module, which will contain both.
- required: true
- type: dict
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a resource record set
- gcp_dns_resource_record_set_info:
- managed_zone: "{{ managed_zone }}"
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- name:
- description:
- - For example, U(www.example.com).
- returned: success
- type: str
- type:
- description:
- - One of valid DNS resource types.
- returned: success
- type: str
- ttl:
- description:
- - Number of seconds that this ResourceRecordSet can be cached by resolvers.
- returned: success
- type: int
- target:
- description:
- - As defined in RFC 1035 (section 5) and RFC 1034 (section 3.6.1) .
- returned: success
- type: list
- managed_zone:
- description:
- - Identifies the managed zone addressed by this request. This must be a dictionary
- that contains both a 'name' key and a 'dnsName' key. You can pass in the results
- of the gcp_dns_managed_zone module, which will contain both.
- returned: success
- type: dict
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(managed_zone=dict(required=True, type='dict')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/ndev.clouddns.readwrite']
-
- return_value = {'resources': fetch_list(module, collection(module))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- res = {'project': module.params['project'], 'managed_zone': replace_resource_dict(module.params['managed_zone'], 'name')}
- return "https://www.googleapis.com/dns/v1/projects/{project}/managedZones/{managed_zone}/rrsets".format(**res)
-
-
-def fetch_list(module, link):
- auth = GcpSession(module, 'dns')
- return auth.list(link, return_if_object, array_name='rrsets')
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_filestore_instance.py b/lib/ansible/modules/cloud/google/gcp_filestore_instance.py
deleted file mode 100644
index 6369fa9756..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_filestore_instance.py
+++ /dev/null
@@ -1,565 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_filestore_instance
-description:
-- A Google Cloud Filestore instance.
-short_description: Creates a GCP Instance
-version_added: '2.9'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- name:
- description:
- - The resource name of the instance.
- required: true
- type: str
- description:
- description:
- - A description of the instance.
- required: false
- type: str
- tier:
- description:
- - The service tier of the instance.
- - 'Some valid choices include: "TIER_UNSPECIFIED", "STANDARD", "PREMIUM"'
- required: true
- type: str
- labels:
- description:
- - Resource labels to represent user-provided metadata.
- required: false
- type: dict
- file_shares:
- description:
- - File system shares on the instance. For this version, only a single file share
- is supported.
- required: true
- type: list
- suboptions:
- name:
- description:
- - The name of the fileshare (16 characters or less) .
- required: true
- type: str
- capacity_gb:
- description:
- - File share capacity in GiB. This must be at least 1024 GiB for the standard
- tier, or 2560 GiB for the premium tier.
- required: true
- type: int
- networks:
- description:
- - VPC networks to which the instance is connected. For this version, only a single
- network is supported.
- required: true
- type: list
- suboptions:
- network:
- description:
- - The name of the GCE VPC network to which the instance is connected.
- required: true
- type: str
- modes:
- description:
- - IP versions for which the instance has IP addresses assigned.
- required: true
- type: list
- reserved_ip_range:
- description:
- - A /29 CIDR block that identifies the range of IP addresses reserved for
- this instance.
- required: false
- type: str
- zone:
- description:
- - The name of the Filestore zone of the instance.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/filestore/docs/reference/rest/v1beta1/projects.locations.instances/create)'
-- 'Official Documentation: U(https://cloud.google.com/filestore/docs/creating-instances)'
-- 'Use with Kubernetes: U(https://cloud.google.com/filestore/docs/accessing-fileshares)'
-- 'Copying Data In/Out: U(https://cloud.google.com/filestore/docs/copying-data)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a instance
- gcp_filestore_instance:
- name: test_object
- zone: us-central1-b
- tier: PREMIUM
- file_shares:
- - capacity_gb: 2660
- name: share1
- networks:
- - network: default
- modes:
- - MODE_IPV4
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-name:
- description:
- - The resource name of the instance.
- returned: success
- type: str
-description:
- description:
- - A description of the instance.
- returned: success
- type: str
-createTime:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
-tier:
- description:
- - The service tier of the instance.
- returned: success
- type: str
-labels:
- description:
- - Resource labels to represent user-provided metadata.
- returned: success
- type: dict
-fileShares:
- description:
- - File system shares on the instance. For this version, only a single file share
- is supported.
- returned: success
- type: complex
- contains:
- name:
- description:
- - The name of the fileshare (16 characters or less) .
- returned: success
- type: str
- capacityGb:
- description:
- - File share capacity in GiB. This must be at least 1024 GiB for the standard
- tier, or 2560 GiB for the premium tier.
- returned: success
- type: int
-networks:
- description:
- - VPC networks to which the instance is connected. For this version, only a single
- network is supported.
- returned: success
- type: complex
- contains:
- network:
- description:
- - The name of the GCE VPC network to which the instance is connected.
- returned: success
- type: str
- modes:
- description:
- - IP versions for which the instance has IP addresses assigned.
- returned: success
- type: list
- reservedIpRange:
- description:
- - A /29 CIDR block that identifies the range of IP addresses reserved for this
- instance.
- returned: success
- type: str
- ipAddresses:
- description:
- - A list of IPv4 or IPv6 addresses.
- returned: success
- type: list
-etag:
- description:
- - Server-specified ETag for the instance resource to prevent simultaneous updates
- from overwriting each other.
- returned: success
- type: str
-zone:
- description:
- - The name of the Filestore zone of the instance.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import re
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- name=dict(required=True, type='str'),
- description=dict(type='str'),
- tier=dict(required=True, type='str'),
- labels=dict(type='dict'),
- file_shares=dict(
- required=True, type='list', elements='dict', options=dict(name=dict(required=True, type='str'), capacity_gb=dict(required=True, type='int'))
- ),
- networks=dict(
- required=True,
- type='list',
- elements='dict',
- options=dict(
- network=dict(required=True, type='str'), modes=dict(required=True, type='list', elements='str'), reserved_ip_range=dict(type='str')
- ),
- ),
- zone=dict(required=True, type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
-
- state = module.params['state']
-
- fetch = fetch_resource(module, self_link(module))
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), fetch)
- fetch = fetch_resource(module, self_link(module))
- changed = True
- else:
- delete(module, self_link(module))
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, create_link(module))
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link):
- auth = GcpSession(module, 'filestore')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, fetch):
- auth = GcpSession(module, 'filestore')
- params = {'updateMask': updateMask(resource_to_request(module), response_to_hash(module, fetch))}
- request = resource_to_request(module)
- return wait_for_operation(module, auth.patch(link, request, params=params))
-
-
-def updateMask(request, response):
- update_mask = []
- if request.get('description') != response.get('description'):
- update_mask.append('description')
- if request.get('labels') != response.get('labels'):
- update_mask.append('labels')
- if request.get('fileShares') != response.get('fileShares'):
- update_mask.append('fileShares')
- return ','.join(update_mask)
-
-
-def delete(module, link):
- auth = GcpSession(module, 'filestore')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'description': module.params.get('description'),
- u'tier': module.params.get('tier'),
- u'labels': module.params.get('labels'),
- u'fileShares': InstanceFilesharesArray(module.params.get('file_shares', []), module).to_request(),
- u'networks': InstanceNetworksArray(module.params.get('networks', []), module).to_request(),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, allow_not_found=True):
- auth = GcpSession(module, 'filestore')
- return return_if_object(module, auth.get(link), allow_not_found)
-
-
-def self_link(module):
- return "https://file.googleapis.com/v1/projects/{project}/locations/{zone}/instances/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://file.googleapis.com/v1/projects/{project}/locations/{zone}/instances".format(**module.params)
-
-
-def create_link(module):
- return "https://file.googleapis.com/v1/projects/{project}/locations/{zone}/instances?instanceId={name}".format(**module.params)
-
-
-def return_if_object(module, response, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'name': response.get(u'name'),
- u'description': response.get(u'description'),
- u'createTime': response.get(u'createTime'),
- u'tier': module.params.get('tier'),
- u'labels': response.get(u'labels'),
- u'fileShares': InstanceFilesharesArray(response.get(u'fileShares', []), module).from_response(),
- u'networks': InstanceNetworksArray(module.params.get('networks', []), module).to_request(),
- u'etag': response.get(u'etag'),
- }
-
-
-def name_pattern(name, module):
- if name is None:
- return
-
- regex = r"projects/.*/locations/.*/instances/.*"
-
- if not re.match(regex, name):
- name = "projects/{project}/locations/{zone}/instances/{name}".format(**module.params)
-
- return name
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://file.googleapis.com/v1/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response)
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['done'])
- wait_done = wait_for_completion(status, op_result, module)
- raise_if_errors(wait_done, ['error'], module)
- return navigate_hash(wait_done, ['response'])
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while not status:
- raise_if_errors(op_result, ['error'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, False)
- status = navigate_hash(op_result, ['done'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-class InstanceFilesharesArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'name': item.get('name'), u'capacityGb': item.get('capacity_gb')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'name': item.get(u'name'), u'capacityGb': item.get(u'capacityGb')})
-
-
-class InstanceNetworksArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'network': item.get('network'), u'modes': item.get('modes'), u'reservedIpRange': item.get('reserved_ip_range')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict(
- {u'network': self.module.params.get('network'), u'modes': self.module.params.get('modes'), u'reservedIpRange': item.get(u'reservedIpRange')}
- )
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_filestore_instance_info.py b/lib/ansible/modules/cloud/google/gcp_filestore_instance_info.py
deleted file mode 100644
index 6c97d115b1..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_filestore_instance_info.py
+++ /dev/null
@@ -1,249 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_filestore_instance_info
-description:
-- Gather info for GCP Instance
-short_description: Gather info for GCP Instance
-version_added: '2.9'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- zone:
- description:
- - The name of the Filestore zone of the instance.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on an instance
- gcp_filestore_instance_info:
- zone: us-central1-b
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- name:
- description:
- - The resource name of the instance.
- returned: success
- type: str
- description:
- description:
- - A description of the instance.
- returned: success
- type: str
- createTime:
- description:
- - Creation timestamp in RFC3339 text format.
- returned: success
- type: str
- tier:
- description:
- - The service tier of the instance.
- returned: success
- type: str
- labels:
- description:
- - Resource labels to represent user-provided metadata.
- returned: success
- type: dict
- fileShares:
- description:
- - File system shares on the instance. For this version, only a single file share
- is supported.
- returned: success
- type: complex
- contains:
- name:
- description:
- - The name of the fileshare (16 characters or less) .
- returned: success
- type: str
- capacityGb:
- description:
- - File share capacity in GiB. This must be at least 1024 GiB for the standard
- tier, or 2560 GiB for the premium tier.
- returned: success
- type: int
- networks:
- description:
- - VPC networks to which the instance is connected. For this version, only a
- single network is supported.
- returned: success
- type: complex
- contains:
- network:
- description:
- - The name of the GCE VPC network to which the instance is connected.
- returned: success
- type: str
- modes:
- description:
- - IP versions for which the instance has IP addresses assigned.
- returned: success
- type: list
- reservedIpRange:
- description:
- - A /29 CIDR block that identifies the range of IP addresses reserved for
- this instance.
- returned: success
- type: str
- ipAddresses:
- description:
- - A list of IPv4 or IPv6 addresses.
- returned: success
- type: list
- etag:
- description:
- - Server-specified ETag for the instance resource to prevent simultaneous updates
- from overwriting each other.
- returned: success
- type: str
- zone:
- description:
- - The name of the Filestore zone of the instance.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(zone=dict(required=True, type='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
-
- return_value = {'resources': fetch_list(module, collection(module))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://file.googleapis.com/v1/projects/{project}/locations/{zone}/instances".format(**module.params)
-
-
-def fetch_list(module, link):
- auth = GcpSession(module, 'filestore')
- return auth.list(link, return_if_object, array_name='instances')
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_iam_role.py b/lib/ansible/modules/cloud/google/gcp_iam_role.py
deleted file mode 100644
index a9159e9112..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_iam_role.py
+++ /dev/null
@@ -1,353 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_iam_role
-description:
-- A role in the Identity and Access Management API .
-short_description: Creates a GCP Role
-version_added: '2.8'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- name:
- description:
- - The name of the role.
- required: true
- type: str
- title:
- description:
- - A human-readable title for the role. Typically this is limited to 100 UTF-8
- bytes.
- required: false
- type: str
- description:
- description:
- - Human-readable description for the role.
- required: false
- type: str
- included_permissions:
- description:
- - Names of permissions this role grants when bound in an IAM policy.
- required: false
- type: list
- stage:
- description:
- - The current launch stage of the role.
- - 'Some valid choices include: "ALPHA", "BETA", "GA", "DEPRECATED", "DISABLED",
- "EAP"'
- required: false
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-'''
-
-EXAMPLES = '''
-- name: create a role
- gcp_iam_role:
- name: myCustomRole2
- title: My Custom Role
- description: My custom role description
- included_permissions:
- - iam.roles.list
- - iam.roles.create
- - iam.roles.delete
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-name:
- description:
- - The name of the role.
- returned: success
- type: str
-title:
- description:
- - A human-readable title for the role. Typically this is limited to 100 UTF-8 bytes.
- returned: success
- type: str
-description:
- description:
- - Human-readable description for the role.
- returned: success
- type: str
-includedPermissions:
- description:
- - Names of permissions this role grants when bound in an IAM policy.
- returned: success
- type: list
-stage:
- description:
- - The current launch stage of the role.
- returned: success
- type: str
-deleted:
- description:
- - The current deleted state of the role.
- returned: success
- type: bool
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- name=dict(required=True, type='str'),
- title=dict(type='str'),
- description=dict(type='str'),
- included_permissions=dict(type='list', elements='str'),
- stage=dict(type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/iam']
-
- state = module.params['state']
-
- fetch = fetch_resource(module, self_link(module))
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), fetch)
- fetch = fetch_resource(module, self_link(module))
- changed = True
- else:
- delete(module, self_link(module))
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module))
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link):
- auth = GcpSession(module, 'iam')
- return return_if_object(module, auth.post(link, resource_to_create(module)))
-
-
-def update(module, link, fetch):
- auth = GcpSession(module, 'iam')
- params = {'updateMask': updateMask(resource_to_request(module), response_to_hash(module, fetch))}
- request = resource_to_request(module)
- del request['name']
- return return_if_object(module, auth.put(link, request, params=params))
-
-
-def updateMask(request, response):
- update_mask = []
- if request.get('name') != response.get('name'):
- update_mask.append('name')
- if request.get('title') != response.get('title'):
- update_mask.append('title')
- if request.get('description') != response.get('description'):
- update_mask.append('description')
- if request.get('includedPermissions') != response.get('includedPermissions'):
- update_mask.append('includedPermissions')
- if request.get('stage') != response.get('stage'):
- update_mask.append('stage')
- return ','.join(update_mask)
-
-
-def delete(module, link):
- auth = GcpSession(module, 'iam')
- return return_if_object(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'name': module.params.get('name'),
- u'title': module.params.get('title'),
- u'description': module.params.get('description'),
- u'includedPermissions': module.params.get('included_permissions'),
- u'stage': module.params.get('stage'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, allow_not_found=True):
- auth = GcpSession(module, 'iam')
- return return_if_object(module, auth.get(link), allow_not_found)
-
-
-def self_link(module):
- return "https://iam.googleapis.com/v1/projects/{project}/roles/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://iam.googleapis.com/v1/projects/{project}/roles".format(**module.params)
-
-
-def return_if_object(module, response, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- result = decode_response(result, module)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
- request = decode_response(request, module)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'name': response.get(u'name'),
- u'title': response.get(u'title'),
- u'description': response.get(u'description'),
- u'includedPermissions': response.get(u'includedPermissions'),
- u'stage': response.get(u'stage'),
- u'deleted': response.get(u'deleted'),
- }
-
-
-def resource_to_create(module):
- role = resource_to_request(module)
- del role['name']
- return {'roleId': module.params['name'], 'role': role}
-
-
-def decode_response(response, module):
- if 'name' in response:
- response['name'] = response['name'].split('/')[-1]
- return response
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_iam_role_info.py b/lib/ansible/modules/cloud/google/gcp_iam_role_info.py
deleted file mode 100644
index 15172c92b1..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_iam_role_info.py
+++ /dev/null
@@ -1,192 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_iam_role_info
-description:
-- Gather info for GCP Role
-short_description: Gather info for GCP Role
-version_added: '2.8'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a role
- gcp_iam_role_info:
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- name:
- description:
- - The name of the role.
- returned: success
- type: str
- title:
- description:
- - A human-readable title for the role. Typically this is limited to 100 UTF-8
- bytes.
- returned: success
- type: str
- description:
- description:
- - Human-readable description for the role.
- returned: success
- type: str
- includedPermissions:
- description:
- - Names of permissions this role grants when bound in an IAM policy.
- returned: success
- type: list
- stage:
- description:
- - The current launch stage of the role.
- returned: success
- type: str
- deleted:
- description:
- - The current deleted state of the role.
- returned: success
- type: bool
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict())
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/iam']
-
- return_value = {'resources': fetch_list(module, collection(module))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://iam.googleapis.com/v1/projects/{project}/roles".format(**module.params)
-
-
-def fetch_list(module, link):
- auth = GcpSession(module, 'iam')
- return auth.list(link, return_if_object, array_name='roles')
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_iam_service_account.py b/lib/ansible/modules/cloud/google/gcp_iam_service_account.py
deleted file mode 100644
index 4a7ec111d3..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_iam_service_account.py
+++ /dev/null
@@ -1,303 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_iam_service_account
-description:
-- A service account in the Identity and Access Management API.
-short_description: Creates a GCP ServiceAccount
-version_added: '2.8'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- name:
- description:
- - The name of the service account.
- required: false
- type: str
- display_name:
- description:
- - User specified description of service account.
- required: false
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-'''
-
-EXAMPLES = '''
-- name: create a service account
- gcp_iam_service_account:
- name: sa-{{ resource_name.split("-")[-1] }}@graphite-playground.google.com.iam.gserviceaccount.com
- display_name: My Ansible test key
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-name:
- description:
- - The name of the service account.
- returned: success
- type: str
-projectId:
- description:
- - Id of the project that owns the service account.
- returned: success
- type: str
-uniqueId:
- description:
- - Unique and stable id of the service account.
- returned: success
- type: str
-email:
- description:
- - Email address of the service account.
- returned: success
- type: str
-displayName:
- description:
- - User specified description of service account.
- returned: success
- type: str
-oauth2ClientId:
- description:
- - OAuth2 client id for the service account.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(state=dict(default='present', choices=['present', 'absent'], type='str'), name=dict(type='str'), display_name=dict(type='str'))
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/iam']
-
- state = module.params['state']
-
- fetch = fetch_resource(module, self_link(module))
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module))
- fetch = fetch_resource(module, self_link(module))
- changed = True
- else:
- delete(module, self_link(module))
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module))
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link):
- auth = GcpSession(module, 'iam')
- return return_if_object(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link):
- auth = GcpSession(module, 'iam')
- return return_if_object(module, auth.put(link, resource_to_request(module)))
-
-
-def delete(module, link):
- auth = GcpSession(module, 'iam')
- return return_if_object(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {u'name': module.params.get('name'), u'displayName': module.params.get('display_name')}
- request = encode_request(request, module)
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, allow_not_found=True):
- auth = GcpSession(module, 'iam')
- return return_if_object(module, auth.get(link), allow_not_found)
-
-
-def self_link(module):
- return "https://iam.googleapis.com/v1/projects/{project}/serviceAccounts/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://iam.googleapis.com/v1/projects/{project}/serviceAccounts".format(**module.params)
-
-
-def return_if_object(module, response, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- result = decode_response(result, module)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
- request = decode_response(request, module)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'name': response.get(u'name'),
- u'projectId': response.get(u'projectId'),
- u'uniqueId': response.get(u'uniqueId'),
- u'email': response.get(u'email'),
- u'displayName': response.get(u'displayName'),
- u'oauth2ClientId': response.get(u'oauth2ClientId'),
- }
-
-
-def encode_request(resource_request, module):
- """Structures the request as accountId + rest of request"""
- account_id = resource_request['name'].split('@')[0]
- del resource_request['name']
- return {'accountId': account_id, 'serviceAccount': resource_request}
-
-
-def decode_response(response, module):
- """Unstructures the request from accountId + rest of request"""
- if 'name' not in response:
- return response
- response['name'] = response['name'].split('/')[-1]
- return response
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_iam_service_account_info.py b/lib/ansible/modules/cloud/google/gcp_iam_service_account_info.py
deleted file mode 100644
index 579fac729d..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_iam_service_account_info.py
+++ /dev/null
@@ -1,191 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_iam_service_account_info
-description:
-- Gather info for GCP ServiceAccount
-short_description: Gather info for GCP ServiceAccount
-version_added: '2.8'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a service account
- gcp_iam_service_account_info:
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- name:
- description:
- - The name of the service account.
- returned: success
- type: str
- projectId:
- description:
- - Id of the project that owns the service account.
- returned: success
- type: str
- uniqueId:
- description:
- - Unique and stable id of the service account.
- returned: success
- type: str
- email:
- description:
- - Email address of the service account.
- returned: success
- type: str
- displayName:
- description:
- - User specified description of service account.
- returned: success
- type: str
- oauth2ClientId:
- description:
- - OAuth2 client id for the service account.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict())
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/iam']
-
- return_value = {'resources': fetch_list(module, collection(module))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://iam.googleapis.com/v1/projects/{project}/serviceAccounts".format(**module.params)
-
-
-def fetch_list(module, link):
- auth = GcpSession(module, 'iam')
- return auth.list(link, return_if_object, array_name='accounts')
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_iam_service_account_key.py b/lib/ansible/modules/cloud/google/gcp_iam_service_account_key.py
deleted file mode 100644
index afa63a40de..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_iam_service_account_key.py
+++ /dev/null
@@ -1,315 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_iam_service_account_key
-description:
-- A service account in the Identity and Access Management API.
-short_description: Creates a GCP ServiceAccountKey
-version_added: '2.8'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- private_key_type:
- description:
- - Output format for the service account key.
- - 'Some valid choices include: "TYPE_UNSPECIFIED", "TYPE_PKCS12_FILE", "TYPE_GOOGLE_CREDENTIALS_FILE"'
- required: false
- type: str
- key_algorithm:
- description:
- - Specifies the algorithm for the key.
- - 'Some valid choices include: "KEY_ALG_UNSPECIFIED", "KEY_ALG_RSA_1024", "KEY_ALG_RSA_2048"'
- required: false
- type: str
- service_account:
- description:
- - The name of the serviceAccount.
- - 'This field represents a link to a ServiceAccount resource in GCP. It can be
- specified in two ways. First, you can place a dictionary with key ''name'' and
- value of your resource''s name Alternatively, you can add `register: name-of-resource`
- to a gcp_iam_service_account task and then set this service_account field to
- "{{ name-of-resource }}"'
- required: false
- type: dict
- path:
- description:
- - The full name of the file that will hold the service account private key. The
- management of this file will depend on the value of sync_file parameter.
- - File path must be absolute.
- required: false
- type: path
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-'''
-
-EXAMPLES = '''
-- name: create a service account
- gcp_iam_service_account:
- name: test-ansible@graphite-playground.google.com.iam.gserviceaccount.com
- display_name: My Ansible test key
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: serviceaccount
-
-- name: create a service account key
- gcp_iam_service_account_key:
- service_account: "{{ serviceaccount }}"
- private_key_type: TYPE_GOOGLE_CREDENTIALS_FILE
- path: "~/test_account.json"
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-name:
- description:
- - The name of the key.
- returned: success
- type: str
-privateKeyType:
- description:
- - Output format for the service account key.
- returned: success
- type: str
-keyAlgorithm:
- description:
- - Specifies the algorithm for the key.
- returned: success
- type: str
-privateKeyData:
- description:
- - Private key data. Base-64 encoded.
- returned: success
- type: str
-publicKeyData:
- description:
- - Public key data. Base-64 encoded.
- returned: success
- type: str
-validAfterTime:
- description:
- - Key can only be used after this time.
- returned: success
- type: str
-validBeforeTime:
- description:
- - Key can only be used before this time.
- returned: success
- type: str
-serviceAccount:
- description:
- - The name of the serviceAccount.
- returned: success
- type: dict
-path:
- description:
- - The full name of the file that will hold the service account private key. The
- management of this file will depend on the value of sync_file parameter.
- - File path must be absolute.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-from ansible.module_utils._text import to_native
-import json
-import os
-import mimetypes
-import hashlib
-import base64
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- private_key_type=dict(type='str'),
- key_algorithm=dict(type='str'),
- service_account=dict(type='dict'),
- path=dict(type='path'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/iam']
-
- state = module.params['state']
-
- # If file exists, we're doing a no-op or deleting the key.
- changed = False
- if os.path.isfile(module.params['path']):
- fetch = fetch_resource(module)
- # If file exists and we should delete the file, delete it.
- if fetch and module.params['state'] == 'absent':
- delete(module)
- changed = True
-
- # Create the file if present state and no current file.
- elif module.params['state'] == 'present':
- create(module)
- changed = True
-
- # Not returning any information about the key because that information should
- # end up in logs.
- module.exit_json(**{'changed': changed, 'file_path': module.params['path']})
-
-
-def create(module):
- auth = GcpSession(module, 'iam')
- json_content = return_if_object(module, auth.post(self_link(module), resource_to_request(module)))
- with open(module.params['path'], 'w') as f:
- private_key_contents = to_native(base64.b64decode(json_content['privateKeyData']))
- f.write(private_key_contents)
-
-
-def delete(module):
- auth = GcpSession(module, 'iam')
- return return_if_object(module, auth.delete(self_link_from_file(module)))
-
-
-def resource_to_request(module):
- request = {u'privateKeyType': module.params.get('private_key_type'), u'keyAlgorithm': module.params.get('key_algorithm')}
- return_vals = {}
- for k, v in request.items():
- if v:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module):
- auth = GcpSession(module, 'iam')
- return return_if_object(module, auth.get(self_link_from_file(module)))
-
-
-def key_name_from_file(filename, module):
- with open(filename, 'r') as f:
- try:
- json_data = json.loads(f.read())
- return "projects/{project_id}/serviceAccounts/{client_email}/keys/{private_key_id}".format(**json_data)
- except ValueError as inst:
- module.fail_json(msg="File is not a valid GCP JSON service account key")
-
-
-def self_link_from_file(module):
- key_name = key_name_from_file(module.params['path'], module)
- return "https://iam.googleapis.com/v1/{key_name}".format(key_name=key_name)
-
-
-def self_link(module):
- results = {'project': module.params['project'], 'service_account': replace_resource_dict(module.params['service_account'], 'name')}
- return "https://iam.googleapis.com/v1/projects/{project}/serviceAccounts/{service_account}/keys".format(**results)
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- # return_if_object not used in any context where 404 means error.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_kms_crypto_key.py b/lib/ansible/modules/cloud/google/gcp_kms_crypto_key.py
deleted file mode 100644
index 9c22b82722..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_kms_crypto_key.py
+++ /dev/null
@@ -1,427 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_kms_crypto_key
-description:
-- A `CryptoKey` represents a logical key that can be used for cryptographic operations.
-short_description: Creates a GCP CryptoKey
-version_added: '2.9'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- name:
- description:
- - The resource name for the CryptoKey.
- required: true
- type: str
- labels:
- description:
- - Labels with user-defined metadata to apply to this resource.
- required: false
- type: dict
- purpose:
- description:
- - Immutable purpose of CryptoKey. See U(https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys#CryptoKeyPurpose)
- for inputs.
- - 'Some valid choices include: "ENCRYPT_DECRYPT", "ASYMMETRIC_SIGN", "ASYMMETRIC_DECRYPT"'
- required: false
- default: ENCRYPT_DECRYPT
- type: str
- rotation_period:
- description:
- - Every time this period passes, generate a new CryptoKeyVersion and set it as
- the primary.
- - The first rotation will take place after the specified period. The rotation
- period has the format of a decimal number with up to 9 fractional digits, followed
- by the letter `s` (seconds). It must be greater than a day (ie, 86400).
- required: false
- type: str
- version_template:
- description:
- - A template describing settings for new crypto key versions.
- required: false
- type: dict
- suboptions:
- algorithm:
- description:
- - The algorithm to use when creating a version based on this template.
- - See the [algorithm reference](U(https://cloud.google.com/kms/docs/reference/rest/v1/CryptoKeyVersionAlgorithm))
- for possible inputs.
- required: true
- type: str
- protection_level:
- description:
- - The protection level to use when creating a version based on this template.
- - 'Some valid choices include: "SOFTWARE", "HSM"'
- required: false
- type: str
- key_ring:
- description:
- - The KeyRing that this key belongs to.
- - 'Format: `''projects/{{project}}/locations/{{location}}/keyRings/{{keyRing}}''`.'
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys)'
-- 'Creating a key: U(https://cloud.google.com/kms/docs/creating-keys#create_a_key)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a key ring
- gcp_kms_key_ring:
- name: key-key-ring
- location: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: keyring
-
-- name: create a crypto key
- gcp_kms_crypto_key:
- name: test_object
- key_ring: projects/{{ gcp_project }}/locations/us-central1/keyRings/key-key-ring
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-name:
- description:
- - The resource name for the CryptoKey.
- returned: success
- type: str
-creationTime:
- description:
- - The time that this resource was created on the server.
- - This is in RFC3339 text format.
- returned: success
- type: str
-labels:
- description:
- - Labels with user-defined metadata to apply to this resource.
- returned: success
- type: dict
-purpose:
- description:
- - Immutable purpose of CryptoKey. See U(https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys#CryptoKeyPurpose)
- for inputs.
- returned: success
- type: str
-rotationPeriod:
- description:
- - Every time this period passes, generate a new CryptoKeyVersion and set it as the
- primary.
- - The first rotation will take place after the specified period. The rotation period
- has the format of a decimal number with up to 9 fractional digits, followed by
- the letter `s` (seconds). It must be greater than a day (ie, 86400).
- returned: success
- type: str
-versionTemplate:
- description:
- - A template describing settings for new crypto key versions.
- returned: success
- type: complex
- contains:
- algorithm:
- description:
- - The algorithm to use when creating a version based on this template.
- - See the [algorithm reference](U(https://cloud.google.com/kms/docs/reference/rest/v1/CryptoKeyVersionAlgorithm))
- for possible inputs.
- returned: success
- type: str
- protectionLevel:
- description:
- - The protection level to use when creating a version based on this template.
- returned: success
- type: str
-keyRing:
- description:
- - The KeyRing that this key belongs to.
- - 'Format: `''projects/{{project}}/locations/{{location}}/keyRings/{{keyRing}}''`.'
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- name=dict(required=True, type='str'),
- labels=dict(type='dict'),
- purpose=dict(default='ENCRYPT_DECRYPT', type='str'),
- rotation_period=dict(type='str'),
- version_template=dict(type='dict', options=dict(algorithm=dict(required=True, type='str'), protection_level=dict(type='str'))),
- key_ring=dict(required=True, type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloudkms']
-
- state = module.params['state']
-
- fetch = fetch_resource(module, self_link(module))
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), fetch)
- fetch = fetch_resource(module, self_link(module))
- changed = True
- else:
- delete(module, self_link(module))
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, create_link(module))
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link):
- auth = GcpSession(module, 'kms')
- return return_if_object(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, fetch):
- auth = GcpSession(module, 'kms')
- params = {'updateMask': updateMask(resource_to_request(module), response_to_hash(module, fetch))}
- request = resource_to_request(module)
- return return_if_object(module, auth.patch(link, request, params=params))
-
-
-def updateMask(request, response):
- update_mask = []
- if request.get('labels') != response.get('labels'):
- update_mask.append('labels')
- if request.get('rotationPeriod') != response.get('rotationPeriod'):
- update_mask.append('rotationPeriod')
- if request.get('versionTemplate') != response.get('versionTemplate'):
- update_mask.append('versionTemplate')
- return ','.join(update_mask)
-
-
-def delete(module, link):
- module.fail_json(msg="KeyRings cannot be deleted")
-
-
-def resource_to_request(module):
- request = {
- u'labels': module.params.get('labels'),
- u'purpose': module.params.get('purpose'),
- u'rotationPeriod': module.params.get('rotation_period'),
- u'versionTemplate': CryptoKeyVersiontemplate(module.params.get('version_template', {}), module).to_request(),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, allow_not_found=True):
- auth = GcpSession(module, 'kms')
- return return_if_object(module, auth.get(link), allow_not_found)
-
-
-def self_link(module):
- return "https://cloudkms.googleapis.com/v1/{key_ring}/cryptoKeys/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://cloudkms.googleapis.com/v1/{key_ring}/cryptoKeys".format(**module.params)
-
-
-def create_link(module):
- return "https://cloudkms.googleapis.com/v1/{key_ring}/cryptoKeys?cryptoKeyId={name}".format(**module.params)
-
-
-def return_if_object(module, response, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- result = decode_response(result, module)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
- request = decode_response(request, module)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'name': module.params.get('name'),
- u'creationTime': response.get(u'creationTime'),
- u'labels': response.get(u'labels'),
- u'purpose': module.params.get('purpose'),
- u'rotationPeriod': response.get(u'rotationPeriod'),
- u'versionTemplate': CryptoKeyVersiontemplate(response.get(u'versionTemplate', {}), module).from_response(),
- }
-
-
-def decode_response(response, module):
- if 'name' in response:
- response['name'] = response['name'].split('/')[-1]
- return response
-
-
-class CryptoKeyVersiontemplate(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'algorithm': self.request.get('algorithm'), u'protectionLevel': self.request.get('protection_level')})
-
- def from_response(self):
- return remove_nones_from_dict({u'algorithm': self.request.get(u'algorithm'), u'protectionLevel': self.module.params.get('protection_level')})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_kms_crypto_key_info.py b/lib/ansible/modules/cloud/google/gcp_kms_crypto_key_info.py
deleted file mode 100644
index 44320e69fd..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_kms_crypto_key_info.py
+++ /dev/null
@@ -1,223 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_kms_crypto_key_info
-description:
-- Gather info for GCP CryptoKey
-short_description: Gather info for GCP CryptoKey
-version_added: '2.9'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- key_ring:
- description:
- - The KeyRing that this key belongs to.
- - 'Format: `''projects/{{project}}/locations/{{location}}/keyRings/{{keyRing}}''`.'
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a crypto key
- gcp_kms_crypto_key_info:
- key_ring: projects/{{ gcp_project }}/locations/us-central1/keyRings/key-key-ring
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- name:
- description:
- - The resource name for the CryptoKey.
- returned: success
- type: str
- creationTime:
- description:
- - The time that this resource was created on the server.
- - This is in RFC3339 text format.
- returned: success
- type: str
- labels:
- description:
- - Labels with user-defined metadata to apply to this resource.
- returned: success
- type: dict
- purpose:
- description:
- - Immutable purpose of CryptoKey. See U(https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings.cryptoKeys#CryptoKeyPurpose)
- for inputs.
- returned: success
- type: str
- rotationPeriod:
- description:
- - Every time this period passes, generate a new CryptoKeyVersion and set it
- as the primary.
- - The first rotation will take place after the specified period. The rotation
- period has the format of a decimal number with up to 9 fractional digits,
- followed by the letter `s` (seconds). It must be greater than a day (ie, 86400).
- returned: success
- type: str
- versionTemplate:
- description:
- - A template describing settings for new crypto key versions.
- returned: success
- type: complex
- contains:
- algorithm:
- description:
- - The algorithm to use when creating a version based on this template.
- - See the [algorithm reference](U(https://cloud.google.com/kms/docs/reference/rest/v1/CryptoKeyVersionAlgorithm))
- for possible inputs.
- returned: success
- type: str
- protectionLevel:
- description:
- - The protection level to use when creating a version based on this template.
- returned: success
- type: str
- keyRing:
- description:
- - The KeyRing that this key belongs to.
- - 'Format: `''projects/{{project}}/locations/{{location}}/keyRings/{{keyRing}}''`.'
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(key_ring=dict(required=True, type='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloudkms']
-
- return_value = {'resources': fetch_list(module, collection(module))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://cloudkms.googleapis.com/v1/{key_ring}/cryptoKeys".format(**module.params)
-
-
-def fetch_list(module, link):
- auth = GcpSession(module, 'kms')
- return auth.list(link, return_if_object, array_name='cryptoKeys')
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_kms_key_ring.py b/lib/ansible/modules/cloud/google/gcp_kms_key_ring.py
deleted file mode 100644
index 4ac1faf5bc..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_kms_key_ring.py
+++ /dev/null
@@ -1,295 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_kms_key_ring
-description:
-- A `KeyRing` is a toplevel logical grouping of `CryptoKeys`.
-short_description: Creates a GCP KeyRing
-version_added: '2.9'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- name:
- description:
- - The resource name for the KeyRing.
- required: true
- type: str
- location:
- description:
- - The location for the KeyRing.
- - A full list of valid locations can be found by running `gcloud kms locations
- list`.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/kms/docs/reference/rest/v1/projects.locations.keyRings)'
-- 'Creating a key ring: U(https://cloud.google.com/kms/docs/creating-keys#create_a_key_ring)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a key ring
- gcp_kms_key_ring:
- name: test_object
- location: us-central1
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-name:
- description:
- - The resource name for the KeyRing.
- returned: success
- type: str
-creationTime:
- description:
- - The time that this resource was created on the server.
- - This is in RFC3339 text format.
- returned: success
- type: str
-location:
- description:
- - The location for the KeyRing.
- - A full list of valid locations can be found by running `gcloud kms locations list`.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- name=dict(required=True, type='str'),
- location=dict(required=True, type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloudkms']
-
- state = module.params['state']
-
- fetch = fetch_resource(module, self_link(module))
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module))
- fetch = fetch_resource(module, self_link(module))
- changed = True
- else:
- delete(module, self_link(module))
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, create_link(module))
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link):
- auth = GcpSession(module, 'kms')
- return return_if_object(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link):
- delete(module, self_link(module))
- create(module, create_link(module))
-
-
-def delete(module, link):
- module.fail_json(msg="KeyRings cannot be deleted")
-
-
-def resource_to_request(module):
- request = {u'name': module.params.get('name')}
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, allow_not_found=True):
- auth = GcpSession(module, 'kms')
- return return_if_object(module, auth.get(link), allow_not_found)
-
-
-def self_link(module):
- return "https://cloudkms.googleapis.com/v1/projects/{project}/locations/{location}/keyRings/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://cloudkms.googleapis.com/v1/projects/{project}/locations/{location}/keyRings".format(**module.params)
-
-
-def create_link(module):
- return "https://cloudkms.googleapis.com/v1/projects/{project}/locations/{location}/keyRings?keyRingId={name}".format(**module.params)
-
-
-def return_if_object(module, response, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- result = decode_response(result, module)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
- request = decode_response(request, module)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {u'name': response.get(u'name'), u'creationTime': response.get(u'creationTime')}
-
-
-def decode_response(response, module):
- if 'name' in response:
- response['name'] = response['name'].split('/')[-1]
- return response
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_kms_key_ring_info.py b/lib/ansible/modules/cloud/google/gcp_kms_key_ring_info.py
deleted file mode 100644
index 0f8e756606..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_kms_key_ring_info.py
+++ /dev/null
@@ -1,187 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_kms_key_ring_info
-description:
-- Gather info for GCP KeyRing
-short_description: Gather info for GCP KeyRing
-version_added: '2.9'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- location:
- description:
- - The location for the KeyRing.
- - A full list of valid locations can be found by running `gcloud kms locations
- list`.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a key ring
- gcp_kms_key_ring_info:
- location: us-central1
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- name:
- description:
- - The resource name for the KeyRing.
- returned: success
- type: str
- creationTime:
- description:
- - The time that this resource was created on the server.
- - This is in RFC3339 text format.
- returned: success
- type: str
- location:
- description:
- - The location for the KeyRing.
- - A full list of valid locations can be found by running `gcloud kms locations
- list`.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(location=dict(required=True, type='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloudkms']
-
- return_value = {'resources': fetch_list(module, collection(module))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://cloudkms.googleapis.com/v1/projects/{project}/locations/{location}/keyRings".format(**module.params)
-
-
-def fetch_list(module, link):
- auth = GcpSession(module, 'kms')
- return auth.list(link, return_if_object, array_name='keyRings')
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_logging_metric.py b/lib/ansible/modules/cloud/google/gcp_logging_metric.py
deleted file mode 100644
index 137c600416..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_logging_metric.py
+++ /dev/null
@@ -1,805 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_logging_metric
-description:
-- Logs-based metric can also be used to extract values from logs and create a a distribution
- of the values. The distribution records the statistics of the extracted values along
- with an optional histogram of the values as specified by the bucket options.
-short_description: Creates a GCP Metric
-version_added: '2.10'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- name:
- description:
- - The client-assigned metric identifier. Examples - "error_count", "nginx/requests".
- - Metric identifiers are limited to 100 characters and can include only the following
- characters A-Z, a-z, 0-9, and the special characters _-.,+!*',()%/. The forward-slash
- character (/) denotes a hierarchy of name pieces, and it cannot be the first
- character of the name.
- required: true
- type: str
- description:
- description:
- - A description of this metric, which is used in documentation. The maximum length
- of the description is 8000 characters.
- required: false
- type: str
- filter:
- description:
- - An advanced logs filter (U(https://cloud.google.com/logging/docs/view/advanced-filters))
- which is used to match log entries.
- required: true
- type: str
- metric_descriptor:
- description:
- - The metric descriptor associated with the logs-based metric.
- required: true
- type: dict
- suboptions:
- unit:
- description:
- - The unit in which the metric value is reported. It is only applicable if
- the valueType is `INT64`, `DOUBLE`, or `DISTRIBUTION`. The supported units
- are a subset of [The Unified Code for Units of Measure](U(http://unitsofmeasure.org/ucum.html))
- standard .
- required: false
- default: '1'
- type: str
- value_type:
- description:
- - Whether the measurement is an integer, a floating-point number, etc.
- - Some combinations of metricKind and valueType might not be supported.
- - For counter metrics, set this to INT64.
- - 'Some valid choices include: "BOOL", "INT64", "DOUBLE", "STRING", "DISTRIBUTION",
- "MONEY"'
- required: true
- type: str
- metric_kind:
- description:
- - Whether the metric records instantaneous values, changes to a value, etc.
- - Some combinations of metricKind and valueType might not be supported.
- - For counter metrics, set this to DELTA.
- - 'Some valid choices include: "DELTA", "GAUGE", "CUMULATIVE"'
- required: true
- type: str
- labels:
- description:
- - The set of labels that can be used to describe a specific instance of this
- metric type. For example, the appengine.googleapis.com/http/server/response_latencies
- metric type has a label for the HTTP response code, response_code, so you
- can look at latencies for successful responses or just for responses that
- failed.
- required: false
- type: list
- suboptions:
- key:
- description:
- - The label key.
- required: true
- type: str
- description:
- description:
- - A human-readable description for the label.
- required: false
- type: str
- value_type:
- description:
- - The type of data that can be assigned to the label.
- - 'Some valid choices include: "BOOL", "INT64", "STRING"'
- required: false
- default: STRING
- type: str
- display_name:
- description:
- - A concise name for the metric, which can be displayed in user interfaces.
- Use sentence case without an ending period, for example "Request count".
- This field is optional but it is recommended to be set for any metrics associated
- with user-visible concepts, such as Quota.
- required: false
- type: str
- label_extractors:
- description:
- - A map from a label key string to an extractor expression which is used to extract
- data from a log entry field and assign as the label value. Each label key specified
- in the LabelDescriptor must have an associated extractor expression in this
- map. The syntax of the extractor expression is the same as for the valueExtractor
- field.
- required: false
- type: dict
- value_extractor:
- description:
- - A valueExtractor is required when using a distribution logs-based metric to
- extract the values to record from a log entry. Two functions are supported for
- value extraction - EXTRACT(field) or REGEXP_EXTRACT(field, regex). The argument
- are 1. field - The name of the log entry field from which the value is to be
- extracted. 2. regex - A regular expression using the Google RE2 syntax (U(https://github.com/google/re2/wiki/Syntax))
- with a single capture group to extract data from the specified log entry field.
- The value of the field is converted to a string before applying the regex. It
- is an error to specify a regex that does not include exactly one capture group.
- required: false
- type: str
- bucket_options:
- description:
- - The bucketOptions are required when the logs-based metric is using a DISTRIBUTION
- value type and it describes the bucket boundaries used to create a histogram
- of the extracted values.
- required: false
- type: dict
- suboptions:
- linear_buckets:
- description:
- - Specifies a linear sequence of buckets that all have the same width (except
- overflow and underflow).
- - Each bucket represents a constant absolute uncertainty on the specific value
- in the bucket.
- required: false
- type: dict
- suboptions:
- num_finite_buckets:
- description:
- - Must be greater than 0.
- required: false
- type: int
- width:
- description:
- - Must be greater than 0.
- required: false
- type: int
- offset:
- description:
- - Lower bound of the first bucket.
- required: false
- type: str
- exponential_buckets:
- description:
- - Specifies an exponential sequence of buckets that have a width that is proportional
- to the value of the lower bound. Each bucket represents a constant relative
- uncertainty on a specific value in the bucket.
- required: false
- type: dict
- suboptions:
- num_finite_buckets:
- description:
- - Must be greater than 0.
- required: false
- type: int
- growth_factor:
- description:
- - Must be greater than 1.
- required: false
- type: str
- scale:
- description:
- - Must be greater than 0.
- required: false
- type: str
- explicit_buckets:
- description:
- - Specifies a set of buckets with arbitrary widths.
- required: false
- type: dict
- suboptions:
- bounds:
- description:
- - The values must be monotonically increasing.
- required: true
- type: list
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/logging/docs/reference/v2/rest/v2/projects.metrics/create)'
-- 'Official Documentation: U(https://cloud.google.com/logging/docs/apis)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a metric
- gcp_logging_metric:
- name: test_object
- filter: resource.type=gae_app AND severity>=ERROR
- metric_descriptor:
- metric_kind: DELTA
- value_type: DISTRIBUTION
- unit: '1'
- labels:
- - key: mass
- value_type: STRING
- description: amount of matter
- value_extractor: EXTRACT(jsonPayload.request)
- label_extractors:
- mass: EXTRACT(jsonPayload.request)
- bucket_options:
- linear_buckets:
- num_finite_buckets: 3
- width: 1
- offset: 1
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-name:
- description:
- - The client-assigned metric identifier. Examples - "error_count", "nginx/requests".
- - Metric identifiers are limited to 100 characters and can include only the following
- characters A-Z, a-z, 0-9, and the special characters _-.,+!*',()%/. The forward-slash
- character (/) denotes a hierarchy of name pieces, and it cannot be the first character
- of the name.
- returned: success
- type: str
-description:
- description:
- - A description of this metric, which is used in documentation. The maximum length
- of the description is 8000 characters.
- returned: success
- type: str
-filter:
- description:
- - An advanced logs filter (U(https://cloud.google.com/logging/docs/view/advanced-filters))
- which is used to match log entries.
- returned: success
- type: str
-metricDescriptor:
- description:
- - The metric descriptor associated with the logs-based metric.
- returned: success
- type: complex
- contains:
- unit:
- description:
- - The unit in which the metric value is reported. It is only applicable if the
- valueType is `INT64`, `DOUBLE`, or `DISTRIBUTION`. The supported units are
- a subset of [The Unified Code for Units of Measure](U(http://unitsofmeasure.org/ucum.html))
- standard .
- returned: success
- type: str
- valueType:
- description:
- - Whether the measurement is an integer, a floating-point number, etc.
- - Some combinations of metricKind and valueType might not be supported.
- - For counter metrics, set this to INT64.
- returned: success
- type: str
- metricKind:
- description:
- - Whether the metric records instantaneous values, changes to a value, etc.
- - Some combinations of metricKind and valueType might not be supported.
- - For counter metrics, set this to DELTA.
- returned: success
- type: str
- labels:
- description:
- - The set of labels that can be used to describe a specific instance of this
- metric type. For example, the appengine.googleapis.com/http/server/response_latencies
- metric type has a label for the HTTP response code, response_code, so you
- can look at latencies for successful responses or just for responses that
- failed.
- returned: success
- type: complex
- contains:
- key:
- description:
- - The label key.
- returned: success
- type: str
- description:
- description:
- - A human-readable description for the label.
- returned: success
- type: str
- valueType:
- description:
- - The type of data that can be assigned to the label.
- returned: success
- type: str
- displayName:
- description:
- - A concise name for the metric, which can be displayed in user interfaces.
- Use sentence case without an ending period, for example "Request count". This
- field is optional but it is recommended to be set for any metrics associated
- with user-visible concepts, such as Quota.
- returned: success
- type: str
-labelExtractors:
- description:
- - A map from a label key string to an extractor expression which is used to extract
- data from a log entry field and assign as the label value. Each label key specified
- in the LabelDescriptor must have an associated extractor expression in this map.
- The syntax of the extractor expression is the same as for the valueExtractor field.
- returned: success
- type: dict
-valueExtractor:
- description:
- - A valueExtractor is required when using a distribution logs-based metric to extract
- the values to record from a log entry. Two functions are supported for value extraction
- - EXTRACT(field) or REGEXP_EXTRACT(field, regex). The argument are 1. field -
- The name of the log entry field from which the value is to be extracted. 2. regex
- - A regular expression using the Google RE2 syntax (U(https://github.com/google/re2/wiki/Syntax))
- with a single capture group to extract data from the specified log entry field.
- The value of the field is converted to a string before applying the regex. It
- is an error to specify a regex that does not include exactly one capture group.
- returned: success
- type: str
-bucketOptions:
- description:
- - The bucketOptions are required when the logs-based metric is using a DISTRIBUTION
- value type and it describes the bucket boundaries used to create a histogram of
- the extracted values.
- returned: success
- type: complex
- contains:
- linearBuckets:
- description:
- - Specifies a linear sequence of buckets that all have the same width (except
- overflow and underflow).
- - Each bucket represents a constant absolute uncertainty on the specific value
- in the bucket.
- returned: success
- type: complex
- contains:
- numFiniteBuckets:
- description:
- - Must be greater than 0.
- returned: success
- type: int
- width:
- description:
- - Must be greater than 0.
- returned: success
- type: int
- offset:
- description:
- - Lower bound of the first bucket.
- returned: success
- type: str
- exponentialBuckets:
- description:
- - Specifies an exponential sequence of buckets that have a width that is proportional
- to the value of the lower bound. Each bucket represents a constant relative
- uncertainty on a specific value in the bucket.
- returned: success
- type: complex
- contains:
- numFiniteBuckets:
- description:
- - Must be greater than 0.
- returned: success
- type: int
- growthFactor:
- description:
- - Must be greater than 1.
- returned: success
- type: str
- scale:
- description:
- - Must be greater than 0.
- returned: success
- type: str
- explicitBuckets:
- description:
- - Specifies a set of buckets with arbitrary widths.
- returned: success
- type: complex
- contains:
- bounds:
- description:
- - The values must be monotonically increasing.
- returned: success
- type: list
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- name=dict(required=True, type='str'),
- description=dict(type='str'),
- filter=dict(required=True, type='str'),
- metric_descriptor=dict(
- required=True,
- type='dict',
- options=dict(
- unit=dict(default='1', type='str'),
- value_type=dict(required=True, type='str'),
- metric_kind=dict(required=True, type='str'),
- labels=dict(
- type='list',
- elements='dict',
- options=dict(key=dict(required=True, type='str'), description=dict(type='str'), value_type=dict(default='STRING', type='str')),
- ),
- display_name=dict(type='str'),
- ),
- ),
- label_extractors=dict(type='dict'),
- value_extractor=dict(type='str'),
- bucket_options=dict(
- type='dict',
- options=dict(
- linear_buckets=dict(type='dict', options=dict(num_finite_buckets=dict(type='int'), width=dict(type='int'), offset=dict(type='str'))),
- exponential_buckets=dict(
- type='dict', options=dict(num_finite_buckets=dict(type='int'), growth_factor=dict(type='str'), scale=dict(type='str'))
- ),
- explicit_buckets=dict(type='dict', options=dict(bounds=dict(required=True, type='list', elements='str'))),
- ),
- ),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
-
- state = module.params['state']
-
- fetch = fetch_resource(module, self_link(module))
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module))
- fetch = fetch_resource(module, self_link(module))
- changed = True
- else:
- delete(module, self_link(module))
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module))
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link):
- auth = GcpSession(module, 'logging')
- return return_if_object(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link):
- auth = GcpSession(module, 'logging')
- return return_if_object(module, auth.put(link, resource_to_request(module)))
-
-
-def delete(module, link):
- auth = GcpSession(module, 'logging')
- return return_if_object(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'name': module.params.get('name'),
- u'description': module.params.get('description'),
- u'filter': module.params.get('filter'),
- u'metricDescriptor': MetricMetricdescriptor(module.params.get('metric_descriptor', {}), module).to_request(),
- u'labelExtractors': module.params.get('label_extractors'),
- u'valueExtractor': module.params.get('value_extractor'),
- u'bucketOptions': MetricBucketoptions(module.params.get('bucket_options', {}), module).to_request(),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, allow_not_found=True):
- auth = GcpSession(module, 'logging')
- return return_if_object(module, auth.get(link), allow_not_found)
-
-
-def self_link(module):
- return "https://logging.googleapis.com/v2/projects/{project}/metrics/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://logging.googleapis.com/v2/projects/{project}/metrics".format(**module.params)
-
-
-def return_if_object(module, response, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'name': response.get(u'name'),
- u'description': response.get(u'description'),
- u'filter': response.get(u'filter'),
- u'metricDescriptor': MetricMetricdescriptor(response.get(u'metricDescriptor', {}), module).from_response(),
- u'labelExtractors': response.get(u'labelExtractors'),
- u'valueExtractor': response.get(u'valueExtractor'),
- u'bucketOptions': MetricBucketoptions(response.get(u'bucketOptions', {}), module).from_response(),
- }
-
-
-class MetricMetricdescriptor(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'unit': self.request.get('unit'),
- u'valueType': self.request.get('value_type'),
- u'metricKind': self.request.get('metric_kind'),
- u'labels': MetricLabelsArray(self.request.get('labels', []), self.module).to_request(),
- u'displayName': self.request.get('display_name'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'unit': self.request.get(u'unit'),
- u'valueType': self.request.get(u'valueType'),
- u'metricKind': self.request.get(u'metricKind'),
- u'labels': MetricLabelsArray(self.request.get(u'labels', []), self.module).from_response(),
- u'displayName': self.request.get(u'displayName'),
- }
- )
-
-
-class MetricLabelsArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'key': item.get('key'), u'description': item.get('description'), u'valueType': item.get('value_type')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'key': item.get(u'key'), u'description': item.get(u'description'), u'valueType': item.get(u'valueType')})
-
-
-class MetricBucketoptions(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'linearBuckets': MetricLinearbuckets(self.request.get('linear_buckets', {}), self.module).to_request(),
- u'exponentialBuckets': MetricExponentialbuckets(self.request.get('exponential_buckets', {}), self.module).to_request(),
- u'explicitBuckets': MetricExplicitbuckets(self.request.get('explicit_buckets', {}), self.module).to_request(),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'linearBuckets': MetricLinearbuckets(self.request.get(u'linearBuckets', {}), self.module).from_response(),
- u'exponentialBuckets': MetricExponentialbuckets(self.request.get(u'exponentialBuckets', {}), self.module).from_response(),
- u'explicitBuckets': MetricExplicitbuckets(self.request.get(u'explicitBuckets', {}), self.module).from_response(),
- }
- )
-
-
-class MetricLinearbuckets(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {u'numFiniteBuckets': self.request.get('num_finite_buckets'), u'width': self.request.get('width'), u'offset': self.request.get('offset')}
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {u'numFiniteBuckets': self.request.get(u'numFiniteBuckets'), u'width': self.request.get(u'width'), u'offset': self.request.get(u'offset')}
- )
-
-
-class MetricExponentialbuckets(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'numFiniteBuckets': self.request.get('num_finite_buckets'),
- u'growthFactor': self.request.get('growth_factor'),
- u'scale': self.request.get('scale'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'numFiniteBuckets': self.request.get(u'numFiniteBuckets'),
- u'growthFactor': self.request.get(u'growthFactor'),
- u'scale': self.request.get(u'scale'),
- }
- )
-
-
-class MetricExplicitbuckets(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'bounds': self.request.get('bounds')})
-
- def from_response(self):
- return remove_nones_from_dict({u'bounds': self.request.get(u'bounds')})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_logging_metric_info.py b/lib/ansible/modules/cloud/google/gcp_logging_metric_info.py
deleted file mode 100644
index 488b457d82..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_logging_metric_info.py
+++ /dev/null
@@ -1,331 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_logging_metric_info
-description:
-- Gather info for GCP Metric
-short_description: Gather info for GCP Metric
-version_added: '2.10'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a metric
- gcp_logging_metric_info:
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- name:
- description:
- - The client-assigned metric identifier. Examples - "error_count", "nginx/requests".
- - Metric identifiers are limited to 100 characters and can include only the
- following characters A-Z, a-z, 0-9, and the special characters _-.,+!*',()%/.
- The forward-slash character (/) denotes a hierarchy of name pieces, and it
- cannot be the first character of the name.
- returned: success
- type: str
- description:
- description:
- - A description of this metric, which is used in documentation. The maximum
- length of the description is 8000 characters.
- returned: success
- type: str
- filter:
- description:
- - An advanced logs filter (U(https://cloud.google.com/logging/docs/view/advanced-filters))
- which is used to match log entries.
- returned: success
- type: str
- metricDescriptor:
- description:
- - The metric descriptor associated with the logs-based metric.
- returned: success
- type: complex
- contains:
- unit:
- description:
- - The unit in which the metric value is reported. It is only applicable
- if the valueType is `INT64`, `DOUBLE`, or `DISTRIBUTION`. The supported
- units are a subset of [The Unified Code for Units of Measure](U(http://unitsofmeasure.org/ucum.html))
- standard .
- returned: success
- type: str
- valueType:
- description:
- - Whether the measurement is an integer, a floating-point number, etc.
- - Some combinations of metricKind and valueType might not be supported.
- - For counter metrics, set this to INT64.
- returned: success
- type: str
- metricKind:
- description:
- - Whether the metric records instantaneous values, changes to a value, etc.
- - Some combinations of metricKind and valueType might not be supported.
- - For counter metrics, set this to DELTA.
- returned: success
- type: str
- labels:
- description:
- - The set of labels that can be used to describe a specific instance of
- this metric type. For example, the appengine.googleapis.com/http/server/response_latencies
- metric type has a label for the HTTP response code, response_code, so
- you can look at latencies for successful responses or just for responses
- that failed.
- returned: success
- type: complex
- contains:
- key:
- description:
- - The label key.
- returned: success
- type: str
- description:
- description:
- - A human-readable description for the label.
- returned: success
- type: str
- valueType:
- description:
- - The type of data that can be assigned to the label.
- returned: success
- type: str
- displayName:
- description:
- - A concise name for the metric, which can be displayed in user interfaces.
- Use sentence case without an ending period, for example "Request count".
- This field is optional but it is recommended to be set for any metrics
- associated with user-visible concepts, such as Quota.
- returned: success
- type: str
- labelExtractors:
- description:
- - A map from a label key string to an extractor expression which is used to
- extract data from a log entry field and assign as the label value. Each label
- key specified in the LabelDescriptor must have an associated extractor expression
- in this map. The syntax of the extractor expression is the same as for the
- valueExtractor field.
- returned: success
- type: dict
- valueExtractor:
- description:
- - A valueExtractor is required when using a distribution logs-based metric to
- extract the values to record from a log entry. Two functions are supported
- for value extraction - EXTRACT(field) or REGEXP_EXTRACT(field, regex). The
- argument are 1. field - The name of the log entry field from which the value
- is to be extracted. 2. regex - A regular expression using the Google RE2 syntax
- (U(https://github.com/google/re2/wiki/Syntax)) with a single capture group
- to extract data from the specified log entry field. The value of the field
- is converted to a string before applying the regex. It is an error to specify
- a regex that does not include exactly one capture group.
- returned: success
- type: str
- bucketOptions:
- description:
- - The bucketOptions are required when the logs-based metric is using a DISTRIBUTION
- value type and it describes the bucket boundaries used to create a histogram
- of the extracted values.
- returned: success
- type: complex
- contains:
- linearBuckets:
- description:
- - Specifies a linear sequence of buckets that all have the same width (except
- overflow and underflow).
- - Each bucket represents a constant absolute uncertainty on the specific
- value in the bucket.
- returned: success
- type: complex
- contains:
- numFiniteBuckets:
- description:
- - Must be greater than 0.
- returned: success
- type: int
- width:
- description:
- - Must be greater than 0.
- returned: success
- type: int
- offset:
- description:
- - Lower bound of the first bucket.
- returned: success
- type: str
- exponentialBuckets:
- description:
- - Specifies an exponential sequence of buckets that have a width that is
- proportional to the value of the lower bound. Each bucket represents a
- constant relative uncertainty on a specific value in the bucket.
- returned: success
- type: complex
- contains:
- numFiniteBuckets:
- description:
- - Must be greater than 0.
- returned: success
- type: int
- growthFactor:
- description:
- - Must be greater than 1.
- returned: success
- type: str
- scale:
- description:
- - Must be greater than 0.
- returned: success
- type: str
- explicitBuckets:
- description:
- - Specifies a set of buckets with arbitrary widths.
- returned: success
- type: complex
- contains:
- bounds:
- description:
- - The values must be monotonically increasing.
- returned: success
- type: list
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict())
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
-
- return_value = {'resources': fetch_list(module, collection(module))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://logging.googleapis.com/v2/projects/{project}/metrics".format(**module.params)
-
-
-def fetch_list(module, link):
- auth = GcpSession(module, 'logging')
- return auth.list(link, return_if_object, array_name='metrics')
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_mlengine_model.py b/lib/ansible/modules/cloud/google/gcp_mlengine_model.py
deleted file mode 100644
index 8bac5f0c6c..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_mlengine_model.py
+++ /dev/null
@@ -1,417 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_mlengine_model
-description:
-- Represents a machine learning solution.
-- A model can have multiple versions, each of which is a deployed, trained model ready
- to receive prediction requests. The model itself is just a container.
-short_description: Creates a GCP Model
-version_added: '2.9'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- name:
- description:
- - The name specified for the model.
- required: true
- type: str
- description:
- description:
- - The description specified for the model when it was created.
- required: false
- type: str
- default_version:
- description:
- - The default version of the model. This version will be used to handle prediction
- requests that do not specify a version.
- required: false
- type: dict
- suboptions:
- name:
- description:
- - The name specified for the version when it was created.
- required: true
- type: str
- regions:
- description:
- - The list of regions where the model is going to be deployed.
- - Currently only one region per model is supported .
- required: false
- type: list
- online_prediction_logging:
- description:
- - If true, online prediction access logs are sent to StackDriver Logging.
- required: false
- type: bool
- online_prediction_console_logging:
- description:
- - If true, online prediction nodes send stderr and stdout streams to Stackdriver
- Logging.
- required: false
- type: bool
- labels:
- description:
- - One or more labels that you can add, to organize your models.
- required: false
- type: dict
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-'''
-
-EXAMPLES = '''
-- name: create a model
- gcp_mlengine_model:
- name: "{{ resource_name | replace('-', '_') }}"
- description: My model
- regions:
- - us-central1
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-name:
- description:
- - The name specified for the model.
- returned: success
- type: str
-description:
- description:
- - The description specified for the model when it was created.
- returned: success
- type: str
-defaultVersion:
- description:
- - The default version of the model. This version will be used to handle prediction
- requests that do not specify a version.
- returned: success
- type: complex
- contains:
- name:
- description:
- - The name specified for the version when it was created.
- returned: success
- type: str
-regions:
- description:
- - The list of regions where the model is going to be deployed.
- - Currently only one region per model is supported .
- returned: success
- type: list
-onlinePredictionLogging:
- description:
- - If true, online prediction access logs are sent to StackDriver Logging.
- returned: success
- type: bool
-onlinePredictionConsoleLogging:
- description:
- - If true, online prediction nodes send stderr and stdout streams to Stackdriver
- Logging.
- returned: success
- type: bool
-labels:
- description:
- - One or more labels that you can add, to organize your models.
- returned: success
- type: dict
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- name=dict(required=True, type='str'),
- description=dict(type='str'),
- default_version=dict(type='dict', options=dict(name=dict(required=True, type='str'))),
- regions=dict(type='list', elements='str'),
- online_prediction_logging=dict(type='bool'),
- online_prediction_console_logging=dict(type='bool'),
- labels=dict(type='dict'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
-
- state = module.params['state']
-
- fetch = fetch_resource(module, self_link(module))
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module))
- fetch = fetch_resource(module, self_link(module))
- changed = True
- else:
- delete(module, self_link(module))
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module))
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link):
- auth = GcpSession(module, 'mlengine')
- return return_if_object(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link):
- delete(module, self_link(module))
- create(module, collection(module))
-
-
-def delete(module, link):
- auth = GcpSession(module, 'mlengine')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'name': module.params.get('name'),
- u'description': module.params.get('description'),
- u'defaultVersion': ModelDefaultversion(module.params.get('default_version', {}), module).to_request(),
- u'regions': module.params.get('regions'),
- u'onlinePredictionLogging': module.params.get('online_prediction_logging'),
- u'onlinePredictionConsoleLogging': module.params.get('online_prediction_console_logging'),
- u'labels': module.params.get('labels'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, allow_not_found=True):
- auth = GcpSession(module, 'mlengine')
- return return_if_object(module, auth.get(link), allow_not_found)
-
-
-def self_link(module):
- return "https://ml.googleapis.com/v1/projects/{project}/models/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://ml.googleapis.com/v1/projects/{project}/models".format(**module.params)
-
-
-def return_if_object(module, response, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- result = decode_response(result, module)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
- request = decode_response(request, module)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'name': response.get(u'name'),
- u'description': response.get(u'description'),
- u'defaultVersion': ModelDefaultversion(response.get(u'defaultVersion', {}), module).from_response(),
- u'regions': response.get(u'regions'),
- u'onlinePredictionLogging': response.get(u'onlinePredictionLogging'),
- u'onlinePredictionConsoleLogging': response.get(u'onlinePredictionConsoleLogging'),
- u'labels': response.get(u'labels'),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://ml.googleapis.com/v1/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response)
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['done'])
- wait_done = wait_for_completion(status, op_result, module)
- raise_if_errors(wait_done, ['error'], module)
- return navigate_hash(wait_done, ['response'])
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while not status:
- raise_if_errors(op_result, ['error'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, False)
- status = navigate_hash(op_result, ['done'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-# Short names are given (and expected) by the API
-# but are returned as full names.
-def decode_response(response, module):
- if 'name' in response and 'metadata' not in response:
- response['name'] = response['name'].split('/')[-1]
- return response
-
-
-class ModelDefaultversion(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'name': self.request.get('name')})
-
- def from_response(self):
- return remove_nones_from_dict({u'name': self.request.get(u'name')})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_mlengine_model_info.py b/lib/ansible/modules/cloud/google/gcp_mlengine_model_info.py
deleted file mode 100644
index 8cb48a3c83..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_mlengine_model_info.py
+++ /dev/null
@@ -1,205 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_mlengine_model_info
-description:
-- Gather info for GCP Model
-short_description: Gather info for GCP Model
-version_added: '2.9'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a model
- gcp_mlengine_model_info:
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- name:
- description:
- - The name specified for the model.
- returned: success
- type: str
- description:
- description:
- - The description specified for the model when it was created.
- returned: success
- type: str
- defaultVersion:
- description:
- - The default version of the model. This version will be used to handle prediction
- requests that do not specify a version.
- returned: success
- type: complex
- contains:
- name:
- description:
- - The name specified for the version when it was created.
- returned: success
- type: str
- regions:
- description:
- - The list of regions where the model is going to be deployed.
- - Currently only one region per model is supported .
- returned: success
- type: list
- onlinePredictionLogging:
- description:
- - If true, online prediction access logs are sent to StackDriver Logging.
- returned: success
- type: bool
- onlinePredictionConsoleLogging:
- description:
- - If true, online prediction nodes send stderr and stdout streams to Stackdriver
- Logging.
- returned: success
- type: bool
- labels:
- description:
- - One or more labels that you can add, to organize your models.
- returned: success
- type: dict
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict())
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
-
- return_value = {'resources': fetch_list(module, collection(module))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://ml.googleapis.com/v1/projects/{project}/models".format(**module.params)
-
-
-def fetch_list(module, link):
- auth = GcpSession(module, 'mlengine')
- return auth.list(link, return_if_object, array_name='models')
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_mlengine_version.py b/lib/ansible/modules/cloud/google/gcp_mlengine_version.py
deleted file mode 100644
index f977ec212a..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_mlengine_version.py
+++ /dev/null
@@ -1,627 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_mlengine_version
-description:
-- Each version is a trained model deployed in the cloud, ready to handle prediction
- requests. A model can have multiple versions .
-short_description: Creates a GCP Version
-version_added: '2.9'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- name:
- description:
- - The name specified for the version when it was created.
- - The version name must be unique within the model it is created in.
- required: true
- type: str
- description:
- description:
- - The description specified for the version when it was created.
- required: false
- type: str
- deployment_uri:
- description:
- - The Cloud Storage location of the trained model used to create the version.
- required: true
- type: str
- runtime_version:
- description:
- - The AI Platform runtime version to use for this deployment.
- required: false
- type: str
- machine_type:
- description:
- - The type of machine on which to serve the model. Currently only applies to online
- prediction service.
- - 'Some valid choices include: "mls1-c1-m2", "mls1-c4-m2"'
- required: false
- type: str
- labels:
- description:
- - One or more labels that you can add, to organize your model versions.
- required: false
- type: dict
- framework:
- description:
- - The machine learning framework AI Platform uses to train this version of the
- model.
- - 'Some valid choices include: "FRAMEWORK_UNSPECIFIED", "TENSORFLOW", "SCIKIT_LEARN",
- "XGBOOST"'
- required: false
- type: str
- python_version:
- description:
- - The version of Python used in prediction. If not set, the default version is
- '2.7'. Python '3.5' is available when runtimeVersion is set to '1.4' and above.
- Python '2.7' works with all supported runtime versions.
- - 'Some valid choices include: "2.7", "3.5"'
- required: false
- type: str
- service_account:
- description:
- - Specifies the service account for resource access control.
- required: false
- type: str
- auto_scaling:
- description:
- - Automatically scale the number of nodes used to serve the model in response
- to increases and decreases in traffic. Care should be taken to ramp up traffic
- according to the model's ability to scale or you will start seeing increases
- in latency and 429 response codes.
- required: false
- type: dict
- suboptions:
- min_nodes:
- description:
- - The minimum number of nodes to allocate for this mode.
- required: false
- type: int
- manual_scaling:
- description:
- - Manually select the number of nodes to use for serving the model. You should
- generally use autoScaling with an appropriate minNodes instead, but this option
- is available if you want more predictable billing. Beware that latency and error
- rates will increase if the traffic exceeds that capability of the system to
- serve it based on the selected number of nodes.
- required: false
- type: dict
- suboptions:
- nodes:
- description:
- - The number of nodes to allocate for this model. These nodes are always up,
- starting from the time the model is deployed.
- required: false
- type: int
- prediction_class:
- description:
- - The fully qualified name (module_name.class_name) of a class that implements
- the Predictor interface described in this reference field. The module containing
- this class should be included in a package provided to the packageUris field.
- required: false
- type: str
- model:
- description:
- - The model that this version belongs to.
- - 'This field represents a link to a Model resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''name'' and value of
- your resource''s name Alternatively, you can add `register: name-of-resource`
- to a gcp_mlengine_model task and then set this model field to "{{ name-of-resource
- }}"'
- required: true
- type: dict
- is_default:
- description:
- - If true, this version will be used to handle prediction requests that do not
- specify a version.
- required: false
- type: bool
- aliases:
- - default
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-'''
-
-EXAMPLES = '''
-- name: create a model
- gcp_mlengine_model:
- name: model_version
- description: My model
- regions:
- - us-central1
- online_prediction_logging: 'true'
- online_prediction_console_logging: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: model
-
-- name: create a version
- gcp_mlengine_version:
- name: "{{ resource_name | replace('-', '_') }}"
- model: "{{ model }}"
- runtime_version: 1.13
- python_version: 3.5
- is_default: 'true'
- deployment_uri: gs://ansible-cloudml-bucket/
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-name:
- description:
- - The name specified for the version when it was created.
- - The version name must be unique within the model it is created in.
- returned: success
- type: str
-description:
- description:
- - The description specified for the version when it was created.
- returned: success
- type: str
-deploymentUri:
- description:
- - The Cloud Storage location of the trained model used to create the version.
- returned: success
- type: str
-createTime:
- description:
- - The time the version was created.
- returned: success
- type: str
-lastUseTime:
- description:
- - The time the version was last used for prediction.
- returned: success
- type: str
-runtimeVersion:
- description:
- - The AI Platform runtime version to use for this deployment.
- returned: success
- type: str
-machineType:
- description:
- - The type of machine on which to serve the model. Currently only applies to online
- prediction service.
- returned: success
- type: str
-state:
- description:
- - The state of a version.
- returned: success
- type: str
-errorMessage:
- description:
- - The details of a failure or cancellation.
- returned: success
- type: str
-packageUris:
- description:
- - Cloud Storage paths (gs://…) of packages for custom prediction routines or scikit-learn
- pipelines with custom code.
- returned: success
- type: list
-labels:
- description:
- - One or more labels that you can add, to organize your model versions.
- returned: success
- type: dict
-framework:
- description:
- - The machine learning framework AI Platform uses to train this version of the model.
- returned: success
- type: str
-pythonVersion:
- description:
- - The version of Python used in prediction. If not set, the default version is '2.7'.
- Python '3.5' is available when runtimeVersion is set to '1.4' and above. Python
- '2.7' works with all supported runtime versions.
- returned: success
- type: str
-serviceAccount:
- description:
- - Specifies the service account for resource access control.
- returned: success
- type: str
-autoScaling:
- description:
- - Automatically scale the number of nodes used to serve the model in response to
- increases and decreases in traffic. Care should be taken to ramp up traffic according
- to the model's ability to scale or you will start seeing increases in latency
- and 429 response codes.
- returned: success
- type: complex
- contains:
- minNodes:
- description:
- - The minimum number of nodes to allocate for this mode.
- returned: success
- type: int
-manualScaling:
- description:
- - Manually select the number of nodes to use for serving the model. You should generally
- use autoScaling with an appropriate minNodes instead, but this option is available
- if you want more predictable billing. Beware that latency and error rates will
- increase if the traffic exceeds that capability of the system to serve it based
- on the selected number of nodes.
- returned: success
- type: complex
- contains:
- nodes:
- description:
- - The number of nodes to allocate for this model. These nodes are always up,
- starting from the time the model is deployed.
- returned: success
- type: int
-predictionClass:
- description:
- - The fully qualified name (module_name.class_name) of a class that implements the
- Predictor interface described in this reference field. The module containing this
- class should be included in a package provided to the packageUris field.
- returned: success
- type: str
-model:
- description:
- - The model that this version belongs to.
- returned: success
- type: dict
-isDefault:
- description:
- - If true, this version will be used to handle prediction requests that do not specify
- a version.
- returned: success
- type: bool
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- name=dict(required=True, type='str'),
- description=dict(type='str'),
- deployment_uri=dict(required=True, type='str'),
- runtime_version=dict(type='str'),
- machine_type=dict(type='str'),
- labels=dict(type='dict'),
- framework=dict(type='str'),
- python_version=dict(type='str'),
- service_account=dict(type='str'),
- auto_scaling=dict(type='dict', options=dict(min_nodes=dict(type='int'))),
- manual_scaling=dict(type='dict', options=dict(nodes=dict(type='int'))),
- prediction_class=dict(type='str'),
- model=dict(required=True, type='dict'),
- is_default=dict(type='bool', aliases=['default']),
- ),
- mutually_exclusive=[['auto_scaling', 'manual_scaling']],
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
-
- state = module.params['state']
-
- fetch = fetch_resource(module, self_link(module))
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module))
- fetch = fetch_resource(module, self_link(module))
- changed = True
- else:
- delete(module, self_link(module))
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module))
- if module.params.get('is_default') is True:
- set_default(module)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link):
- auth = GcpSession(module, 'mlengine')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link):
- if module.params.get('is_default') is True:
- set_default(module)
-
-
-def delete(module, link):
- auth = GcpSession(module, 'mlengine')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'name': module.params.get('name'),
- u'description': module.params.get('description'),
- u'deploymentUri': module.params.get('deployment_uri'),
- u'runtimeVersion': module.params.get('runtime_version'),
- u'machineType': module.params.get('machine_type'),
- u'labels': module.params.get('labels'),
- u'framework': module.params.get('framework'),
- u'pythonVersion': module.params.get('python_version'),
- u'serviceAccount': module.params.get('service_account'),
- u'autoScaling': VersionAutoscaling(module.params.get('auto_scaling', {}), module).to_request(),
- u'manualScaling': VersionManualscaling(module.params.get('manual_scaling', {}), module).to_request(),
- u'predictionClass': module.params.get('prediction_class'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, allow_not_found=True):
- auth = GcpSession(module, 'mlengine')
- return return_if_object(module, auth.get(link), allow_not_found)
-
-
-def self_link(module):
- res = {'project': module.params['project'], 'model': replace_resource_dict(module.params['model'], 'name'), 'name': module.params['name']}
- return "https://ml.googleapis.com/v1/projects/{project}/models/{model}/versions/{name}".format(**res)
-
-
-def collection(module):
- res = {'project': module.params['project'], 'model': replace_resource_dict(module.params['model'], 'name')}
- return "https://ml.googleapis.com/v1/projects/{project}/models/{model}/versions".format(**res)
-
-
-def return_if_object(module, response, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- result = decode_response(result, module)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
- request = decode_response(request, module)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'name': response.get(u'name'),
- u'description': response.get(u'description'),
- u'deploymentUri': response.get(u'deploymentUri'),
- u'createTime': response.get(u'createTime'),
- u'lastUseTime': response.get(u'lastUseTime'),
- u'runtimeVersion': response.get(u'runtimeVersion'),
- u'machineType': response.get(u'machineType'),
- u'state': response.get(u'state'),
- u'errorMessage': response.get(u'errorMessage'),
- u'packageUris': response.get(u'packageUris'),
- u'labels': response.get(u'labels'),
- u'framework': response.get(u'framework'),
- u'pythonVersion': response.get(u'pythonVersion'),
- u'serviceAccount': response.get(u'serviceAccount'),
- u'autoScaling': VersionAutoscaling(response.get(u'autoScaling', {}), module).from_response(),
- u'manualScaling': VersionManualscaling(response.get(u'manualScaling', {}), module).from_response(),
- u'predictionClass': response.get(u'predictionClass'),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://ml.googleapis.com/v1/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response)
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['done'])
- wait_done = wait_for_completion(status, op_result, module)
- raise_if_errors(wait_done, ['error'], module)
- return navigate_hash(wait_done, ['response'])
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while not status:
- raise_if_errors(op_result, ['error'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, False)
- status = navigate_hash(op_result, ['done'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-# Short names are given (and expected) by the API
-# but are returned as full names.
-def decode_response(response, module):
- if 'name' in response and 'metadata' not in response:
- response['name'] = response['name'].split('/')[-1]
- return response
-
-
-# Sets this version as default.
-def set_default(module):
- res = {'project': module.params['project'], 'model': replace_resource_dict(module.params['model'], 'name'), 'name': module.params['name']}
- link = "https://ml.googleapis.com/v1/projects/{project}/models/{model}/versions/{name}:setDefault".format(**res)
-
- auth = GcpSession(module, 'mlengine')
- return_if_object(module, auth.post(link))
-
-
-class VersionAutoscaling(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'minNodes': self.request.get('min_nodes')})
-
- def from_response(self):
- return remove_nones_from_dict({u'minNodes': self.request.get(u'minNodes')})
-
-
-class VersionManualscaling(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'nodes': self.request.get('nodes')})
-
- def from_response(self):
- return remove_nones_from_dict({u'nodes': self.request.get(u'nodes')})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_mlengine_version_info.py b/lib/ansible/modules/cloud/google/gcp_mlengine_version_info.py
deleted file mode 100644
index 1385382b64..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_mlengine_version_info.py
+++ /dev/null
@@ -1,297 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_mlengine_version_info
-description:
-- Gather info for GCP Version
-short_description: Gather info for GCP Version
-version_added: '2.9'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- model:
- description:
- - The model that this version belongs to.
- - 'This field represents a link to a Model resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''name'' and value of
- your resource''s name Alternatively, you can add `register: name-of-resource`
- to a gcp_mlengine_model task and then set this model field to "{{ name-of-resource
- }}"'
- required: true
- type: dict
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a version
- gcp_mlengine_version_info:
- model: "{{ model }}"
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- name:
- description:
- - The name specified for the version when it was created.
- - The version name must be unique within the model it is created in.
- returned: success
- type: str
- description:
- description:
- - The description specified for the version when it was created.
- returned: success
- type: str
- deploymentUri:
- description:
- - The Cloud Storage location of the trained model used to create the version.
- returned: success
- type: str
- createTime:
- description:
- - The time the version was created.
- returned: success
- type: str
- lastUseTime:
- description:
- - The time the version was last used for prediction.
- returned: success
- type: str
- runtimeVersion:
- description:
- - The AI Platform runtime version to use for this deployment.
- returned: success
- type: str
- machineType:
- description:
- - The type of machine on which to serve the model. Currently only applies to
- online prediction service.
- returned: success
- type: str
- state:
- description:
- - The state of a version.
- returned: success
- type: str
- errorMessage:
- description:
- - The details of a failure or cancellation.
- returned: success
- type: str
- packageUris:
- description:
- - Cloud Storage paths (gs://…) of packages for custom prediction routines or
- scikit-learn pipelines with custom code.
- returned: success
- type: list
- labels:
- description:
- - One or more labels that you can add, to organize your model versions.
- returned: success
- type: dict
- framework:
- description:
- - The machine learning framework AI Platform uses to train this version of the
- model.
- returned: success
- type: str
- pythonVersion:
- description:
- - The version of Python used in prediction. If not set, the default version
- is '2.7'. Python '3.5' is available when runtimeVersion is set to '1.4' and
- above. Python '2.7' works with all supported runtime versions.
- returned: success
- type: str
- serviceAccount:
- description:
- - Specifies the service account for resource access control.
- returned: success
- type: str
- autoScaling:
- description:
- - Automatically scale the number of nodes used to serve the model in response
- to increases and decreases in traffic. Care should be taken to ramp up traffic
- according to the model's ability to scale or you will start seeing increases
- in latency and 429 response codes.
- returned: success
- type: complex
- contains:
- minNodes:
- description:
- - The minimum number of nodes to allocate for this mode.
- returned: success
- type: int
- manualScaling:
- description:
- - Manually select the number of nodes to use for serving the model. You should
- generally use autoScaling with an appropriate minNodes instead, but this option
- is available if you want more predictable billing. Beware that latency and
- error rates will increase if the traffic exceeds that capability of the system
- to serve it based on the selected number of nodes.
- returned: success
- type: complex
- contains:
- nodes:
- description:
- - The number of nodes to allocate for this model. These nodes are always
- up, starting from the time the model is deployed.
- returned: success
- type: int
- predictionClass:
- description:
- - The fully qualified name (module_name.class_name) of a class that implements
- the Predictor interface described in this reference field. The module containing
- this class should be included in a package provided to the packageUris field.
- returned: success
- type: str
- model:
- description:
- - The model that this version belongs to.
- returned: success
- type: dict
- isDefault:
- description:
- - If true, this version will be used to handle prediction requests that do not
- specify a version.
- returned: success
- type: bool
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(model=dict(required=True, type='dict')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
-
- return_value = {'resources': fetch_list(module, collection(module))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- res = {'project': module.params['project'], 'model': replace_resource_dict(module.params['model'], 'name')}
- return "https://ml.googleapis.com/v1/projects/{project}/models/{model}/versions".format(**res)
-
-
-def fetch_list(module, link):
- auth = GcpSession(module, 'mlengine')
- return auth.list(link, return_if_object, array_name='versions')
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_pubsub_subscription.py b/lib/ansible/modules/cloud/google/gcp_pubsub_subscription.py
deleted file mode 100644
index b22d592a77..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_pubsub_subscription.py
+++ /dev/null
@@ -1,669 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_pubsub_subscription
-description:
-- A named resource representing the stream of messages from a single, specific topic,
- to be delivered to the subscribing application.
-short_description: Creates a GCP Subscription
-version_added: '2.6'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- name:
- description:
- - Name of the subscription.
- required: true
- type: str
- topic:
- description:
- - A reference to a Topic resource.
- - 'This field represents a link to a Topic resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''name'' and value of
- your resource''s name Alternatively, you can add `register: name-of-resource`
- to a gcp_pubsub_topic task and then set this topic field to "{{ name-of-resource
- }}"'
- required: true
- type: dict
- labels:
- description:
- - A set of key/value label pairs to assign to this Subscription.
- required: false
- type: dict
- version_added: '2.8'
- push_config:
- description:
- - If push delivery is used with this subscription, this field is used to configure
- it. An empty pushConfig signifies that the subscriber will pull and ack messages
- using API methods.
- required: false
- type: dict
- suboptions:
- oidc_token:
- description:
- - If specified, Pub/Sub will generate and attach an OIDC JWT token as an Authorization
- header in the HTTP request for every pushed message.
- required: false
- type: dict
- version_added: '2.10'
- suboptions:
- service_account_email:
- description:
- - Service account email to be used for generating the OIDC token.
- - The caller (for subscriptions.create, subscriptions.patch, and subscriptions.modifyPushConfig
- RPCs) must have the iam.serviceAccounts.actAs permission for the service
- account.
- required: true
- type: str
- audience:
- description:
- - 'Audience to be used when generating OIDC token. The audience claim
- identifies the recipients that the JWT is intended for. The audience
- value is a single case-sensitive string. Having multiple values (array)
- for the audience field is not supported. More info about the OIDC JWT
- token audience here: U(https://tools.ietf.org/html/rfc7519#section-4.1.3)
- Note: if not specified, the Push endpoint URL will be used.'
- required: false
- type: str
- push_endpoint:
- description:
- - A URL locating the endpoint to which messages should be pushed.
- - For example, a Webhook endpoint might use "U(https://example.com/push").
- required: true
- type: str
- attributes:
- description:
- - Endpoint configuration attributes.
- - Every endpoint has a set of API supported attributes that can be used to
- control different aspects of the message delivery.
- - The currently supported attribute is x-goog-version, which you can use to
- change the format of the pushed message. This attribute indicates the version
- of the data expected by the endpoint. This controls the shape of the pushed
- message (i.e., its fields and metadata). The endpoint version is based on
- the version of the Pub/Sub API.
- - If not present during the subscriptions.create call, it will default to
- the version of the API used to make such call. If not present during a subscriptions.modifyPushConfig
- call, its value will not be changed. subscriptions.get calls will always
- return a valid version, even if the subscription was created without this
- attribute.
- - 'The possible values for this attribute are: - v1beta1: uses the push format
- defined in the v1beta1 Pub/Sub API.'
- - "- v1 or v1beta2: uses the push format defined in the v1 Pub/Sub API."
- required: false
- type: dict
- ack_deadline_seconds:
- description:
- - This value is the maximum time after a subscriber receives a message before
- the subscriber should acknowledge the message. After message delivery but before
- the ack deadline expires and before the message is acknowledged, it is an outstanding
- message and will not be delivered again during that time (on a best-effort basis).
- - For pull subscriptions, this value is used as the initial value for the ack
- deadline. To override this value for a given message, call subscriptions.modifyAckDeadline
- with the corresponding ackId if using pull. The minimum custom deadline you
- can specify is 10 seconds. The maximum custom deadline you can specify is 600
- seconds (10 minutes).
- - If this parameter is 0, a default value of 10 seconds is used.
- - For push delivery, this value is also used to set the request timeout for the
- call to the push endpoint.
- - If the subscriber never acknowledges the message, the Pub/Sub system will eventually
- redeliver the message.
- required: false
- type: int
- message_retention_duration:
- description:
- - How long to retain unacknowledged messages in the subscription's backlog, from
- the moment a message is published. If retainAckedMessages is true, then this
- also configures the retention of acknowledged messages, and thus configures
- how far back in time a subscriptions.seek can be done. Defaults to 7 days. Cannot
- be more than 7 days (`"604800s"`) or less than 10 minutes (`"600s"`).
- - 'A duration in seconds with up to nine fractional digits, terminated by ''s''.
- Example: `"600.5s"`.'
- required: false
- default: 604800s
- type: str
- version_added: '2.8'
- retain_acked_messages:
- description:
- - Indicates whether to retain acknowledged messages. If `true`, then messages
- are not expunged from the subscription's backlog, even if they are acknowledged,
- until they fall out of the messageRetentionDuration window.
- required: false
- type: bool
- version_added: '2.8'
- expiration_policy:
- description:
- - A policy that specifies the conditions for this subscription's expiration.
- - A subscription is considered active as long as any connected subscriber is successfully
- consuming messages from the subscription or is issuing operations on the subscription.
- If expirationPolicy is not set, a default policy with ttl of 31 days will be
- used. If it is set but ttl is "", the resource never expires. The minimum allowed
- value for expirationPolicy.ttl is 1 day.
- required: false
- type: dict
- version_added: '2.9'
- suboptions:
- ttl:
- description:
- - Specifies the "time-to-live" duration for an associated resource. The resource
- expires if it is not active for a period of ttl.
- - If ttl is not set, the associated resource never expires.
- - A duration in seconds with up to nine fractional digits, terminated by 's'.
- - Example - "3.5s".
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.subscriptions)'
-- 'Managing Subscriptions: U(https://cloud.google.com/pubsub/docs/admin#managing_subscriptions)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a topic
- gcp_pubsub_topic:
- name: topic-subscription
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: topic
-
-- name: create a subscription
- gcp_pubsub_subscription:
- name: test_object
- topic: "{{ topic }}"
- ack_deadline_seconds: 300
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-name:
- description:
- - Name of the subscription.
- returned: success
- type: str
-topic:
- description:
- - A reference to a Topic resource.
- returned: success
- type: dict
-labels:
- description:
- - A set of key/value label pairs to assign to this Subscription.
- returned: success
- type: dict
-pushConfig:
- description:
- - If push delivery is used with this subscription, this field is used to configure
- it. An empty pushConfig signifies that the subscriber will pull and ack messages
- using API methods.
- returned: success
- type: complex
- contains:
- oidcToken:
- description:
- - If specified, Pub/Sub will generate and attach an OIDC JWT token as an Authorization
- header in the HTTP request for every pushed message.
- returned: success
- type: complex
- contains:
- serviceAccountEmail:
- description:
- - Service account email to be used for generating the OIDC token.
- - The caller (for subscriptions.create, subscriptions.patch, and subscriptions.modifyPushConfig
- RPCs) must have the iam.serviceAccounts.actAs permission for the service
- account.
- returned: success
- type: str
- audience:
- description:
- - 'Audience to be used when generating OIDC token. The audience claim identifies
- the recipients that the JWT is intended for. The audience value is a single
- case-sensitive string. Having multiple values (array) for the audience
- field is not supported. More info about the OIDC JWT token audience here:
- U(https://tools.ietf.org/html/rfc7519#section-4.1.3) Note: if not specified,
- the Push endpoint URL will be used.'
- returned: success
- type: str
- pushEndpoint:
- description:
- - A URL locating the endpoint to which messages should be pushed.
- - For example, a Webhook endpoint might use "U(https://example.com/push").
- returned: success
- type: str
- attributes:
- description:
- - Endpoint configuration attributes.
- - Every endpoint has a set of API supported attributes that can be used to control
- different aspects of the message delivery.
- - The currently supported attribute is x-goog-version, which you can use to
- change the format of the pushed message. This attribute indicates the version
- of the data expected by the endpoint. This controls the shape of the pushed
- message (i.e., its fields and metadata). The endpoint version is based on
- the version of the Pub/Sub API.
- - If not present during the subscriptions.create call, it will default to the
- version of the API used to make such call. If not present during a subscriptions.modifyPushConfig
- call, its value will not be changed. subscriptions.get calls will always return
- a valid version, even if the subscription was created without this attribute.
- - 'The possible values for this attribute are: - v1beta1: uses the push format
- defined in the v1beta1 Pub/Sub API.'
- - "- v1 or v1beta2: uses the push format defined in the v1 Pub/Sub API."
- returned: success
- type: dict
-ackDeadlineSeconds:
- description:
- - This value is the maximum time after a subscriber receives a message before the
- subscriber should acknowledge the message. After message delivery but before the
- ack deadline expires and before the message is acknowledged, it is an outstanding
- message and will not be delivered again during that time (on a best-effort basis).
- - For pull subscriptions, this value is used as the initial value for the ack deadline.
- To override this value for a given message, call subscriptions.modifyAckDeadline
- with the corresponding ackId if using pull. The minimum custom deadline you can
- specify is 10 seconds. The maximum custom deadline you can specify is 600 seconds
- (10 minutes).
- - If this parameter is 0, a default value of 10 seconds is used.
- - For push delivery, this value is also used to set the request timeout for the
- call to the push endpoint.
- - If the subscriber never acknowledges the message, the Pub/Sub system will eventually
- redeliver the message.
- returned: success
- type: int
-messageRetentionDuration:
- description:
- - How long to retain unacknowledged messages in the subscription's backlog, from
- the moment a message is published. If retainAckedMessages is true, then this also
- configures the retention of acknowledged messages, and thus configures how far
- back in time a subscriptions.seek can be done. Defaults to 7 days. Cannot be more
- than 7 days (`"604800s"`) or less than 10 minutes (`"600s"`).
- - 'A duration in seconds with up to nine fractional digits, terminated by ''s''.
- Example: `"600.5s"`.'
- returned: success
- type: str
-retainAckedMessages:
- description:
- - Indicates whether to retain acknowledged messages. If `true`, then messages are
- not expunged from the subscription's backlog, even if they are acknowledged, until
- they fall out of the messageRetentionDuration window.
- returned: success
- type: bool
-expirationPolicy:
- description:
- - A policy that specifies the conditions for this subscription's expiration.
- - A subscription is considered active as long as any connected subscriber is successfully
- consuming messages from the subscription or is issuing operations on the subscription.
- If expirationPolicy is not set, a default policy with ttl of 31 days will be used.
- If it is set but ttl is "", the resource never expires. The minimum allowed value
- for expirationPolicy.ttl is 1 day.
- returned: success
- type: complex
- contains:
- ttl:
- description:
- - Specifies the "time-to-live" duration for an associated resource. The resource
- expires if it is not active for a period of ttl.
- - If ttl is not set, the associated resource never expires.
- - A duration in seconds with up to nine fractional digits, terminated by 's'.
- - Example - "3.5s".
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import re
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- name=dict(required=True, type='str'),
- topic=dict(required=True, type='dict'),
- labels=dict(type='dict'),
- push_config=dict(
- type='dict',
- options=dict(
- oidc_token=dict(type='dict', options=dict(service_account_email=dict(required=True, type='str'), audience=dict(type='str'))),
- push_endpoint=dict(required=True, type='str'),
- attributes=dict(type='dict'),
- ),
- ),
- ack_deadline_seconds=dict(type='int'),
- message_retention_duration=dict(default='604800s', type='str'),
- retain_acked_messages=dict(type='bool'),
- expiration_policy=dict(type='dict', options=dict(ttl=dict(required=True, type='str'))),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/pubsub']
-
- state = module.params['state']
-
- fetch = fetch_resource(module, self_link(module))
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), fetch)
- fetch = fetch_resource(module, self_link(module))
- changed = True
- else:
- delete(module, self_link(module))
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, self_link(module))
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link):
- auth = GcpSession(module, 'pubsub')
- return return_if_object(module, auth.put(link, resource_to_request(module)))
-
-
-def update(module, link, fetch):
- auth = GcpSession(module, 'pubsub')
- params = {'updateMask': updateMask(resource_to_request(module), response_to_hash(module, fetch))}
- request = resource_to_request(module)
- del request['name']
- return return_if_object(module, auth.patch(link, request, params=params))
-
-
-def updateMask(request, response):
- update_mask = []
- if request.get('labels') != response.get('labels'):
- update_mask.append('labels')
- if request.get('pushConfig') != response.get('pushConfig'):
- update_mask.append('pushConfig')
- if request.get('ackDeadlineSeconds') != response.get('ackDeadlineSeconds'):
- update_mask.append('ackDeadlineSeconds')
- if request.get('messageRetentionDuration') != response.get('messageRetentionDuration'):
- update_mask.append('messageRetentionDuration')
- if request.get('retainAckedMessages') != response.get('retainAckedMessages'):
- update_mask.append('retainAckedMessages')
- if request.get('expirationPolicy') != response.get('expirationPolicy'):
- update_mask.append('expirationPolicy')
- return ','.join(update_mask)
-
-
-def delete(module, link):
- auth = GcpSession(module, 'pubsub')
- return return_if_object(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'name': name_pattern(module.params.get('name'), module),
- u'topic': topic_pattern(replace_resource_dict(module.params.get(u'topic', {}), 'name'), module),
- u'labels': module.params.get('labels'),
- u'pushConfig': SubscriptionPushconfig(module.params.get('push_config', {}), module).to_request(),
- u'ackDeadlineSeconds': module.params.get('ack_deadline_seconds'),
- u'messageRetentionDuration': module.params.get('message_retention_duration'),
- u'retainAckedMessages': module.params.get('retain_acked_messages'),
- u'expirationPolicy': SubscriptionExpirationpolicy(module.params.get('expiration_policy', {}), module).to_request(),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, allow_not_found=True):
- auth = GcpSession(module, 'pubsub')
- return return_if_object(module, auth.get(link), allow_not_found)
-
-
-def self_link(module):
- return "https://pubsub.googleapis.com/v1/projects/{project}/subscriptions/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://pubsub.googleapis.com/v1/projects/{project}/subscriptions".format(**module.params)
-
-
-def return_if_object(module, response, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'name': name_pattern(module.params.get('name'), module),
- u'topic': topic_pattern(replace_resource_dict(module.params.get(u'topic', {}), 'name'), module),
- u'labels': response.get(u'labels'),
- u'pushConfig': SubscriptionPushconfig(response.get(u'pushConfig', {}), module).from_response(),
- u'ackDeadlineSeconds': response.get(u'ackDeadlineSeconds'),
- u'messageRetentionDuration': response.get(u'messageRetentionDuration'),
- u'retainAckedMessages': response.get(u'retainAckedMessages'),
- u'expirationPolicy': SubscriptionExpirationpolicy(response.get(u'expirationPolicy', {}), module).from_response(),
- }
-
-
-def name_pattern(name, module):
- if name is None:
- return
-
- regex = r"projects/.*/subscriptions/.*"
-
- if not re.match(regex, name):
- name = "projects/{project}/subscriptions/{name}".format(**module.params)
-
- return name
-
-
-def topic_pattern(name, module):
- if name is None:
- return
-
- regex = r"projects/.*/topics/.*"
-
- if not re.match(regex, name):
- formatted_params = {'project': module.params['project'], 'topic': replace_resource_dict(module.params['topic'], 'name')}
- name = "projects/{project}/topics/{topic}".format(**formatted_params)
-
- return name
-
-
-class SubscriptionPushconfig(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'oidcToken': SubscriptionOidctoken(self.request.get('oidc_token', {}), self.module).to_request(),
- u'pushEndpoint': self.request.get('push_endpoint'),
- u'attributes': self.request.get('attributes'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'oidcToken': SubscriptionOidctoken(self.request.get(u'oidcToken', {}), self.module).from_response(),
- u'pushEndpoint': self.request.get(u'pushEndpoint'),
- u'attributes': self.request.get(u'attributes'),
- }
- )
-
-
-class SubscriptionOidctoken(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'serviceAccountEmail': self.request.get('service_account_email'), u'audience': self.request.get('audience')})
-
- def from_response(self):
- return remove_nones_from_dict({u'serviceAccountEmail': self.request.get(u'serviceAccountEmail'), u'audience': self.request.get(u'audience')})
-
-
-class SubscriptionExpirationpolicy(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'ttl': self.request.get('ttl')})
-
- def from_response(self):
- return remove_nones_from_dict({u'ttl': self.request.get(u'ttl')})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_pubsub_subscription_info.py b/lib/ansible/modules/cloud/google/gcp_pubsub_subscription_info.py
deleted file mode 100644
index 3281b0c18b..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_pubsub_subscription_info.py
+++ /dev/null
@@ -1,293 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_pubsub_subscription_info
-description:
-- Gather info for GCP Subscription
-short_description: Gather info for GCP Subscription
-version_added: '2.8'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a subscription
- gcp_pubsub_subscription_info:
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- name:
- description:
- - Name of the subscription.
- returned: success
- type: str
- topic:
- description:
- - A reference to a Topic resource.
- returned: success
- type: dict
- labels:
- description:
- - A set of key/value label pairs to assign to this Subscription.
- returned: success
- type: dict
- pushConfig:
- description:
- - If push delivery is used with this subscription, this field is used to configure
- it. An empty pushConfig signifies that the subscriber will pull and ack messages
- using API methods.
- returned: success
- type: complex
- contains:
- oidcToken:
- description:
- - If specified, Pub/Sub will generate and attach an OIDC JWT token as an
- Authorization header in the HTTP request for every pushed message.
- returned: success
- type: complex
- contains:
- serviceAccountEmail:
- description:
- - Service account email to be used for generating the OIDC token.
- - The caller (for subscriptions.create, subscriptions.patch, and subscriptions.modifyPushConfig
- RPCs) must have the iam.serviceAccounts.actAs permission for the service
- account.
- returned: success
- type: str
- audience:
- description:
- - 'Audience to be used when generating OIDC token. The audience claim
- identifies the recipients that the JWT is intended for. The audience
- value is a single case-sensitive string. Having multiple values (array)
- for the audience field is not supported. More info about the OIDC
- JWT token audience here: U(https://tools.ietf.org/html/rfc7519#section-4.1.3)
- Note: if not specified, the Push endpoint URL will be used.'
- returned: success
- type: str
- pushEndpoint:
- description:
- - A URL locating the endpoint to which messages should be pushed.
- - For example, a Webhook endpoint might use "U(https://example.com/push").
- returned: success
- type: str
- attributes:
- description:
- - Endpoint configuration attributes.
- - Every endpoint has a set of API supported attributes that can be used
- to control different aspects of the message delivery.
- - The currently supported attribute is x-goog-version, which you can use
- to change the format of the pushed message. This attribute indicates the
- version of the data expected by the endpoint. This controls the shape
- of the pushed message (i.e., its fields and metadata). The endpoint version
- is based on the version of the Pub/Sub API.
- - If not present during the subscriptions.create call, it will default to
- the version of the API used to make such call. If not present during a
- subscriptions.modifyPushConfig call, its value will not be changed. subscriptions.get
- calls will always return a valid version, even if the subscription was
- created without this attribute.
- - 'The possible values for this attribute are: - v1beta1: uses the push
- format defined in the v1beta1 Pub/Sub API.'
- - "- v1 or v1beta2: uses the push format defined in the v1 Pub/Sub API."
- returned: success
- type: dict
- ackDeadlineSeconds:
- description:
- - This value is the maximum time after a subscriber receives a message before
- the subscriber should acknowledge the message. After message delivery but
- before the ack deadline expires and before the message is acknowledged, it
- is an outstanding message and will not be delivered again during that time
- (on a best-effort basis).
- - For pull subscriptions, this value is used as the initial value for the ack
- deadline. To override this value for a given message, call subscriptions.modifyAckDeadline
- with the corresponding ackId if using pull. The minimum custom deadline you
- can specify is 10 seconds. The maximum custom deadline you can specify is
- 600 seconds (10 minutes).
- - If this parameter is 0, a default value of 10 seconds is used.
- - For push delivery, this value is also used to set the request timeout for
- the call to the push endpoint.
- - If the subscriber never acknowledges the message, the Pub/Sub system will
- eventually redeliver the message.
- returned: success
- type: int
- messageRetentionDuration:
- description:
- - How long to retain unacknowledged messages in the subscription's backlog,
- from the moment a message is published. If retainAckedMessages is true, then
- this also configures the retention of acknowledged messages, and thus configures
- how far back in time a subscriptions.seek can be done. Defaults to 7 days.
- Cannot be more than 7 days (`"604800s"`) or less than 10 minutes (`"600s"`).
- - 'A duration in seconds with up to nine fractional digits, terminated by ''s''.
- Example: `"600.5s"`.'
- returned: success
- type: str
- retainAckedMessages:
- description:
- - Indicates whether to retain acknowledged messages. If `true`, then messages
- are not expunged from the subscription's backlog, even if they are acknowledged,
- until they fall out of the messageRetentionDuration window.
- returned: success
- type: bool
- expirationPolicy:
- description:
- - A policy that specifies the conditions for this subscription's expiration.
- - A subscription is considered active as long as any connected subscriber is
- successfully consuming messages from the subscription or is issuing operations
- on the subscription. If expirationPolicy is not set, a default policy with
- ttl of 31 days will be used. If it is set but ttl is "", the resource never
- expires. The minimum allowed value for expirationPolicy.ttl is 1 day.
- returned: success
- type: complex
- contains:
- ttl:
- description:
- - Specifies the "time-to-live" duration for an associated resource. The
- resource expires if it is not active for a period of ttl.
- - If ttl is not set, the associated resource never expires.
- - A duration in seconds with up to nine fractional digits, terminated by
- 's'.
- - Example - "3.5s".
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict())
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/pubsub']
-
- return_value = {'resources': fetch_list(module, collection(module))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://pubsub.googleapis.com/v1/projects/{project}/subscriptions".format(**module.params)
-
-
-def fetch_list(module, link):
- auth = GcpSession(module, 'pubsub')
- return auth.list(link, return_if_object, array_name='subscriptions')
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_pubsub_topic.py b/lib/ansible/modules/cloud/google/gcp_pubsub_topic.py
deleted file mode 100644
index d197c6012c..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_pubsub_topic.py
+++ /dev/null
@@ -1,377 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_pubsub_topic
-description:
-- A named resource to which messages are sent by publishers.
-short_description: Creates a GCP Topic
-version_added: '2.6'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- name:
- description:
- - Name of the topic.
- required: true
- type: str
- kms_key_name:
- description:
- - The resource name of the Cloud KMS CryptoKey to be used to protect access to
- messages published on this topic. Your project's PubSub service account (`service-{{PROJECT_NUMBER}}@gcp-sa-pubsub.iam.gserviceaccount.com`)
- must have `roles/cloudkms.cryptoKeyEncrypterDecrypter` to use this feature.
- - The expected format is `projects/*/locations/*/keyRings/*/cryptoKeys/*` .
- required: false
- type: str
- version_added: '2.9'
- labels:
- description:
- - A set of key/value label pairs to assign to this Topic.
- required: false
- type: dict
- version_added: '2.8'
- message_storage_policy:
- description:
- - Policy constraining the set of Google Cloud Platform regions where messages
- published to the topic may be stored. If not present, then no constraints are
- in effect.
- required: false
- type: dict
- version_added: '2.9'
- suboptions:
- allowed_persistence_regions:
- description:
- - A list of IDs of GCP regions where messages that are published to the topic
- may be persisted in storage. Messages published by publishers running in
- non-allowed GCP regions (or running outside of GCP altogether) will be routed
- for storage in one of the allowed regions. An empty list means that no regions
- are allowed, and is not a valid configuration.
- required: true
- type: list
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/pubsub/docs/reference/rest/v1/projects.topics)'
-- 'Managing Topics: U(https://cloud.google.com/pubsub/docs/admin#managing_topics)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a topic
- gcp_pubsub_topic:
- name: test-topic1
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-name:
- description:
- - Name of the topic.
- returned: success
- type: str
-kmsKeyName:
- description:
- - The resource name of the Cloud KMS CryptoKey to be used to protect access to messages
- published on this topic. Your project's PubSub service account (`service-{{PROJECT_NUMBER}}@gcp-sa-pubsub.iam.gserviceaccount.com`)
- must have `roles/cloudkms.cryptoKeyEncrypterDecrypter` to use this feature.
- - The expected format is `projects/*/locations/*/keyRings/*/cryptoKeys/*` .
- returned: success
- type: str
-labels:
- description:
- - A set of key/value label pairs to assign to this Topic.
- returned: success
- type: dict
-messageStoragePolicy:
- description:
- - Policy constraining the set of Google Cloud Platform regions where messages published
- to the topic may be stored. If not present, then no constraints are in effect.
- returned: success
- type: complex
- contains:
- allowedPersistenceRegions:
- description:
- - A list of IDs of GCP regions where messages that are published to the topic
- may be persisted in storage. Messages published by publishers running in non-allowed
- GCP regions (or running outside of GCP altogether) will be routed for storage
- in one of the allowed regions. An empty list means that no regions are allowed,
- and is not a valid configuration.
- returned: success
- type: list
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import re
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- name=dict(required=True, type='str'),
- kms_key_name=dict(type='str'),
- labels=dict(type='dict'),
- message_storage_policy=dict(type='dict', options=dict(allowed_persistence_regions=dict(required=True, type='list', elements='str'))),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/pubsub']
-
- state = module.params['state']
-
- fetch = fetch_resource(module, self_link(module))
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), fetch)
- fetch = fetch_resource(module, self_link(module))
- changed = True
- else:
- delete(module, self_link(module))
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, self_link(module))
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link):
- auth = GcpSession(module, 'pubsub')
- return return_if_object(module, auth.put(link, resource_to_request(module)))
-
-
-def update(module, link, fetch):
- auth = GcpSession(module, 'pubsub')
- params = {'updateMask': updateMask(resource_to_request(module), response_to_hash(module, fetch))}
- request = resource_to_request(module)
- del request['name']
- return return_if_object(module, auth.patch(link, request, params=params))
-
-
-def updateMask(request, response):
- update_mask = []
- if request.get('labels') != response.get('labels'):
- update_mask.append('labels')
- if request.get('messageStoragePolicy') != response.get('messageStoragePolicy'):
- update_mask.append('messageStoragePolicy')
- return ','.join(update_mask)
-
-
-def delete(module, link):
- auth = GcpSession(module, 'pubsub')
- return return_if_object(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'name': name_pattern(module.params.get('name'), module),
- u'kmsKeyName': module.params.get('kms_key_name'),
- u'labels': module.params.get('labels'),
- u'messageStoragePolicy': TopicMessagestoragepolicy(module.params.get('message_storage_policy', {}), module).to_request(),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, allow_not_found=True):
- auth = GcpSession(module, 'pubsub')
- return return_if_object(module, auth.get(link), allow_not_found)
-
-
-def self_link(module):
- return "https://pubsub.googleapis.com/v1/projects/{project}/topics/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://pubsub.googleapis.com/v1/projects/{project}/topics".format(**module.params)
-
-
-def return_if_object(module, response, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'name': name_pattern(module.params.get('name'), module),
- u'kmsKeyName': module.params.get('kms_key_name'),
- u'labels': response.get(u'labels'),
- u'messageStoragePolicy': TopicMessagestoragepolicy(response.get(u'messageStoragePolicy', {}), module).from_response(),
- }
-
-
-def name_pattern(name, module):
- if name is None:
- return
-
- regex = r"projects/.*/topics/.*"
-
- if not re.match(regex, name):
- name = "projects/{project}/topics/{name}".format(**module.params)
-
- return name
-
-
-class TopicMessagestoragepolicy(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'allowedPersistenceRegions': self.request.get('allowed_persistence_regions')})
-
- def from_response(self):
- return remove_nones_from_dict({u'allowedPersistenceRegions': self.request.get(u'allowedPersistenceRegions')})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_pubsub_topic_info.py b/lib/ansible/modules/cloud/google/gcp_pubsub_topic_info.py
deleted file mode 100644
index d0d70c802c..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_pubsub_topic_info.py
+++ /dev/null
@@ -1,197 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_pubsub_topic_info
-description:
-- Gather info for GCP Topic
-short_description: Gather info for GCP Topic
-version_added: '2.8'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a topic
- gcp_pubsub_topic_info:
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- name:
- description:
- - Name of the topic.
- returned: success
- type: str
- kmsKeyName:
- description:
- - The resource name of the Cloud KMS CryptoKey to be used to protect access
- to messages published on this topic. Your project's PubSub service account
- (`service-{{PROJECT_NUMBER}}@gcp-sa-pubsub.iam.gserviceaccount.com`) must
- have `roles/cloudkms.cryptoKeyEncrypterDecrypter` to use this feature.
- - The expected format is `projects/*/locations/*/keyRings/*/cryptoKeys/*` .
- returned: success
- type: str
- labels:
- description:
- - A set of key/value label pairs to assign to this Topic.
- returned: success
- type: dict
- messageStoragePolicy:
- description:
- - Policy constraining the set of Google Cloud Platform regions where messages
- published to the topic may be stored. If not present, then no constraints
- are in effect.
- returned: success
- type: complex
- contains:
- allowedPersistenceRegions:
- description:
- - A list of IDs of GCP regions where messages that are published to the
- topic may be persisted in storage. Messages published by publishers running
- in non-allowed GCP regions (or running outside of GCP altogether) will
- be routed for storage in one of the allowed regions. An empty list means
- that no regions are allowed, and is not a valid configuration.
- returned: success
- type: list
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict())
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/pubsub']
-
- return_value = {'resources': fetch_list(module, collection(module))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://pubsub.googleapis.com/v1/projects/{project}/topics".format(**module.params)
-
-
-def fetch_list(module, link):
- auth = GcpSession(module, 'pubsub')
- return auth.list(link, return_if_object, array_name='topics')
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_redis_instance.py b/lib/ansible/modules/cloud/google/gcp_redis_instance.py
deleted file mode 100644
index 422e2fca3e..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_redis_instance.py
+++ /dev/null
@@ -1,543 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_redis_instance
-description:
-- A Google Cloud Redis instance.
-short_description: Creates a GCP Instance
-version_added: '2.8'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- alternative_location_id:
- description:
- - Only applicable to STANDARD_HA tier which protects the instance against zonal
- failures by provisioning it across two zones.
- - If provided, it must be a different zone from the one provided in [locationId].
- required: false
- type: str
- authorized_network:
- description:
- - The full name of the Google Compute Engine network to which the instance is
- connected. If left unspecified, the default network will be used.
- required: false
- type: str
- display_name:
- description:
- - An arbitrary and optional user-provided name for the instance.
- required: false
- type: str
- labels:
- description:
- - Resource labels to represent user provided metadata.
- required: false
- type: dict
- redis_configs:
- description:
- - Redis configuration parameters, according to U(http://redis.io/topics/config).
- - 'Please check Memorystore documentation for the list of supported parameters:
- U(https://cloud.google.com/memorystore/docs/redis/reference/rest/v1/projects.locations.instances#Instance.FIELDS.redis_configs)
- .'
- required: false
- type: dict
- location_id:
- description:
- - The zone where the instance will be provisioned. If not provided, the service
- will choose a zone for the instance. For STANDARD_HA tier, instances will be
- created across two zones for protection against zonal failures. If [alternativeLocationId]
- is also provided, it must be different from [locationId].
- required: false
- type: str
- name:
- description:
- - The ID of the instance or a fully qualified identifier for the instance.
- required: true
- type: str
- memory_size_gb:
- description:
- - Redis memory size in GiB.
- required: true
- type: int
- redis_version:
- description:
- - 'The version of Redis software. If not provided, latest supported version will
- be used. Currently, the supported values are: - REDIS_4_0 for Redis 4.0 compatibility
- - REDIS_3_2 for Redis 3.2 compatibility .'
- required: false
- type: str
- reserved_ip_range:
- description:
- - The CIDR range of internal addresses that are reserved for this instance. If
- not provided, the service will choose an unused /29 block, for example, 10.0.0.0/29
- or 192.168.0.0/29. Ranges must be unique and non-overlapping with existing subnets
- in an authorized network.
- required: false
- type: str
- tier:
- description:
- - 'The service tier of the instance. Must be one of these values: - BASIC: standalone
- instance - STANDARD_HA: highly available primary/replica instances .'
- - 'Some valid choices include: "BASIC", "STANDARD_HA"'
- required: false
- default: BASIC
- type: str
- region:
- description:
- - The name of the Redis region of the instance.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/memorystore/docs/redis/reference/rest/)'
-- 'Official Documentation: U(https://cloud.google.com/memorystore/docs/redis/)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a network
- gcp_compute_network:
- name: network-instance
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: network
-
-- name: create a instance
- gcp_redis_instance:
- name: instance37
- tier: STANDARD_HA
- memory_size_gb: 1
- region: us-central1
- location_id: us-central1-a
- redis_version: REDIS_3_2
- display_name: Ansible Test Instance
- reserved_ip_range: 192.168.0.0/29
- labels:
- my_key: my_val
- other_key: other_val
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-alternativeLocationId:
- description:
- - Only applicable to STANDARD_HA tier which protects the instance against zonal
- failures by provisioning it across two zones.
- - If provided, it must be a different zone from the one provided in [locationId].
- returned: success
- type: str
-authorizedNetwork:
- description:
- - The full name of the Google Compute Engine network to which the instance is connected.
- If left unspecified, the default network will be used.
- returned: success
- type: str
-createTime:
- description:
- - The time the instance was created in RFC3339 UTC "Zulu" format, accurate to nanoseconds.
- returned: success
- type: str
-currentLocationId:
- description:
- - The current zone where the Redis endpoint is placed.
- - For Basic Tier instances, this will always be the same as the [locationId] provided
- by the user at creation time. For Standard Tier instances, this can be either
- [locationId] or [alternativeLocationId] and can change after a failover event.
- returned: success
- type: str
-displayName:
- description:
- - An arbitrary and optional user-provided name for the instance.
- returned: success
- type: str
-host:
- description:
- - Hostname or IP address of the exposed Redis endpoint used by clients to connect
- to the service.
- returned: success
- type: str
-labels:
- description:
- - Resource labels to represent user provided metadata.
- returned: success
- type: dict
-redisConfigs:
- description:
- - Redis configuration parameters, according to U(http://redis.io/topics/config).
- - 'Please check Memorystore documentation for the list of supported parameters:
- U(https://cloud.google.com/memorystore/docs/redis/reference/rest/v1/projects.locations.instances#Instance.FIELDS.redis_configs)
- .'
- returned: success
- type: dict
-locationId:
- description:
- - The zone where the instance will be provisioned. If not provided, the service
- will choose a zone for the instance. For STANDARD_HA tier, instances will be created
- across two zones for protection against zonal failures. If [alternativeLocationId]
- is also provided, it must be different from [locationId].
- returned: success
- type: str
-name:
- description:
- - The ID of the instance or a fully qualified identifier for the instance.
- returned: success
- type: str
-memorySizeGb:
- description:
- - Redis memory size in GiB.
- returned: success
- type: int
-port:
- description:
- - The port number of the exposed Redis endpoint.
- returned: success
- type: int
-redisVersion:
- description:
- - 'The version of Redis software. If not provided, latest supported version will
- be used. Currently, the supported values are: - REDIS_4_0 for Redis 4.0 compatibility
- - REDIS_3_2 for Redis 3.2 compatibility .'
- returned: success
- type: str
-reservedIpRange:
- description:
- - The CIDR range of internal addresses that are reserved for this instance. If not
- provided, the service will choose an unused /29 block, for example, 10.0.0.0/29
- or 192.168.0.0/29. Ranges must be unique and non-overlapping with existing subnets
- in an authorized network.
- returned: success
- type: str
-tier:
- description:
- - 'The service tier of the instance. Must be one of these values: - BASIC: standalone
- instance - STANDARD_HA: highly available primary/replica instances .'
- returned: success
- type: str
-region:
- description:
- - The name of the Redis region of the instance.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- alternative_location_id=dict(type='str'),
- authorized_network=dict(type='str'),
- display_name=dict(type='str'),
- labels=dict(type='dict'),
- redis_configs=dict(type='dict'),
- location_id=dict(type='str'),
- name=dict(required=True, type='str'),
- memory_size_gb=dict(required=True, type='int'),
- redis_version=dict(type='str'),
- reserved_ip_range=dict(type='str'),
- tier=dict(default='BASIC', type='str'),
- region=dict(required=True, type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
-
- state = module.params['state']
-
- fetch = fetch_resource(module, self_link(module))
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), fetch)
- fetch = fetch_resource(module, self_link(module))
- changed = True
- else:
- delete(module, self_link(module))
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, create_link(module))
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link):
- auth = GcpSession(module, 'redis')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, fetch):
- auth = GcpSession(module, 'redis')
- params = {'updateMask': updateMask(resource_to_request(module), response_to_hash(module, fetch))}
- request = resource_to_request(module)
- del request['name']
- return wait_for_operation(module, auth.patch(link, request, params=params))
-
-
-def updateMask(request, response):
- update_mask = []
- if request.get('displayName') != response.get('displayName'):
- update_mask.append('displayName')
- if request.get('labels') != response.get('labels'):
- update_mask.append('labels')
- if request.get('redisConfigs') != response.get('redisConfigs'):
- update_mask.append('redisConfigs')
- if request.get('memorySizeGb') != response.get('memorySizeGb'):
- update_mask.append('memorySizeGb')
- return ','.join(update_mask)
-
-
-def delete(module, link):
- auth = GcpSession(module, 'redis')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'alternativeLocationId': module.params.get('alternative_location_id'),
- u'authorizedNetwork': module.params.get('authorized_network'),
- u'displayName': module.params.get('display_name'),
- u'labels': module.params.get('labels'),
- u'redisConfigs': module.params.get('redis_configs'),
- u'locationId': module.params.get('location_id'),
- u'name': module.params.get('name'),
- u'memorySizeGb': module.params.get('memory_size_gb'),
- u'redisVersion': module.params.get('redis_version'),
- u'reservedIpRange': module.params.get('reserved_ip_range'),
- u'tier': module.params.get('tier'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, allow_not_found=True):
- auth = GcpSession(module, 'redis')
- return return_if_object(module, auth.get(link), allow_not_found)
-
-
-def self_link(module):
- return "https://redis.googleapis.com/v1/projects/{project}/locations/{region}/instances/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://redis.googleapis.com/v1/projects/{project}/locations/{region}/instances".format(**module.params)
-
-
-def create_link(module):
- return "https://redis.googleapis.com/v1/projects/{project}/locations/{region}/instances?instanceId={name}".format(**module.params)
-
-
-def return_if_object(module, response, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'alternativeLocationId': module.params.get('alternative_location_id'),
- u'authorizedNetwork': module.params.get('authorized_network'),
- u'createTime': response.get(u'createTime'),
- u'currentLocationId': module.params.get('current_location_id'),
- u'displayName': response.get(u'displayName'),
- u'host': response.get(u'host'),
- u'labels': response.get(u'labels'),
- u'redisConfigs': response.get(u'redisConfigs'),
- u'locationId': module.params.get('location_id'),
- u'name': module.params.get('name'),
- u'memorySizeGb': response.get(u'memorySizeGb'),
- u'port': response.get(u'port'),
- u'redisVersion': module.params.get('redis_version'),
- u'reservedIpRange': module.params.get('reserved_ip_range'),
- u'tier': module.params.get('tier'),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://redis.googleapis.com/v1/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response)
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['done'])
- wait_done = wait_for_completion(status, op_result, module)
- raise_if_errors(wait_done, ['error'], module)
- return navigate_hash(wait_done, ['response'])
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while not status:
- raise_if_errors(op_result, ['error'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, False)
- status = navigate_hash(op_result, ['done'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_redis_instance_info.py b/lib/ansible/modules/cloud/google/gcp_redis_instance_info.py
deleted file mode 100644
index dfdcbfbe85..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_redis_instance_info.py
+++ /dev/null
@@ -1,268 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_redis_instance_info
-description:
-- Gather info for GCP Instance
-short_description: Gather info for GCP Instance
-version_added: '2.8'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- region:
- description:
- - The name of the Redis region of the instance.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on an instance
- gcp_redis_instance_info:
- region: us-central1
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- alternativeLocationId:
- description:
- - Only applicable to STANDARD_HA tier which protects the instance against zonal
- failures by provisioning it across two zones.
- - If provided, it must be a different zone from the one provided in [locationId].
- returned: success
- type: str
- authorizedNetwork:
- description:
- - The full name of the Google Compute Engine network to which the instance is
- connected. If left unspecified, the default network will be used.
- returned: success
- type: str
- createTime:
- description:
- - The time the instance was created in RFC3339 UTC "Zulu" format, accurate to
- nanoseconds.
- returned: success
- type: str
- currentLocationId:
- description:
- - The current zone where the Redis endpoint is placed.
- - For Basic Tier instances, this will always be the same as the [locationId]
- provided by the user at creation time. For Standard Tier instances, this can
- be either [locationId] or [alternativeLocationId] and can change after a failover
- event.
- returned: success
- type: str
- displayName:
- description:
- - An arbitrary and optional user-provided name for the instance.
- returned: success
- type: str
- host:
- description:
- - Hostname or IP address of the exposed Redis endpoint used by clients to connect
- to the service.
- returned: success
- type: str
- labels:
- description:
- - Resource labels to represent user provided metadata.
- returned: success
- type: dict
- redisConfigs:
- description:
- - Redis configuration parameters, according to U(http://redis.io/topics/config).
- - 'Please check Memorystore documentation for the list of supported parameters:
- U(https://cloud.google.com/memorystore/docs/redis/reference/rest/v1/projects.locations.instances#Instance.FIELDS.redis_configs)
- .'
- returned: success
- type: dict
- locationId:
- description:
- - The zone where the instance will be provisioned. If not provided, the service
- will choose a zone for the instance. For STANDARD_HA tier, instances will
- be created across two zones for protection against zonal failures. If [alternativeLocationId]
- is also provided, it must be different from [locationId].
- returned: success
- type: str
- name:
- description:
- - The ID of the instance or a fully qualified identifier for the instance.
- returned: success
- type: str
- memorySizeGb:
- description:
- - Redis memory size in GiB.
- returned: success
- type: int
- port:
- description:
- - The port number of the exposed Redis endpoint.
- returned: success
- type: int
- redisVersion:
- description:
- - 'The version of Redis software. If not provided, latest supported version
- will be used. Currently, the supported values are: - REDIS_4_0 for Redis 4.0
- compatibility - REDIS_3_2 for Redis 3.2 compatibility .'
- returned: success
- type: str
- reservedIpRange:
- description:
- - The CIDR range of internal addresses that are reserved for this instance.
- If not provided, the service will choose an unused /29 block, for example,
- 10.0.0.0/29 or 192.168.0.0/29. Ranges must be unique and non-overlapping with
- existing subnets in an authorized network.
- returned: success
- type: str
- tier:
- description:
- - 'The service tier of the instance. Must be one of these values: - BASIC: standalone
- instance - STANDARD_HA: highly available primary/replica instances .'
- returned: success
- type: str
- region:
- description:
- - The name of the Redis region of the instance.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(region=dict(required=True, type='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
-
- return_value = {'resources': fetch_list(module, collection(module))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://redis.googleapis.com/v1/projects/{project}/locations/{region}/instances".format(**module.params)
-
-
-def fetch_list(module, link):
- auth = GcpSession(module, 'redis')
- return auth.list(link, return_if_object, array_name='instances')
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_resourcemanager_project.py b/lib/ansible/modules/cloud/google/gcp_resourcemanager_project.py
deleted file mode 100644
index 6908446d6d..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_resourcemanager_project.py
+++ /dev/null
@@ -1,412 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_resourcemanager_project
-description:
-- Represents a GCP Project. A project is a container for ACLs, APIs, App Engine Apps,
- VMs, and other Google Cloud Platform resources.
-short_description: Creates a GCP Project
-version_added: '2.8'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- name:
- description:
- - 'The user-assigned display name of the Project. It must be 4 to 30 characters.
- Allowed characters are: lowercase and uppercase letters, numbers, hyphen, single-quote,
- double-quote, space, and exclamation point.'
- required: false
- type: str
- labels:
- description:
- - The labels associated with this Project.
- - 'Label keys must be between 1 and 63 characters long and must conform to the
- following regular expression: `[a-z]([-a-z0-9]*[a-z0-9])?`.'
- - Label values must be between 0 and 63 characters long and must conform to the
- regular expression `([a-z]([-a-z0-9]*[a-z0-9])?)?`.
- - No more than 256 labels can be associated with a given resource.
- - Clients should store labels in a representation such as JSON that does not depend
- on specific characters being disallowed .
- required: false
- type: dict
- parent:
- description:
- - A parent organization.
- required: false
- type: dict
- suboptions:
- type:
- description:
- - Must be organization.
- required: false
- type: str
- id:
- description:
- - Id of the organization.
- required: false
- type: str
- id:
- description:
- - The unique, user-assigned ID of the Project. It must be 6 to 30 lowercase letters,
- digits, or hyphens. It must start with a letter.
- - Trailing hyphens are prohibited.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-'''
-
-EXAMPLES = '''
-- name: create a project
- gcp_resourcemanager_project:
- name: My Sample Project
- id: alextest-{{ 10000000000 | random }}
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- parent:
- type: organization
- id: 636173955921
- state: present
-'''
-
-RETURN = '''
-number:
- description:
- - Number uniquely identifying the project.
- returned: success
- type: int
-lifecycleState:
- description:
- - The Project lifecycle state.
- returned: success
- type: str
-name:
- description:
- - 'The user-assigned display name of the Project. It must be 4 to 30 characters.
- Allowed characters are: lowercase and uppercase letters, numbers, hyphen, single-quote,
- double-quote, space, and exclamation point.'
- returned: success
- type: str
-createTime:
- description:
- - Time of creation.
- returned: success
- type: str
-labels:
- description:
- - The labels associated with this Project.
- - 'Label keys must be between 1 and 63 characters long and must conform to the following
- regular expression: `[a-z]([-a-z0-9]*[a-z0-9])?`.'
- - Label values must be between 0 and 63 characters long and must conform to the
- regular expression `([a-z]([-a-z0-9]*[a-z0-9])?)?`.
- - No more than 256 labels can be associated with a given resource.
- - Clients should store labels in a representation such as JSON that does not depend
- on specific characters being disallowed .
- returned: success
- type: dict
-parent:
- description:
- - A parent organization.
- returned: success
- type: complex
- contains:
- type:
- description:
- - Must be organization.
- returned: success
- type: str
- id:
- description:
- - Id of the organization.
- returned: success
- type: str
-id:
- description:
- - The unique, user-assigned ID of the Project. It must be 6 to 30 lowercase letters,
- digits, or hyphens. It must start with a letter.
- - Trailing hyphens are prohibited.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- name=dict(type='str'),
- labels=dict(type='dict'),
- parent=dict(type='dict', options=dict(type=dict(type='str'), id=dict(type='str'))),
- id=dict(required=True, type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
-
- state = module.params['state']
-
- fetch = fetch_resource(module, self_link(module))
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module))
- fetch = fetch_resource(module, self_link(module))
- changed = True
- else:
- delete(module, self_link(module))
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module))
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link):
- auth = GcpSession(module, 'resourcemanager')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link):
- auth = GcpSession(module, 'resourcemanager')
- return wait_for_operation(module, auth.put(link, resource_to_request(module)))
-
-
-def delete(module, link):
- auth = GcpSession(module, 'resourcemanager')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'projectId': module.params.get('id'),
- u'name': module.params.get('name'),
- u'labels': module.params.get('labels'),
- u'parent': ProjectParent(module.params.get('parent', {}), module).to_request(),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, allow_not_found=True):
- auth = GcpSession(module, 'resourcemanager')
- return return_if_object(module, auth.get(link), allow_not_found)
-
-
-def self_link(module):
- return "https://cloudresourcemanager.googleapis.com/v1/projects/{id}".format(**module.params)
-
-
-def collection(module):
- return "https://cloudresourcemanager.googleapis.com/v1/projects".format(**module.params)
-
-
-def return_if_object(module, response, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- # SQL only: return on 403 if not exist
- if allow_not_found and response.status_code == 403:
- return None
-
- try:
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'message']):
- module.fail_json(msg=navigate_hash(result, ['error', 'message']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'projectNumber': response.get(u'projectNumber'),
- u'lifecycleState': response.get(u'lifecycleState'),
- u'name': response.get(u'name'),
- u'createTime': response.get(u'createTime'),
- u'labels': response.get(u'labels'),
- u'parent': ProjectParent(response.get(u'parent', {}), module).from_response(),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://cloudresourcemanager.googleapis.com/v1/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response)
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['done'])
- wait_done = wait_for_completion(status, op_result, module)
- raise_if_errors(wait_done, ['error'], module)
- return navigate_hash(wait_done, ['response'])
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while not status:
- raise_if_errors(op_result, ['error'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, False)
- status = navigate_hash(op_result, ['done'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-class ProjectParent(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'type': self.request.get('type'), u'id': self.request.get('id')})
-
- def from_response(self):
- return remove_nones_from_dict({u'type': self.request.get(u'type'), u'id': self.request.get(u'id')})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_resourcemanager_project_info.py b/lib/ansible/modules/cloud/google/gcp_resourcemanager_project_info.py
deleted file mode 100644
index 161d9fb232..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_resourcemanager_project_info.py
+++ /dev/null
@@ -1,218 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_resourcemanager_project_info
-description:
-- Gather info for GCP Project
-short_description: Gather info for GCP Project
-version_added: '2.8'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a project
- gcp_resourcemanager_project_info:
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- number:
- description:
- - Number uniquely identifying the project.
- returned: success
- type: int
- lifecycleState:
- description:
- - The Project lifecycle state.
- returned: success
- type: str
- name:
- description:
- - 'The user-assigned display name of the Project. It must be 4 to 30 characters.
- Allowed characters are: lowercase and uppercase letters, numbers, hyphen,
- single-quote, double-quote, space, and exclamation point.'
- returned: success
- type: str
- createTime:
- description:
- - Time of creation.
- returned: success
- type: str
- labels:
- description:
- - The labels associated with this Project.
- - 'Label keys must be between 1 and 63 characters long and must conform to the
- following regular expression: `[a-z]([-a-z0-9]*[a-z0-9])?`.'
- - Label values must be between 0 and 63 characters long and must conform to
- the regular expression `([a-z]([-a-z0-9]*[a-z0-9])?)?`.
- - No more than 256 labels can be associated with a given resource.
- - Clients should store labels in a representation such as JSON that does not
- depend on specific characters being disallowed .
- returned: success
- type: dict
- parent:
- description:
- - A parent organization.
- returned: success
- type: complex
- contains:
- type:
- description:
- - Must be organization.
- returned: success
- type: str
- id:
- description:
- - Id of the organization.
- returned: success
- type: str
- id:
- description:
- - The unique, user-assigned ID of the Project. It must be 6 to 30 lowercase
- letters, digits, or hyphens. It must start with a letter.
- - Trailing hyphens are prohibited.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict())
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
-
- return_value = {'resources': fetch_list(module, collection(module))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://cloudresourcemanager.googleapis.com/v1/projects".format(**module.params)
-
-
-def fetch_list(module, link):
- auth = GcpSession(module, 'resourcemanager')
- return auth.list(link, return_if_object, array_name='projects')
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_runtimeconfig_config.py b/lib/ansible/modules/cloud/google/gcp_runtimeconfig_config.py
deleted file mode 100644
index 3b8fe98f30..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_runtimeconfig_config.py
+++ /dev/null
@@ -1,273 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_runtimeconfig_config
-description:
-- A RuntimeConfig resource is the primary resource in the Cloud RuntimeConfig service.
-- A RuntimeConfig resource consists of metadata and a hierarchy of variables.
-short_description: Creates a GCP Config
-version_added: '2.10'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- description:
- description:
- - The description to associate with the runtime config.
- required: false
- type: str
- name:
- description:
- - The name of the runtime config.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-'''
-
-EXAMPLES = '''
-- name: create a config
- gcp_runtimeconfig_config:
- name: test_object
- description: My config
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-description:
- description:
- - The description to associate with the runtime config.
- returned: success
- type: str
-name:
- description:
- - The name of the runtime config.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-import re
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'), description=dict(type='str'), name=dict(required=True, type='str')
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloudruntimeconfig']
-
- state = module.params['state']
-
- fetch = fetch_resource(module, self_link(module))
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module))
- fetch = fetch_resource(module, self_link(module))
- changed = True
- else:
- delete(module, self_link(module))
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module))
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link):
- auth = GcpSession(module, 'runtimeconfig')
- return return_if_object(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link):
- auth = GcpSession(module, 'runtimeconfig')
- return return_if_object(module, auth.put(link, resource_to_request(module)))
-
-
-def delete(module, link):
- auth = GcpSession(module, 'runtimeconfig')
- return return_if_object(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {u'name': name_pattern(module.params.get('name'), module), u'description': module.params.get('description')}
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, allow_not_found=True):
- auth = GcpSession(module, 'runtimeconfig')
- return return_if_object(module, auth.get(link), allow_not_found)
-
-
-def self_link(module):
- return "https://runtimeconfig.googleapis.com/v1beta1/projects/{project}/configs/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://runtimeconfig.googleapis.com/v1beta1/projects/{project}/configs".format(**module.params)
-
-
-def return_if_object(module, response, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {u'description': response.get(u'description')}
-
-
-def name_pattern(name, module):
- if name is None:
- return
-
- regex = r"projects/.*/configs/.*"
-
- if not re.match(regex, name):
- name = "projects/{project}/configs/{name}".format(**module.params)
-
- return name
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_runtimeconfig_config_info.py b/lib/ansible/modules/cloud/google/gcp_runtimeconfig_config_info.py
deleted file mode 100644
index 38a5349be3..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_runtimeconfig_config_info.py
+++ /dev/null
@@ -1,171 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_runtimeconfig_config_info
-description:
-- Gather info for GCP Config
-short_description: Gather info for GCP Config
-version_added: '2.10'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a config
- gcp_runtimeconfig_config_info:
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- description:
- description:
- - The description to associate with the runtime config.
- returned: success
- type: str
- name:
- description:
- - The name of the runtime config.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict())
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloudruntimeconfig']
-
- return_value = {'resources': fetch_list(module, collection(module))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://runtimeconfig.googleapis.com/v1beta1/projects/{project}/configs".format(**module.params)
-
-
-def fetch_list(module, link):
- auth = GcpSession(module, 'runtimeconfig')
- return auth.list(link, return_if_object, array_name='configs')
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_runtimeconfig_variable.py b/lib/ansible/modules/cloud/google/gcp_runtimeconfig_variable.py
deleted file mode 100644
index 31f2ef9776..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_runtimeconfig_variable.py
+++ /dev/null
@@ -1,321 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_runtimeconfig_variable
-description:
-- Describes a single variable within a runtime config resource.
-short_description: Creates a GCP Variable
-version_added: '2.10'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- value:
- description:
- - The binary value of the variable. Either this or `text` can be set.
- required: false
- type: str
- text:
- description:
- - The string value of the variable. Either this or `value` can be set.
- required: false
- type: str
- name:
- description:
- - The name of the variable resource.
- required: true
- type: str
- config:
- description:
- - The name of the runtime config that this variable belongs to.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-'''
-
-EXAMPLES = '''
-- name: create a config
- gcp_runtimeconfig_config:
- name: my-config
- description: My config
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: config
-
-- name: create a variable
- gcp_runtimeconfig_variable:
- name: prod-variables/hostname
- config: my-config
- text: example.com
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-value:
- description:
- - The binary value of the variable. Either this or `text` can be set.
- returned: success
- type: str
-text:
- description:
- - The string value of the variable. Either this or `value` can be set.
- returned: success
- type: str
-name:
- description:
- - The name of the variable resource.
- returned: success
- type: str
-config:
- description:
- - The name of the runtime config that this variable belongs to.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-import re
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- value=dict(type='str'),
- text=dict(type='str'),
- name=dict(required=True, type='str'),
- config=dict(required=True, type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloudruntimeconfig']
-
- state = module.params['state']
-
- fetch = fetch_resource(module, self_link(module))
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module))
- fetch = fetch_resource(module, self_link(module))
- changed = True
- else:
- delete(module, self_link(module))
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module))
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link):
- auth = GcpSession(module, 'runtimeconfig')
- return return_if_object(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link):
- auth = GcpSession(module, 'runtimeconfig')
- return return_if_object(module, auth.put(link, resource_to_request(module)))
-
-
-def delete(module, link):
- auth = GcpSession(module, 'runtimeconfig')
- return return_if_object(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'name': name_pattern(module.params.get('name'), module),
- u'config': module.params.get('config'),
- u'value': module.params.get('value'),
- u'text': module.params.get('text'),
- }
- request = encode_request(request, module)
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, allow_not_found=True):
- auth = GcpSession(module, 'runtimeconfig')
- return return_if_object(module, auth.get(link), allow_not_found)
-
-
-def self_link(module):
- return "https://runtimeconfig.googleapis.com/v1beta1/projects/{project}/configs/{config}/variables/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://runtimeconfig.googleapis.com/v1beta1/projects/{project}/configs/{config}/variables".format(**module.params)
-
-
-def return_if_object(module, response, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {u'value': response.get(u'value'), u'text': response.get(u'text')}
-
-
-def name_pattern(name, module):
- if name is None:
- return
-
- regex = r"projects/.*/configs/.*/variables/.*"
-
- if not re.match(regex, name):
- name = "projects/{project}/configs/{config}/variables/{name}".format(**module.params)
-
- return name
-
-
-# `config` is a useful parameter for declarative syntax, but
-# is not a part of the GCP API
-def encode_request(request, module):
- if 'config' in request:
- del request['config']
- return request
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_runtimeconfig_variable_info.py b/lib/ansible/modules/cloud/google/gcp_runtimeconfig_variable_info.py
deleted file mode 100644
index d06e7ee49b..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_runtimeconfig_variable_info.py
+++ /dev/null
@@ -1,187 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_runtimeconfig_variable_info
-description:
-- Gather info for GCP Variable
-short_description: Gather info for GCP Variable
-version_added: '2.10'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- config:
- description:
- - The name of the runtime config that this variable belongs to.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a variable
- gcp_runtimeconfig_variable_info:
- config: my-config
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- value:
- description:
- - The binary value of the variable. Either this or `text` can be set.
- returned: success
- type: str
- text:
- description:
- - The string value of the variable. Either this or `value` can be set.
- returned: success
- type: str
- name:
- description:
- - The name of the variable resource.
- returned: success
- type: str
- config:
- description:
- - The name of the runtime config that this variable belongs to.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(config=dict(required=True, type='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloudruntimeconfig']
-
- return_value = {'resources': fetch_list(module, collection(module))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://runtimeconfig.googleapis.com/v1beta1/projects/{project}/configs/{config}/variables".format(**module.params)
-
-
-def fetch_list(module, link):
- auth = GcpSession(module, 'runtimeconfig')
- return auth.list(link, return_if_object, array_name='variables')
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_serviceusage_service.py b/lib/ansible/modules/cloud/google/gcp_serviceusage_service.py
deleted file mode 100644
index d4e708a36e..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_serviceusage_service.py
+++ /dev/null
@@ -1,440 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_serviceusage_service
-description:
-- A service that is available for use .
-short_description: Creates a GCP Service
-version_added: '2.10'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- name:
- description:
- - The resource name of the service .
- required: true
- type: str
- disable_dependent_services:
- description:
- - Indicates if dependent services should also be disabled. Can only be turned
- on if service is disabled.
- required: false
- type: bool
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'Getting Started: U(https://cloud.google.com/service-usage/docs/getting-started)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a service
- gcp_serviceusage_service:
- name: spanner.googleapis.com
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-name:
- description:
- - The resource name of the service .
- returned: success
- type: str
-parent:
- description:
- - The name of the parent of this service. For example 'projects/123' .
- returned: success
- type: str
-state:
- description:
- - Whether or not the service has been enabled for use by the consumer.
- returned: success
- type: str
-disableDependentServices:
- description:
- - Indicates if dependent services should also be disabled. Can only be turned on
- if service is disabled.
- returned: success
- type: bool
-config:
- description:
- - The service configuration of the available service.
- returned: success
- type: complex
- contains:
- name:
- description:
- - The DNS address at which this service is available.
- returned: success
- type: str
- title:
- description:
- - The product title for this service.
- returned: success
- type: str
- apis:
- description:
- - The list of API interfaces exported by this service.
- returned: success
- type: complex
- contains:
- name:
- description:
- - Name of the API.
- returned: success
- type: str
- version:
- description:
- - The version of the API.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import re
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- name=dict(required=True, type='str'),
- disable_dependent_services=dict(type='bool'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
-
- state = module.params['state']
-
- fetch = fetch_resource(module, self_link(module))
- changed = False
-
- if module.params['state'] == 'present' and module.params['disable_dependent_services']:
- module.fail_json(msg="You cannot enable a service and use the disable_dependent_service option")
-
- if fetch and fetch.get('state') == 'DISABLED':
- fetch = {}
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module))
- fetch = fetch_resource(module, self_link(module))
- changed = True
- else:
- delete(module, delete_link(module))
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, create_link(module))
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link):
- auth = GcpSession(module, 'serviceusage')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link):
- auth = GcpSession(module, 'serviceusage')
- return wait_for_operation(module, auth.put(link, resource_to_request(module)))
-
-
-def delete(module, link):
- auth = GcpSession(module, 'serviceusage')
- return wait_for_operation(module, auth.post(link))
-
-
-def resource_to_request(module):
- request = {u'disableDependentServices': module.params.get('disable_dependent_services')}
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, allow_not_found=True):
- auth = GcpSession(module, 'serviceusage')
- return return_if_object(module, auth.get(link), allow_not_found)
-
-
-def self_link(module):
- return "https://serviceusage.googleapis.com/v1/projects/{project}/services/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://serviceusage.googleapis.com/v1/projects/{project}/services".format(**module.params)
-
-
-def create_link(module):
- return "https://serviceusage.googleapis.com/v1/projects/{project}/services/{name}:enable".format(**module.params)
-
-
-def delete_link(module):
- return "https://serviceusage.googleapis.com/v1/projects/{project}/services/{name}:disable".format(**module.params)
-
-
-def return_if_object(module, response, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'name': response.get(u'name'),
- u'parent': response.get(u'parent'),
- u'state': response.get(u'state'),
- u'disableDependentServices': response.get(u'disableDependentServices'),
- u'config': ServiceConfig(response.get(u'config', {}), module).from_response(),
- }
-
-
-def name_pattern(name, module):
- if name is None:
- return
-
- regex = r"projects/.*/services/.*"
-
- if not re.match(regex, name):
- name = "projects/{project}/services/{name}".format(**module.params)
-
- return name
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://serviceusage.googleapis.com/v1/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response)
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['done'])
- wait_done = wait_for_completion(status, op_result, module)
- raise_if_errors(wait_done, ['error'], module)
- return navigate_hash(wait_done, ['response'])
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while not status:
- raise_if_errors(op_result, ['error'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, False)
- status = navigate_hash(op_result, ['done'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-class ServiceConfig(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'name': self.request.get('name'),
- u'title': self.request.get('title'),
- u'apis': ServiceApisArray(self.request.get('apis', []), self.module).to_request(),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'name': self.request.get(u'name'),
- u'title': self.request.get(u'title'),
- u'apis': ServiceApisArray(self.request.get(u'apis', []), self.module).from_response(),
- }
- )
-
-
-class ServiceApisArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'name': item.get('name'), u'version': item.get('version')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'name': item.get(u'name'), u'version': item.get(u'version')})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_serviceusage_service_info.py b/lib/ansible/modules/cloud/google/gcp_serviceusage_service_info.py
deleted file mode 100644
index 291344ebba..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_serviceusage_service_info.py
+++ /dev/null
@@ -1,214 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_serviceusage_service_info
-description:
-- Gather info for GCP Service
-short_description: Gather info for GCP Service
-version_added: '2.10'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a service
- gcp_serviceusage_service_info:
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- name:
- description:
- - The resource name of the service .
- returned: success
- type: str
- parent:
- description:
- - The name of the parent of this service. For example 'projects/123' .
- returned: success
- type: str
- state:
- description:
- - Whether or not the service has been enabled for use by the consumer.
- returned: success
- type: str
- disableDependentServices:
- description:
- - Indicates if dependent services should also be disabled. Can only be turned
- on if service is disabled.
- returned: success
- type: bool
- config:
- description:
- - The service configuration of the available service.
- returned: success
- type: complex
- contains:
- name:
- description:
- - The DNS address at which this service is available.
- returned: success
- type: str
- title:
- description:
- - The product title for this service.
- returned: success
- type: str
- apis:
- description:
- - The list of API interfaces exported by this service.
- returned: success
- type: complex
- contains:
- name:
- description:
- - Name of the API.
- returned: success
- type: str
- version:
- description:
- - The version of the API.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict())
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
-
- return_value = {'resources': fetch_list(module, collection(module))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://serviceusage.googleapis.com/v1/projects/{project}/services".format(**module.params)
-
-
-def fetch_list(module, link):
- auth = GcpSession(module, 'serviceusage')
- return auth.list(link, return_if_object, array_name='services')
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_sourcerepo_repository.py b/lib/ansible/modules/cloud/google/gcp_sourcerepo_repository.py
deleted file mode 100644
index 536ee2bab6..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_sourcerepo_repository.py
+++ /dev/null
@@ -1,292 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_sourcerepo_repository
-description:
-- A repository (or repo) is a Git repository storing versioned source content.
-short_description: Creates a GCP Repository
-version_added: '2.8'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- name:
- description:
- - Resource name of the repository, of the form projects/{{project}}/repos/{{repo}}.
- - The repo name may contain slashes. eg, projects/myproject/repos/name/with/slash
- .
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/source-repositories/docs/reference/rest/v1/projects.repos)'
-- 'Official Documentation: U(https://cloud.google.com/source-repositories/)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a repository
- gcp_sourcerepo_repository:
- name: test_object
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-name:
- description:
- - Resource name of the repository, of the form projects/{{project}}/repos/{{repo}}.
- - The repo name may contain slashes. eg, projects/myproject/repos/name/with/slash
- .
- returned: success
- type: str
-url:
- description:
- - URL to clone the repository from Google Cloud Source Repositories.
- returned: success
- type: str
-size:
- description:
- - The disk usage of the repo, in bytes.
- returned: success
- type: int
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-import re
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(argument_spec=dict(state=dict(default='present', choices=['present', 'absent'], type='str'), name=dict(required=True, type='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
-
- state = module.params['state']
-
- fetch = fetch_resource(module, self_link(module))
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), fetch)
- fetch = fetch_resource(module, self_link(module))
- changed = True
- else:
- delete(module, self_link(module))
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module))
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link):
- auth = GcpSession(module, 'sourcerepo')
- return return_if_object(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, fetch):
- auth = GcpSession(module, 'sourcerepo')
- params = {'updateMask': updateMask(resource_to_request(module), response_to_hash(module, fetch))}
- request = resource_to_request(module)
- del request['name']
- return return_if_object(module, auth.patch(link, request, params=params))
-
-
-def updateMask(request, response):
- update_mask = []
- return ','.join(update_mask)
-
-
-def delete(module, link):
- auth = GcpSession(module, 'sourcerepo')
- return return_if_object(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {u'name': name_pattern(module.params.get('name'), module)}
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, allow_not_found=True):
- auth = GcpSession(module, 'sourcerepo')
- return return_if_object(module, auth.get(link), allow_not_found)
-
-
-def self_link(module):
- return "https://sourcerepo.googleapis.com/v1/projects/{project}/repos/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://sourcerepo.googleapis.com/v1/projects/{project}/repos".format(**module.params)
-
-
-def return_if_object(module, response, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {u'name': name_pattern(module.params.get('name'), module), u'url': response.get(u'url'), u'size': response.get(u'size')}
-
-
-def name_pattern(name, module):
- if name is None:
- return
-
- regex = r"projects/.*/repos/.*"
-
- if not re.match(regex, name):
- name = "projects/{project}/repos/{name}".format(**module.params)
-
- return name
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_sourcerepo_repository_info.py b/lib/ansible/modules/cloud/google/gcp_sourcerepo_repository_info.py
deleted file mode 100644
index 7f630b7721..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_sourcerepo_repository_info.py
+++ /dev/null
@@ -1,178 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_sourcerepo_repository_info
-description:
-- Gather info for GCP Repository
-short_description: Gather info for GCP Repository
-version_added: '2.8'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a repository
- gcp_sourcerepo_repository_info:
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- name:
- description:
- - Resource name of the repository, of the form projects/{{project}}/repos/{{repo}}.
- - The repo name may contain slashes. eg, projects/myproject/repos/name/with/slash
- .
- returned: success
- type: str
- url:
- description:
- - URL to clone the repository from Google Cloud Source Repositories.
- returned: success
- type: str
- size:
- description:
- - The disk usage of the repo, in bytes.
- returned: success
- type: int
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict())
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
-
- return_value = {'resources': fetch_list(module, collection(module))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://sourcerepo.googleapis.com/v1/projects/{project}/repos".format(**module.params)
-
-
-def fetch_list(module, link):
- auth = GcpSession(module, 'sourcerepo')
- return auth.list(link, return_if_object, array_name='repos')
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_spanner_database.py b/lib/ansible/modules/cloud/google/gcp_spanner_database.py
deleted file mode 100644
index c7721c6199..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_spanner_database.py
+++ /dev/null
@@ -1,377 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_spanner_database
-description:
-- A Cloud Spanner Database which is hosted on a Spanner instance.
-short_description: Creates a GCP Database
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- name:
- description:
- - A unique identifier for the database, which cannot be changed after the instance
- is created. Values are of the form [a-z][-a-z0-9]*[a-z0-9].
- required: true
- type: str
- extra_statements:
- description:
- - 'An optional list of DDL statements to run inside the newly created database.
- Statements can create tables, indexes, etc. These statements execute atomically
- with the creation of the database: if there is an error in any statement, the
- database is not created.'
- required: false
- type: list
- instance:
- description:
- - The instance to create the database on.
- - 'This field represents a link to a Instance resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''name'' and value of
- your resource''s name Alternatively, you can add `register: name-of-resource`
- to a gcp_spanner_instance task and then set this instance field to "{{ name-of-resource
- }}"'
- required: true
- type: dict
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/spanner/docs/reference/rest/v1/projects.instances.databases)'
-- 'Official Documentation: U(https://cloud.google.com/spanner/)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a instance
- gcp_spanner_instance:
- name: instance-database
- display_name: My Spanner Instance
- node_count: 2
- labels:
- cost_center: ti-1700004
- config: regional-us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: instance
-
-- name: create a database
- gcp_spanner_database:
- name: webstore
- instance: "{{ instance }}"
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-name:
- description:
- - A unique identifier for the database, which cannot be changed after the instance
- is created. Values are of the form [a-z][-a-z0-9]*[a-z0-9].
- returned: success
- type: str
-extraStatements:
- description:
- - 'An optional list of DDL statements to run inside the newly created database.
- Statements can create tables, indexes, etc. These statements execute atomically
- with the creation of the database: if there is an error in any statement, the
- database is not created.'
- returned: success
- type: list
-instance:
- description:
- - The instance to create the database on.
- returned: success
- type: dict
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- name=dict(required=True, type='str'),
- extra_statements=dict(type='list', elements='str'),
- instance=dict(required=True, type='dict'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/spanner.admin']
-
- state = module.params['state']
-
- fetch = fetch_resource(module, self_link(module))
- changed = False
-
- if 'instance' in module.params and 'name' in module.params['instance']:
- module.params['instance']['name'] = module.params['instance']['name'].split('/')[-1]
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module))
- fetch = fetch_resource(module, self_link(module))
- changed = True
- else:
- delete(module, self_link(module))
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module))
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link):
- auth = GcpSession(module, 'spanner')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link):
- module.fail_json(msg="Spanner objects can't be updated to ensure data safety")
-
-
-def delete(module, link):
- auth = GcpSession(module, 'spanner')
- return return_if_object(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {u'name': module.params.get('name'), u'extraStatements': module.params.get('extra_statements')}
- request = encode_request(request, module)
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, allow_not_found=True):
- auth = GcpSession(module, 'spanner')
- return return_if_object(module, auth.get(link), allow_not_found)
-
-
-def self_link(module):
- res = {'project': module.params['project'], 'instance': replace_resource_dict(module.params['instance'], 'name'), 'name': module.params['name']}
- return "https://spanner.googleapis.com/v1/projects/{project}/instances/{instance}/databases/{name}".format(**res)
-
-
-def collection(module):
- res = {'project': module.params['project'], 'instance': replace_resource_dict(module.params['instance'], 'name')}
- return "https://spanner.googleapis.com/v1/projects/{project}/instances/{instance}/databases".format(**res)
-
-
-def return_if_object(module, response, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- result = decode_response(result, module)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
- request = decode_response(request, module)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {u'name': module.params.get('name'), u'extraStatements': module.params.get('extra_statements')}
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://spanner.googleapis.com/v1/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response)
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['done'])
- wait_done = wait_for_completion(status, op_result, module)
- raise_if_errors(wait_done, ['error'], module)
- return navigate_hash(wait_done, ['response'])
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while not status:
- raise_if_errors(op_result, ['error'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, False)
- status = navigate_hash(op_result, ['done'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-def decode_response(response, module):
- if not response:
- return response
-
- if 'name' not in response:
- return response
-
- if '/operations/' in response['name']:
- return response
-
- response['name'] = response['name'].split('/')[-1]
- return response
-
-
-def encode_request(request, module):
- request['create_statement'] = "CREATE DATABASE `{0}`".format(module.params['name'])
- del request['name']
- return request
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_spanner_database_info.py b/lib/ansible/modules/cloud/google/gcp_spanner_database_info.py
deleted file mode 100644
index 223086b173..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_spanner_database_info.py
+++ /dev/null
@@ -1,192 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_spanner_database_info
-description:
-- Gather info for GCP Database
-short_description: Gather info for GCP Database
-version_added: '2.8'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- instance:
- description:
- - The instance to create the database on.
- - 'This field represents a link to a Instance resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''name'' and value of
- your resource''s name Alternatively, you can add `register: name-of-resource`
- to a gcp_spanner_instance task and then set this instance field to "{{ name-of-resource
- }}"'
- required: true
- type: dict
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a database
- gcp_spanner_database_info:
- instance: "{{ instance }}"
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- name:
- description:
- - A unique identifier for the database, which cannot be changed after the instance
- is created. Values are of the form [a-z][-a-z0-9]*[a-z0-9].
- returned: success
- type: str
- extraStatements:
- description:
- - 'An optional list of DDL statements to run inside the newly created database.
- Statements can create tables, indexes, etc. These statements execute atomically
- with the creation of the database: if there is an error in any statement,
- the database is not created.'
- returned: success
- type: list
- instance:
- description:
- - The instance to create the database on.
- returned: success
- type: dict
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(instance=dict(required=True, type='dict')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/spanner.admin']
-
- return_value = {'resources': fetch_list(module, collection(module))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- res = {'project': module.params['project'], 'instance': replace_resource_dict(module.params['instance'], 'name')}
- return "https://spanner.googleapis.com/v1/projects/{project}/instances/{instance}/databases".format(**res)
-
-
-def fetch_list(module, link):
- auth = GcpSession(module, 'spanner')
- return auth.list(link, return_if_object, array_name='databases')
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_spanner_instance.py b/lib/ansible/modules/cloud/google/gcp_spanner_instance.py
deleted file mode 100644
index 6a4d047575..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_spanner_instance.py
+++ /dev/null
@@ -1,405 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_spanner_instance
-description:
-- An isolated set of Cloud Spanner resources on which databases can be hosted.
-short_description: Creates a GCP Instance
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- name:
- description:
- - A unique identifier for the instance, which cannot be changed after the instance
- is created. The name must be between 6 and 30 characters in length.
- required: true
- type: str
- config:
- description:
- - The name of the instance's configuration (similar but not quite the same as
- a region) which defines defines the geographic placement and replication of
- your databases in this instance. It determines where your data is stored. Values
- are typically of the form `regional-europe-west1` , `us-central` etc.
- - In order to obtain a valid list please consult the [Configuration section of
- the docs](U(https://cloud.google.com/spanner/docs/instances)).
- required: true
- type: str
- display_name:
- description:
- - The descriptive name for this instance as it appears in UIs. Must be unique
- per project and between 4 and 30 characters in length.
- required: true
- type: str
- node_count:
- description:
- - The number of nodes allocated to this instance.
- required: false
- default: '1'
- type: int
- labels:
- description:
- - 'An object containing a list of "key": value pairs.'
- - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.'
- required: false
- type: dict
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/spanner/docs/reference/rest/v1/projects.instances)'
-- 'Official Documentation: U(https://cloud.google.com/spanner/)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a instance
- gcp_spanner_instance:
- name: testinstance
- display_name: My Spanner Instance
- node_count: 2
- labels:
- cost_center: ti-1700004
- config: regional-us-central1
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-name:
- description:
- - A unique identifier for the instance, which cannot be changed after the instance
- is created. The name must be between 6 and 30 characters in length.
- returned: success
- type: str
-config:
- description:
- - The name of the instance's configuration (similar but not quite the same as a
- region) which defines defines the geographic placement and replication of your
- databases in this instance. It determines where your data is stored. Values are
- typically of the form `regional-europe-west1` , `us-central` etc.
- - In order to obtain a valid list please consult the [Configuration section of the
- docs](U(https://cloud.google.com/spanner/docs/instances)).
- returned: success
- type: str
-displayName:
- description:
- - The descriptive name for this instance as it appears in UIs. Must be unique per
- project and between 4 and 30 characters in length.
- returned: success
- type: str
-nodeCount:
- description:
- - The number of nodes allocated to this instance.
- returned: success
- type: int
-labels:
- description:
- - 'An object containing a list of "key": value pairs.'
- - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.'
- returned: success
- type: dict
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- name=dict(required=True, type='str'),
- config=dict(required=True, type='str'),
- display_name=dict(required=True, type='str'),
- node_count=dict(default=1, type='int'),
- labels=dict(type='dict'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/spanner.admin']
-
- state = module.params['state']
-
- fetch = fetch_resource(module, self_link(module))
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module))
- fetch = fetch_resource(module, self_link(module))
- changed = True
- else:
- delete(module, self_link(module))
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module))
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link):
- auth = GcpSession(module, 'spanner')
- return wait_for_operation(module, auth.post(link, resource_to_create(module)))
-
-
-def update(module, link):
- module.fail_json(msg="Spanner objects can't be updated to ensure data safety")
-
-
-def delete(module, link):
- auth = GcpSession(module, 'spanner')
- return return_if_object(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'name': module.params.get('name'),
- u'config': module.params.get('config'),
- u'displayName': module.params.get('display_name'),
- u'nodeCount': module.params.get('node_count'),
- u'labels': module.params.get('labels'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, allow_not_found=True):
- auth = GcpSession(module, 'spanner')
- return return_if_object(module, auth.get(link), allow_not_found)
-
-
-def self_link(module):
- return "https://spanner.googleapis.com/v1/projects/{project}/instances/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://spanner.googleapis.com/v1/projects/{project}/instances".format(**module.params)
-
-
-def return_if_object(module, response, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- result = decode_response(result, module)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
- request = decode_response(request, module)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'name': module.params.get('name'),
- u'config': response.get(u'config'),
- u'displayName': response.get(u'displayName'),
- u'nodeCount': response.get(u'nodeCount'),
- u'labels': response.get(u'labels'),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://spanner.googleapis.com/v1/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response)
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['done'])
- wait_done = wait_for_completion(status, op_result, module)
- raise_if_errors(wait_done, ['error'], module)
- return navigate_hash(wait_done, ['response'])
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while not status:
- raise_if_errors(op_result, ['error'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, False)
- status = navigate_hash(op_result, ['done'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-def resource_to_create(module):
- instance = resource_to_request(module)
- instance['name'] = "projects/{0}/instances/{1}".format(module.params['project'], module.params['name'])
- instance['config'] = "projects/{0}/instanceConfigs/{1}".format(module.params['project'], instance['config'])
- return {'instanceId': module.params['name'], 'instance': instance}
-
-
-def resource_to_update(module):
- instance = resource_to_request(module)
- instance['name'] = "projects/{0}/instances/{1}".format(module.params['project'], module.params['name'])
- instance['config'] = "projects/{0}/instanceConfigs/{1}".format(module.params['project'], instance['config'])
- return {'instance': instance, 'fieldMask': "'name' ,'config' ,'displayName' ,'nodeCount' ,'labels'"}
-
-
-def decode_response(response, module):
- if not response:
- return response
-
- if '/operations/' in response['name']:
- return response
-
- response['name'] = response['name'].split('/')[-1]
- response['config'] = response['config'].split('/')[-1]
- return response
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_spanner_instance_info.py b/lib/ansible/modules/cloud/google/gcp_spanner_instance_info.py
deleted file mode 100644
index 35ae75b090..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_spanner_instance_info.py
+++ /dev/null
@@ -1,194 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_spanner_instance_info
-description:
-- Gather info for GCP Instance
-short_description: Gather info for GCP Instance
-version_added: '2.8'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on an instance
- gcp_spanner_instance_info:
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- name:
- description:
- - A unique identifier for the instance, which cannot be changed after the instance
- is created. The name must be between 6 and 30 characters in length.
- returned: success
- type: str
- config:
- description:
- - The name of the instance's configuration (similar but not quite the same as
- a region) which defines defines the geographic placement and replication of
- your databases in this instance. It determines where your data is stored.
- Values are typically of the form `regional-europe-west1` , `us-central` etc.
- - In order to obtain a valid list please consult the [Configuration section
- of the docs](U(https://cloud.google.com/spanner/docs/instances)).
- returned: success
- type: str
- displayName:
- description:
- - The descriptive name for this instance as it appears in UIs. Must be unique
- per project and between 4 and 30 characters in length.
- returned: success
- type: str
- nodeCount:
- description:
- - The number of nodes allocated to this instance.
- returned: success
- type: int
- labels:
- description:
- - 'An object containing a list of "key": value pairs.'
- - 'Example: { "name": "wrench", "mass": "1.3kg", "count": "3" }.'
- returned: success
- type: dict
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict())
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/spanner.admin']
-
- return_value = {'resources': fetch_list(module, collection(module))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://spanner.googleapis.com/v1/projects/{project}/instances".format(**module.params)
-
-
-def fetch_list(module, link):
- auth = GcpSession(module, 'spanner')
- return auth.list(link, return_if_object, array_name='instances')
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_sql_database.py b/lib/ansible/modules/cloud/google/gcp_sql_database.py
deleted file mode 100644
index 037b588acf..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_sql_database.py
+++ /dev/null
@@ -1,359 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_sql_database
-description:
-- Represents a SQL database inside the Cloud SQL instance, hosted in Google's cloud.
-short_description: Creates a GCP Database
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- charset:
- description:
- - The charset value. See MySQL's [Supported Character Sets and Collations](U(https://dev.mysql.com/doc/refman/5.7/en/charset-charsets.html))
- and Postgres' [Character Set Support](U(https://www.postgresql.org/docs/9.6/static/multibyte.html))
- for more details and supported values. Postgres databases only support a value
- of `UTF8` at creation time.
- required: false
- type: str
- collation:
- description:
- - The collation value. See MySQL's [Supported Character Sets and Collations](U(https://dev.mysql.com/doc/refman/5.7/en/charset-charsets.html))
- and Postgres' [Collation Support](U(https://www.postgresql.org/docs/9.6/static/collation.html))
- for more details and supported values. Postgres databases only support a value
- of `en_US.UTF8` at creation time.
- required: false
- type: str
- name:
- description:
- - The name of the database in the Cloud SQL instance.
- - This does not include the project ID or instance name.
- required: true
- type: str
- instance:
- description:
- - The name of the Cloud SQL instance. This does not include the project ID.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-'''
-
-EXAMPLES = '''
-- name: create a instance
- gcp_sql_instance:
- name: "{{resource_name}}-3"
- settings:
- ip_configuration:
- authorized_networks:
- - name: google dns server
- value: 8.8.8.8/32
- tier: db-n1-standard-1
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: instance
-
-- name: create a database
- gcp_sql_database:
- name: test_object
- charset: utf8
- instance: "{{ instance.name }}"
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-charset:
- description:
- - The charset value. See MySQL's [Supported Character Sets and Collations](U(https://dev.mysql.com/doc/refman/5.7/en/charset-charsets.html))
- and Postgres' [Character Set Support](U(https://www.postgresql.org/docs/9.6/static/multibyte.html))
- for more details and supported values. Postgres databases only support a value
- of `UTF8` at creation time.
- returned: success
- type: str
-collation:
- description:
- - The collation value. See MySQL's [Supported Character Sets and Collations](U(https://dev.mysql.com/doc/refman/5.7/en/charset-charsets.html))
- and Postgres' [Collation Support](U(https://www.postgresql.org/docs/9.6/static/collation.html))
- for more details and supported values. Postgres databases only support a value
- of `en_US.UTF8` at creation time.
- returned: success
- type: str
-name:
- description:
- - The name of the database in the Cloud SQL instance.
- - This does not include the project ID or instance name.
- returned: success
- type: str
-instance:
- description:
- - The name of the Cloud SQL instance. This does not include the project ID.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- charset=dict(type='str'),
- collation=dict(type='str'),
- name=dict(required=True, type='str'),
- instance=dict(required=True, type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/sqlservice.admin']
-
- state = module.params['state']
- kind = 'sql#database'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'sql')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind):
- module.fail_json(msg="SQL objects can't be updated to ensure data safety")
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'sql')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'sql#database',
- u'instance': module.params.get('instance'),
- u'charset': module.params.get('charset'),
- u'collation': module.params.get('collation'),
- u'name': module.params.get('name'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'sql')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/sql/v1beta4/projects/{project}/instances/{instance}/databases/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/sql/v1beta4/projects/{project}/instances/{instance}/databases".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- # SQL only: return on 403 if not exist
- if allow_not_found and response.status_code == 403:
- return None
-
- try:
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {u'charset': response.get(u'charset'), u'collation': response.get(u'collation'), u'name': module.params.get('name')}
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/sql/v1beta4/projects/{project}/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'sql#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'sql#database')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'sql#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_sql_database_info.py b/lib/ansible/modules/cloud/google/gcp_sql_database_info.py
deleted file mode 100644
index 7e9bed1791..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_sql_database_info.py
+++ /dev/null
@@ -1,194 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_sql_database_info
-description:
-- Gather info for GCP Database
-short_description: Gather info for GCP Database
-version_added: '2.8'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- instance:
- description:
- - The name of the Cloud SQL instance. This does not include the project ID.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a database
- gcp_sql_database_info:
- instance: "{{ instance.name }}"
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- charset:
- description:
- - The charset value. See MySQL's [Supported Character Sets and Collations](U(https://dev.mysql.com/doc/refman/5.7/en/charset-charsets.html))
- and Postgres' [Character Set Support](U(https://www.postgresql.org/docs/9.6/static/multibyte.html))
- for more details and supported values. Postgres databases only support a value
- of `UTF8` at creation time.
- returned: success
- type: str
- collation:
- description:
- - The collation value. See MySQL's [Supported Character Sets and Collations](U(https://dev.mysql.com/doc/refman/5.7/en/charset-charsets.html))
- and Postgres' [Collation Support](U(https://www.postgresql.org/docs/9.6/static/collation.html))
- for more details and supported values. Postgres databases only support a value
- of `en_US.UTF8` at creation time.
- returned: success
- type: str
- name:
- description:
- - The name of the database in the Cloud SQL instance.
- - This does not include the project ID or instance name.
- returned: success
- type: str
- instance:
- description:
- - The name of the Cloud SQL instance. This does not include the project ID.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(instance=dict(required=True, type='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/sqlservice.admin']
-
- return_value = {'resources': fetch_list(module, collection(module))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/sql/v1beta4/projects/{project}/instances/{instance}/databases".format(**module.params)
-
-
-def fetch_list(module, link):
- auth = GcpSession(module, 'sql')
- return auth.list(link, return_if_object, array_name='items')
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_sql_instance.py b/lib/ansible/modules/cloud/google/gcp_sql_instance.py
deleted file mode 100644
index 021eb56490..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_sql_instance.py
+++ /dev/null
@@ -1,1190 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_sql_instance
-description:
-- Represents a Cloud SQL instance. Cloud SQL instances are SQL databases hosted in
- Google's cloud. The Instances resource provides methods for common configuration
- and management tasks.
-short_description: Creates a GCP Instance
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- backend_type:
- description:
- - "* FIRST_GEN: First Generation instance. MySQL only."
- - "* SECOND_GEN: Second Generation instance or PostgreSQL instance."
- - "* EXTERNAL: A database server that is not managed by Google."
- - 'Some valid choices include: "FIRST_GEN", "SECOND_GEN", "EXTERNAL"'
- required: false
- type: str
- connection_name:
- description:
- - Connection name of the Cloud SQL instance used in connection strings.
- required: false
- type: str
- database_version:
- description:
- - The database engine type and version. For First Generation instances, can be
- MYSQL_5_5, or MYSQL_5_6. For Second Generation instances, can be MYSQL_5_6 or
- MYSQL_5_7. Defaults to MYSQL_5_6.
- - 'PostgreSQL instances: POSTGRES_9_6 The databaseVersion property can not be
- changed after instance creation.'
- - 'Some valid choices include: "MYSQL_5_5", "MYSQL_5_6", "MYSQL_5_7", "POSTGRES_9_6"'
- required: false
- type: str
- failover_replica:
- description:
- - The name and status of the failover replica. This property is applicable only
- to Second Generation instances.
- required: false
- type: dict
- suboptions:
- name:
- description:
- - The name of the failover replica. If specified at instance creation, a failover
- replica is created for the instance. The name doesn't include the project
- ID. This property is applicable only to Second Generation instances.
- required: false
- type: str
- instance_type:
- description:
- - The instance type. This can be one of the following.
- - "* CLOUD_SQL_INSTANCE: A Cloud SQL instance that is not replicating from a master."
- - "* ON_PREMISES_INSTANCE: An instance running on the customer's premises."
- - "* READ_REPLICA_INSTANCE: A Cloud SQL instance configured as a read-replica."
- - 'Some valid choices include: "CLOUD_SQL_INSTANCE", "ON_PREMISES_INSTANCE", "READ_REPLICA_INSTANCE"'
- required: false
- type: str
- ipv6_address:
- description:
- - The IPv6 address assigned to the instance. This property is applicable only
- to First Generation instances.
- required: false
- type: str
- master_instance_name:
- description:
- - The name of the instance which will act as master in the replication setup.
- required: false
- type: str
- max_disk_size:
- description:
- - The maximum disk size of the instance in bytes.
- required: false
- type: int
- name:
- description:
- - Name of the Cloud SQL instance. This does not include the project ID.
- required: true
- type: str
- region:
- description:
- - The geographical region. Defaults to us-central or us-central1 depending on
- the instance type (First Generation or Second Generation/PostgreSQL).
- required: false
- type: str
- replica_configuration:
- description:
- - Configuration specific to failover replicas and read replicas.
- required: false
- type: dict
- suboptions:
- failover_target:
- description:
- - Specifies if the replica is the failover target. If the field is set to
- true the replica will be designated as a failover replica.
- - In case the master instance fails, the replica instance will be promoted
- as the new master instance.
- - Only one replica can be specified as failover target, and the replica has
- to be in different zone with the master instance.
- required: false
- type: bool
- mysql_replica_configuration:
- description:
- - MySQL specific configuration when replicating from a MySQL on-premises master.
- Replication configuration information such as the username, password, certificates,
- and keys are not stored in the instance metadata. The configuration information
- is used only to set up the replication connection and is stored by MySQL
- in a file named master.info in the data directory.
- required: false
- type: dict
- suboptions:
- ca_certificate:
- description:
- - PEM representation of the trusted CA's x509 certificate.
- required: false
- type: str
- client_certificate:
- description:
- - PEM representation of the slave's x509 certificate .
- required: false
- type: str
- client_key:
- description:
- - PEM representation of the slave's private key. The corresponding public
- key is encoded in the client's certificate.
- required: false
- type: str
- connect_retry_interval:
- description:
- - Seconds to wait between connect retries. MySQL's default is 60 seconds.
- required: false
- type: int
- dump_file_path:
- description:
- - Path to a SQL dump file in Google Cloud Storage from which the slave
- instance is to be created. The URI is in the form gs://bucketName/fileName.
- Compressed gzip files (.gz) are also supported. Dumps should have the
- binlog coordinates from which replication should begin. This can be
- accomplished by setting --master-data to 1 when using mysqldump.
- required: false
- type: str
- master_heartbeat_period:
- description:
- - Interval in milliseconds between replication heartbeats.
- required: false
- type: int
- password:
- description:
- - The password for the replication connection.
- required: false
- type: str
- ssl_cipher:
- description:
- - A list of permissible ciphers to use for SSL encryption.
- required: false
- type: str
- username:
- description:
- - The username for the replication connection.
- required: false
- type: str
- verify_server_certificate:
- description:
- - Whether or not to check the master's Common Name value in the certificate
- that it sends during the SSL handshake.
- required: false
- type: bool
- replica_names:
- description:
- - The replicas of the instance.
- required: false
- type: list
- service_account_email_address:
- description:
- - The service account email address assigned to the instance. This property
- is applicable only to Second Generation instances.
- required: false
- type: str
- settings:
- description:
- - The user settings.
- required: false
- type: dict
- suboptions:
- database_flags:
- description:
- - The database flags passed to the instance at startup.
- required: false
- type: list
- version_added: '2.9'
- suboptions:
- name:
- description:
- - The name of the flag. These flags are passed at instance startup, so
- include both server options and system variables for MySQL. Flags should
- be specified with underscores, not hyphens.
- required: false
- type: str
- value:
- description:
- - The value of the flag. Booleans should be set to on for true and off
- for false. This field must be omitted if the flag doesn't take a value.
- required: false
- type: str
- ip_configuration:
- description:
- - The settings for IP Management. This allows to enable or disable the instance
- IP and manage which external networks can connect to the instance. The IPv4
- address cannot be disabled for Second Generation instances.
- required: false
- type: dict
- suboptions:
- ipv4_enabled:
- description:
- - Whether the instance should be assigned an IP address or not.
- required: false
- type: bool
- authorized_networks:
- description:
- - The list of external networks that are allowed to connect to the instance
- using the IP. In CIDR notation, also known as 'slash' notation (e.g.
- 192.168.100.0/24).
- required: false
- type: list
- suboptions:
- expiration_time:
- description:
- - The time when this access control entry expires in RFC 3339 format,
- for example 2012-11-15T16:19:00.094Z.
- required: false
- type: str
- name:
- description:
- - An optional label to identify this entry.
- required: false
- type: str
- value:
- description:
- - The whitelisted value for the access control list. For example,
- to grant access to a client from an external IP (IPv4 or IPv6) address
- or subnet, use that address or subnet here.
- required: false
- type: str
- require_ssl:
- description:
- - Whether the mysqld should default to 'REQUIRE X509' for users connecting
- over IP.
- required: false
- type: bool
- tier:
- description:
- - The tier or machine type for this instance, for example db-n1-standard-1.
- For MySQL instances, this field determines whether the instance is Second
- Generation (recommended) or First Generation.
- required: false
- type: str
- availability_type:
- description:
- - The availabilityType define if your postgres instance is run zonal or regional.
- - 'Some valid choices include: "ZONAL", "REGIONAL"'
- required: false
- type: str
- backup_configuration:
- description:
- - The daily backup configuration for the instance.
- required: false
- type: dict
- suboptions:
- enabled:
- description:
- - Enable Autobackup for your instance.
- required: false
- type: bool
- binary_log_enabled:
- description:
- - Whether binary log is enabled. If backup configuration is disabled,
- binary log must be disabled as well. MySQL only.
- required: false
- type: bool
- start_time:
- description:
- - Define the backup start time in UTC (HH:MM) .
- required: false
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-'''
-
-EXAMPLES = '''
-- name: create a instance
- gcp_sql_instance:
- name: "{{resource_name}}-2"
- settings:
- ip_configuration:
- authorized_networks:
- - name: google dns server
- value: 8.8.8.8/32
- tier: db-n1-standard-1
- region: us-central1
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-backendType:
- description:
- - "* FIRST_GEN: First Generation instance. MySQL only."
- - "* SECOND_GEN: Second Generation instance or PostgreSQL instance."
- - "* EXTERNAL: A database server that is not managed by Google."
- returned: success
- type: str
-connectionName:
- description:
- - Connection name of the Cloud SQL instance used in connection strings.
- returned: success
- type: str
-databaseVersion:
- description:
- - The database engine type and version. For First Generation instances, can be MYSQL_5_5,
- or MYSQL_5_6. For Second Generation instances, can be MYSQL_5_6 or MYSQL_5_7.
- Defaults to MYSQL_5_6.
- - 'PostgreSQL instances: POSTGRES_9_6 The databaseVersion property can not be changed
- after instance creation.'
- returned: success
- type: str
-failoverReplica:
- description:
- - The name and status of the failover replica. This property is applicable only
- to Second Generation instances.
- returned: success
- type: complex
- contains:
- available:
- description:
- - The availability status of the failover replica. A false status indicates
- that the failover replica is out of sync. The master can only failover to
- the failover replica when the status is true.
- returned: success
- type: bool
- name:
- description:
- - The name of the failover replica. If specified at instance creation, a failover
- replica is created for the instance. The name doesn't include the project
- ID. This property is applicable only to Second Generation instances.
- returned: success
- type: str
-instanceType:
- description:
- - The instance type. This can be one of the following.
- - "* CLOUD_SQL_INSTANCE: A Cloud SQL instance that is not replicating from a master."
- - "* ON_PREMISES_INSTANCE: An instance running on the customer's premises."
- - "* READ_REPLICA_INSTANCE: A Cloud SQL instance configured as a read-replica."
- returned: success
- type: str
-ipAddresses:
- description:
- - The assigned IP addresses for the instance.
- returned: success
- type: complex
- contains:
- ipAddress:
- description:
- - The IP address assigned.
- returned: success
- type: str
- timeToRetire:
- description:
- - The due time for this IP to be retired in RFC 3339 format, for example 2012-11-15T16:19:00.094Z.
- This field is only available when the IP is scheduled to be retired.
- returned: success
- type: str
- type:
- description:
- - The type of this IP address. A PRIMARY address is an address that can accept
- incoming connections. An OUTGOING address is the source address of connections
- originating from the instance, if supported.
- returned: success
- type: str
-ipv6Address:
- description:
- - The IPv6 address assigned to the instance. This property is applicable only to
- First Generation instances.
- returned: success
- type: str
-masterInstanceName:
- description:
- - The name of the instance which will act as master in the replication setup.
- returned: success
- type: str
-maxDiskSize:
- description:
- - The maximum disk size of the instance in bytes.
- returned: success
- type: int
-name:
- description:
- - Name of the Cloud SQL instance. This does not include the project ID.
- returned: success
- type: str
-region:
- description:
- - The geographical region. Defaults to us-central or us-central1 depending on the
- instance type (First Generation or Second Generation/PostgreSQL).
- returned: success
- type: str
-replicaConfiguration:
- description:
- - Configuration specific to failover replicas and read replicas.
- returned: success
- type: complex
- contains:
- failoverTarget:
- description:
- - Specifies if the replica is the failover target. If the field is set to true
- the replica will be designated as a failover replica.
- - In case the master instance fails, the replica instance will be promoted as
- the new master instance.
- - Only one replica can be specified as failover target, and the replica has
- to be in different zone with the master instance.
- returned: success
- type: bool
- mysqlReplicaConfiguration:
- description:
- - MySQL specific configuration when replicating from a MySQL on-premises master.
- Replication configuration information such as the username, password, certificates,
- and keys are not stored in the instance metadata. The configuration information
- is used only to set up the replication connection and is stored by MySQL in
- a file named master.info in the data directory.
- returned: success
- type: complex
- contains:
- caCertificate:
- description:
- - PEM representation of the trusted CA's x509 certificate.
- returned: success
- type: str
- clientCertificate:
- description:
- - PEM representation of the slave's x509 certificate .
- returned: success
- type: str
- clientKey:
- description:
- - PEM representation of the slave's private key. The corresponding public
- key is encoded in the client's certificate.
- returned: success
- type: str
- connectRetryInterval:
- description:
- - Seconds to wait between connect retries. MySQL's default is 60 seconds.
- returned: success
- type: int
- dumpFilePath:
- description:
- - Path to a SQL dump file in Google Cloud Storage from which the slave instance
- is to be created. The URI is in the form gs://bucketName/fileName. Compressed
- gzip files (.gz) are also supported. Dumps should have the binlog coordinates
- from which replication should begin. This can be accomplished by setting
- --master-data to 1 when using mysqldump.
- returned: success
- type: str
- masterHeartbeatPeriod:
- description:
- - Interval in milliseconds between replication heartbeats.
- returned: success
- type: int
- password:
- description:
- - The password for the replication connection.
- returned: success
- type: str
- sslCipher:
- description:
- - A list of permissible ciphers to use for SSL encryption.
- returned: success
- type: str
- username:
- description:
- - The username for the replication connection.
- returned: success
- type: str
- verifyServerCertificate:
- description:
- - Whether or not to check the master's Common Name value in the certificate
- that it sends during the SSL handshake.
- returned: success
- type: bool
- replicaNames:
- description:
- - The replicas of the instance.
- returned: success
- type: list
- serviceAccountEmailAddress:
- description:
- - The service account email address assigned to the instance. This property
- is applicable only to Second Generation instances.
- returned: success
- type: str
-settings:
- description:
- - The user settings.
- returned: success
- type: complex
- contains:
- databaseFlags:
- description:
- - The database flags passed to the instance at startup.
- returned: success
- type: complex
- contains:
- name:
- description:
- - The name of the flag. These flags are passed at instance startup, so include
- both server options and system variables for MySQL. Flags should be specified
- with underscores, not hyphens.
- returned: success
- type: str
- value:
- description:
- - The value of the flag. Booleans should be set to on for true and off for
- false. This field must be omitted if the flag doesn't take a value.
- returned: success
- type: str
- ipConfiguration:
- description:
- - The settings for IP Management. This allows to enable or disable the instance
- IP and manage which external networks can connect to the instance. The IPv4
- address cannot be disabled for Second Generation instances.
- returned: success
- type: complex
- contains:
- ipv4Enabled:
- description:
- - Whether the instance should be assigned an IP address or not.
- returned: success
- type: bool
- authorizedNetworks:
- description:
- - The list of external networks that are allowed to connect to the instance
- using the IP. In CIDR notation, also known as 'slash' notation (e.g. 192.168.100.0/24).
- returned: success
- type: complex
- contains:
- expirationTime:
- description:
- - The time when this access control entry expires in RFC 3339 format,
- for example 2012-11-15T16:19:00.094Z.
- returned: success
- type: str
- name:
- description:
- - An optional label to identify this entry.
- returned: success
- type: str
- value:
- description:
- - The whitelisted value for the access control list. For example, to
- grant access to a client from an external IP (IPv4 or IPv6) address
- or subnet, use that address or subnet here.
- returned: success
- type: str
- requireSsl:
- description:
- - Whether the mysqld should default to 'REQUIRE X509' for users connecting
- over IP.
- returned: success
- type: bool
- tier:
- description:
- - The tier or machine type for this instance, for example db-n1-standard-1.
- For MySQL instances, this field determines whether the instance is Second
- Generation (recommended) or First Generation.
- returned: success
- type: str
- availabilityType:
- description:
- - The availabilityType define if your postgres instance is run zonal or regional.
- returned: success
- type: str
- backupConfiguration:
- description:
- - The daily backup configuration for the instance.
- returned: success
- type: complex
- contains:
- enabled:
- description:
- - Enable Autobackup for your instance.
- returned: success
- type: bool
- binaryLogEnabled:
- description:
- - Whether binary log is enabled. If backup configuration is disabled, binary
- log must be disabled as well. MySQL only.
- returned: success
- type: bool
- startTime:
- description:
- - Define the backup start time in UTC (HH:MM) .
- returned: success
- type: str
- settingsVersion:
- description:
- - The version of instance settings. This is a required field for update method
- to make sure concurrent updates are handled properly. During update, use the
- most recent settingsVersion value for this instance and do not try to update
- this value.
- returned: success
- type: int
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- backend_type=dict(type='str'),
- connection_name=dict(type='str'),
- database_version=dict(type='str'),
- failover_replica=dict(type='dict', options=dict(name=dict(type='str'))),
- instance_type=dict(type='str'),
- ipv6_address=dict(type='str'),
- master_instance_name=dict(type='str'),
- max_disk_size=dict(type='int'),
- name=dict(required=True, type='str'),
- region=dict(type='str'),
- replica_configuration=dict(
- type='dict',
- options=dict(
- failover_target=dict(type='bool'),
- mysql_replica_configuration=dict(
- type='dict',
- options=dict(
- ca_certificate=dict(type='str'),
- client_certificate=dict(type='str'),
- client_key=dict(type='str'),
- connect_retry_interval=dict(type='int'),
- dump_file_path=dict(type='str'),
- master_heartbeat_period=dict(type='int'),
- password=dict(type='str'),
- ssl_cipher=dict(type='str'),
- username=dict(type='str'),
- verify_server_certificate=dict(type='bool'),
- ),
- ),
- replica_names=dict(type='list', elements='str'),
- service_account_email_address=dict(type='str'),
- ),
- ),
- settings=dict(
- type='dict',
- options=dict(
- database_flags=dict(type='list', elements='dict', options=dict(name=dict(type='str'), value=dict(type='str'))),
- ip_configuration=dict(
- type='dict',
- options=dict(
- ipv4_enabled=dict(type='bool'),
- authorized_networks=dict(
- type='list', elements='dict', options=dict(expiration_time=dict(type='str'), name=dict(type='str'), value=dict(type='str'))
- ),
- require_ssl=dict(type='bool'),
- ),
- ),
- tier=dict(type='str'),
- availability_type=dict(type='str'),
- backup_configuration=dict(
- type='dict', options=dict(enabled=dict(type='bool'), binary_log_enabled=dict(type='bool'), start_time=dict(type='str'))
- ),
- ),
- ),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/sqlservice.admin']
-
- state = module.params['state']
- kind = 'sql#instance'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind, fetch)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind, fetch)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'sql')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind, fetch):
- module.fail_json(msg="SQL objects can't be updated to ensure data safety")
-
-
-def delete(module, link, kind, fetch):
- auth = GcpSession(module, 'sql')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'sql#instance',
- u'backendType': module.params.get('backend_type'),
- u'connectionName': module.params.get('connection_name'),
- u'databaseVersion': module.params.get('database_version'),
- u'failoverReplica': InstanceFailoverreplica(module.params.get('failover_replica', {}), module).to_request(),
- u'instanceType': module.params.get('instance_type'),
- u'ipv6Address': module.params.get('ipv6_address'),
- u'masterInstanceName': module.params.get('master_instance_name'),
- u'maxDiskSize': module.params.get('max_disk_size'),
- u'name': module.params.get('name'),
- u'region': module.params.get('region'),
- u'replicaConfiguration': InstanceReplicaconfiguration(module.params.get('replica_configuration', {}), module).to_request(),
- u'settings': InstanceSettings(module.params.get('settings', {}), module).to_request(),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'sql')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/sql/v1beta4/projects/{project}/instances/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/sql/v1beta4/projects/{project}/instances".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- # SQL only: return on 403 if not exist
- if allow_not_found and response.status_code == 403:
- return None
-
- try:
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'backendType': response.get(u'backendType'),
- u'connectionName': response.get(u'connectionName'),
- u'databaseVersion': response.get(u'databaseVersion'),
- u'failoverReplica': InstanceFailoverreplica(response.get(u'failoverReplica', {}), module).from_response(),
- u'instanceType': response.get(u'instanceType'),
- u'ipAddresses': InstanceIpaddressesArray(response.get(u'ipAddresses', []), module).from_response(),
- u'ipv6Address': response.get(u'ipv6Address'),
- u'masterInstanceName': response.get(u'masterInstanceName'),
- u'maxDiskSize': response.get(u'maxDiskSize'),
- u'name': response.get(u'name'),
- u'region': response.get(u'region'),
- u'replicaConfiguration': InstanceReplicaconfiguration(response.get(u'replicaConfiguration', {}), module).from_response(),
- u'settings': InstanceSettings(response.get(u'settings', {}), module).from_response(),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/sql/v1beta4/projects/{project}/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'sql#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_done = wait_for_completion(status, op_result, module)
- return fetch_resource(module, navigate_hash(wait_done, ['targetLink']), 'sql#instance')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'sql#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-class InstanceFailoverreplica(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'name': self.request.get('name')})
-
- def from_response(self):
- return remove_nones_from_dict({u'name': self.request.get(u'name')})
-
-
-class InstanceIpaddressesArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'ipAddress': item.get('ip_address'), u'timeToRetire': item.get('time_to_retire'), u'type': item.get('type')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'ipAddress': item.get(u'ipAddress'), u'timeToRetire': item.get(u'timeToRetire'), u'type': item.get(u'type')})
-
-
-class InstanceReplicaconfiguration(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'failoverTarget': self.request.get('failover_target'),
- u'mysqlReplicaConfiguration': InstanceMysqlreplicaconfiguration(self.request.get('mysql_replica_configuration', {}), self.module).to_request(),
- u'replicaNames': self.request.get('replica_names'),
- u'serviceAccountEmailAddress': self.request.get('service_account_email_address'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'failoverTarget': self.request.get(u'failoverTarget'),
- u'mysqlReplicaConfiguration': InstanceMysqlreplicaconfiguration(
- self.request.get(u'mysqlReplicaConfiguration', {}), self.module
- ).from_response(),
- u'replicaNames': self.request.get(u'replicaNames'),
- u'serviceAccountEmailAddress': self.request.get(u'serviceAccountEmailAddress'),
- }
- )
-
-
-class InstanceMysqlreplicaconfiguration(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'caCertificate': self.request.get('ca_certificate'),
- u'clientCertificate': self.request.get('client_certificate'),
- u'clientKey': self.request.get('client_key'),
- u'connectRetryInterval': self.request.get('connect_retry_interval'),
- u'dumpFilePath': self.request.get('dump_file_path'),
- u'masterHeartbeatPeriod': self.request.get('master_heartbeat_period'),
- u'password': self.request.get('password'),
- u'sslCipher': self.request.get('ssl_cipher'),
- u'username': self.request.get('username'),
- u'verifyServerCertificate': self.request.get('verify_server_certificate'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'caCertificate': self.request.get(u'caCertificate'),
- u'clientCertificate': self.request.get(u'clientCertificate'),
- u'clientKey': self.request.get(u'clientKey'),
- u'connectRetryInterval': self.request.get(u'connectRetryInterval'),
- u'dumpFilePath': self.request.get(u'dumpFilePath'),
- u'masterHeartbeatPeriod': self.request.get(u'masterHeartbeatPeriod'),
- u'password': self.request.get(u'password'),
- u'sslCipher': self.request.get(u'sslCipher'),
- u'username': self.request.get(u'username'),
- u'verifyServerCertificate': self.request.get(u'verifyServerCertificate'),
- }
- )
-
-
-class InstanceSettings(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'databaseFlags': InstanceDatabaseflagsArray(self.request.get('database_flags', []), self.module).to_request(),
- u'ipConfiguration': InstanceIpconfiguration(self.request.get('ip_configuration', {}), self.module).to_request(),
- u'tier': self.request.get('tier'),
- u'availabilityType': self.request.get('availability_type'),
- u'backupConfiguration': InstanceBackupconfiguration(self.request.get('backup_configuration', {}), self.module).to_request(),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'databaseFlags': InstanceDatabaseflagsArray(self.request.get(u'databaseFlags', []), self.module).from_response(),
- u'ipConfiguration': InstanceIpconfiguration(self.request.get(u'ipConfiguration', {}), self.module).from_response(),
- u'tier': self.request.get(u'tier'),
- u'availabilityType': self.request.get(u'availabilityType'),
- u'backupConfiguration': InstanceBackupconfiguration(self.request.get(u'backupConfiguration', {}), self.module).from_response(),
- }
- )
-
-
-class InstanceDatabaseflagsArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'name': item.get('name'), u'value': item.get('value')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'name': item.get(u'name'), u'value': item.get(u'value')})
-
-
-class InstanceIpconfiguration(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'ipv4Enabled': self.request.get('ipv4_enabled'),
- u'authorizedNetworks': InstanceAuthorizednetworksArray(self.request.get('authorized_networks', []), self.module).to_request(),
- u'requireSsl': self.request.get('require_ssl'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'ipv4Enabled': self.request.get(u'ipv4Enabled'),
- u'authorizedNetworks': InstanceAuthorizednetworksArray(self.request.get(u'authorizedNetworks', []), self.module).from_response(),
- u'requireSsl': self.request.get(u'requireSsl'),
- }
- )
-
-
-class InstanceAuthorizednetworksArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({u'expirationTime': item.get('expiration_time'), u'name': item.get('name'), u'value': item.get('value')})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({u'expirationTime': item.get(u'expirationTime'), u'name': item.get(u'name'), u'value': item.get(u'value')})
-
-
-class InstanceBackupconfiguration(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {u'enabled': self.request.get('enabled'), u'binaryLogEnabled': self.request.get('binary_log_enabled'), u'startTime': self.request.get('start_time')}
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {u'enabled': self.request.get(u'enabled'), u'binaryLogEnabled': self.request.get(u'binaryLogEnabled'), u'startTime': self.request.get(u'startTime')}
- )
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_sql_instance_info.py b/lib/ansible/modules/cloud/google/gcp_sql_instance_info.py
deleted file mode 100644
index c249bfc48a..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_sql_instance_info.py
+++ /dev/null
@@ -1,471 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_sql_instance_info
-description:
-- Gather info for GCP Instance
-short_description: Gather info for GCP Instance
-version_added: '2.8'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on an instance
- gcp_sql_instance_info:
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- backendType:
- description:
- - "* FIRST_GEN: First Generation instance. MySQL only."
- - "* SECOND_GEN: Second Generation instance or PostgreSQL instance."
- - "* EXTERNAL: A database server that is not managed by Google."
- returned: success
- type: str
- connectionName:
- description:
- - Connection name of the Cloud SQL instance used in connection strings.
- returned: success
- type: str
- databaseVersion:
- description:
- - The database engine type and version. For First Generation instances, can
- be MYSQL_5_5, or MYSQL_5_6. For Second Generation instances, can be MYSQL_5_6
- or MYSQL_5_7. Defaults to MYSQL_5_6.
- - 'PostgreSQL instances: POSTGRES_9_6 The databaseVersion property can not be
- changed after instance creation.'
- returned: success
- type: str
- failoverReplica:
- description:
- - The name and status of the failover replica. This property is applicable only
- to Second Generation instances.
- returned: success
- type: complex
- contains:
- available:
- description:
- - The availability status of the failover replica. A false status indicates
- that the failover replica is out of sync. The master can only failover
- to the failover replica when the status is true.
- returned: success
- type: bool
- name:
- description:
- - The name of the failover replica. If specified at instance creation, a
- failover replica is created for the instance. The name doesn't include
- the project ID. This property is applicable only to Second Generation
- instances.
- returned: success
- type: str
- instanceType:
- description:
- - The instance type. This can be one of the following.
- - "* CLOUD_SQL_INSTANCE: A Cloud SQL instance that is not replicating from a
- master."
- - "* ON_PREMISES_INSTANCE: An instance running on the customer's premises."
- - "* READ_REPLICA_INSTANCE: A Cloud SQL instance configured as a read-replica."
- returned: success
- type: str
- ipAddresses:
- description:
- - The assigned IP addresses for the instance.
- returned: success
- type: complex
- contains:
- ipAddress:
- description:
- - The IP address assigned.
- returned: success
- type: str
- timeToRetire:
- description:
- - The due time for this IP to be retired in RFC 3339 format, for example
- 2012-11-15T16:19:00.094Z. This field is only available when the IP is
- scheduled to be retired.
- returned: success
- type: str
- type:
- description:
- - The type of this IP address. A PRIMARY address is an address that can
- accept incoming connections. An OUTGOING address is the source address
- of connections originating from the instance, if supported.
- returned: success
- type: str
- ipv6Address:
- description:
- - The IPv6 address assigned to the instance. This property is applicable only
- to First Generation instances.
- returned: success
- type: str
- masterInstanceName:
- description:
- - The name of the instance which will act as master in the replication setup.
- returned: success
- type: str
- maxDiskSize:
- description:
- - The maximum disk size of the instance in bytes.
- returned: success
- type: int
- name:
- description:
- - Name of the Cloud SQL instance. This does not include the project ID.
- returned: success
- type: str
- region:
- description:
- - The geographical region. Defaults to us-central or us-central1 depending on
- the instance type (First Generation or Second Generation/PostgreSQL).
- returned: success
- type: str
- replicaConfiguration:
- description:
- - Configuration specific to failover replicas and read replicas.
- returned: success
- type: complex
- contains:
- failoverTarget:
- description:
- - Specifies if the replica is the failover target. If the field is set to
- true the replica will be designated as a failover replica.
- - In case the master instance fails, the replica instance will be promoted
- as the new master instance.
- - Only one replica can be specified as failover target, and the replica
- has to be in different zone with the master instance.
- returned: success
- type: bool
- mysqlReplicaConfiguration:
- description:
- - MySQL specific configuration when replicating from a MySQL on-premises
- master. Replication configuration information such as the username, password,
- certificates, and keys are not stored in the instance metadata. The configuration
- information is used only to set up the replication connection and is stored
- by MySQL in a file named master.info in the data directory.
- returned: success
- type: complex
- contains:
- caCertificate:
- description:
- - PEM representation of the trusted CA's x509 certificate.
- returned: success
- type: str
- clientCertificate:
- description:
- - PEM representation of the slave's x509 certificate .
- returned: success
- type: str
- clientKey:
- description:
- - PEM representation of the slave's private key. The corresponding public
- key is encoded in the client's certificate.
- returned: success
- type: str
- connectRetryInterval:
- description:
- - Seconds to wait between connect retries. MySQL's default is 60 seconds.
- returned: success
- type: int
- dumpFilePath:
- description:
- - Path to a SQL dump file in Google Cloud Storage from which the slave
- instance is to be created. The URI is in the form gs://bucketName/fileName.
- Compressed gzip files (.gz) are also supported. Dumps should have
- the binlog coordinates from which replication should begin. This can
- be accomplished by setting --master-data to 1 when using mysqldump.
- returned: success
- type: str
- masterHeartbeatPeriod:
- description:
- - Interval in milliseconds between replication heartbeats.
- returned: success
- type: int
- password:
- description:
- - The password for the replication connection.
- returned: success
- type: str
- sslCipher:
- description:
- - A list of permissible ciphers to use for SSL encryption.
- returned: success
- type: str
- username:
- description:
- - The username for the replication connection.
- returned: success
- type: str
- verifyServerCertificate:
- description:
- - Whether or not to check the master's Common Name value in the certificate
- that it sends during the SSL handshake.
- returned: success
- type: bool
- replicaNames:
- description:
- - The replicas of the instance.
- returned: success
- type: list
- serviceAccountEmailAddress:
- description:
- - The service account email address assigned to the instance. This property
- is applicable only to Second Generation instances.
- returned: success
- type: str
- settings:
- description:
- - The user settings.
- returned: success
- type: complex
- contains:
- databaseFlags:
- description:
- - The database flags passed to the instance at startup.
- returned: success
- type: complex
- contains:
- name:
- description:
- - The name of the flag. These flags are passed at instance startup,
- so include both server options and system variables for MySQL. Flags
- should be specified with underscores, not hyphens.
- returned: success
- type: str
- value:
- description:
- - The value of the flag. Booleans should be set to on for true and off
- for false. This field must be omitted if the flag doesn't take a value.
- returned: success
- type: str
- ipConfiguration:
- description:
- - The settings for IP Management. This allows to enable or disable the instance
- IP and manage which external networks can connect to the instance. The
- IPv4 address cannot be disabled for Second Generation instances.
- returned: success
- type: complex
- contains:
- ipv4Enabled:
- description:
- - Whether the instance should be assigned an IP address or not.
- returned: success
- type: bool
- authorizedNetworks:
- description:
- - The list of external networks that are allowed to connect to the instance
- using the IP. In CIDR notation, also known as 'slash' notation (e.g.
- 192.168.100.0/24).
- returned: success
- type: complex
- contains:
- expirationTime:
- description:
- - The time when this access control entry expires in RFC 3339 format,
- for example 2012-11-15T16:19:00.094Z.
- returned: success
- type: str
- name:
- description:
- - An optional label to identify this entry.
- returned: success
- type: str
- value:
- description:
- - The whitelisted value for the access control list. For example,
- to grant access to a client from an external IP (IPv4 or IPv6)
- address or subnet, use that address or subnet here.
- returned: success
- type: str
- requireSsl:
- description:
- - Whether the mysqld should default to 'REQUIRE X509' for users connecting
- over IP.
- returned: success
- type: bool
- tier:
- description:
- - The tier or machine type for this instance, for example db-n1-standard-1.
- For MySQL instances, this field determines whether the instance is Second
- Generation (recommended) or First Generation.
- returned: success
- type: str
- availabilityType:
- description:
- - The availabilityType define if your postgres instance is run zonal or
- regional.
- returned: success
- type: str
- backupConfiguration:
- description:
- - The daily backup configuration for the instance.
- returned: success
- type: complex
- contains:
- enabled:
- description:
- - Enable Autobackup for your instance.
- returned: success
- type: bool
- binaryLogEnabled:
- description:
- - Whether binary log is enabled. If backup configuration is disabled,
- binary log must be disabled as well. MySQL only.
- returned: success
- type: bool
- startTime:
- description:
- - Define the backup start time in UTC (HH:MM) .
- returned: success
- type: str
- settingsVersion:
- description:
- - The version of instance settings. This is a required field for update
- method to make sure concurrent updates are handled properly. During update,
- use the most recent settingsVersion value for this instance and do not
- try to update this value.
- returned: success
- type: int
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict())
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/sqlservice.admin']
-
- return_value = {'resources': fetch_list(module, collection(module))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://www.googleapis.com/sql/v1beta4/projects/{project}/instances".format(**module.params)
-
-
-def fetch_list(module, link):
- auth = GcpSession(module, 'sql')
- return auth.list(link, return_if_object, array_name='items')
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_sql_user.py b/lib/ansible/modules/cloud/google/gcp_sql_user.py
deleted file mode 100644
index f9622dba92..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_sql_user.py
+++ /dev/null
@@ -1,392 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_sql_user
-description:
-- The Users resource represents a database user in a Cloud SQL instance.
-short_description: Creates a GCP User
-version_added: '2.7'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- host:
- description:
- - The host name from which the user can connect. For insert operations, host defaults
- to an empty string. For update operations, host is specified as part of the
- request URL. The host name cannot be updated after insertion.
- required: true
- type: str
- name:
- description:
- - The name of the user in the Cloud SQL instance.
- required: true
- type: str
- instance:
- description:
- - The name of the Cloud SQL instance. This does not include the project ID.
- - 'This field represents a link to a Instance resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''name'' and value of
- your resource''s name Alternatively, you can add `register: name-of-resource`
- to a gcp_sql_instance task and then set this instance field to "{{ name-of-resource
- }}"'
- required: true
- type: dict
- password:
- description:
- - The password for the user.
- required: false
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-'''
-
-EXAMPLES = '''
-- name: create a instance
- gcp_sql_instance:
- name: "{{resource_name}}-1"
- settings:
- ip_configuration:
- authorized_networks:
- - name: google dns server
- value: 8.8.8.8/32
- tier: db-n1-standard-1
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: instance
-
-- name: create a user
- gcp_sql_user:
- name: test-user
- host: 10.1.2.3
- password: secret-password
- instance: "{{ instance }}"
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-host:
- description:
- - The host name from which the user can connect. For insert operations, host defaults
- to an empty string. For update operations, host is specified as part of the request
- URL. The host name cannot be updated after insertion.
- returned: success
- type: str
-name:
- description:
- - The name of the user in the Cloud SQL instance.
- returned: success
- type: str
-instance:
- description:
- - The name of the Cloud SQL instance. This does not include the project ID.
- returned: success
- type: dict
-password:
- description:
- - The password for the user.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- host=dict(required=True, type='str'),
- name=dict(required=True, type='str'),
- instance=dict(required=True, type='dict'),
- password=dict(type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/sqlservice.admin']
-
- state = module.params['state']
- kind = 'sql#user'
-
- fetch = fetch_wrapped_resource(module, 'sql#user', 'sql#usersList', 'items')
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'sql')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, kind):
- auth = GcpSession(module, 'sql')
- return wait_for_operation(module, auth.put(link, resource_to_request(module)))
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'sql')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {u'kind': 'sql#user', u'password': module.params.get('password'), u'host': module.params.get('host'), u'name': module.params.get('name')}
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def unwrap_resource_filter(module):
- return {'name': module.params['name'], 'host': module.params['host']}
-
-
-def unwrap_resource(result, module):
- query_predicate = unwrap_resource_filter(module)
- matched_items = []
- for item in result:
- if all(item[k] == query_predicate[k] for k in query_predicate.keys()):
- matched_items.append(item)
- if len(matched_items) > 1:
- module.fail_json(msg="More than 1 result found: %s" % matched_items)
-
- if matched_items:
- return matched_items[0]
- else:
- return None
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'sql')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def fetch_wrapped_resource(module, kind, wrap_kind, wrap_path):
- result = fetch_resource(module, self_link(module), wrap_kind)
- if result is None or wrap_path not in result:
- return None
-
- result = unwrap_resource(result[wrap_path], module)
-
- if result is None:
- return None
-
- if result['kind'] != kind:
- module.fail_json(msg="Incorrect result: {kind}".format(**result))
-
- return result
-
-
-def self_link(module):
- res = {
- 'project': module.params['project'],
- 'instance': replace_resource_dict(module.params['instance'], 'name'),
- 'name': module.params['name'],
- 'host': module.params['host'],
- }
- return "https://www.googleapis.com/sql/v1beta4/projects/{project}/instances/{instance}/users?name={name}&host={host}".format(**res)
-
-
-def collection(module):
- res = {'project': module.params['project'], 'instance': replace_resource_dict(module.params['instance'], 'name')}
- return "https://www.googleapis.com/sql/v1beta4/projects/{project}/instances/{instance}/users".format(**res)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- # SQL only: return on 403 if not exist
- if allow_not_found and response.status_code == 403:
- return None
-
- try:
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {u'host': response.get(u'host'), u'name': response.get(u'name')}
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://www.googleapis.com/sql/v1beta4/projects/{project}/operations/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response, 'sql#operation')
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['status'])
- wait_for_completion(status, op_result, module)
- return fetch_wrapped_resource(module, 'sql#user', 'sql#usersList', 'items')
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while status != 'DONE':
- raise_if_errors(op_result, ['error', 'errors'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, 'sql#operation', False)
- status = navigate_hash(op_result, ['status'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_sql_user_info.py b/lib/ansible/modules/cloud/google/gcp_sql_user_info.py
deleted file mode 100644
index 23a77bfd53..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_sql_user_info.py
+++ /dev/null
@@ -1,195 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_sql_user_info
-description:
-- Gather info for GCP User
-short_description: Gather info for GCP User
-version_added: '2.8'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- instance:
- description:
- - The name of the Cloud SQL instance. This does not include the project ID.
- - 'This field represents a link to a Instance resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''name'' and value of
- your resource''s name Alternatively, you can add `register: name-of-resource`
- to a gcp_sql_instance task and then set this instance field to "{{ name-of-resource
- }}"'
- required: true
- type: dict
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a user
- gcp_sql_user_info:
- instance: "{{ instance }}"
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- host:
- description:
- - The host name from which the user can connect. For insert operations, host
- defaults to an empty string. For update operations, host is specified as part
- of the request URL. The host name cannot be updated after insertion.
- returned: success
- type: str
- name:
- description:
- - The name of the user in the Cloud SQL instance.
- returned: success
- type: str
- instance:
- description:
- - The name of the Cloud SQL instance. This does not include the project ID.
- returned: success
- type: dict
- password:
- description:
- - The password for the user.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(instance=dict(required=True, type='dict')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/sqlservice.admin']
-
- return_value = {'resources': fetch_list(module, collection(module))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- res = {'project': module.params['project'], 'instance': replace_resource_dict(module.params['instance'], 'name')}
- return "https://www.googleapis.com/sql/v1beta4/projects/{project}/instances/{instance}/users".format(**res)
-
-
-def fetch_list(module, link):
- auth = GcpSession(module, 'sql')
- return auth.list(link, return_if_object, array_name='items')
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_storage_bucket.py b/lib/ansible/modules/cloud/google/gcp_storage_bucket.py
deleted file mode 100644
index 7f4fb8c640..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_storage_bucket.py
+++ /dev/null
@@ -1,1318 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_storage_bucket
-description:
-- The Buckets resource represents a bucket in Google Cloud Storage. There is a single
- global namespace shared by all buckets. For more information, see Bucket Name Requirements.
-- Buckets contain objects which can be accessed by their own methods. In addition
- to the acl property, buckets contain bucketAccessControls, for use in fine-grained
- manipulation of an existing bucket's access controls.
-- A bucket is always owned by the project team owners group.
-short_description: Creates a GCP Bucket
-version_added: '2.6'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- acl:
- description:
- - Access controls on the bucket.
- required: false
- type: list
- suboptions:
- bucket:
- description:
- - The name of the bucket.
- - 'This field represents a link to a Bucket resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''name'' and value
- of your resource''s name Alternatively, you can add `register: name-of-resource`
- to a gcp_storage_bucket task and then set this bucket field to "{{ name-of-resource
- }}"'
- required: true
- type: dict
- entity:
- description:
- - 'The entity holding the permission, in one of the following forms: user-userId
- user-email group-groupId group-email domain-domain project-team-projectId
- allUsers allAuthenticatedUsers Examples: The user liz@example.com would
- be user-liz@example.com.'
- - The group example@googlegroups.com would be group-example@googlegroups.com.
- - To refer to all members of the Google Apps for Business domain example.com,
- the entity would be domain-example.com.
- required: true
- type: str
- entity_id:
- description:
- - The ID for the entity.
- required: false
- type: str
- project_team:
- description:
- - The project team associated with the entity.
- required: false
- type: dict
- suboptions:
- project_number:
- description:
- - The project team associated with the entity.
- required: false
- type: str
- team:
- description:
- - The team.
- - 'Some valid choices include: "editors", "owners", "viewers"'
- required: false
- type: str
- role:
- description:
- - The access permission for the entity.
- - 'Some valid choices include: "OWNER", "READER", "WRITER"'
- required: false
- type: str
- cors:
- description:
- - The bucket's Cross-Origin Resource Sharing (CORS) configuration.
- required: false
- type: list
- suboptions:
- max_age_seconds:
- description:
- - The value, in seconds, to return in the Access-Control-Max-Age header used
- in preflight responses.
- required: false
- type: int
- method:
- description:
- - 'The list of HTTP methods on which to include CORS response headers, (GET,
- OPTIONS, POST, etc) Note: "*" is permitted in the list of methods, and means
- "any method".'
- required: false
- type: list
- origin:
- description:
- - The list of Origins eligible to receive CORS response headers.
- - 'Note: "*" is permitted in the list of origins, and means "any Origin".'
- required: false
- type: list
- response_header:
- description:
- - The list of HTTP headers other than the simple response headers to give
- permission for the user-agent to share across domains.
- required: false
- type: list
- default_object_acl:
- description:
- - Default access controls to apply to new objects when no ACL is provided.
- required: false
- type: list
- version_added: '2.7'
- suboptions:
- bucket:
- description:
- - The name of the bucket.
- - 'This field represents a link to a Bucket resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''name'' and value
- of your resource''s name Alternatively, you can add `register: name-of-resource`
- to a gcp_storage_bucket task and then set this bucket field to "{{ name-of-resource
- }}"'
- required: true
- type: dict
- entity:
- description:
- - 'The entity holding the permission, in one of the following forms: * user-{{userId}}
- * user-{{email}} (such as "user-liz@example.com") * group-{{groupId}} *
- group-{{email}} (such as "group-example@googlegroups.com") * domain-{{domain}}
- (such as "domain-example.com") * project-team-{{projectId}} * allUsers *
- allAuthenticatedUsers .'
- required: true
- type: str
- object:
- description:
- - The name of the object, if applied to an object.
- required: false
- type: str
- role:
- description:
- - The access permission for the entity.
- - 'Some valid choices include: "OWNER", "READER"'
- required: true
- type: str
- lifecycle:
- description:
- - The bucket's lifecycle configuration.
- - See U(https://developers.google.com/storage/docs/lifecycle) for more information.
- required: false
- type: dict
- suboptions:
- rule:
- description:
- - A lifecycle management rule, which is made of an action to take and the
- condition(s) under which the action will be taken.
- required: false
- type: list
- suboptions:
- action:
- description:
- - The action to take.
- required: false
- type: dict
- suboptions:
- storage_class:
- description:
- - Target storage class. Required iff the type of the action is SetStorageClass.
- required: false
- type: str
- type:
- description:
- - Type of the action. Currently, only Delete and SetStorageClass are
- supported.
- - 'Some valid choices include: "Delete", "SetStorageClass"'
- required: false
- type: str
- condition:
- description:
- - The condition(s) under which the action will be taken.
- required: false
- type: dict
- suboptions:
- age_days:
- description:
- - Age of an object (in days). This condition is satisfied when an
- object reaches the specified age.
- required: false
- type: int
- created_before:
- description:
- - A date in RFC 3339 format with only the date part (for instance,
- "2013-01-15"). This condition is satisfied when an object is created
- before midnight of the specified date in UTC.
- required: false
- type: str
- is_live:
- description:
- - Relevant only for versioned objects. If the value is true, this
- condition matches live objects; if the value is false, it matches
- archived objects.
- required: false
- type: bool
- matches_storage_class:
- description:
- - Objects having any of the storage classes specified by this condition
- will be matched. Values include MULTI_REGIONAL, REGIONAL, NEARLINE,
- COLDLINE, STANDARD, and DURABLE_REDUCED_AVAILABILITY.
- required: false
- type: list
- num_newer_versions:
- description:
- - Relevant only for versioned objects. If the value is N, this condition
- is satisfied when there are at least N versions (including the live
- version) newer than this version of the object.
- required: false
- type: int
- location:
- description:
- - The location of the bucket. Object data for objects in the bucket resides in
- physical storage within this region. Defaults to US. See the developer's guide
- for the authoritative list.
- required: false
- type: str
- logging:
- description:
- - The bucket's logging configuration, which defines the destination bucket and
- optional name prefix for the current bucket's logs.
- required: false
- type: dict
- suboptions:
- log_bucket:
- description:
- - The destination bucket where the current bucket's logs should be placed.
- required: false
- type: str
- log_object_prefix:
- description:
- - A prefix for log object names.
- required: false
- type: str
- metageneration:
- description:
- - The metadata generation of this bucket.
- required: false
- type: int
- name:
- description:
- - The name of the bucket.
- required: false
- type: str
- owner:
- description:
- - The owner of the bucket. This is always the project team's owner group.
- required: false
- type: dict
- suboptions:
- entity:
- description:
- - The entity, in the form project-owner-projectId.
- required: false
- type: str
- storage_class:
- description:
- - The bucket's default storage class, used whenever no storageClass is specified
- for a newly-created object. This defines how objects in the bucket are stored
- and determines the SLA and the cost of storage.
- - Values include MULTI_REGIONAL, REGIONAL, STANDARD, NEARLINE, COLDLINE, and DURABLE_REDUCED_AVAILABILITY.
- If this value is not specified when the bucket is created, it will default to
- STANDARD. For more information, see storage classes.
- - 'Some valid choices include: "MULTI_REGIONAL", "REGIONAL", "STANDARD", "NEARLINE",
- "COLDLINE", "DURABLE_REDUCED_AVAILABILITY"'
- required: false
- type: str
- versioning:
- description:
- - The bucket's versioning configuration.
- required: false
- type: dict
- suboptions:
- enabled:
- description:
- - While set to true, versioning is fully enabled for this bucket.
- required: false
- type: bool
- website:
- description:
- - The bucket's website configuration, controlling how the service behaves when
- accessing bucket contents as a web site. See the Static Website Examples for
- more information.
- required: false
- type: dict
- suboptions:
- main_page_suffix:
- description:
- - If the requested object path is missing, the service will ensure the path
- has a trailing '/', append this suffix, and attempt to retrieve the resulting
- object. This allows the creation of index.html objects to represent directory
- pages.
- required: false
- type: str
- not_found_page:
- description:
- - If the requested object path is missing, and any mainPageSuffix object is
- missing, if applicable, the service will return the named object from this
- bucket as the content for a 404 Not Found result.
- required: false
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- predefined_default_object_acl:
- description:
- - Apply a predefined set of default object access controls to this bucket.
- - 'Acceptable values are: - "authenticatedRead": Object owner gets OWNER access,
- and allAuthenticatedUsers get READER access.'
- - '- "bucketOwnerFullControl": Object owner gets OWNER access, and project team
- owners get OWNER access.'
- - '- "bucketOwnerRead": Object owner gets OWNER access, and project team owners
- get READER access.'
- - '- "private": Object owner gets OWNER access.'
- - '- "projectPrivate": Object owner gets OWNER access, and project team members
- get access according to their roles.'
- - '- "publicRead": Object owner gets OWNER access, and allUsers get READER access.'
- - 'Some valid choices include: "authenticatedRead", "bucketOwnerFullControl",
- "bucketOwnerRead", "private", "projectPrivate", "publicRead"'
- required: false
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-'''
-
-EXAMPLES = '''
-- name: create a bucket
- gcp_storage_bucket:
- name: ansible-storage-module
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-acl:
- description:
- - Access controls on the bucket.
- returned: success
- type: complex
- contains:
- bucket:
- description:
- - The name of the bucket.
- returned: success
- type: dict
- domain:
- description:
- - The domain associated with the entity.
- returned: success
- type: str
- email:
- description:
- - The email address associated with the entity.
- returned: success
- type: str
- entity:
- description:
- - 'The entity holding the permission, in one of the following forms: user-userId
- user-email group-groupId group-email domain-domain project-team-projectId
- allUsers allAuthenticatedUsers Examples: The user liz@example.com would be
- user-liz@example.com.'
- - The group example@googlegroups.com would be group-example@googlegroups.com.
- - To refer to all members of the Google Apps for Business domain example.com,
- the entity would be domain-example.com.
- returned: success
- type: str
- entityId:
- description:
- - The ID for the entity.
- returned: success
- type: str
- id:
- description:
- - The ID of the access-control entry.
- returned: success
- type: str
- projectTeam:
- description:
- - The project team associated with the entity.
- returned: success
- type: complex
- contains:
- projectNumber:
- description:
- - The project team associated with the entity.
- returned: success
- type: str
- team:
- description:
- - The team.
- returned: success
- type: str
- role:
- description:
- - The access permission for the entity.
- returned: success
- type: str
-cors:
- description:
- - The bucket's Cross-Origin Resource Sharing (CORS) configuration.
- returned: success
- type: complex
- contains:
- maxAgeSeconds:
- description:
- - The value, in seconds, to return in the Access-Control-Max-Age header used
- in preflight responses.
- returned: success
- type: int
- method:
- description:
- - 'The list of HTTP methods on which to include CORS response headers, (GET,
- OPTIONS, POST, etc) Note: "*" is permitted in the list of methods, and means
- "any method".'
- returned: success
- type: list
- origin:
- description:
- - The list of Origins eligible to receive CORS response headers.
- - 'Note: "*" is permitted in the list of origins, and means "any Origin".'
- returned: success
- type: list
- responseHeader:
- description:
- - The list of HTTP headers other than the simple response headers to give permission
- for the user-agent to share across domains.
- returned: success
- type: list
-defaultObjectAcl:
- description:
- - Default access controls to apply to new objects when no ACL is provided.
- returned: success
- type: complex
- contains:
- bucket:
- description:
- - The name of the bucket.
- returned: success
- type: dict
- domain:
- description:
- - The domain associated with the entity.
- returned: success
- type: str
- email:
- description:
- - The email address associated with the entity.
- returned: success
- type: str
- entity:
- description:
- - 'The entity holding the permission, in one of the following forms: * user-{{userId}}
- * user-{{email}} (such as "user-liz@example.com") * group-{{groupId}} * group-{{email}}
- (such as "group-example@googlegroups.com") * domain-{{domain}} (such as "domain-example.com")
- * project-team-{{projectId}} * allUsers * allAuthenticatedUsers .'
- returned: success
- type: str
- entityId:
- description:
- - The ID for the entity.
- returned: success
- type: str
- generation:
- description:
- - The content generation of the object, if applied to an object.
- returned: success
- type: int
- id:
- description:
- - The ID of the access-control entry.
- returned: success
- type: str
- object:
- description:
- - The name of the object, if applied to an object.
- returned: success
- type: str
- projectTeam:
- description:
- - The project team associated with the entity.
- returned: success
- type: complex
- contains:
- projectNumber:
- description:
- - The project team associated with the entity.
- returned: success
- type: str
- team:
- description:
- - The team.
- returned: success
- type: str
- role:
- description:
- - The access permission for the entity.
- returned: success
- type: str
-id:
- description:
- - The ID of the bucket. For buckets, the id and name properities are the same.
- returned: success
- type: str
-lifecycle:
- description:
- - The bucket's lifecycle configuration.
- - See U(https://developers.google.com/storage/docs/lifecycle) for more information.
- returned: success
- type: complex
- contains:
- rule:
- description:
- - A lifecycle management rule, which is made of an action to take and the condition(s)
- under which the action will be taken.
- returned: success
- type: complex
- contains:
- action:
- description:
- - The action to take.
- returned: success
- type: complex
- contains:
- storageClass:
- description:
- - Target storage class. Required iff the type of the action is SetStorageClass.
- returned: success
- type: str
- type:
- description:
- - Type of the action. Currently, only Delete and SetStorageClass are
- supported.
- returned: success
- type: str
- condition:
- description:
- - The condition(s) under which the action will be taken.
- returned: success
- type: complex
- contains:
- ageDays:
- description:
- - Age of an object (in days). This condition is satisfied when an object
- reaches the specified age.
- returned: success
- type: int
- createdBefore:
- description:
- - A date in RFC 3339 format with only the date part (for instance, "2013-01-15").
- This condition is satisfied when an object is created before midnight
- of the specified date in UTC.
- returned: success
- type: str
- isLive:
- description:
- - Relevant only for versioned objects. If the value is true, this condition
- matches live objects; if the value is false, it matches archived objects.
- returned: success
- type: bool
- matchesStorageClass:
- description:
- - Objects having any of the storage classes specified by this condition
- will be matched. Values include MULTI_REGIONAL, REGIONAL, NEARLINE,
- COLDLINE, STANDARD, and DURABLE_REDUCED_AVAILABILITY.
- returned: success
- type: list
- numNewerVersions:
- description:
- - Relevant only for versioned objects. If the value is N, this condition
- is satisfied when there are at least N versions (including the live
- version) newer than this version of the object.
- returned: success
- type: int
-location:
- description:
- - The location of the bucket. Object data for objects in the bucket resides in physical
- storage within this region. Defaults to US. See the developer's guide for the
- authoritative list.
- returned: success
- type: str
-logging:
- description:
- - The bucket's logging configuration, which defines the destination bucket and optional
- name prefix for the current bucket's logs.
- returned: success
- type: complex
- contains:
- logBucket:
- description:
- - The destination bucket where the current bucket's logs should be placed.
- returned: success
- type: str
- logObjectPrefix:
- description:
- - A prefix for log object names.
- returned: success
- type: str
-metageneration:
- description:
- - The metadata generation of this bucket.
- returned: success
- type: int
-name:
- description:
- - The name of the bucket.
- returned: success
- type: str
-owner:
- description:
- - The owner of the bucket. This is always the project team's owner group.
- returned: success
- type: complex
- contains:
- entity:
- description:
- - The entity, in the form project-owner-projectId.
- returned: success
- type: str
- entityId:
- description:
- - The ID for the entity.
- returned: success
- type: str
-projectNumber:
- description:
- - The project number of the project the bucket belongs to.
- returned: success
- type: int
-storageClass:
- description:
- - The bucket's default storage class, used whenever no storageClass is specified
- for a newly-created object. This defines how objects in the bucket are stored
- and determines the SLA and the cost of storage.
- - Values include MULTI_REGIONAL, REGIONAL, STANDARD, NEARLINE, COLDLINE, and DURABLE_REDUCED_AVAILABILITY.
- If this value is not specified when the bucket is created, it will default to
- STANDARD. For more information, see storage classes.
- returned: success
- type: str
-timeCreated:
- description:
- - The creation time of the bucket in RFC 3339 format.
- returned: success
- type: str
-updated:
- description:
- - The modification time of the bucket in RFC 3339 format.
- returned: success
- type: str
-versioning:
- description:
- - The bucket's versioning configuration.
- returned: success
- type: complex
- contains:
- enabled:
- description:
- - While set to true, versioning is fully enabled for this bucket.
- returned: success
- type: bool
-website:
- description:
- - The bucket's website configuration, controlling how the service behaves when accessing
- bucket contents as a web site. See the Static Website Examples for more information.
- returned: success
- type: complex
- contains:
- mainPageSuffix:
- description:
- - If the requested object path is missing, the service will ensure the path
- has a trailing '/', append this suffix, and attempt to retrieve the resulting
- object. This allows the creation of index.html objects to represent directory
- pages.
- returned: success
- type: str
- notFoundPage:
- description:
- - If the requested object path is missing, and any mainPageSuffix object is
- missing, if applicable, the service will return the named object from this
- bucket as the content for a 404 Not Found result.
- returned: success
- type: str
-project:
- description:
- - A valid API project identifier.
- returned: success
- type: str
-predefinedDefaultObjectAcl:
- description:
- - Apply a predefined set of default object access controls to this bucket.
- - 'Acceptable values are: - "authenticatedRead": Object owner gets OWNER access,
- and allAuthenticatedUsers get READER access.'
- - '- "bucketOwnerFullControl": Object owner gets OWNER access, and project team
- owners get OWNER access.'
- - '- "bucketOwnerRead": Object owner gets OWNER access, and project team owners
- get READER access.'
- - '- "private": Object owner gets OWNER access.'
- - '- "projectPrivate": Object owner gets OWNER access, and project team members
- get access according to their roles.'
- - '- "publicRead": Object owner gets OWNER access, and allUsers get READER access.'
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- acl=dict(
- type='list',
- elements='dict',
- options=dict(
- bucket=dict(required=True, type='dict'),
- entity=dict(required=True, type='str'),
- entity_id=dict(type='str'),
- project_team=dict(type='dict', options=dict(project_number=dict(type='str'), team=dict(type='str'))),
- role=dict(type='str'),
- ),
- ),
- cors=dict(
- type='list',
- elements='dict',
- options=dict(
- max_age_seconds=dict(type='int'),
- method=dict(type='list', elements='str'),
- origin=dict(type='list', elements='str'),
- response_header=dict(type='list', elements='str'),
- ),
- ),
- default_object_acl=dict(
- type='list',
- elements='dict',
- options=dict(
- bucket=dict(required=True, type='dict'),
- entity=dict(required=True, type='str'),
- object=dict(type='str'),
- role=dict(required=True, type='str'),
- ),
- ),
- lifecycle=dict(
- type='dict',
- options=dict(
- rule=dict(
- type='list',
- elements='dict',
- options=dict(
- action=dict(type='dict', options=dict(storage_class=dict(type='str'), type=dict(type='str'))),
- condition=dict(
- type='dict',
- options=dict(
- age_days=dict(type='int'),
- created_before=dict(type='str'),
- is_live=dict(type='bool'),
- matches_storage_class=dict(type='list', elements='str'),
- num_newer_versions=dict(type='int'),
- ),
- ),
- ),
- )
- ),
- ),
- location=dict(type='str'),
- logging=dict(type='dict', options=dict(log_bucket=dict(type='str'), log_object_prefix=dict(type='str'))),
- metageneration=dict(type='int'),
- name=dict(type='str'),
- owner=dict(type='dict', options=dict(entity=dict(type='str'))),
- storage_class=dict(type='str'),
- versioning=dict(type='dict', options=dict(enabled=dict(type='bool'))),
- website=dict(type='dict', options=dict(main_page_suffix=dict(type='str'), not_found_page=dict(type='str'))),
- project=dict(type='str'),
- predefined_default_object_acl=dict(type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/devstorage.full_control']
-
- state = module.params['state']
- kind = 'storage#bucket'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'storage')
- return return_if_object(module, auth.post(link, resource_to_request(module)), kind)
-
-
-def update(module, link, kind):
- auth = GcpSession(module, 'storage')
- return return_if_object(module, auth.put(link, resource_to_request(module)), kind)
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'storage')
- return return_if_object(module, auth.delete(link), kind)
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'storage#bucket',
- u'project': module.params.get('project'),
- u'predefinedDefaultObjectAcl': module.params.get('predefined_default_object_acl'),
- u'acl': BucketAclArray(module.params.get('acl', []), module).to_request(),
- u'cors': BucketCorsArray(module.params.get('cors', []), module).to_request(),
- u'defaultObjectAcl': BucketDefaultobjectaclArray(module.params.get('default_object_acl', []), module).to_request(),
- u'lifecycle': BucketLifecycle(module.params.get('lifecycle', {}), module).to_request(),
- u'location': module.params.get('location'),
- u'logging': BucketLogging(module.params.get('logging', {}), module).to_request(),
- u'metageneration': module.params.get('metageneration'),
- u'name': module.params.get('name'),
- u'owner': BucketOwner(module.params.get('owner', {}), module).to_request(),
- u'storageClass': module.params.get('storage_class'),
- u'versioning': BucketVersioning(module.params.get('versioning', {}), module).to_request(),
- u'website': BucketWebsite(module.params.get('website', {}), module).to_request(),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'storage')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- return "https://www.googleapis.com/storage/v1/b/{name}?projection=full".format(**module.params)
-
-
-def collection(module):
- return "https://www.googleapis.com/storage/v1/b?project={project}".format(**module.params)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'acl': BucketAclArray(response.get(u'acl', []), module).from_response(),
- u'cors': BucketCorsArray(response.get(u'cors', []), module).from_response(),
- u'defaultObjectAcl': BucketDefaultobjectaclArray(module.params.get('default_object_acl', []), module).to_request(),
- u'id': response.get(u'id'),
- u'lifecycle': BucketLifecycle(response.get(u'lifecycle', {}), module).from_response(),
- u'location': response.get(u'location'),
- u'logging': BucketLogging(response.get(u'logging', {}), module).from_response(),
- u'metageneration': response.get(u'metageneration'),
- u'name': response.get(u'name'),
- u'owner': BucketOwner(response.get(u'owner', {}), module).from_response(),
- u'projectNumber': response.get(u'projectNumber'),
- u'storageClass': response.get(u'storageClass'),
- u'timeCreated': response.get(u'timeCreated'),
- u'updated': response.get(u'updated'),
- u'versioning': BucketVersioning(response.get(u'versioning', {}), module).from_response(),
- u'website': BucketWebsite(response.get(u'website', {}), module).from_response(),
- }
-
-
-class BucketAclArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict(
- {
- u'bucket': replace_resource_dict(item.get(u'bucket', {}), 'name'),
- u'entity': item.get('entity'),
- u'entityId': item.get('entity_id'),
- u'projectTeam': BucketProjectteam(item.get('project_team', {}), self.module).to_request(),
- u'role': item.get('role'),
- }
- )
-
- def _response_from_item(self, item):
- return remove_nones_from_dict(
- {
- u'bucket': item.get(u'bucket'),
- u'entity': item.get(u'entity'),
- u'entityId': item.get(u'entityId'),
- u'projectTeam': BucketProjectteam(item.get(u'projectTeam', {}), self.module).from_response(),
- u'role': item.get(u'role'),
- }
- )
-
-
-class BucketProjectteam(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'projectNumber': self.request.get('project_number'), u'team': self.request.get('team')})
-
- def from_response(self):
- return remove_nones_from_dict({u'projectNumber': self.request.get(u'projectNumber'), u'team': self.request.get(u'team')})
-
-
-class BucketCorsArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict(
- {
- u'maxAgeSeconds': item.get('max_age_seconds'),
- u'method': item.get('method'),
- u'origin': item.get('origin'),
- u'responseHeader': item.get('response_header'),
- }
- )
-
- def _response_from_item(self, item):
- return remove_nones_from_dict(
- {
- u'maxAgeSeconds': item.get(u'maxAgeSeconds'),
- u'method': item.get(u'method'),
- u'origin': item.get(u'origin'),
- u'responseHeader': item.get(u'responseHeader'),
- }
- )
-
-
-class BucketDefaultobjectaclArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict(
- {
- u'bucket': replace_resource_dict(item.get(u'bucket', {}), 'name'),
- u'entity': item.get('entity'),
- u'object': item.get('object'),
- u'role': item.get('role'),
- }
- )
-
- def _response_from_item(self, item):
- return remove_nones_from_dict(
- {u'bucket': item.get(u'bucket'), u'entity': item.get(u'entity'), u'object': item.get(u'object'), u'role': item.get(u'role')}
- )
-
-
-class BucketProjectteam(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'projectNumber': self.request.get('project_number'), u'team': self.request.get('team')})
-
- def from_response(self):
- return remove_nones_from_dict({u'projectNumber': self.request.get(u'projectNumber'), u'team': self.request.get(u'team')})
-
-
-class BucketLifecycle(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'rule': BucketRuleArray(self.request.get('rule', []), self.module).to_request()})
-
- def from_response(self):
- return remove_nones_from_dict({u'rule': BucketRuleArray(self.request.get(u'rule', []), self.module).from_response()})
-
-
-class BucketRuleArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict(
- {
- u'action': BucketAction(item.get('action', {}), self.module).to_request(),
- u'condition': BucketCondition(item.get('condition', {}), self.module).to_request(),
- }
- )
-
- def _response_from_item(self, item):
- return remove_nones_from_dict(
- {
- u'action': BucketAction(item.get(u'action', {}), self.module).from_response(),
- u'condition': BucketCondition(item.get(u'condition', {}), self.module).from_response(),
- }
- )
-
-
-class BucketAction(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'storageClass': self.request.get('storage_class'), u'type': self.request.get('type')})
-
- def from_response(self):
- return remove_nones_from_dict({u'storageClass': self.request.get(u'storageClass'), u'type': self.request.get(u'type')})
-
-
-class BucketCondition(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict(
- {
- u'age': self.request.get('age_days'),
- u'createdBefore': self.request.get('created_before'),
- u'isLive': self.request.get('is_live'),
- u'matchesStorageClass': self.request.get('matches_storage_class'),
- u'numNewerVersions': self.request.get('num_newer_versions'),
- }
- )
-
- def from_response(self):
- return remove_nones_from_dict(
- {
- u'age': self.request.get(u'age'),
- u'createdBefore': self.request.get(u'createdBefore'),
- u'isLive': self.request.get(u'isLive'),
- u'matchesStorageClass': self.request.get(u'matchesStorageClass'),
- u'numNewerVersions': self.request.get(u'numNewerVersions'),
- }
- )
-
-
-class BucketLogging(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'logBucket': self.request.get('log_bucket'), u'logObjectPrefix': self.request.get('log_object_prefix')})
-
- def from_response(self):
- return remove_nones_from_dict({u'logBucket': self.request.get(u'logBucket'), u'logObjectPrefix': self.request.get(u'logObjectPrefix')})
-
-
-class BucketOwner(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'entity': self.request.get('entity')})
-
- def from_response(self):
- return remove_nones_from_dict({u'entity': self.request.get(u'entity')})
-
-
-class BucketVersioning(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'enabled': self.request.get('enabled')})
-
- def from_response(self):
- return remove_nones_from_dict({u'enabled': self.request.get(u'enabled')})
-
-
-class BucketWebsite(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'mainPageSuffix': self.request.get('main_page_suffix'), u'notFoundPage': self.request.get('not_found_page')})
-
- def from_response(self):
- return remove_nones_from_dict({u'mainPageSuffix': self.request.get(u'mainPageSuffix'), u'notFoundPage': self.request.get(u'notFoundPage')})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_storage_bucket_access_control.py b/lib/ansible/modules/cloud/google/gcp_storage_bucket_access_control.py
deleted file mode 100644
index 79c4fe7003..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_storage_bucket_access_control.py
+++ /dev/null
@@ -1,375 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_storage_bucket_access_control
-description:
-- The BucketAccessControls resource represents the Access Control Lists (ACLs) for
- buckets within Google Cloud Storage. ACLs let you specify who has access to your
- data and to what extent.
-- 'There are three roles that can be assigned to an entity: READERs can get the bucket,
- though no acl property will be returned, and list the bucket''s objects. WRITERs
- are READERs, and they can insert objects into the bucket and delete the bucket''s
- objects. OWNERs are WRITERs, and they can get the acl property of a bucket, update
- a bucket, and call all BucketAccessControls methods on the bucket. For more information,
- see Access Control, with the caveat that this API uses READER, WRITER, and OWNER
- instead of READ, WRITE, and FULL_CONTROL.'
-short_description: Creates a GCP BucketAccessControl
-version_added: '2.6'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- bucket:
- description:
- - The name of the bucket.
- - 'This field represents a link to a Bucket resource in GCP. It can be specified
- in two ways. First, you can place a dictionary with key ''name'' and value of
- your resource''s name Alternatively, you can add `register: name-of-resource`
- to a gcp_storage_bucket task and then set this bucket field to "{{ name-of-resource
- }}"'
- required: true
- type: dict
- entity:
- description:
- - 'The entity holding the permission, in one of the following forms: user-userId
- user-email group-groupId group-email domain-domain project-team-projectId allUsers
- allAuthenticatedUsers Examples: The user liz@example.com would be user-liz@example.com.'
- - The group example@googlegroups.com would be group-example@googlegroups.com.
- - To refer to all members of the Google Apps for Business domain example.com,
- the entity would be domain-example.com.
- required: true
- type: str
- role:
- description:
- - The access permission for the entity.
- - 'Some valid choices include: "OWNER", "READER", "WRITER"'
- required: false
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-'''
-
-EXAMPLES = '''
-- name: create a bucket
- gcp_storage_bucket:
- name: "{{ resource_name }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: bucket
-
-- name: create a bucket access control
- gcp_storage_bucket_access_control:
- bucket: "{{ bucket }}"
- entity: user-alexstephen@google.com
- role: WRITER
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-bucket:
- description:
- - The name of the bucket.
- returned: success
- type: dict
-domain:
- description:
- - The domain associated with the entity.
- returned: success
- type: str
-email:
- description:
- - The email address associated with the entity.
- returned: success
- type: str
-entity:
- description:
- - 'The entity holding the permission, in one of the following forms: user-userId
- user-email group-groupId group-email domain-domain project-team-projectId allUsers
- allAuthenticatedUsers Examples: The user liz@example.com would be user-liz@example.com.'
- - The group example@googlegroups.com would be group-example@googlegroups.com.
- - To refer to all members of the Google Apps for Business domain example.com, the
- entity would be domain-example.com.
- returned: success
- type: str
-entityId:
- description:
- - The ID for the entity.
- returned: success
- type: str
-id:
- description:
- - The ID of the access-control entry.
- returned: success
- type: str
-projectTeam:
- description:
- - The project team associated with the entity.
- returned: success
- type: complex
- contains:
- projectNumber:
- description:
- - The project team associated with the entity.
- returned: success
- type: str
- team:
- description:
- - The team.
- returned: success
- type: str
-role:
- description:
- - The access permission for the entity.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- bucket=dict(required=True, type='dict'),
- entity=dict(required=True, type='str'),
- role=dict(type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/devstorage.full_control']
-
- state = module.params['state']
- kind = 'storage#bucketAccessControl'
-
- fetch = fetch_resource(module, self_link(module), kind)
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), kind)
- fetch = fetch_resource(module, self_link(module), kind)
- changed = True
- else:
- delete(module, self_link(module), kind)
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, collection(module), kind)
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link, kind):
- auth = GcpSession(module, 'storage')
- return return_if_object(module, auth.post(link, resource_to_request(module)), kind)
-
-
-def update(module, link, kind):
- auth = GcpSession(module, 'storage')
- return return_if_object(module, auth.put(link, resource_to_request(module)), kind)
-
-
-def delete(module, link, kind):
- auth = GcpSession(module, 'storage')
- return return_if_object(module, auth.delete(link), kind)
-
-
-def resource_to_request(module):
- request = {
- u'kind': 'storage#bucketAccessControl',
- u'bucket': replace_resource_dict(module.params.get(u'bucket', {}), 'name'),
- u'entity': module.params.get('entity'),
- u'role': module.params.get('role'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, kind, allow_not_found=True):
- auth = GcpSession(module, 'storage')
- return return_if_object(module, auth.get(link), kind, allow_not_found)
-
-
-def self_link(module):
- res = {'bucket': replace_resource_dict(module.params['bucket'], 'name'), 'entity': module.params['entity']}
- return "https://www.googleapis.com/storage/v1/b/{bucket}/acl/{entity}".format(**res)
-
-
-def collection(module):
- res = {'bucket': replace_resource_dict(module.params['bucket'], 'name')}
- return "https://www.googleapis.com/storage/v1/b/{bucket}/acl".format(**res)
-
-
-def return_if_object(module, response, kind, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'bucket': replace_resource_dict(module.params.get(u'bucket', {}), 'name'),
- u'domain': response.get(u'domain'),
- u'email': response.get(u'email'),
- u'entity': module.params.get('entity'),
- u'entityId': response.get(u'entityId'),
- u'id': response.get(u'id'),
- u'projectTeam': BucketAccessControlProjectteam(response.get(u'projectTeam', {}), module).from_response(),
- u'role': response.get(u'role'),
- }
-
-
-class BucketAccessControlProjectteam(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'projectNumber': self.request.get('project_number'), u'team': self.request.get('team')})
-
- def from_response(self):
- return remove_nones_from_dict({u'projectNumber': self.request.get(u'projectNumber'), u'team': self.request.get(u'team')})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_storage_object.py b/lib/ansible/modules/cloud/google/gcp_storage_object.py
deleted file mode 100644
index fcaa68ea9f..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_storage_object.py
+++ /dev/null
@@ -1,322 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_storage_object
-description:
-- Upload or download a file from a GCS bucket.
-short_description: Creates a GCP Object
-version_added: '2.8'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- action:
- description:
- - Upload or download from the bucket.
- - 'Some valid choices include: "download", "upload"'
- required: false
- type: str
- overwrite:
- description:
- - "'Overwrite the file on the bucket/local machine. If overwrite is false and
- a difference exists between GCS + local, module will fail with error' ."
- required: false
- type: bool
- src:
- description:
- - Source location of file (may be local machine or cloud depending on action).
- required: false
- type: path
- dest:
- description:
- - Destination location of file (may be local machine or cloud depending on action).
- required: false
- type: path
- bucket:
- description:
- - The name of the bucket.
- required: false
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-'''
-
-EXAMPLES = '''
-- name: create a object
- gcp_storage_object:
- action: download
- bucket: ansible-bucket
- src: modules.zip
- dest: "~/modules.zip"
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-action:
- description:
- - Upload or download from the bucket.
- returned: success
- type: str
-overwrite:
- description:
- - "'Overwrite the file on the bucket/local machine. If overwrite is false and a
- difference exists between GCS + local, module will fail with error' ."
- returned: success
- type: bool
-src:
- description:
- - Source location of file (may be local machine or cloud depending on action).
- returned: success
- type: str
-dest:
- description:
- - Destination location of file (may be local machine or cloud depending on action).
- returned: success
- type: str
-bucket:
- description:
- - The name of the bucket.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, replace_resource_dict
-import json
-import os
-import mimetypes
-import hashlib
-import base64
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- action=dict(type='str'),
- overwrite=dict(type='bool'),
- src=dict(type='path'),
- dest=dict(type='path'),
- bucket=dict(type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/devstorage.full_control']
-
- remote_object = fetch_resource(module, self_link(module))
- local_file_exists = os.path.isfile(local_file_path(module))
-
- # Check if files exist.
- if module.params['action'] == 'download' and not remote_object:
- module.fail_json(msg="File does not exist in bucket")
-
- if module.params['action'] == 'upload' and not local_file_exists:
- module.fail_json(msg="File does not exist on disk")
-
- # Check if we'll be overwriting files.
- if not module.params['overwrite']:
- remote_object['changed'] = False
- if module.params['action'] == 'download' and local_file_exists:
- # If files differ, throw an error
- if get_md5_local(local_file_path(module)) != remote_object['md5Hash']:
- module.fail_json(msg="Local file is different than remote file")
- # If files are the same, module is done running.
- else:
- module.exit_json(**remote_object)
-
- elif module.params['action'] == 'upload' and remote_object:
- # If files differ, throw an error
- if get_md5_local(local_file_path(module)) != remote_object['md5Hash']:
- module.fail_json(msg="Local file is different than remote file")
- # If files are the same, module is done running.
- else:
- module.exit_json(**remote_object)
-
- # Upload/download the files
- auth = GcpSession(module, 'storage')
- if module.params['action'] == 'download':
- results = download_file(module)
- else:
- results = upload_file(module)
-
- module.exit_json(**results)
-
-
-def download_file(module):
- auth = GcpSession(module, 'storage')
- data = auth.get(media_link(module))
- with open(module.params['dest'], 'w') as f:
- f.write(data.text.encode('utf8'))
- return fetch_resource(module, self_link(module))
-
-
-def upload_file(module):
- auth = GcpSession(module, 'storage')
- with open(module.params['src'], 'r') as f:
- results = return_if_object(module, auth.post_contents(upload_link(module), f, object_headers(module)))
- results['changed'] = True
- return results
-
-
-def get_md5_local(path):
- md5 = hashlib.md5()
- with open(path, "rb") as f:
- for chunk in iter(lambda: f.read(4096), b""):
- md5.update(chunk)
- return base64.b64encode(md5.digest())
-
-
-def get_md5_remote(module):
- resource = fetch_resource(module, self_link(module))
- return resource.get('md5Hash')
-
-
-def fetch_resource(module, link, allow_not_found=True):
- auth = GcpSession(module, 'storage')
- return return_if_object(module, auth.get(link), allow_not_found)
-
-
-def self_link(module):
- if module.params['action'] == 'download':
- return "https://www.googleapis.com/storage/v1/b/{bucket}/o/{src}".format(**module.params)
- else:
- return "https://www.googleapis.com/storage/v1/b/{bucket}/o/{dest}".format(**module.params)
-
-
-def local_file_path(module):
- if module.params['action'] == 'download':
- return module.params['dest']
- else:
- return module.params['src']
-
-
-def media_link(module):
- if module.params['action'] == 'download':
- return "https://www.googleapis.com/storage/v1/b/{bucket}/o/{src}?alt=media".format(**module.params)
- else:
- return "https://www.googleapis.com/storage/v1/b/{bucket}/o/{dest}?alt=media".format(**module.params)
-
-
-def upload_link(module):
- return "https://www.googleapis.com/upload/storage/v1/b/{bucket}/o?uploadType=media&name={dest}".format(**module.params)
-
-
-def return_if_object(module, response, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def object_headers(module):
- return {
- "name": module.params['dest'],
- "Content-Type": mimetypes.guess_type(module.params['src'])[0],
- "Content-Length": str(os.path.getsize(module.params['src'])),
- }
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_tpu_node.py b/lib/ansible/modules/cloud/google/gcp_tpu_node.py
deleted file mode 100644
index 7c5249ff2b..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_tpu_node.py
+++ /dev/null
@@ -1,524 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_tpu_node
-description:
-- A Cloud TPU instance.
-short_description: Creates a GCP Node
-version_added: '2.9'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- state:
- description:
- - Whether the given object should exist in GCP
- choices:
- - present
- - absent
- default: present
- type: str
- name:
- description:
- - The immutable name of the TPU.
- required: true
- type: str
- description:
- description:
- - The user-supplied description of the TPU. Maximum of 512 characters.
- required: false
- type: str
- accelerator_type:
- description:
- - The type of hardware accelerators associated with this node.
- required: true
- type: str
- tensorflow_version:
- description:
- - The version of Tensorflow running in the Node.
- required: true
- type: str
- network:
- description:
- - The name of a network to peer the TPU node to. It must be a preexisting Compute
- Engine network inside of the project on which this API has been activated. If
- none is provided, "default" will be used.
- required: false
- type: str
- cidr_block:
- description:
- - The CIDR block that the TPU node will use when selecting an IP address. This
- CIDR block must be a /29 block; the Compute Engine networks API forbids a smaller
- block, and using a larger block would be wasteful (a node can only consume one
- IP address).
- - Errors will occur if the CIDR block has already been used for a currently existing
- TPU node, the CIDR block conflicts with any subnetworks in the user's provided
- network, or the provided network is peered with another network that is using
- that CIDR block.
- required: true
- type: str
- scheduling_config:
- description:
- - Sets the scheduling options for this TPU instance.
- required: false
- type: dict
- suboptions:
- preemptible:
- description:
- - Defines whether the TPU instance is preemptible.
- required: true
- type: bool
- labels:
- description:
- - Resource labels to represent user provided metadata.
- required: false
- type: dict
- zone:
- description:
- - The GCP location for the TPU.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- 'API Reference: U(https://cloud.google.com/tpu/docs/reference/rest/)'
-- 'Official Documentation: U(https://cloud.google.com/tpu/docs/)'
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: create a node
- gcp_tpu_node:
- name: test_object
- zone: us-central1-b
- accelerator_type: v3-8
- tensorflow_version: '1.11'
- cidr_block: 10.2.0.0/29
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
- state: present
-'''
-
-RETURN = '''
-name:
- description:
- - The immutable name of the TPU.
- returned: success
- type: str
-description:
- description:
- - The user-supplied description of the TPU. Maximum of 512 characters.
- returned: success
- type: str
-acceleratorType:
- description:
- - The type of hardware accelerators associated with this node.
- returned: success
- type: str
-tensorflowVersion:
- description:
- - The version of Tensorflow running in the Node.
- returned: success
- type: str
-network:
- description:
- - The name of a network to peer the TPU node to. It must be a preexisting Compute
- Engine network inside of the project on which this API has been activated. If
- none is provided, "default" will be used.
- returned: success
- type: str
-cidrBlock:
- description:
- - The CIDR block that the TPU node will use when selecting an IP address. This CIDR
- block must be a /29 block; the Compute Engine networks API forbids a smaller block,
- and using a larger block would be wasteful (a node can only consume one IP address).
- - Errors will occur if the CIDR block has already been used for a currently existing
- TPU node, the CIDR block conflicts with any subnetworks in the user's provided
- network, or the provided network is peered with another network that is using
- that CIDR block.
- returned: success
- type: str
-serviceAccount:
- description:
- - The service account used to run the tensor flow services within the node. To share
- resources, including Google Cloud Storage data, with the Tensorflow job running
- in the Node, this account must have permissions to that data.
- returned: success
- type: str
-schedulingConfig:
- description:
- - Sets the scheduling options for this TPU instance.
- returned: success
- type: complex
- contains:
- preemptible:
- description:
- - Defines whether the TPU instance is preemptible.
- returned: success
- type: bool
-networkEndpoints:
- description:
- - The network endpoints where TPU workers can be accessed and sent work.
- - It is recommended that Tensorflow clients of the node first reach out to the first
- (index 0) entry.
- returned: success
- type: complex
- contains:
- ipAddress:
- description:
- - The IP address of this network endpoint.
- returned: success
- type: str
- port:
- description:
- - The port of this network endpoint.
- returned: success
- type: int
-labels:
- description:
- - Resource labels to represent user provided metadata.
- returned: success
- type: dict
-zone:
- description:
- - The GCP location for the TPU.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest, remove_nones_from_dict, replace_resource_dict
-import json
-import time
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- """Main function"""
-
- module = GcpModule(
- argument_spec=dict(
- state=dict(default='present', choices=['present', 'absent'], type='str'),
- name=dict(required=True, type='str'),
- description=dict(type='str'),
- accelerator_type=dict(required=True, type='str'),
- tensorflow_version=dict(required=True, type='str'),
- network=dict(type='str'),
- cidr_block=dict(required=True, type='str'),
- scheduling_config=dict(type='dict', options=dict(preemptible=dict(required=True, type='bool'))),
- labels=dict(type='dict'),
- zone=dict(required=True, type='str'),
- )
- )
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
-
- state = module.params['state']
-
- fetch = fetch_resource(module, self_link(module))
- changed = False
-
- if fetch:
- if state == 'present':
- if is_different(module, fetch):
- update(module, self_link(module), fetch)
- fetch = fetch_resource(module, self_link(module))
- changed = True
- else:
- delete(module, self_link(module))
- fetch = {}
- changed = True
- else:
- if state == 'present':
- fetch = create(module, create_link(module))
- changed = True
- else:
- fetch = {}
-
- fetch.update({'changed': changed})
-
- module.exit_json(**fetch)
-
-
-def create(module, link):
- auth = GcpSession(module, 'tpu')
- return wait_for_operation(module, auth.post(link, resource_to_request(module)))
-
-
-def update(module, link, fetch):
- update_fields(module, resource_to_request(module), response_to_hash(module, fetch))
- return fetch_resource(module, self_link(module))
-
-
-def update_fields(module, request, response):
- if response.get('tensorflowVersion') != request.get('tensorflowVersion'):
- tensorflow_version_update(module, request, response)
-
-
-def tensorflow_version_update(module, request, response):
- auth = GcpSession(module, 'tpu')
- auth.post(
- ''.join(["https://tpu.googleapis.com/v1/", "projects/{project}/locations/{zone}/nodes/{name}:reimage"]).format(**module.params),
- {u'tensorflowVersion': module.params.get('tensorflow_version')},
- )
-
-
-def delete(module, link):
- auth = GcpSession(module, 'tpu')
- return wait_for_operation(module, auth.delete(link))
-
-
-def resource_to_request(module):
- request = {
- u'name': module.params.get('name'),
- u'description': module.params.get('description'),
- u'acceleratorType': module.params.get('accelerator_type'),
- u'tensorflowVersion': module.params.get('tensorflow_version'),
- u'network': module.params.get('network'),
- u'cidrBlock': module.params.get('cidr_block'),
- u'schedulingConfig': NodeSchedulingconfig(module.params.get('scheduling_config', {}), module).to_request(),
- u'labels': module.params.get('labels'),
- }
- return_vals = {}
- for k, v in request.items():
- if v or v is False:
- return_vals[k] = v
-
- return return_vals
-
-
-def fetch_resource(module, link, allow_not_found=True):
- auth = GcpSession(module, 'tpu')
- return return_if_object(module, auth.get(link), allow_not_found)
-
-
-def self_link(module):
- return "https://tpu.googleapis.com/v1/projects/{project}/locations/{zone}/nodes/{name}".format(**module.params)
-
-
-def collection(module):
- return "https://tpu.googleapis.com/v1/projects/{project}/locations/{zone}/nodes".format(**module.params)
-
-
-def create_link(module):
- return "https://tpu.googleapis.com/v1/projects/{project}/locations/{zone}/nodes?nodeId={name}".format(**module.params)
-
-
-def return_if_object(module, response, allow_not_found=False):
- # If not found, return nothing.
- if allow_not_found and response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError):
- module.fail_json(msg="Invalid JSON response with error: %s" % response.text)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-def is_different(module, response):
- request = resource_to_request(module)
- response = response_to_hash(module, response)
-
- # Remove all output-only from response.
- response_vals = {}
- for k, v in response.items():
- if k in request:
- response_vals[k] = v
-
- request_vals = {}
- for k, v in request.items():
- if k in response:
- request_vals[k] = v
-
- return GcpRequest(request_vals) != GcpRequest(response_vals)
-
-
-# Remove unnecessary properties from the response.
-# This is for doing comparisons with Ansible's current parameters.
-def response_to_hash(module, response):
- return {
- u'name': module.params.get('name'),
- u'description': module.params.get('description'),
- u'acceleratorType': module.params.get('accelerator_type'),
- u'tensorflowVersion': response.get(u'tensorflowVersion'),
- u'network': module.params.get('network'),
- u'cidrBlock': module.params.get('cidr_block'),
- u'serviceAccount': response.get(u'serviceAccount'),
- u'schedulingConfig': NodeSchedulingconfig(module.params.get('scheduling_config', {}), module).to_request(),
- u'networkEndpoints': NodeNetworkendpointsArray(response.get(u'networkEndpoints', []), module).from_response(),
- u'labels': module.params.get('labels'),
- }
-
-
-def async_op_url(module, extra_data=None):
- if extra_data is None:
- extra_data = {}
- url = "https://tpu.googleapis.com/v1/{op_id}"
- combined = extra_data.copy()
- combined.update(module.params)
- return url.format(**combined)
-
-
-def wait_for_operation(module, response):
- op_result = return_if_object(module, response)
- if op_result is None:
- return {}
- status = navigate_hash(op_result, ['done'])
- wait_done = wait_for_completion(status, op_result, module)
- raise_if_errors(wait_done, ['error'], module)
- return navigate_hash(wait_done, ['response'])
-
-
-def wait_for_completion(status, op_result, module):
- op_id = navigate_hash(op_result, ['name'])
- op_uri = async_op_url(module, {'op_id': op_id})
- while not status:
- raise_if_errors(op_result, ['error'], module)
- time.sleep(1.0)
- op_result = fetch_resource(module, op_uri, False)
- status = navigate_hash(op_result, ['done'])
- return op_result
-
-
-def raise_if_errors(response, err_path, module):
- errors = navigate_hash(response, err_path)
- if errors is not None:
- module.fail_json(msg=errors)
-
-
-class NodeSchedulingconfig(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = {}
-
- def to_request(self):
- return remove_nones_from_dict({u'preemptible': self.request.get('preemptible')})
-
- def from_response(self):
- return remove_nones_from_dict({u'preemptible': self.request.get(u'preemptible')})
-
-
-class NodeNetworkendpointsArray(object):
- def __init__(self, request, module):
- self.module = module
- if request:
- self.request = request
- else:
- self.request = []
-
- def to_request(self):
- items = []
- for item in self.request:
- items.append(self._request_for_item(item))
- return items
-
- def from_response(self):
- items = []
- for item in self.request:
- items.append(self._response_from_item(item))
- return items
-
- def _request_for_item(self, item):
- return remove_nones_from_dict({})
-
- def _response_from_item(self, item):
- return remove_nones_from_dict({})
-
-
-if __name__ == '__main__':
- main()
diff --git a/lib/ansible/modules/cloud/google/gcp_tpu_node_info.py b/lib/ansible/modules/cloud/google/gcp_tpu_node_info.py
deleted file mode 100644
index b7f6fbf950..0000000000
--- a/lib/ansible/modules/cloud/google/gcp_tpu_node_info.py
+++ /dev/null
@@ -1,252 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2017 Google
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-################################################################################
-# Documentation
-################################################################################
-
-ANSIBLE_METADATA = {'metadata_version': '1.1', 'status': ["preview"], 'supported_by': 'community'}
-
-DOCUMENTATION = '''
----
-module: gcp_tpu_node_info
-description:
-- Gather info for GCP Node
-short_description: Gather info for GCP Node
-version_added: '2.9'
-author: Google Inc. (@googlecloudplatform)
-requirements:
-- python >= 2.6
-- requests >= 2.18.4
-- google-auth >= 1.3.0
-options:
- zone:
- description:
- - The GCP location for the TPU.
- required: true
- type: str
- project:
- description:
- - The Google Cloud Platform project to use.
- type: str
- auth_kind:
- description:
- - The type of credential used.
- type: str
- required: true
- choices:
- - application
- - machineaccount
- - serviceaccount
- service_account_contents:
- description:
- - The contents of a Service Account JSON file, either in a dictionary or as a
- JSON string that represents it.
- type: jsonarg
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected and
- the user does not wish to use the default email.
- type: str
- scopes:
- description:
- - Array of scopes to be used
- type: list
- env_type:
- description:
- - Specifies which Ansible environment you're running this module within.
- - This should not be set unless you know what you're doing.
- - This only alters the User Agent string for any API requests.
- type: str
-notes:
-- for authentication, you can set service_account_file using the C(gcp_service_account_file)
- env variable.
-- for authentication, you can set service_account_contents using the C(GCP_SERVICE_ACCOUNT_CONTENTS)
- env variable.
-- For authentication, you can set service_account_email using the C(GCP_SERVICE_ACCOUNT_EMAIL)
- env variable.
-- For authentication, you can set auth_kind using the C(GCP_AUTH_KIND) env variable.
-- For authentication, you can set scopes using the C(GCP_SCOPES) env variable.
-- Environment variables values will only be used if the playbook values are not set.
-- The I(service_account_email) and I(service_account_file) options are mutually exclusive.
-'''
-
-EXAMPLES = '''
-- name: get info on a node
- gcp_tpu_node_info:
- zone: us-central1-b
- project: test_project
- auth_kind: serviceaccount
- service_account_file: "/tmp/auth.pem"
-'''
-
-RETURN = '''
-resources:
- description: List of resources
- returned: always
- type: complex
- contains:
- name:
- description:
- - The immutable name of the TPU.
- returned: success
- type: str
- description:
- description:
- - The user-supplied description of the TPU. Maximum of 512 characters.
- returned: success
- type: str
- acceleratorType:
- description:
- - The type of hardware accelerators associated with this node.
- returned: success
- type: str
- tensorflowVersion:
- description:
- - The version of Tensorflow running in the Node.
- returned: success
- type: str
- network:
- description:
- - The name of a network to peer the TPU node to. It must be a preexisting Compute
- Engine network inside of the project on which this API has been activated.
- If none is provided, "default" will be used.
- returned: success
- type: str
- cidrBlock:
- description:
- - The CIDR block that the TPU node will use when selecting an IP address. This
- CIDR block must be a /29 block; the Compute Engine networks API forbids a
- smaller block, and using a larger block would be wasteful (a node can only
- consume one IP address).
- - Errors will occur if the CIDR block has already been used for a currently
- existing TPU node, the CIDR block conflicts with any subnetworks in the user's
- provided network, or the provided network is peered with another network that
- is using that CIDR block.
- returned: success
- type: str
- serviceAccount:
- description:
- - The service account used to run the tensor flow services within the node.
- To share resources, including Google Cloud Storage data, with the Tensorflow
- job running in the Node, this account must have permissions to that data.
- returned: success
- type: str
- schedulingConfig:
- description:
- - Sets the scheduling options for this TPU instance.
- returned: success
- type: complex
- contains:
- preemptible:
- description:
- - Defines whether the TPU instance is preemptible.
- returned: success
- type: bool
- networkEndpoints:
- description:
- - The network endpoints where TPU workers can be accessed and sent work.
- - It is recommended that Tensorflow clients of the node first reach out to the
- first (index 0) entry.
- returned: success
- type: complex
- contains:
- ipAddress:
- description:
- - The IP address of this network endpoint.
- returned: success
- type: str
- port:
- description:
- - The port of this network endpoint.
- returned: success
- type: int
- labels:
- description:
- - Resource labels to represent user provided metadata.
- returned: success
- type: dict
- zone:
- description:
- - The GCP location for the TPU.
- returned: success
- type: str
-'''
-
-################################################################################
-# Imports
-################################################################################
-from ansible.module_utils.gcp_utils import navigate_hash, GcpSession, GcpModule, GcpRequest
-import json
-
-################################################################################
-# Main
-################################################################################
-
-
-def main():
- module = GcpModule(argument_spec=dict(zone=dict(required=True, type='str')))
-
- if not module.params['scopes']:
- module.params['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
-
- return_value = {'resources': fetch_list(module, collection(module))}
- module.exit_json(**return_value)
-
-
-def collection(module):
- return "https://tpu.googleapis.com/v1/projects/{project}/locations/{zone}/nodes".format(**module.params)
-
-
-def fetch_list(module, link):
- auth = GcpSession(module, 'tpu')
- return auth.list(link, return_if_object, array_name='nodes')
-
-
-def return_if_object(module, response):
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- module.raise_for_status(response)
- result = response.json()
- except getattr(json.decoder, 'JSONDecodeError', ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
-
- if navigate_hash(result, ['error', 'errors']):
- module.fail_json(msg=navigate_hash(result, ['error', 'errors']))
-
- return result
-
-
-if __name__ == "__main__":
- main()
diff --git a/lib/ansible/plugins/inventory/gcp_compute.py b/lib/ansible/plugins/inventory/gcp_compute.py
deleted file mode 100644
index a7a06fb72e..0000000000
--- a/lib/ansible/plugins/inventory/gcp_compute.py
+++ /dev/null
@@ -1,616 +0,0 @@
-# Copyright (c) 2017 Ansible Project
-# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-
-from __future__ import absolute_import, division, print_function
-
-__metaclass__ = type
-
-DOCUMENTATION = """
- name: gcp_compute
- plugin_type: inventory
- short_description: Google Cloud Compute Engine inventory source
- requirements:
- - requests >= 2.18.4
- - google-auth >= 1.3.0
- extends_documentation_fragment:
- - constructed
- - inventory_cache
- description:
- - Get inventory hosts from Google Cloud Platform GCE.
- - Uses a YAML configuration file that ends with gcp_compute.(yml|yaml) or gcp.(yml|yaml).
- options:
- plugin:
- description: token that ensures this is a source file for the 'gcp_compute' plugin.
- required: True
- choices: ['gcp_compute']
- zones:
- description: A list of regions in which to describe GCE instances.
- If none provided, it defaults to all zones available to a given project.
- type: list
- folders:
- description: A folder that contains many projects
- type: list
- required: False
- projects:
- description: A list of projects in which to describe GCE instances.
- type: list
- required: False
- filters:
- description: >
- A list of filter value pairs. Available filters are listed here
- U(https://cloud.google.com/compute/docs/reference/rest/v1/instances/aggregatedList).
- Each additional filter in the list will act be added as an AND condition
- (filter1 and filter2)
- type: list
- hostnames:
- description: A list of options that describe the ordering for which
- hostnames should be assigned. Currently supported hostnames are
- 'public_ip', 'private_ip', or 'name'.
- default: ['public_ip', 'private_ip', 'name']
- type: list
- auth_kind:
- description:
- - The type of credential used.
- required: True
- choices: ['application', 'serviceaccount', 'machineaccount']
- env:
- - name: GCP_AUTH_KIND
- version_added: "2.8.2"
- scopes:
- description: list of authentication scopes
- type: list
- default: ['https://www.googleapis.com/auth/compute']
- env:
- - name: GCP_SCOPES
- version_added: "2.8.2"
- service_account_file:
- description:
- - The path of a Service Account JSON file if serviceaccount is selected as type.
- type: path
- env:
- - name: GCP_SERVICE_ACCOUNT_FILE
- version_added: "2.8.2"
- - name: GCE_CREDENTIALS_FILE_PATH
- version_added: "2.8"
- service_account_contents:
- description:
- - A string representing the contents of a Service Account JSON file. This should not be passed in as a dictionary,
- but a string that has the exact contents of a service account json file (valid JSON).
- type: string
- env:
- - name: GCP_SERVICE_ACCOUNT_CONTENTS
- version_added: "2.8.2"
- service_account_email:
- description:
- - An optional service account email address if machineaccount is selected
- and the user does not wish to use the default email.
- env:
- - name: GCP_SERVICE_ACCOUNT_EMAIL
- version_added: "2.8.2"
- vars_prefix:
- description: prefix to apply to host variables, does not include facts nor params
- default: ''
- use_contrib_script_compatible_sanitization:
- description:
- - By default this plugin is using a general group name sanitization to create safe and usable group names for use in Ansible.
- This option allows you to override that, in efforts to allow migration from the old inventory script.
- - For this to work you should also turn off the TRANSFORM_INVALID_GROUP_CHARS setting,
- otherwise the core engine will just use the standard sanitization on top.
- - This is not the default as such names break certain functionality as not all characters are valid Python identifiers
- which group names end up being used as.
- type: bool
- default: False
- version_added: '2.8'
- retrieve_image_info:
- description:
- - Populate the C(image) host fact for the instances returned with the GCP image name
- - By default this plugin does not attempt to resolve the boot image of an instance to the image name cataloged in GCP
- because of the performance overhead of the task.
- - Unless this option is enabled, the C(image) host variable will be C(null)
- type: bool
- default: False
- version_added: '2.8'
-"""
-
-EXAMPLES = """
-plugin: gcp_compute
-zones: # populate inventory with instances in these regions
- - us-east1-a
-projects:
- - gcp-prod-gke-100
- - gcp-cicd-101
-filters:
- - machineType = n1-standard-1
- - scheduling.automaticRestart = true AND machineType = n1-standard-1
-service_account_file: /tmp/service_account.json
-auth_kind: serviceaccount
-scopes:
- - 'https://www.googleapis.com/auth/cloud-platform'
- - 'https://www.googleapis.com/auth/compute.readonly'
-keyed_groups:
- # Create groups from GCE labels
- - prefix: gcp
- key: labels
-hostnames:
- # List host by name instead of the default public ip
- - name
-compose:
- # Set an inventory parameter to use the Public IP address to connect to the host
- # For Private ip use "networkInterfaces[0].networkIP"
- ansible_host: networkInterfaces[0].accessConfigs[0].natIP
-"""
-
-import json
-
-from ansible.errors import AnsibleError, AnsibleParserError
-from ansible.module_utils._text import to_text
-from ansible.module_utils.basic import missing_required_lib
-from ansible.module_utils.gcp_utils import (
- GcpSession,
- navigate_hash,
- GcpRequestException,
- HAS_GOOGLE_LIBRARIES,
-)
-from ansible.plugins.inventory import BaseInventoryPlugin, Constructable, Cacheable
-
-
-# Mocking a module to reuse module_utils
-class GcpMockModule(object):
- def __init__(self, params):
- self.params = params
-
- def fail_json(self, *args, **kwargs):
- raise AnsibleError(kwargs["msg"])
-
-
-class GcpInstance(object):
- def __init__(self, json, hostname_ordering, project_disks, should_format=True):
- self.hostname_ordering = hostname_ordering
- self.project_disks = project_disks
- self.json = json
- if should_format:
- self.convert()
-
- def to_json(self):
- return self.json
-
- def convert(self):
- if "zone" in self.json:
- self.json["zone_selflink"] = self.json["zone"]
- self.json["zone"] = self.json["zone"].split("/")[-1]
- if "machineType" in self.json:
- self.json["machineType_selflink"] = self.json["machineType"]
- self.json["machineType"] = self.json["machineType"].split("/")[-1]
-
- if "networkInterfaces" in self.json:
- for network in self.json["networkInterfaces"]:
- if "network" in network:
- network["network"] = self._format_network_info(network["network"])
- if "subnetwork" in network:
- network["subnetwork"] = self._format_network_info(
- network["subnetwork"]
- )
-
- if "metadata" in self.json:
- # If no metadata, 'items' will be blank.
- # We want the metadata hash overriden anyways for consistency.
- self.json["metadata"] = self._format_metadata(
- self.json["metadata"].get("items", {})
- )
-
- self.json["project"] = self.json["selfLink"].split("/")[6]
- self.json["image"] = self._get_image()
-
- def _format_network_info(self, address):
- """
- :param address: A GCP network address
- :return a dict with network shortname and region
- """
- split = address.split("/")
- region = ""
- if "global" in split:
- region = "global"
- else:
- region = split[8]
- return {"region": region, "name": split[-1], "selfLink": address}
-
- def _format_metadata(self, metadata):
- """
- :param metadata: A list of dicts where each dict has keys "key" and "value"
- :return a dict with key/value pairs for each in list.
- """
- new_metadata = {}
- for pair in metadata:
- new_metadata[pair["key"]] = pair["value"]
- return new_metadata
-
- def hostname(self):
- """
- :return the hostname of this instance
- """
- for order in self.hostname_ordering:
- name = None
- if order == "public_ip":
- name = self._get_publicip()
- elif order == "private_ip":
- name = self._get_privateip()
- elif order == "name":
- name = self.json[u"name"]
- else:
- raise AnsibleParserError("%s is not a valid hostname precedent" % order)
-
- if name:
- return name
-
- raise AnsibleParserError("No valid name found for host")
-
- def _get_publicip(self):
- """
- :return the publicIP of this instance or None
- """
- # Get public IP if exists
- for interface in self.json["networkInterfaces"]:
- if "accessConfigs" in interface:
- for accessConfig in interface["accessConfigs"]:
- if "natIP" in accessConfig:
- return accessConfig[u"natIP"]
- return None
-
- def _get_image(self):
- """
- :param instance: A instance response from GCP
- :return the image of this instance or None
- """
- image = None
- if self.project_disks and "disks" in self.json:
- for disk in self.json["disks"]:
- if disk.get("boot"):
- image = self.project_disks[disk["source"]]
- return image
-
- def _get_privateip(self):
- """
- :param item: A host response from GCP
- :return the privateIP of this instance or None
- """
- # Fallback: Get private IP
- for interface in self.json[u"networkInterfaces"]:
- if "networkIP" in interface:
- return interface[u"networkIP"]
-
-
-class InventoryModule(BaseInventoryPlugin, Constructable, Cacheable):
-
- NAME = "gcp_compute"
-
- _instances = (
- r"https://www.googleapis.com/compute/v1/projects/%s/aggregated/instances"
- )
-
- def __init__(self):
- super(InventoryModule, self).__init__()
-
- self.group_prefix = "gcp_"
-
- def _populate_host(self, item):
- """
- :param item: A GCP instance
- """
- hostname = item.hostname()
- self.inventory.add_host(hostname)
- for key in item.to_json():
- try:
- self.inventory.set_variable(
- hostname, self.get_option("vars_prefix") + key, item.to_json()[key]
- )
- except (ValueError, TypeError) as e:
- self.display.warning(
- "Could not set host info hostvar for %s, skipping %s: %s"
- % (hostname, key, to_text(e))
- )
- self.inventory.add_child("all", hostname)
-
- def verify_file(self, path):
- """
- :param path: the path to the inventory config file
- :return the contents of the config file
- """
- if super(InventoryModule, self).verify_file(path):
- if path.endswith(("gcp.yml", "gcp.yaml")):
- return True
- elif path.endswith(("gcp_compute.yml", "gcp_compute.yaml")):
- return True
- return False
-
- def fetch_list(self, params, link, query):
- """
- :param params: a dict containing all of the fields relevant to build URL
- :param link: a formatted URL
- :param query: a formatted query string
- :return the JSON response containing a list of instances.
- """
- lists = []
- resp = self._return_if_object(
- self.fake_module, self.auth_session.get(link, params={"filter": query})
- )
- if resp:
- lists.append(resp.get("items"))
- while resp.get("nextPageToken"):
- resp = self._return_if_object(
- self.fake_module,
- self.auth_session.get(
- link,
- params={"filter": query, "pageToken": resp.get("nextPageToken")},
- ),
- )
- lists.append(resp.get("items"))
- return self.build_list(lists)
-
- def build_list(self, lists):
- arrays_for_zones = {}
- for resp in lists:
- for zone in resp:
- if "instances" in resp[zone]:
- if zone in arrays_for_zones:
- arrays_for_zones[zone] = (
- arrays_for_zones[zone] + resp[zone]["instances"]
- )
- else:
- arrays_for_zones[zone] = resp[zone]["instances"]
- return arrays_for_zones
-
- def _get_query_options(self, filters):
- """
- :param config_data: contents of the inventory config file
- :return A fully built query string
- """
- if not filters:
- return ""
-
- if len(filters) == 1:
- return filters[0]
- else:
- queries = []
- for f in filters:
- # For multiple queries, all queries should have ()
- if f[0] != "(" and f[-1] != ")":
- queries.append("(%s)" % "".join(f))
- else:
- queries.append(f)
-
- return " ".join(queries)
-
- def _return_if_object(self, module, response):
- """
- :param module: A GcpModule
- :param response: A Requests response object
- :return JSON response
- """
- # If not found, return nothing.
- if response.status_code == 404:
- return None
-
- # If no content, return nothing.
- if response.status_code == 204:
- return None
-
- try:
- response.raise_for_status
- result = response.json()
- except getattr(json.decoder, "JSONDecodeError", ValueError) as inst:
- module.fail_json(msg="Invalid JSON response with error: %s" % inst)
- except GcpRequestException as inst:
- module.fail_json(msg="Network error: %s" % inst)
-
- if navigate_hash(result, ["error", "errors"]):
- module.fail_json(msg=navigate_hash(result, ["error", "errors"]))
-
- return result
-
- def _add_hosts(self, items, config_data, format_items=True, project_disks=None):
- """
- :param items: A list of hosts
- :param config_data: configuration data
- :param format_items: format items or not
- """
- if not items:
- return
-
- hostname_ordering = ["public_ip", "private_ip", "name"]
- if self.get_option("hostnames"):
- hostname_ordering = self.get_option("hostnames")
-
- for host_json in items:
- host = GcpInstance(
- host_json, hostname_ordering, project_disks, format_items
- )
- self._populate_host(host)
-
- hostname = host.hostname()
- self._set_composite_vars(
- self.get_option("compose"), host.to_json(), hostname
- )
- self._add_host_to_composed_groups(
- self.get_option("groups"), host.to_json(), hostname
- )
- self._add_host_to_keyed_groups(
- self.get_option("keyed_groups"), host.to_json(), hostname
- )
-
- def _get_project_disks(self, config_data, query):
- """
- project space disk images
- """
-
- try:
- self._project_disks
- except AttributeError:
- self._project_disks = {}
- request_params = {"maxResults": 500, "filter": query}
-
- for project in config_data["projects"]:
- session_responses = []
- page_token = True
- while page_token:
- response = self.auth_session.get(
- "https://www.googleapis.com/compute/v1/projects/{0}/aggregated/disks".format(
- project
- ),
- params=request_params,
- )
- response_json = response.json()
- if "nextPageToken" in response_json:
- request_params["pageToken"] = response_json["nextPageToken"]
- elif "pageToken" in request_params:
- del request_params["pageToken"]
-
- if "items" in response_json:
- session_responses.append(response_json)
- page_token = "pageToken" in request_params
-
- for response in session_responses:
- if "items" in response:
- # example k would be a zone or region name
- # example v would be { "disks" : [], "otherkey" : "..." }
- for zone_or_region, aggregate in response["items"].items():
- if "zones" in zone_or_region:
- if "disks" in aggregate:
- zone = zone_or_region.replace("zones/", "")
- for disk in aggregate["disks"]:
- if (
- "zones" in config_data
- and zone in config_data["zones"]
- ):
- # If zones specified, only store those zones' data
- if "sourceImage" in disk:
- self._project_disks[
- disk["selfLink"]
- ] = disk["sourceImage"].split("/")[-1]
- else:
- self._project_disks[
- disk["selfLink"]
- ] = disk["selfLink"].split("/")[-1]
-
- else:
- if "sourceImage" in disk:
- self._project_disks[
- disk["selfLink"]
- ] = disk["sourceImage"].split("/")[-1]
- else:
- self._project_disks[
- disk["selfLink"]
- ] = disk["selfLink"].split("/")[-1]
-
- return self._project_disks
-
- def fetch_projects(self, params, link, query):
- module = GcpMockModule(params)
- auth = GcpSession(module, 'cloudresourcemanager')
- response = auth.get(link, params={'filter': query})
- return self._return_if_object(module, response)
-
- def projects_for_folder(self, config_data, folder):
- link = 'https://cloudresourcemanager.googleapis.com/v1/projects'.format()
- query = 'parent.id = {0}'.format(folder)
- projects = []
- config_data['scopes'] = ['https://www.googleapis.com/auth/cloud-platform']
- projects_response = self.fetch_projects(config_data, link, query)
-
- if 'projects' in projects_response:
- for item in projects_response.get('projects'):
- projects.append(item['name'])
- return projects
-
- def parse(self, inventory, loader, path, cache=True):
-
- if not HAS_GOOGLE_LIBRARIES:
- raise AnsibleParserError(
- "gce inventory plugin cannot start: %s"
- % missing_required_lib("google-auth")
- )
-
- super(InventoryModule, self).parse(inventory, loader, path)
-
- config_data = {}
- config_data = self._read_config_data(path)
-
- if self.get_option("use_contrib_script_compatible_sanitization"):
- self._sanitize_group_name = (
- self._legacy_script_compatible_group_sanitization
- )
-
- # setup parameters as expected by 'fake module class' to reuse module_utils w/o changing the API
- params = {
- "filters": self.get_option("filters"),
- "projects": self.get_option("projects"),
- "folders": self.get_option("folders"),
- "scopes": self.get_option("scopes"),
- "zones": self.get_option("zones"),
- "auth_kind": self.get_option("auth_kind"),
- "service_account_file": self.get_option("service_account_file"),
- "service_account_contents": self.get_option("service_account_contents"),
- "service_account_email": self.get_option("service_account_email"),
- }
-
- self.fake_module = GcpMockModule(params)
- self.auth_session = GcpSession(self.fake_module, "compute")
-
- query = self._get_query_options(params["filters"])
-
- if self.get_option("retrieve_image_info"):
- project_disks = self._get_project_disks(config_data, query)
- else:
- project_disks = None
-
- # Cache logic
- if cache:
- cache = self.get_option("cache")
- cache_key = self.get_cache_key(path)
- else:
- cache_key = None
-
- cache_needs_update = False
- if cache:
- try:
- results = self._cache[cache_key]
- for project in results:
- for zone in results[project]:
- self._add_hosts(
- results[project][zone],
- config_data,
- False,
- project_disks=project_disks,
- )
- except KeyError:
- cache_needs_update = True
-
- projects = []
- if params["projects"]:
- projects = projects + params["projects"]
-
- if params["folders"]:
- for folder in params["folders"]:
- projects = projects + self.projects_for_folder(config_data, folder)
-
- if not cache or cache_needs_update:
- cached_data = {}
- for project in projects:
- cached_data[project] = {}
- params["project"] = project
- zones = params["zones"]
- # Fetch all instances
- link = self._instances % project
- resp = self.fetch_list(params, link, query)
- for key, value in resp.items():
- zone = key[6:]
- if not zones or zone in zones:
- self._add_hosts(value, config_data, project_disks=project_disks)
- cached_data[project][zone] = value
-
- if cache_needs_update:
- self._cache[cache_key] = cached_data
-
- @staticmethod
- def _legacy_script_compatible_group_sanitization(name):
-
- return name
diff --git a/test/integration/targets/gcp_appengine_firewall_rule/aliases b/test/integration/targets/gcp_appengine_firewall_rule/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_appengine_firewall_rule/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_appengine_firewall_rule/defaults/main.yml b/test/integration/targets/gcp_appengine_firewall_rule/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_appengine_firewall_rule/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_appengine_firewall_rule/meta/main.yml b/test/integration/targets/gcp_appengine_firewall_rule/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_appengine_firewall_rule/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_appengine_firewall_rule/tasks/autogen.yml b/test/integration/targets/gcp_appengine_firewall_rule/tasks/autogen.yml
deleted file mode 100644
index 5233e460a0..0000000000
--- a/test/integration/targets/gcp_appengine_firewall_rule/tasks/autogen.yml
+++ /dev/null
@@ -1,108 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a firewall rule
- gcp_appengine_firewall_rule:
- priority: 1000
- source_range: 10.0.0.0
- action: ALLOW
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a firewall rule
- gcp_appengine_firewall_rule:
- priority: 1000
- source_range: 10.0.0.0
- action: ALLOW
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that firewall_rule was created
- gcp_appengine_firewall_rule_info:
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloud-platform
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length >= 1
-# ----------------------------------------------------------------------------
-- name: create a firewall rule that already exists
- gcp_appengine_firewall_rule:
- priority: 1000
- source_range: 10.0.0.0
- action: ALLOW
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a firewall rule
- gcp_appengine_firewall_rule:
- priority: 1000
- source_range: 10.0.0.0
- action: ALLOW
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that firewall_rule was deleted
- gcp_appengine_firewall_rule_info:
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloud-platform
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a firewall rule that does not exist
- gcp_appengine_firewall_rule:
- priority: 1000
- source_range: 10.0.0.0
- action: ALLOW
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_appengine_firewall_rule/tasks/main.yml b/test/integration/targets/gcp_appengine_firewall_rule/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_appengine_firewall_rule/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_bigquery_dataset/aliases b/test/integration/targets/gcp_bigquery_dataset/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_bigquery_dataset/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_bigquery_dataset/defaults/main.yml b/test/integration/targets/gcp_bigquery_dataset/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_bigquery_dataset/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_bigquery_dataset/meta/main.yml b/test/integration/targets/gcp_bigquery_dataset/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_bigquery_dataset/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_bigquery_dataset/tasks/autogen.yml b/test/integration/targets/gcp_bigquery_dataset/tasks/autogen.yml
deleted file mode 100644
index ac1eae0dde..0000000000
--- a/test/integration/targets/gcp_bigquery_dataset/tasks/autogen.yml
+++ /dev/null
@@ -1,108 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a dataset
- gcp_bigquery_dataset:
- name: my_example_dataset
- dataset_reference:
- dataset_id: my_example_dataset
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a dataset
- gcp_bigquery_dataset:
- name: my_example_dataset
- dataset_reference:
- dataset_id: my_example_dataset
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that dataset was created
- gcp_bigquery_dataset_info:
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/bigquery
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='datasetReference') | map(attribute='datasetId') | select("match", ".*my_example_dataset.*") | list | length == 1
-# ----------------------------------------------------------------------------
-- name: create a dataset that already exists
- gcp_bigquery_dataset:
- name: my_example_dataset
- dataset_reference:
- dataset_id: my_example_dataset
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a dataset
- gcp_bigquery_dataset:
- name: my_example_dataset
- dataset_reference:
- dataset_id: my_example_dataset
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that dataset was deleted
- gcp_bigquery_dataset_info:
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/bigquery
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='datasetReference') | map(attribute='datasetId') | select("match", ".*my_example_dataset.*") | list | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a dataset that does not exist
- gcp_bigquery_dataset:
- name: my_example_dataset
- dataset_reference:
- dataset_id: my_example_dataset
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_bigquery_dataset/tasks/main.yml b/test/integration/targets/gcp_bigquery_dataset/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_bigquery_dataset/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_bigquery_table/aliases b/test/integration/targets/gcp_bigquery_table/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_bigquery_table/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_bigquery_table/defaults/main.yml b/test/integration/targets/gcp_bigquery_table/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_bigquery_table/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_bigquery_table/meta/main.yml b/test/integration/targets/gcp_bigquery_table/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_bigquery_table/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_bigquery_table/tasks/autogen.yml b/test/integration/targets/gcp_bigquery_table/tasks/autogen.yml
deleted file mode 100644
index caa12eb97f..0000000000
--- a/test/integration/targets/gcp_bigquery_table/tasks/autogen.yml
+++ /dev/null
@@ -1,149 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a dataset
- gcp_bigquery_dataset:
- name: example_dataset
- dataset_reference:
- dataset_id: example_dataset
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: dataset
-- name: delete a table
- gcp_bigquery_table:
- name: example_table
- dataset: example_dataset
- table_reference:
- dataset_id: example_dataset
- project_id: "{{ gcp_project }}"
- table_id: example_table
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a table
- gcp_bigquery_table:
- name: example_table
- dataset: example_dataset
- table_reference:
- dataset_id: example_dataset
- project_id: "{{ gcp_project }}"
- table_id: example_table
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that table was created
- gcp_bigquery_table_info:
- dataset: example_dataset
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/bigquery
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='tableReference') | map(attribute='tableId') | select("match", ".*example_table.*") | list | length == 1
-# ----------------------------------------------------------------------------
-- name: create a table that already exists
- gcp_bigquery_table:
- name: example_table
- dataset: example_dataset
- table_reference:
- dataset_id: example_dataset
- project_id: "{{ gcp_project }}"
- table_id: example_table
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a table
- gcp_bigquery_table:
- name: example_table
- dataset: example_dataset
- table_reference:
- dataset_id: example_dataset
- project_id: "{{ gcp_project }}"
- table_id: example_table
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that table was deleted
- gcp_bigquery_table_info:
- dataset: example_dataset
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/bigquery
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='tableReference') | map(attribute='tableId') | select("match", ".*example_table.*") | list | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a table that does not exist
- gcp_bigquery_table:
- name: example_table
- dataset: example_dataset
- table_reference:
- dataset_id: example_dataset
- project_id: "{{ gcp_project }}"
- table_id: example_table
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a dataset
- gcp_bigquery_dataset:
- name: example_dataset
- dataset_reference:
- dataset_id: example_dataset
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: dataset
- ignore_errors: true
diff --git a/test/integration/targets/gcp_bigquery_table/tasks/main.yml b/test/integration/targets/gcp_bigquery_table/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_bigquery_table/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_cloudbuild_trigger/aliases b/test/integration/targets/gcp_cloudbuild_trigger/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_cloudbuild_trigger/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_cloudbuild_trigger/defaults/main.yml b/test/integration/targets/gcp_cloudbuild_trigger/defaults/main.yml
deleted file mode 100644
index aa87a2a8e0..0000000000
--- a/test/integration/targets/gcp_cloudbuild_trigger/defaults/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
----
-# defaults file
-resource_name: '{{resource_prefix}}'
diff --git a/test/integration/targets/gcp_cloudbuild_trigger/meta/main.yml b/test/integration/targets/gcp_cloudbuild_trigger/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_cloudbuild_trigger/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_cloudfunctions_cloud_function/aliases b/test/integration/targets/gcp_cloudfunctions_cloud_function/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_cloudfunctions_cloud_function/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_cloudfunctions_cloud_function/defaults/main.yml b/test/integration/targets/gcp_cloudfunctions_cloud_function/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_cloudfunctions_cloud_function/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_cloudfunctions_cloud_function/meta/main.yml b/test/integration/targets/gcp_cloudfunctions_cloud_function/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_cloudfunctions_cloud_function/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_cloudfunctions_cloud_function/tasks/autogen.yml b/test/integration/targets/gcp_cloudfunctions_cloud_function/tasks/autogen.yml
deleted file mode 100644
index 7c76f7149f..0000000000
--- a/test/integration/targets/gcp_cloudfunctions_cloud_function/tasks/autogen.yml
+++ /dev/null
@@ -1,120 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a cloud function
- gcp_cloudfunctions_cloud_function:
- name: "{{ resource_name }}"
- location: us-central1
- entry_point: helloGET
- source_archive_url: gs://ansible-cloudfunctions-bucket/function.zip
- trigger_http: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a cloud function
- gcp_cloudfunctions_cloud_function:
- name: "{{ resource_name }}"
- location: us-central1
- entry_point: helloGET
- source_archive_url: gs://ansible-cloudfunctions-bucket/function.zip
- trigger_http: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that cloud_function was created
- gcp_cloudfunctions_cloud_function_info:
- location: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloud-platform
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 1
-# ----------------------------------------------------------------------------
-- name: create a cloud function that already exists
- gcp_cloudfunctions_cloud_function:
- name: "{{ resource_name }}"
- location: us-central1
- entry_point: helloGET
- source_archive_url: gs://ansible-cloudfunctions-bucket/function.zip
- trigger_http: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a cloud function
- gcp_cloudfunctions_cloud_function:
- name: "{{ resource_name }}"
- location: us-central1
- entry_point: helloGET
- source_archive_url: gs://ansible-cloudfunctions-bucket/function.zip
- trigger_http: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that cloud_function was deleted
- gcp_cloudfunctions_cloud_function_info:
- location: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloud-platform
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a cloud function that does not exist
- gcp_cloudfunctions_cloud_function:
- name: "{{ resource_name }}"
- location: us-central1
- entry_point: helloGET
- source_archive_url: gs://ansible-cloudfunctions-bucket/function.zip
- trigger_http: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_cloudfunctions_cloud_function/tasks/main.yml b/test/integration/targets/gcp_cloudfunctions_cloud_function/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_cloudfunctions_cloud_function/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_cloudscheduler_job/aliases b/test/integration/targets/gcp_cloudscheduler_job/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_cloudscheduler_job/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_cloudscheduler_job/defaults/main.yml b/test/integration/targets/gcp_cloudscheduler_job/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_cloudscheduler_job/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_cloudscheduler_job/meta/main.yml b/test/integration/targets/gcp_cloudscheduler_job/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_cloudscheduler_job/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_cloudscheduler_job/tasks/autogen.yml b/test/integration/targets/gcp_cloudscheduler_job/tasks/autogen.yml
deleted file mode 100644
index ffe687b767..0000000000
--- a/test/integration/targets/gcp_cloudscheduler_job/tasks/autogen.yml
+++ /dev/null
@@ -1,155 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a job
- gcp_cloudscheduler_job:
- name: job
- region: us-central1
- schedule: "*/4 * * * *"
- description: test app engine job
- time_zone: Europe/London
- app_engine_http_target:
- http_method: POST
- app_engine_routing:
- service: web
- version: prod
- instance: my-instance-001
- relative_uri: "/ping"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a job
- gcp_cloudscheduler_job:
- name: job
- region: us-central1
- schedule: "*/4 * * * *"
- description: test app engine job
- time_zone: Europe/London
- app_engine_http_target:
- http_method: POST
- app_engine_routing:
- service: web
- version: prod
- instance: my-instance-001
- relative_uri: "/ping"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that job was created
- gcp_cloudscheduler_job_info:
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloud-platform
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*job.*") | list | length == 1
-# ----------------------------------------------------------------------------
-- name: create a job that already exists
- gcp_cloudscheduler_job:
- name: job
- region: us-central1
- schedule: "*/4 * * * *"
- description: test app engine job
- time_zone: Europe/London
- app_engine_http_target:
- http_method: POST
- app_engine_routing:
- service: web
- version: prod
- instance: my-instance-001
- relative_uri: "/ping"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a job
- gcp_cloudscheduler_job:
- name: job
- region: us-central1
- schedule: "*/4 * * * *"
- description: test app engine job
- time_zone: Europe/London
- app_engine_http_target:
- http_method: POST
- app_engine_routing:
- service: web
- version: prod
- instance: my-instance-001
- relative_uri: "/ping"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that job was deleted
- gcp_cloudscheduler_job_info:
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloud-platform
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*job.*") | list | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a job that does not exist
- gcp_cloudscheduler_job:
- name: job
- region: us-central1
- schedule: "*/4 * * * *"
- description: test app engine job
- time_zone: Europe/London
- app_engine_http_target:
- http_method: POST
- app_engine_routing:
- service: web
- version: prod
- instance: my-instance-001
- relative_uri: "/ping"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_cloudscheduler_job/tasks/main.yml b/test/integration/targets/gcp_cloudscheduler_job/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_cloudscheduler_job/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_cloudtasks_queue/aliases b/test/integration/targets/gcp_cloudtasks_queue/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_cloudtasks_queue/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_cloudtasks_queue/defaults/main.yml b/test/integration/targets/gcp_cloudtasks_queue/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_cloudtasks_queue/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_cloudtasks_queue/meta/main.yml b/test/integration/targets/gcp_cloudtasks_queue/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_cloudtasks_queue/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_cloudtasks_queue/tasks/autogen.yml b/test/integration/targets/gcp_cloudtasks_queue/tasks/autogen.yml
deleted file mode 100644
index 19d583c442..0000000000
--- a/test/integration/targets/gcp_cloudtasks_queue/tasks/autogen.yml
+++ /dev/null
@@ -1,105 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a queue
- gcp_cloudtasks_queue:
- name: "{{ resource_name }}"
- location: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a queue
- gcp_cloudtasks_queue:
- name: "{{ resource_name }}"
- location: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that queue was created
- gcp_cloudtasks_queue_info:
- location: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloud-platform
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 1
-# ----------------------------------------------------------------------------
-- name: create a queue that already exists
- gcp_cloudtasks_queue:
- name: "{{ resource_name }}"
- location: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a queue
- gcp_cloudtasks_queue:
- name: "{{ resource_name }}"
- location: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that queue was deleted
- gcp_cloudtasks_queue_info:
- location: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloud-platform
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a queue that does not exist
- gcp_cloudtasks_queue:
- name: "{{ resource_name }}"
- location: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_cloudtasks_queue/tasks/main.yml b/test/integration/targets/gcp_cloudtasks_queue/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_cloudtasks_queue/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_address/aliases b/test/integration/targets/gcp_compute_address/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_address/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_address/defaults/main.yml b/test/integration/targets/gcp_compute_address/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_compute_address/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_compute_address/meta/main.yml b/test/integration/targets/gcp_compute_address/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_address/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_address/tasks/autogen.yml b/test/integration/targets/gcp_compute_address/tasks/autogen.yml
deleted file mode 100644
index 124e44d2f1..0000000000
--- a/test/integration/targets/gcp_compute_address/tasks/autogen.yml
+++ /dev/null
@@ -1,109 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a address
- gcp_compute_address:
- name: test-address1
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a address
- gcp_compute_address:
- name: test-address1
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that address was created
- gcp_compute_address_info:
- filters:
- - name = test-address1
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a address that already exists
- gcp_compute_address:
- name: test-address1
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a address
- gcp_compute_address:
- name: test-address1
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that address was deleted
- gcp_compute_address_info:
- filters:
- - name = test-address1
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a address that does not exist
- gcp_compute_address:
- name: test-address1
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_compute_address/tasks/main.yml b/test/integration/targets/gcp_compute_address/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_address/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_autoscaler/aliases b/test/integration/targets/gcp_compute_autoscaler/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_autoscaler/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_autoscaler/defaults/main.yml b/test/integration/targets/gcp_compute_autoscaler/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_compute_autoscaler/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_compute_autoscaler/meta/main.yml b/test/integration/targets/gcp_compute_autoscaler/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_autoscaler/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_autoscaler/tasks/autogen.yml b/test/integration/targets/gcp_compute_autoscaler/tasks/autogen.yml
deleted file mode 100644
index 899c88df1f..0000000000
--- a/test/integration/targets/gcp_compute_autoscaler/tasks/autogen.yml
+++ /dev/null
@@ -1,251 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a network
- gcp_compute_network:
- name: network-instancetemplate
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: network
-- name: create a address
- gcp_compute_address:
- name: address-instancetemplate
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: address
-- name: create a instance template
- gcp_compute_instance_template:
- name: "{{ resource_name }}"
- properties:
- disks:
- - auto_delete: 'true'
- boot: 'true'
- initialize_params:
- source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
- machine_type: n1-standard-1
- network_interfaces:
- - network: "{{ network }}"
- access_configs:
- - name: test-config
- type: ONE_TO_ONE_NAT
- nat_ip: "{{ address }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: instancetemplate
-- name: create a instance group manager
- gcp_compute_instance_group_manager:
- name: "{{ resource_name }}"
- base_instance_name: test1-child
- instance_template: "{{ instancetemplate }}"
- target_size: 3
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: igm
-- name: delete a autoscaler
- gcp_compute_autoscaler:
- name: "{{ resource_name }}"
- zone: us-central1-a
- target: "{{ igm }}"
- autoscaling_policy:
- max_num_replicas: 5
- min_num_replicas: 1
- cool_down_period_sec: 60
- cpu_utilization:
- utilization_target: 0.5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a autoscaler
- gcp_compute_autoscaler:
- name: "{{ resource_name }}"
- zone: us-central1-a
- target: "{{ igm }}"
- autoscaling_policy:
- max_num_replicas: 5
- min_num_replicas: 1
- cool_down_period_sec: 60
- cpu_utilization:
- utilization_target: 0.5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that autoscaler was created
- gcp_compute_autoscaler_info:
- filters:
- - name = {{ resource_name }}
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a autoscaler that already exists
- gcp_compute_autoscaler:
- name: "{{ resource_name }}"
- zone: us-central1-a
- target: "{{ igm }}"
- autoscaling_policy:
- max_num_replicas: 5
- min_num_replicas: 1
- cool_down_period_sec: 60
- cpu_utilization:
- utilization_target: 0.5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a autoscaler
- gcp_compute_autoscaler:
- name: "{{ resource_name }}"
- zone: us-central1-a
- target: "{{ igm }}"
- autoscaling_policy:
- max_num_replicas: 5
- min_num_replicas: 1
- cool_down_period_sec: 60
- cpu_utilization:
- utilization_target: 0.5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that autoscaler was deleted
- gcp_compute_autoscaler_info:
- filters:
- - name = {{ resource_name }}
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a autoscaler that does not exist
- gcp_compute_autoscaler:
- name: "{{ resource_name }}"
- zone: us-central1-a
- target: "{{ igm }}"
- autoscaling_policy:
- max_num_replicas: 5
- min_num_replicas: 1
- cool_down_period_sec: 60
- cpu_utilization:
- utilization_target: 0.5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a instance group manager
- gcp_compute_instance_group_manager:
- name: "{{ resource_name }}"
- base_instance_name: test1-child
- instance_template: "{{ instancetemplate }}"
- target_size: 3
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: igm
- ignore_errors: true
-- name: delete a instance template
- gcp_compute_instance_template:
- name: "{{ resource_name }}"
- properties:
- disks:
- - auto_delete: 'true'
- boot: 'true'
- initialize_params:
- source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
- machine_type: n1-standard-1
- network_interfaces:
- - network: "{{ network }}"
- access_configs:
- - name: test-config
- type: ONE_TO_ONE_NAT
- nat_ip: "{{ address }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: instancetemplate
- ignore_errors: true
-- name: delete a address
- gcp_compute_address:
- name: address-instancetemplate
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: address
- ignore_errors: true
-- name: delete a network
- gcp_compute_network:
- name: network-instancetemplate
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: network
- ignore_errors: true
diff --git a/test/integration/targets/gcp_compute_autoscaler/tasks/main.yml b/test/integration/targets/gcp_compute_autoscaler/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_autoscaler/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_backend_bucket/aliases b/test/integration/targets/gcp_compute_backend_bucket/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_backend_bucket/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_backend_bucket/defaults/main.yml b/test/integration/targets/gcp_compute_backend_bucket/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_compute_backend_bucket/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_compute_backend_bucket/meta/main.yml b/test/integration/targets/gcp_compute_backend_bucket/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_backend_bucket/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_backend_bucket/tasks/autogen.yml b/test/integration/targets/gcp_compute_backend_bucket/tasks/autogen.yml
deleted file mode 100644
index 35963c90c1..0000000000
--- a/test/integration/targets/gcp_compute_backend_bucket/tasks/autogen.yml
+++ /dev/null
@@ -1,137 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a bucket
- gcp_storage_bucket:
- name: bucket-backendbucket
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: bucket
-- name: delete a backend bucket
- gcp_compute_backend_bucket:
- name: "{{ resource_name }}"
- bucket_name: "{{ bucket.name }}"
- description: A BackendBucket to connect LNB w/ Storage Bucket
- enable_cdn: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a backend bucket
- gcp_compute_backend_bucket:
- name: "{{ resource_name }}"
- bucket_name: "{{ bucket.name }}"
- description: A BackendBucket to connect LNB w/ Storage Bucket
- enable_cdn: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that backend_bucket was created
- gcp_compute_backend_bucket_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a backend bucket that already exists
- gcp_compute_backend_bucket:
- name: "{{ resource_name }}"
- bucket_name: "{{ bucket.name }}"
- description: A BackendBucket to connect LNB w/ Storage Bucket
- enable_cdn: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a backend bucket
- gcp_compute_backend_bucket:
- name: "{{ resource_name }}"
- bucket_name: "{{ bucket.name }}"
- description: A BackendBucket to connect LNB w/ Storage Bucket
- enable_cdn: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that backend_bucket was deleted
- gcp_compute_backend_bucket_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a backend bucket that does not exist
- gcp_compute_backend_bucket:
- name: "{{ resource_name }}"
- bucket_name: "{{ bucket.name }}"
- description: A BackendBucket to connect LNB w/ Storage Bucket
- enable_cdn: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a bucket
- gcp_storage_bucket:
- name: bucket-backendbucket
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: bucket
- ignore_errors: true
diff --git a/test/integration/targets/gcp_compute_backend_bucket/tasks/main.yml b/test/integration/targets/gcp_compute_backend_bucket/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_backend_bucket/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_backend_service/aliases b/test/integration/targets/gcp_compute_backend_service/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_backend_service/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_backend_service/defaults/main.yml b/test/integration/targets/gcp_compute_backend_service/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_compute_backend_service/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_compute_backend_service/meta/main.yml b/test/integration/targets/gcp_compute_backend_service/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_backend_service/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_backend_service/tasks/autogen.yml b/test/integration/targets/gcp_compute_backend_service/tasks/autogen.yml
deleted file mode 100644
index 60fa24c4be..0000000000
--- a/test/integration/targets/gcp_compute_backend_service/tasks/autogen.yml
+++ /dev/null
@@ -1,174 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a instance group
- gcp_compute_instance_group:
- name: instancegroup-backendservice
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: instancegroup
-- name: create a HTTP health check
- gcp_compute_http_health_check:
- name: httphealthcheck-backendservice
- healthy_threshold: 10
- port: 8080
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: healthcheck
-- name: delete a backend service
- gcp_compute_backend_service:
- name: "{{ resource_name }}"
- backends:
- - group: "{{ instancegroup.selfLink }}"
- health_checks:
- - "{{ healthcheck.selfLink }}"
- enable_cdn: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a backend service
- gcp_compute_backend_service:
- name: "{{ resource_name }}"
- backends:
- - group: "{{ instancegroup.selfLink }}"
- health_checks:
- - "{{ healthcheck.selfLink }}"
- enable_cdn: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that backend_service was created
- gcp_compute_backend_service_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a backend service that already exists
- gcp_compute_backend_service:
- name: "{{ resource_name }}"
- backends:
- - group: "{{ instancegroup.selfLink }}"
- health_checks:
- - "{{ healthcheck.selfLink }}"
- enable_cdn: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a backend service
- gcp_compute_backend_service:
- name: "{{ resource_name }}"
- backends:
- - group: "{{ instancegroup.selfLink }}"
- health_checks:
- - "{{ healthcheck.selfLink }}"
- enable_cdn: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that backend_service was deleted
- gcp_compute_backend_service_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a backend service that does not exist
- gcp_compute_backend_service:
- name: "{{ resource_name }}"
- backends:
- - group: "{{ instancegroup.selfLink }}"
- health_checks:
- - "{{ healthcheck.selfLink }}"
- enable_cdn: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a HTTP health check
- gcp_compute_http_health_check:
- name: httphealthcheck-backendservice
- healthy_threshold: 10
- port: 8080
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: healthcheck
- ignore_errors: true
-- name: delete a instance group
- gcp_compute_instance_group:
- name: instancegroup-backendservice
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: instancegroup
- ignore_errors: true
diff --git a/test/integration/targets/gcp_compute_backend_service/tasks/main.yml b/test/integration/targets/gcp_compute_backend_service/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_backend_service/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_disk/aliases b/test/integration/targets/gcp_compute_disk/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_disk/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_disk/defaults/main.yml b/test/integration/targets/gcp_compute_disk/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_compute_disk/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_compute_disk/meta/main.yml b/test/integration/targets/gcp_compute_disk/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_disk/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_disk/tasks/autogen.yml b/test/integration/targets/gcp_compute_disk/tasks/autogen.yml
deleted file mode 100644
index 9dd08f1b48..0000000000
--- a/test/integration/targets/gcp_compute_disk/tasks/autogen.yml
+++ /dev/null
@@ -1,124 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a disk
- gcp_compute_disk:
- name: "{{ resource_name }}"
- size_gb: 50
- disk_encryption_key:
- raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0=
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a disk
- gcp_compute_disk:
- name: "{{ resource_name }}"
- size_gb: 50
- disk_encryption_key:
- raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0=
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that disk was created
- gcp_compute_disk_info:
- filters:
- - name = {{ resource_name }}
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a disk that already exists
- gcp_compute_disk:
- name: "{{ resource_name }}"
- size_gb: 50
- disk_encryption_key:
- raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0=
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a disk
- gcp_compute_disk:
- name: "{{ resource_name }}"
- size_gb: 50
- disk_encryption_key:
- raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0=
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that disk was deleted
- gcp_compute_disk_info:
- filters:
- - name = {{ resource_name }}
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a disk that does not exist
- gcp_compute_disk:
- name: "{{ resource_name }}"
- size_gb: 50
- disk_encryption_key:
- raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0=
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_compute_disk/tasks/main.yml b/test/integration/targets/gcp_compute_disk/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_disk/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_firewall/aliases b/test/integration/targets/gcp_compute_firewall/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_firewall/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_firewall/defaults/main.yml b/test/integration/targets/gcp_compute_firewall/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_compute_firewall/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_compute_firewall/meta/main.yml b/test/integration/targets/gcp_compute_firewall/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_firewall/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_firewall/tasks/autogen.yml b/test/integration/targets/gcp_compute_firewall/tasks/autogen.yml
deleted file mode 100644
index 7a775501f5..0000000000
--- a/test/integration/targets/gcp_compute_firewall/tasks/autogen.yml
+++ /dev/null
@@ -1,147 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a firewall
- gcp_compute_firewall:
- name: "{{ resource_name }}"
- allowed:
- - ip_protocol: tcp
- ports:
- - '22'
- target_tags:
- - test-ssh-server
- - staging-ssh-server
- source_tags:
- - test-ssh-clients
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a firewall
- gcp_compute_firewall:
- name: "{{ resource_name }}"
- allowed:
- - ip_protocol: tcp
- ports:
- - '22'
- target_tags:
- - test-ssh-server
- - staging-ssh-server
- source_tags:
- - test-ssh-clients
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that firewall was created
- gcp_compute_firewall_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a firewall that already exists
- gcp_compute_firewall:
- name: "{{ resource_name }}"
- allowed:
- - ip_protocol: tcp
- ports:
- - '22'
- target_tags:
- - test-ssh-server
- - staging-ssh-server
- source_tags:
- - test-ssh-clients
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a firewall
- gcp_compute_firewall:
- name: "{{ resource_name }}"
- allowed:
- - ip_protocol: tcp
- ports:
- - '22'
- target_tags:
- - test-ssh-server
- - staging-ssh-server
- source_tags:
- - test-ssh-clients
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that firewall was deleted
- gcp_compute_firewall_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a firewall that does not exist
- gcp_compute_firewall:
- name: "{{ resource_name }}"
- allowed:
- - ip_protocol: tcp
- ports:
- - '22'
- target_tags:
- - test-ssh-server
- - staging-ssh-server
- source_tags:
- - test-ssh-clients
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_compute_firewall/tasks/main.yml b/test/integration/targets/gcp_compute_firewall/tasks/main.yml
deleted file mode 100644
index 3cfb1cb12b..0000000000
--- a/test/integration/targets/gcp_compute_firewall/tasks/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
----
-- include_tasks: update.yml
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_firewall/tasks/update.yml b/test/integration/targets/gcp_compute_firewall/tasks/update.yml
deleted file mode 100644
index 3ebbd21d07..0000000000
--- a/test/integration/targets/gcp_compute_firewall/tasks/update.yml
+++ /dev/null
@@ -1,179 +0,0 @@
-# Copyright 2019 Google Inc.
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a firewall
- google.cloud.gcp_compute_firewall:
- name: "{{ resource_name }}"
- allowed:
- - ip_protocol: tcp
- ports:
- - '22'
- target_tags:
- - test-ssh-server
- - staging-ssh-server
- source_tags:
- - test-ssh-clients
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a firewall
- google.cloud.gcp_compute_firewall:
- name: "{{ resource_name }}"
- allowed:
- - ip_protocol: tcp
- ports:
- - '22'
- target_tags:
- - test-ssh-server
- - staging-ssh-server
- source_tags:
- - test-ssh-clients
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that firewall was created
- google.cloud.gcp_compute_firewall_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: update the firewall
- google.cloud.gcp_compute_firewall:
- name: "{{ resource_name }}"
- allowed:
- - ip_protocol: tcp
- ports:
- - '55'
- target_tags:
- - test-ssh-server
- - staging-ssh-server
- source_tags:
- - test-ssh-clients
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-# ----------------------------------------------------------------------------
-- name: check firewall was updated.
- google.cloud.gcp_compute_firewall_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-- name: verify that update succeeded
- assert:
- that:
- - results['resources'][0]['allowed'][0]['ports'][0] == '55'
-#----------------------------------------------------------
-- name: delete a firewall
- google.cloud.gcp_compute_firewall:
- name: "{{ resource_name }}"
- allowed:
- - ip_protocol: tcp
- ports:
- - '22'
- target_tags:
- - test-ssh-server
- - staging-ssh-server
- source_tags:
- - test-ssh-clients
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that firewall was deleted
- google.cloud.gcp_compute_firewall_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a firewall that does not exist
- google.cloud.gcp_compute_firewall:
- name: "{{ resource_name }}"
- allowed:
- - ip_protocol: tcp
- ports:
- - '22'
- target_tags:
- - test-ssh-server
- - staging-ssh-server
- source_tags:
- - test-ssh-clients
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_compute_forwarding_rule/aliases b/test/integration/targets/gcp_compute_forwarding_rule/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_forwarding_rule/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_forwarding_rule/defaults/main.yml b/test/integration/targets/gcp_compute_forwarding_rule/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_compute_forwarding_rule/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_compute_forwarding_rule/meta/main.yml b/test/integration/targets/gcp_compute_forwarding_rule/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_forwarding_rule/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_forwarding_rule/tasks/autogen.yml b/test/integration/targets/gcp_compute_forwarding_rule/tasks/autogen.yml
deleted file mode 100644
index c46fa9b8ba..0000000000
--- a/test/integration/targets/gcp_compute_forwarding_rule/tasks/autogen.yml
+++ /dev/null
@@ -1,170 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a address
- gcp_compute_address:
- name: address-forwardingrule
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: address
-- name: create a target pool
- gcp_compute_target_pool:
- name: targetpool-forwardingrule
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: targetpool
-- name: delete a forwarding rule
- gcp_compute_forwarding_rule:
- name: "{{ resource_name }}"
- region: us-west1
- target: "{{ targetpool }}"
- ip_protocol: TCP
- port_range: 80-80
- ip_address: "{{ address.address }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a forwarding rule
- gcp_compute_forwarding_rule:
- name: "{{ resource_name }}"
- region: us-west1
- target: "{{ targetpool }}"
- ip_protocol: TCP
- port_range: 80-80
- ip_address: "{{ address.address }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that forwarding_rule was created
- gcp_compute_forwarding_rule_info:
- filters:
- - name = {{ resource_name }}
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a forwarding rule that already exists
- gcp_compute_forwarding_rule:
- name: "{{ resource_name }}"
- region: us-west1
- target: "{{ targetpool }}"
- ip_protocol: TCP
- port_range: 80-80
- ip_address: "{{ address.address }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a forwarding rule
- gcp_compute_forwarding_rule:
- name: "{{ resource_name }}"
- region: us-west1
- target: "{{ targetpool }}"
- ip_protocol: TCP
- port_range: 80-80
- ip_address: "{{ address.address }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that forwarding_rule was deleted
- gcp_compute_forwarding_rule_info:
- filters:
- - name = {{ resource_name }}
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a forwarding rule that does not exist
- gcp_compute_forwarding_rule:
- name: "{{ resource_name }}"
- region: us-west1
- target: "{{ targetpool }}"
- ip_protocol: TCP
- port_range: 80-80
- ip_address: "{{ address.address }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a target pool
- gcp_compute_target_pool:
- name: targetpool-forwardingrule
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: targetpool
- ignore_errors: true
-- name: delete a address
- gcp_compute_address:
- name: address-forwardingrule
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: address
- ignore_errors: true
diff --git a/test/integration/targets/gcp_compute_forwarding_rule/tasks/main.yml b/test/integration/targets/gcp_compute_forwarding_rule/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_forwarding_rule/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_global_address/aliases b/test/integration/targets/gcp_compute_global_address/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_global_address/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_global_address/defaults/main.yml b/test/integration/targets/gcp_compute_global_address/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_compute_global_address/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_compute_global_address/meta/main.yml b/test/integration/targets/gcp_compute_global_address/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_global_address/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_global_address/tasks/autogen.yml b/test/integration/targets/gcp_compute_global_address/tasks/autogen.yml
deleted file mode 100644
index fdbd73770a..0000000000
--- a/test/integration/targets/gcp_compute_global_address/tasks/autogen.yml
+++ /dev/null
@@ -1,102 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a global address
- gcp_compute_global_address:
- name: "{{ resource_name }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a global address
- gcp_compute_global_address:
- name: "{{ resource_name }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that global_address was created
- gcp_compute_global_address_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a global address that already exists
- gcp_compute_global_address:
- name: "{{ resource_name }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a global address
- gcp_compute_global_address:
- name: "{{ resource_name }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that global_address was deleted
- gcp_compute_global_address_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a global address that does not exist
- gcp_compute_global_address:
- name: "{{ resource_name }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_compute_global_address/tasks/main.yml b/test/integration/targets/gcp_compute_global_address/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_global_address/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_global_forwarding_rule/aliases b/test/integration/targets/gcp_compute_global_forwarding_rule/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_global_forwarding_rule/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_global_forwarding_rule/defaults/main.yml b/test/integration/targets/gcp_compute_global_forwarding_rule/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_compute_global_forwarding_rule/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_compute_global_forwarding_rule/meta/main.yml b/test/integration/targets/gcp_compute_global_forwarding_rule/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_global_forwarding_rule/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_global_forwarding_rule/tasks/autogen.yml b/test/integration/targets/gcp_compute_global_forwarding_rule/tasks/autogen.yml
deleted file mode 100644
index 234f036046..0000000000
--- a/test/integration/targets/gcp_compute_global_forwarding_rule/tasks/autogen.yml
+++ /dev/null
@@ -1,251 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a global address
- gcp_compute_global_address:
- name: globaladdress-globalforwardingrule
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: globaladdress
-- name: create a instance group
- gcp_compute_instance_group:
- name: instancegroup-globalforwardingrule
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: instancegroup
-- name: create a HTTP health check
- gcp_compute_http_health_check:
- name: httphealthcheck-globalforwardingrule
- healthy_threshold: 10
- port: 8080
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: healthcheck
-- name: create a backend service
- gcp_compute_backend_service:
- name: backendservice-globalforwardingrule
- backends:
- - group: "{{ instancegroup.selfLink }}"
- health_checks:
- - "{{ healthcheck.selfLink }}"
- enable_cdn: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: backendservice
-- name: create a URL map
- gcp_compute_url_map:
- name: urlmap-globalforwardingrule
- default_service: "{{ backendservice }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: urlmap
-- name: create a target HTTP proxy
- gcp_compute_target_http_proxy:
- name: targethttpproxy-globalforwardingrule
- url_map: "{{ urlmap }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: httpproxy
-- name: delete a global forwarding rule
- gcp_compute_global_forwarding_rule:
- name: "{{ resource_name }}"
- ip_address: "{{ globaladdress.address }}"
- ip_protocol: TCP
- port_range: 80-80
- target: "{{ httpproxy.selfLink }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a global forwarding rule
- gcp_compute_global_forwarding_rule:
- name: "{{ resource_name }}"
- ip_address: "{{ globaladdress.address }}"
- ip_protocol: TCP
- port_range: 80-80
- target: "{{ httpproxy.selfLink }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that global_forwarding_rule was created
- gcp_compute_global_forwarding_rule_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a global forwarding rule that already exists
- gcp_compute_global_forwarding_rule:
- name: "{{ resource_name }}"
- ip_address: "{{ globaladdress.address }}"
- ip_protocol: TCP
- port_range: 80-80
- target: "{{ httpproxy.selfLink }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a global forwarding rule
- gcp_compute_global_forwarding_rule:
- name: "{{ resource_name }}"
- ip_address: "{{ globaladdress.address }}"
- ip_protocol: TCP
- port_range: 80-80
- target: "{{ httpproxy.selfLink }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that global_forwarding_rule was deleted
- gcp_compute_global_forwarding_rule_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a global forwarding rule that does not exist
- gcp_compute_global_forwarding_rule:
- name: "{{ resource_name }}"
- ip_address: "{{ globaladdress.address }}"
- ip_protocol: TCP
- port_range: 80-80
- target: "{{ httpproxy.selfLink }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a target HTTP proxy
- gcp_compute_target_http_proxy:
- name: targethttpproxy-globalforwardingrule
- url_map: "{{ urlmap }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: httpproxy
- ignore_errors: true
-- name: delete a URL map
- gcp_compute_url_map:
- name: urlmap-globalforwardingrule
- default_service: "{{ backendservice }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: urlmap
- ignore_errors: true
-- name: delete a backend service
- gcp_compute_backend_service:
- name: backendservice-globalforwardingrule
- backends:
- - group: "{{ instancegroup.selfLink }}"
- health_checks:
- - "{{ healthcheck.selfLink }}"
- enable_cdn: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: backendservice
- ignore_errors: true
-- name: delete a HTTP health check
- gcp_compute_http_health_check:
- name: httphealthcheck-globalforwardingrule
- healthy_threshold: 10
- port: 8080
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: healthcheck
- ignore_errors: true
-- name: delete a instance group
- gcp_compute_instance_group:
- name: instancegroup-globalforwardingrule
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: instancegroup
- ignore_errors: true
-- name: delete a global address
- gcp_compute_global_address:
- name: globaladdress-globalforwardingrule
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: globaladdress
- ignore_errors: true
diff --git a/test/integration/targets/gcp_compute_global_forwarding_rule/tasks/main.yml b/test/integration/targets/gcp_compute_global_forwarding_rule/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_global_forwarding_rule/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_health_check/aliases b/test/integration/targets/gcp_compute_health_check/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_health_check/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_health_check/defaults/main.yml b/test/integration/targets/gcp_compute_health_check/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_compute_health_check/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_compute_health_check/meta/main.yml b/test/integration/targets/gcp_compute_health_check/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_health_check/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_health_check/tasks/autogen.yml b/test/integration/targets/gcp_compute_health_check/tasks/autogen.yml
deleted file mode 100644
index ab1c837cc7..0000000000
--- a/test/integration/targets/gcp_compute_health_check/tasks/autogen.yml
+++ /dev/null
@@ -1,142 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a health check
- gcp_compute_health_check:
- name: "{{ resource_name }}"
- type: TCP
- tcp_health_check:
- port_name: service-health
- request: ping
- response: pong
- healthy_threshold: 10
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a health check
- gcp_compute_health_check:
- name: "{{ resource_name }}"
- type: TCP
- tcp_health_check:
- port_name: service-health
- request: ping
- response: pong
- healthy_threshold: 10
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that health_check was created
- gcp_compute_health_check_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a health check that already exists
- gcp_compute_health_check:
- name: "{{ resource_name }}"
- type: TCP
- tcp_health_check:
- port_name: service-health
- request: ping
- response: pong
- healthy_threshold: 10
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a health check
- gcp_compute_health_check:
- name: "{{ resource_name }}"
- type: TCP
- tcp_health_check:
- port_name: service-health
- request: ping
- response: pong
- healthy_threshold: 10
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that health_check was deleted
- gcp_compute_health_check_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a health check that does not exist
- gcp_compute_health_check:
- name: "{{ resource_name }}"
- type: TCP
- tcp_health_check:
- port_name: service-health
- request: ping
- response: pong
- healthy_threshold: 10
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_compute_health_check/tasks/main.yml b/test/integration/targets/gcp_compute_health_check/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_health_check/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_http_health_check/aliases b/test/integration/targets/gcp_compute_http_health_check/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_http_health_check/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_http_health_check/defaults/main.yml b/test/integration/targets/gcp_compute_http_health_check/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_compute_http_health_check/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_compute_http_health_check/meta/main.yml b/test/integration/targets/gcp_compute_http_health_check/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_http_health_check/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_http_health_check/tasks/autogen.yml b/test/integration/targets/gcp_compute_http_health_check/tasks/autogen.yml
deleted file mode 100644
index 5e27f31b38..0000000000
--- a/test/integration/targets/gcp_compute_http_health_check/tasks/autogen.yml
+++ /dev/null
@@ -1,122 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a HTTP health check
- gcp_compute_http_health_check:
- name: "{{ resource_name }}"
- healthy_threshold: 10
- port: 8080
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a HTTP health check
- gcp_compute_http_health_check:
- name: "{{ resource_name }}"
- healthy_threshold: 10
- port: 8080
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that http_health_check was created
- gcp_compute_http_health_check_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a HTTP health check that already exists
- gcp_compute_http_health_check:
- name: "{{ resource_name }}"
- healthy_threshold: 10
- port: 8080
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a HTTP health check
- gcp_compute_http_health_check:
- name: "{{ resource_name }}"
- healthy_threshold: 10
- port: 8080
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that http_health_check was deleted
- gcp_compute_http_health_check_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a HTTP health check that does not exist
- gcp_compute_http_health_check:
- name: "{{ resource_name }}"
- healthy_threshold: 10
- port: 8080
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_compute_http_health_check/tasks/main.yml b/test/integration/targets/gcp_compute_http_health_check/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_http_health_check/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_https_health_check/aliases b/test/integration/targets/gcp_compute_https_health_check/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_https_health_check/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_https_health_check/defaults/main.yml b/test/integration/targets/gcp_compute_https_health_check/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_compute_https_health_check/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_compute_https_health_check/meta/main.yml b/test/integration/targets/gcp_compute_https_health_check/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_https_health_check/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_https_health_check/tasks/autogen.yml b/test/integration/targets/gcp_compute_https_health_check/tasks/autogen.yml
deleted file mode 100644
index 7d34fc8374..0000000000
--- a/test/integration/targets/gcp_compute_https_health_check/tasks/autogen.yml
+++ /dev/null
@@ -1,122 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a HTTPS health check
- gcp_compute_https_health_check:
- name: "{{ resource_name }}"
- healthy_threshold: 10
- port: 8080
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a HTTPS health check
- gcp_compute_https_health_check:
- name: "{{ resource_name }}"
- healthy_threshold: 10
- port: 8080
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that https_health_check was created
- gcp_compute_https_health_check_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a HTTPS health check that already exists
- gcp_compute_https_health_check:
- name: "{{ resource_name }}"
- healthy_threshold: 10
- port: 8080
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a HTTPS health check
- gcp_compute_https_health_check:
- name: "{{ resource_name }}"
- healthy_threshold: 10
- port: 8080
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that https_health_check was deleted
- gcp_compute_https_health_check_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a HTTPS health check that does not exist
- gcp_compute_https_health_check:
- name: "{{ resource_name }}"
- healthy_threshold: 10
- port: 8080
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_compute_https_health_check/tasks/main.yml b/test/integration/targets/gcp_compute_https_health_check/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_https_health_check/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_image/aliases b/test/integration/targets/gcp_compute_image/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_image/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_image/defaults/main.yml b/test/integration/targets/gcp_compute_image/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_compute_image/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_compute_image/meta/main.yml b/test/integration/targets/gcp_compute_image/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_image/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_image/tasks/autogen.yml b/test/integration/targets/gcp_compute_image/tasks/autogen.yml
deleted file mode 100644
index b51608bc11..0000000000
--- a/test/integration/targets/gcp_compute_image/tasks/autogen.yml
+++ /dev/null
@@ -1,129 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a disk
- gcp_compute_disk:
- name: disk-image
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: disk
-- name: delete a image
- gcp_compute_image:
- name: "{{ resource_name }}"
- source_disk: "{{ disk }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a image
- gcp_compute_image:
- name: "{{ resource_name }}"
- source_disk: "{{ disk }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that image was created
- gcp_compute_image_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a image that already exists
- gcp_compute_image:
- name: "{{ resource_name }}"
- source_disk: "{{ disk }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a image
- gcp_compute_image:
- name: "{{ resource_name }}"
- source_disk: "{{ disk }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that image was deleted
- gcp_compute_image_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a image that does not exist
- gcp_compute_image:
- name: "{{ resource_name }}"
- source_disk: "{{ disk }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a disk
- gcp_compute_disk:
- name: disk-image
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: disk
- ignore_errors: true
diff --git a/test/integration/targets/gcp_compute_image/tasks/main.yml b/test/integration/targets/gcp_compute_image/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_image/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_instance/aliases b/test/integration/targets/gcp_compute_instance/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_instance/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_instance/defaults/main.yml b/test/integration/targets/gcp_compute_instance/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_compute_instance/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_compute_instance/meta/main.yml b/test/integration/targets/gcp_compute_instance/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_instance/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_instance/tasks/autogen.yml b/test/integration/targets/gcp_compute_instance/tasks/autogen.yml
deleted file mode 100644
index bb42e4eae7..0000000000
--- a/test/integration/targets/gcp_compute_instance/tasks/autogen.yml
+++ /dev/null
@@ -1,276 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a disk
- gcp_compute_disk:
- name: disk-instance
- size_gb: 50
- source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: disk
-- name: create a network
- gcp_compute_network:
- name: network-instance
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: network
-- name: create a address
- gcp_compute_address:
- name: address-instance
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: address
-- name: delete a instance
- gcp_compute_instance:
- name: "{{ resource_name }}"
- machine_type: n1-standard-1
- disks:
- - auto_delete: 'true'
- boot: 'true'
- source: "{{ disk }}"
- - auto_delete: 'true'
- interface: NVME
- type: SCRATCH
- initialize_params:
- disk_type: local-ssd
- metadata:
- startup-script-url: gs:://graphite-playground/bootstrap.sh
- cost-center: '12345'
- labels:
- environment: production
- network_interfaces:
- - network: "{{ network }}"
- access_configs:
- - name: External NAT
- nat_ip: "{{ address }}"
- type: ONE_TO_ONE_NAT
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a instance
- gcp_compute_instance:
- name: "{{ resource_name }}"
- machine_type: n1-standard-1
- disks:
- - auto_delete: 'true'
- boot: 'true'
- source: "{{ disk }}"
- - auto_delete: 'true'
- interface: NVME
- type: SCRATCH
- initialize_params:
- disk_type: local-ssd
- metadata:
- startup-script-url: gs:://graphite-playground/bootstrap.sh
- cost-center: '12345'
- labels:
- environment: production
- network_interfaces:
- - network: "{{ network }}"
- access_configs:
- - name: External NAT
- nat_ip: "{{ address }}"
- type: ONE_TO_ONE_NAT
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that instance was created
- gcp_compute_instance_info:
- filters:
- - name = {{ resource_name }}
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a instance that already exists
- gcp_compute_instance:
- name: "{{ resource_name }}"
- machine_type: n1-standard-1
- disks:
- - auto_delete: 'true'
- boot: 'true'
- source: "{{ disk }}"
- - auto_delete: 'true'
- interface: NVME
- type: SCRATCH
- initialize_params:
- disk_type: local-ssd
- metadata:
- startup-script-url: gs:://graphite-playground/bootstrap.sh
- cost-center: '12345'
- labels:
- environment: production
- network_interfaces:
- - network: "{{ network }}"
- access_configs:
- - name: External NAT
- nat_ip: "{{ address }}"
- type: ONE_TO_ONE_NAT
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a instance
- gcp_compute_instance:
- name: "{{ resource_name }}"
- machine_type: n1-standard-1
- disks:
- - auto_delete: 'true'
- boot: 'true'
- source: "{{ disk }}"
- - auto_delete: 'true'
- interface: NVME
- type: SCRATCH
- initialize_params:
- disk_type: local-ssd
- metadata:
- startup-script-url: gs:://graphite-playground/bootstrap.sh
- cost-center: '12345'
- labels:
- environment: production
- network_interfaces:
- - network: "{{ network }}"
- access_configs:
- - name: External NAT
- nat_ip: "{{ address }}"
- type: ONE_TO_ONE_NAT
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that instance was deleted
- gcp_compute_instance_info:
- filters:
- - name = {{ resource_name }}
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a instance that does not exist
- gcp_compute_instance:
- name: "{{ resource_name }}"
- machine_type: n1-standard-1
- disks:
- - auto_delete: 'true'
- boot: 'true'
- source: "{{ disk }}"
- - auto_delete: 'true'
- interface: NVME
- type: SCRATCH
- initialize_params:
- disk_type: local-ssd
- metadata:
- startup-script-url: gs:://graphite-playground/bootstrap.sh
- cost-center: '12345'
- labels:
- environment: production
- network_interfaces:
- - network: "{{ network }}"
- access_configs:
- - name: External NAT
- nat_ip: "{{ address }}"
- type: ONE_TO_ONE_NAT
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a address
- gcp_compute_address:
- name: address-instance
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: address
- ignore_errors: true
-- name: delete a network
- gcp_compute_network:
- name: network-instance
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: network
- ignore_errors: true
-- name: delete a disk
- gcp_compute_disk:
- name: disk-instance
- size_gb: 50
- source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: disk
- ignore_errors: true
diff --git a/test/integration/targets/gcp_compute_instance/tasks/main.yml b/test/integration/targets/gcp_compute_instance/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_instance/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_instance_group/aliases b/test/integration/targets/gcp_compute_instance_group/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_instance_group/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_instance_group/defaults/main.yml b/test/integration/targets/gcp_compute_instance_group/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_compute_instance_group/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_compute_instance_group/meta/main.yml b/test/integration/targets/gcp_compute_instance_group/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_instance_group/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_instance_group/tasks/autogen.yml b/test/integration/targets/gcp_compute_instance_group/tasks/autogen.yml
deleted file mode 100644
index b16a128bbd..0000000000
--- a/test/integration/targets/gcp_compute_instance_group/tasks/autogen.yml
+++ /dev/null
@@ -1,149 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a network
- gcp_compute_network:
- name: network-instancegroup
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: network
-- name: delete a instance group
- gcp_compute_instance_group:
- name: "{{ resource_name }}"
- named_ports:
- - name: ansible
- port: 1234
- network: "{{ network }}"
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a instance group
- gcp_compute_instance_group:
- name: "{{ resource_name }}"
- named_ports:
- - name: ansible
- port: 1234
- network: "{{ network }}"
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that instance_group was created
- gcp_compute_instance_group_info:
- filters:
- - name = {{ resource_name }}
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a instance group that already exists
- gcp_compute_instance_group:
- name: "{{ resource_name }}"
- named_ports:
- - name: ansible
- port: 1234
- network: "{{ network }}"
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a instance group
- gcp_compute_instance_group:
- name: "{{ resource_name }}"
- named_ports:
- - name: ansible
- port: 1234
- network: "{{ network }}"
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that instance_group was deleted
- gcp_compute_instance_group_info:
- filters:
- - name = {{ resource_name }}
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a instance group that does not exist
- gcp_compute_instance_group:
- name: "{{ resource_name }}"
- named_ports:
- - name: ansible
- port: 1234
- network: "{{ network }}"
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a network
- gcp_compute_network:
- name: network-instancegroup
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: network
- ignore_errors: true
diff --git a/test/integration/targets/gcp_compute_instance_group/tasks/main.yml b/test/integration/targets/gcp_compute_instance_group/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_instance_group/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_instance_group_manager/aliases b/test/integration/targets/gcp_compute_instance_group_manager/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_instance_group_manager/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_instance_group_manager/defaults/main.yml b/test/integration/targets/gcp_compute_instance_group_manager/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_compute_instance_group_manager/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_compute_instance_group_manager/meta/main.yml b/test/integration/targets/gcp_compute_instance_group_manager/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_instance_group_manager/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_instance_group_manager/tasks/autogen.yml b/test/integration/targets/gcp_compute_instance_group_manager/tasks/autogen.yml
deleted file mode 100644
index 39c62e3956..0000000000
--- a/test/integration/targets/gcp_compute_instance_group_manager/tasks/autogen.yml
+++ /dev/null
@@ -1,206 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a network
- gcp_compute_network:
- name: network-instancetemplate
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: network
-- name: create a address
- gcp_compute_address:
- name: address-instancetemplate
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: address
-- name: create a instance template
- gcp_compute_instance_template:
- name: "{{ resource_name }}"
- properties:
- disks:
- - auto_delete: 'true'
- boot: 'true'
- initialize_params:
- source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
- machine_type: n1-standard-1
- network_interfaces:
- - network: "{{ network }}"
- access_configs:
- - name: test-config
- type: ONE_TO_ONE_NAT
- nat_ip: "{{ address }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: instancetemplate
-- name: delete a instance group manager
- gcp_compute_instance_group_manager:
- name: "{{ resource_name }}"
- base_instance_name: test1-child
- instance_template: "{{ instancetemplate }}"
- target_size: 3
- zone: us-west1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a instance group manager
- gcp_compute_instance_group_manager:
- name: "{{ resource_name }}"
- base_instance_name: test1-child
- instance_template: "{{ instancetemplate }}"
- target_size: 3
- zone: us-west1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that instance_group_manager was created
- gcp_compute_instance_group_manager_info:
- filters:
- - name = {{ resource_name }}
- zone: us-west1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a instance group manager that already exists
- gcp_compute_instance_group_manager:
- name: "{{ resource_name }}"
- base_instance_name: test1-child
- instance_template: "{{ instancetemplate }}"
- target_size: 3
- zone: us-west1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a instance group manager
- gcp_compute_instance_group_manager:
- name: "{{ resource_name }}"
- base_instance_name: test1-child
- instance_template: "{{ instancetemplate }}"
- target_size: 3
- zone: us-west1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that instance_group_manager was deleted
- gcp_compute_instance_group_manager_info:
- filters:
- - name = {{ resource_name }}
- zone: us-west1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a instance group manager that does not exist
- gcp_compute_instance_group_manager:
- name: "{{ resource_name }}"
- base_instance_name: test1-child
- instance_template: "{{ instancetemplate }}"
- target_size: 3
- zone: us-west1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a instance template
- gcp_compute_instance_template:
- name: "{{ resource_name }}"
- properties:
- disks:
- - auto_delete: 'true'
- boot: 'true'
- initialize_params:
- source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
- machine_type: n1-standard-1
- network_interfaces:
- - network: "{{ network }}"
- access_configs:
- - name: test-config
- type: ONE_TO_ONE_NAT
- nat_ip: "{{ address }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: instancetemplate
- ignore_errors: true
-- name: delete a address
- gcp_compute_address:
- name: address-instancetemplate
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: address
- ignore_errors: true
-- name: delete a network
- gcp_compute_network:
- name: network-instancetemplate
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: network
- ignore_errors: true
diff --git a/test/integration/targets/gcp_compute_instance_group_manager/tasks/main.yml b/test/integration/targets/gcp_compute_instance_group_manager/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_instance_group_manager/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_instance_template/aliases b/test/integration/targets/gcp_compute_instance_template/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_instance_template/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_instance_template/defaults/main.yml b/test/integration/targets/gcp_compute_instance_template/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_compute_instance_template/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_compute_instance_template/meta/main.yml b/test/integration/targets/gcp_compute_instance_template/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_instance_template/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_instance_template/tasks/autogen.yml b/test/integration/targets/gcp_compute_instance_template/tasks/autogen.yml
deleted file mode 100644
index b1336624bc..0000000000
--- a/test/integration/targets/gcp_compute_instance_template/tasks/autogen.yml
+++ /dev/null
@@ -1,206 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a network
- gcp_compute_network:
- name: network-instancetemplate
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: network
-- name: create a address
- gcp_compute_address:
- name: address-instancetemplate
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: address
-- name: delete a instance template
- gcp_compute_instance_template:
- name: "{{ resource_name }}"
- properties:
- disks:
- - auto_delete: 'true'
- boot: 'true'
- initialize_params:
- source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
- machine_type: n1-standard-1
- network_interfaces:
- - network: "{{ network }}"
- access_configs:
- - name: test-config
- type: ONE_TO_ONE_NAT
- nat_ip: "{{ address }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a instance template
- gcp_compute_instance_template:
- name: "{{ resource_name }}"
- properties:
- disks:
- - auto_delete: 'true'
- boot: 'true'
- initialize_params:
- source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
- machine_type: n1-standard-1
- network_interfaces:
- - network: "{{ network }}"
- access_configs:
- - name: test-config
- type: ONE_TO_ONE_NAT
- nat_ip: "{{ address }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that instance_template was created
- gcp_compute_instance_template_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a instance template that already exists
- gcp_compute_instance_template:
- name: "{{ resource_name }}"
- properties:
- disks:
- - auto_delete: 'true'
- boot: 'true'
- initialize_params:
- source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
- machine_type: n1-standard-1
- network_interfaces:
- - network: "{{ network }}"
- access_configs:
- - name: test-config
- type: ONE_TO_ONE_NAT
- nat_ip: "{{ address }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a instance template
- gcp_compute_instance_template:
- name: "{{ resource_name }}"
- properties:
- disks:
- - auto_delete: 'true'
- boot: 'true'
- initialize_params:
- source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
- machine_type: n1-standard-1
- network_interfaces:
- - network: "{{ network }}"
- access_configs:
- - name: test-config
- type: ONE_TO_ONE_NAT
- nat_ip: "{{ address }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that instance_template was deleted
- gcp_compute_instance_template_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a instance template that does not exist
- gcp_compute_instance_template:
- name: "{{ resource_name }}"
- properties:
- disks:
- - auto_delete: 'true'
- boot: 'true'
- initialize_params:
- source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
- machine_type: n1-standard-1
- network_interfaces:
- - network: "{{ network }}"
- access_configs:
- - name: test-config
- type: ONE_TO_ONE_NAT
- nat_ip: "{{ address }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a address
- gcp_compute_address:
- name: address-instancetemplate
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: address
- ignore_errors: true
-- name: delete a network
- gcp_compute_network:
- name: network-instancetemplate
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: network
- ignore_errors: true
diff --git a/test/integration/targets/gcp_compute_instance_template/tasks/main.yml b/test/integration/targets/gcp_compute_instance_template/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_instance_template/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_interconnect_attachment/aliases b/test/integration/targets/gcp_compute_interconnect_attachment/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_interconnect_attachment/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_interconnect_attachment/defaults/main.yml b/test/integration/targets/gcp_compute_interconnect_attachment/defaults/main.yml
deleted file mode 100644
index aa87a2a8e0..0000000000
--- a/test/integration/targets/gcp_compute_interconnect_attachment/defaults/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
----
-# defaults file
-resource_name: '{{resource_prefix}}'
diff --git a/test/integration/targets/gcp_compute_interconnect_attachment/meta/main.yml b/test/integration/targets/gcp_compute_interconnect_attachment/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_interconnect_attachment/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_network/aliases b/test/integration/targets/gcp_compute_network/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_network/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_network/defaults/main.yml b/test/integration/targets/gcp_compute_network/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_compute_network/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_compute_network/meta/main.yml b/test/integration/targets/gcp_compute_network/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_network/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_network/tasks/autogen.yml b/test/integration/targets/gcp_compute_network/tasks/autogen.yml
deleted file mode 100644
index fa121c8fbe..0000000000
--- a/test/integration/targets/gcp_compute_network/tasks/autogen.yml
+++ /dev/null
@@ -1,107 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a network
- gcp_compute_network:
- name: "{{ resource_name }}"
- auto_create_subnetworks: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a network
- gcp_compute_network:
- name: "{{ resource_name }}"
- auto_create_subnetworks: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that network was created
- gcp_compute_network_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a network that already exists
- gcp_compute_network:
- name: "{{ resource_name }}"
- auto_create_subnetworks: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a network
- gcp_compute_network:
- name: "{{ resource_name }}"
- auto_create_subnetworks: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that network was deleted
- gcp_compute_network_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a network that does not exist
- gcp_compute_network:
- name: "{{ resource_name }}"
- auto_create_subnetworks: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_compute_network/tasks/main.yml b/test/integration/targets/gcp_compute_network/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_network/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_network_endpoint_group/aliases b/test/integration/targets/gcp_compute_network_endpoint_group/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_network_endpoint_group/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_network_endpoint_group/meta/main.yml b/test/integration/targets/gcp_compute_network_endpoint_group/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_network_endpoint_group/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_network_endpoint_group/tasks/autogen.yml b/test/integration/targets/gcp_compute_network_endpoint_group/tasks/autogen.yml
deleted file mode 100644
index b4db16b19e..0000000000
--- a/test/integration/targets/gcp_compute_network_endpoint_group/tasks/autogen.yml
+++ /dev/null
@@ -1,169 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a network
- gcp_compute_network:
- name: "{{ resource_name }}"
- auto_create_subnetworks: 'false'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: network
-- name: create a subnetwork
- gcp_compute_subnetwork:
- name: "{{ resource_name }}"
- ip_cidr_range: 10.0.0.0/16
- region: us-central1
- network: "{{ network }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: subnetwork
-- name: delete a network endpoint group
- gcp_compute_network_endpoint_group:
- name: "{{ resource_name }}"
- network: "{{ network }}"
- subnetwork: "{{ subnetwork }}"
- default_port: 90
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a network endpoint group
- gcp_compute_network_endpoint_group:
- name: "{{ resource_name }}"
- network: "{{ network }}"
- subnetwork: "{{ subnetwork }}"
- default_port: 90
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that network_endpoint_group was created
- gcp_compute_network_endpoint_group_info:
- filters:
- - name = {{ resource_name }}
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a network endpoint group that already exists
- gcp_compute_network_endpoint_group:
- name: "{{ resource_name }}"
- network: "{{ network }}"
- subnetwork: "{{ subnetwork }}"
- default_port: 90
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a network endpoint group
- gcp_compute_network_endpoint_group:
- name: "{{ resource_name }}"
- network: "{{ network }}"
- subnetwork: "{{ subnetwork }}"
- default_port: 90
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that network_endpoint_group was deleted
- gcp_compute_network_endpoint_group_info:
- filters:
- - name = {{ resource_name }}
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a network endpoint group that does not exist
- gcp_compute_network_endpoint_group:
- name: "{{ resource_name }}"
- network: "{{ network }}"
- subnetwork: "{{ subnetwork }}"
- default_port: 90
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a subnetwork
- gcp_compute_subnetwork:
- name: "{{ resource_name }}"
- ip_cidr_range: 10.0.0.0/16
- region: us-central1
- network: "{{ network }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: subnetwork
- ignore_errors: true
-- name: delete a network
- gcp_compute_network:
- name: "{{ resource_name }}"
- auto_create_subnetworks: 'false'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: network
- ignore_errors: true
diff --git a/test/integration/targets/gcp_compute_network_endpoint_group/tasks/main.yml b/test/integration/targets/gcp_compute_network_endpoint_group/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_network_endpoint_group/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_node_group/aliases b/test/integration/targets/gcp_compute_node_group/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_node_group/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_node_group/meta/main.yml b/test/integration/targets/gcp_compute_node_group/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_node_group/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_node_group/tasks/autogen.yml b/test/integration/targets/gcp_compute_node_group/tasks/autogen.yml
deleted file mode 100644
index 36c65a0858..0000000000
--- a/test/integration/targets/gcp_compute_node_group/tasks/autogen.yml
+++ /dev/null
@@ -1,148 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a node template
- gcp_compute_node_template:
- name: "{{ resource_name }}"
- region: us-central1
- node_type: n1-node-96-624
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: node_template
-- name: delete a node group
- gcp_compute_node_group:
- name: "{{ resource_name }}"
- zone: us-central1-a
- description: example group for ansible
- size: 1
- node_template: "{{ node_template }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a node group
- gcp_compute_node_group:
- name: "{{ resource_name }}"
- zone: us-central1-a
- description: example group for ansible
- size: 1
- node_template: "{{ node_template }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that node_group was created
- gcp_compute_node_group_info:
- filters:
- - name = {{ resource_name }}
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a node group that already exists
- gcp_compute_node_group:
- name: "{{ resource_name }}"
- zone: us-central1-a
- description: example group for ansible
- size: 1
- node_template: "{{ node_template }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a node group
- gcp_compute_node_group:
- name: "{{ resource_name }}"
- zone: us-central1-a
- description: example group for ansible
- size: 1
- node_template: "{{ node_template }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that node_group was deleted
- gcp_compute_node_group_info:
- filters:
- - name = {{ resource_name }}
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a node group that does not exist
- gcp_compute_node_group:
- name: "{{ resource_name }}"
- zone: us-central1-a
- description: example group for ansible
- size: 1
- node_template: "{{ node_template }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a node template
- gcp_compute_node_template:
- name: "{{ resource_name }}"
- region: us-central1
- node_type: n1-node-96-624
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: node_template
- ignore_errors: true
diff --git a/test/integration/targets/gcp_compute_node_group/tasks/main.yml b/test/integration/targets/gcp_compute_node_group/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_node_group/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_node_template/aliases b/test/integration/targets/gcp_compute_node_template/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_node_template/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_node_template/meta/main.yml b/test/integration/targets/gcp_compute_node_template/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_node_template/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_node_template/tasks/autogen.yml b/test/integration/targets/gcp_compute_node_template/tasks/autogen.yml
deleted file mode 100644
index 604016423d..0000000000
--- a/test/integration/targets/gcp_compute_node_template/tasks/autogen.yml
+++ /dev/null
@@ -1,114 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a node template
- gcp_compute_node_template:
- name: "{{ resource_name }}"
- region: us-central1
- node_type: n1-node-96-624
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a node template
- gcp_compute_node_template:
- name: "{{ resource_name }}"
- region: us-central1
- node_type: n1-node-96-624
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that node_template was created
- gcp_compute_node_template_info:
- filters:
- - name = {{ resource_name }}
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a node template that already exists
- gcp_compute_node_template:
- name: "{{ resource_name }}"
- region: us-central1
- node_type: n1-node-96-624
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a node template
- gcp_compute_node_template:
- name: "{{ resource_name }}"
- region: us-central1
- node_type: n1-node-96-624
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that node_template was deleted
- gcp_compute_node_template_info:
- filters:
- - name = {{ resource_name }}
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a node template that does not exist
- gcp_compute_node_template:
- name: "{{ resource_name }}"
- region: us-central1
- node_type: n1-node-96-624
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_compute_node_template/tasks/main.yml b/test/integration/targets/gcp_compute_node_template/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_node_template/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_region_backend_service/aliases b/test/integration/targets/gcp_compute_region_backend_service/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_region_backend_service/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_region_backend_service/meta/main.yml b/test/integration/targets/gcp_compute_region_backend_service/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_region_backend_service/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_region_backend_service/tasks/autogen.yml b/test/integration/targets/gcp_compute_region_backend_service/tasks/autogen.yml
deleted file mode 100644
index 7b577e2ce1..0000000000
--- a/test/integration/targets/gcp_compute_region_backend_service/tasks/autogen.yml
+++ /dev/null
@@ -1,164 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a health check
- gcp_compute_health_check:
- name: "{{ resource_name }}"
- type: TCP
- tcp_health_check:
- port: 80
- check_interval_sec: 1
- timeout_sec: 1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: healthcheck
-- name: delete a region backend service
- gcp_compute_region_backend_service:
- name: "{{ resource_name }}"
- region: us-central1
- health_checks:
- - "{{ healthcheck.selfLink }}"
- connection_draining:
- draining_timeout_sec: 10
- session_affinity: CLIENT_IP
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a region backend service
- gcp_compute_region_backend_service:
- name: "{{ resource_name }}"
- region: us-central1
- health_checks:
- - "{{ healthcheck.selfLink }}"
- connection_draining:
- draining_timeout_sec: 10
- session_affinity: CLIENT_IP
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that region_backend_service was created
- gcp_compute_region_backend_service_info:
- filters:
- - name = {{ resource_name }}
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a region backend service that already exists
- gcp_compute_region_backend_service:
- name: "{{ resource_name }}"
- region: us-central1
- health_checks:
- - "{{ healthcheck.selfLink }}"
- connection_draining:
- draining_timeout_sec: 10
- session_affinity: CLIENT_IP
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a region backend service
- gcp_compute_region_backend_service:
- name: "{{ resource_name }}"
- region: us-central1
- health_checks:
- - "{{ healthcheck.selfLink }}"
- connection_draining:
- draining_timeout_sec: 10
- session_affinity: CLIENT_IP
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that region_backend_service was deleted
- gcp_compute_region_backend_service_info:
- filters:
- - name = {{ resource_name }}
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a region backend service that does not exist
- gcp_compute_region_backend_service:
- name: "{{ resource_name }}"
- region: us-central1
- health_checks:
- - "{{ healthcheck.selfLink }}"
- connection_draining:
- draining_timeout_sec: 10
- session_affinity: CLIENT_IP
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a health check
- gcp_compute_health_check:
- name: "{{ resource_name }}"
- type: TCP
- tcp_health_check:
- port: 80
- check_interval_sec: 1
- timeout_sec: 1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: healthcheck
- ignore_errors: true
diff --git a/test/integration/targets/gcp_compute_region_backend_service/tasks/main.yml b/test/integration/targets/gcp_compute_region_backend_service/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_region_backend_service/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_region_disk/aliases b/test/integration/targets/gcp_compute_region_disk/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_region_disk/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_region_disk/defaults/main.yml b/test/integration/targets/gcp_compute_region_disk/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_compute_region_disk/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_compute_region_disk/meta/main.yml b/test/integration/targets/gcp_compute_region_disk/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_region_disk/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_region_disk/tasks/autogen.yml b/test/integration/targets/gcp_compute_region_disk/tasks/autogen.yml
deleted file mode 100644
index 462dd56af1..0000000000
--- a/test/integration/targets/gcp_compute_region_disk/tasks/autogen.yml
+++ /dev/null
@@ -1,139 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a region disk
- gcp_compute_region_disk:
- name: "{{ resource_name }}"
- size_gb: 500
- disk_encryption_key:
- raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0=
- region: us-central1
- replica_zones:
- - https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-a
- - https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-b
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a region disk
- gcp_compute_region_disk:
- name: "{{ resource_name }}"
- size_gb: 500
- disk_encryption_key:
- raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0=
- region: us-central1
- replica_zones:
- - https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-a
- - https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-b
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that region_disk was created
- gcp_compute_region_disk_info:
- filters:
- - name = {{ resource_name }}
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a region disk that already exists
- gcp_compute_region_disk:
- name: "{{ resource_name }}"
- size_gb: 500
- disk_encryption_key:
- raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0=
- region: us-central1
- replica_zones:
- - https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-a
- - https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-b
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a region disk
- gcp_compute_region_disk:
- name: "{{ resource_name }}"
- size_gb: 500
- disk_encryption_key:
- raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0=
- region: us-central1
- replica_zones:
- - https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-a
- - https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-b
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that region_disk was deleted
- gcp_compute_region_disk_info:
- filters:
- - name = {{ resource_name }}
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a region disk that does not exist
- gcp_compute_region_disk:
- name: "{{ resource_name }}"
- size_gb: 500
- disk_encryption_key:
- raw_key: SGVsbG8gZnJvbSBHb29nbGUgQ2xvdWQgUGxhdGZvcm0=
- region: us-central1
- replica_zones:
- - https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-a
- - https://www.googleapis.com/compute/v1/projects/google.com:graphite-playground/zones/us-central1-b
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_compute_region_disk/tasks/main.yml b/test/integration/targets/gcp_compute_region_disk/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_region_disk/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_reservation/aliases b/test/integration/targets/gcp_compute_reservation/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_reservation/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_reservation/meta/main.yml b/test/integration/targets/gcp_compute_reservation/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_reservation/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_reservation/tasks/autogen.yml b/test/integration/targets/gcp_compute_reservation/tasks/autogen.yml
deleted file mode 100644
index 71d1a8cafa..0000000000
--- a/test/integration/targets/gcp_compute_reservation/tasks/autogen.yml
+++ /dev/null
@@ -1,134 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a reservation
- gcp_compute_reservation:
- name: "{{ resource_name }}"
- zone: us-central1-a
- specific_reservation:
- count: 1
- instance_properties:
- min_cpu_platform: Intel Cascade Lake
- machine_type: n2-standard-2
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a reservation
- gcp_compute_reservation:
- name: "{{ resource_name }}"
- zone: us-central1-a
- specific_reservation:
- count: 1
- instance_properties:
- min_cpu_platform: Intel Cascade Lake
- machine_type: n2-standard-2
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that reservation was created
- gcp_compute_reservation_info:
- filters:
- - name = {{ resource_name }}
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a reservation that already exists
- gcp_compute_reservation:
- name: "{{ resource_name }}"
- zone: us-central1-a
- specific_reservation:
- count: 1
- instance_properties:
- min_cpu_platform: Intel Cascade Lake
- machine_type: n2-standard-2
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a reservation
- gcp_compute_reservation:
- name: "{{ resource_name }}"
- zone: us-central1-a
- specific_reservation:
- count: 1
- instance_properties:
- min_cpu_platform: Intel Cascade Lake
- machine_type: n2-standard-2
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that reservation was deleted
- gcp_compute_reservation_info:
- filters:
- - name = {{ resource_name }}
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a reservation that does not exist
- gcp_compute_reservation:
- name: "{{ resource_name }}"
- zone: us-central1-a
- specific_reservation:
- count: 1
- instance_properties:
- min_cpu_platform: Intel Cascade Lake
- machine_type: n2-standard-2
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_compute_reservation/tasks/main.yml b/test/integration/targets/gcp_compute_reservation/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_reservation/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_route/aliases b/test/integration/targets/gcp_compute_route/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_route/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_route/defaults/main.yml b/test/integration/targets/gcp_compute_route/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_compute_route/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_compute_route/meta/main.yml b/test/integration/targets/gcp_compute_route/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_route/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_route/tasks/autogen.yml b/test/integration/targets/gcp_compute_route/tasks/autogen.yml
deleted file mode 100644
index 8ffb557a61..0000000000
--- a/test/integration/targets/gcp_compute_route/tasks/autogen.yml
+++ /dev/null
@@ -1,152 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a network
- gcp_compute_network:
- name: network-route
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: network
-- name: delete a route
- gcp_compute_route:
- name: "{{ resource_name }}"
- dest_range: 192.168.6.0/24
- next_hop_gateway: global/gateways/default-internet-gateway
- network: "{{ network }}"
- tags:
- - backends
- - databases
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a route
- gcp_compute_route:
- name: "{{ resource_name }}"
- dest_range: 192.168.6.0/24
- next_hop_gateway: global/gateways/default-internet-gateway
- network: "{{ network }}"
- tags:
- - backends
- - databases
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that route was created
- gcp_compute_route_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a route that already exists
- gcp_compute_route:
- name: "{{ resource_name }}"
- dest_range: 192.168.6.0/24
- next_hop_gateway: global/gateways/default-internet-gateway
- network: "{{ network }}"
- tags:
- - backends
- - databases
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a route
- gcp_compute_route:
- name: "{{ resource_name }}"
- dest_range: 192.168.6.0/24
- next_hop_gateway: global/gateways/default-internet-gateway
- network: "{{ network }}"
- tags:
- - backends
- - databases
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that route was deleted
- gcp_compute_route_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a route that does not exist
- gcp_compute_route:
- name: "{{ resource_name }}"
- dest_range: 192.168.6.0/24
- next_hop_gateway: global/gateways/default-internet-gateway
- network: "{{ network }}"
- tags:
- - backends
- - databases
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a network
- gcp_compute_network:
- name: network-route
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: network
- ignore_errors: true
diff --git a/test/integration/targets/gcp_compute_route/tasks/main.yml b/test/integration/targets/gcp_compute_route/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_route/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_router/aliases b/test/integration/targets/gcp_compute_router/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_router/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_router/defaults/main.yml b/test/integration/targets/gcp_compute_router/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_compute_router/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_compute_router/meta/main.yml b/test/integration/targets/gcp_compute_router/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_router/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_router/tasks/autogen.yml b/test/integration/targets/gcp_compute_router/tasks/autogen.yml
deleted file mode 100644
index 8a80e03efd..0000000000
--- a/test/integration/targets/gcp_compute_router/tasks/autogen.yml
+++ /dev/null
@@ -1,174 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a network
- gcp_compute_network:
- name: network-router
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: network
-- name: delete a router
- gcp_compute_router:
- name: "{{ resource_name }}"
- network: "{{ network }}"
- bgp:
- asn: 64514
- advertise_mode: CUSTOM
- advertised_groups:
- - ALL_SUBNETS
- advertised_ip_ranges:
- - range: 1.2.3.4
- - range: 6.7.0.0/16
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a router
- gcp_compute_router:
- name: "{{ resource_name }}"
- network: "{{ network }}"
- bgp:
- asn: 64514
- advertise_mode: CUSTOM
- advertised_groups:
- - ALL_SUBNETS
- advertised_ip_ranges:
- - range: 1.2.3.4
- - range: 6.7.0.0/16
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that router was created
- gcp_compute_router_info:
- filters:
- - name = {{ resource_name }}
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a router that already exists
- gcp_compute_router:
- name: "{{ resource_name }}"
- network: "{{ network }}"
- bgp:
- asn: 64514
- advertise_mode: CUSTOM
- advertised_groups:
- - ALL_SUBNETS
- advertised_ip_ranges:
- - range: 1.2.3.4
- - range: 6.7.0.0/16
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a router
- gcp_compute_router:
- name: "{{ resource_name }}"
- network: "{{ network }}"
- bgp:
- asn: 64514
- advertise_mode: CUSTOM
- advertised_groups:
- - ALL_SUBNETS
- advertised_ip_ranges:
- - range: 1.2.3.4
- - range: 6.7.0.0/16
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that router was deleted
- gcp_compute_router_info:
- filters:
- - name = {{ resource_name }}
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a router that does not exist
- gcp_compute_router:
- name: "{{ resource_name }}"
- network: "{{ network }}"
- bgp:
- asn: 64514
- advertise_mode: CUSTOM
- advertised_groups:
- - ALL_SUBNETS
- advertised_ip_ranges:
- - range: 1.2.3.4
- - range: 6.7.0.0/16
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a network
- gcp_compute_network:
- name: network-router
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: network
- ignore_errors: true
diff --git a/test/integration/targets/gcp_compute_router/tasks/main.yml b/test/integration/targets/gcp_compute_router/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_router/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_snapshot/aliases b/test/integration/targets/gcp_compute_snapshot/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_snapshot/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_snapshot/defaults/main.yml b/test/integration/targets/gcp_compute_snapshot/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_compute_snapshot/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_compute_snapshot/meta/main.yml b/test/integration/targets/gcp_compute_snapshot/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_snapshot/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_snapshot/tasks/autogen.yml b/test/integration/targets/gcp_compute_snapshot/tasks/autogen.yml
deleted file mode 100644
index f3f7932838..0000000000
--- a/test/integration/targets/gcp_compute_snapshot/tasks/autogen.yml
+++ /dev/null
@@ -1,144 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a disk
- gcp_compute_disk:
- name: disk-snapshot
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: disk
-- name: delete a snapshot
- gcp_compute_snapshot:
- name: "{{ resource_name }}"
- source_disk: "{{ disk }}"
- zone: us-central1-a
- labels:
- my_label: value
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a snapshot
- gcp_compute_snapshot:
- name: "{{ resource_name }}"
- source_disk: "{{ disk }}"
- zone: us-central1-a
- labels:
- my_label: value
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that snapshot was created
- gcp_compute_snapshot_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a snapshot that already exists
- gcp_compute_snapshot:
- name: "{{ resource_name }}"
- source_disk: "{{ disk }}"
- zone: us-central1-a
- labels:
- my_label: value
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a snapshot
- gcp_compute_snapshot:
- name: "{{ resource_name }}"
- source_disk: "{{ disk }}"
- zone: us-central1-a
- labels:
- my_label: value
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that snapshot was deleted
- gcp_compute_snapshot_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a snapshot that does not exist
- gcp_compute_snapshot:
- name: "{{ resource_name }}"
- source_disk: "{{ disk }}"
- zone: us-central1-a
- labels:
- my_label: value
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a disk
- gcp_compute_disk:
- name: disk-snapshot
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: disk
- ignore_errors: true
diff --git a/test/integration/targets/gcp_compute_snapshot/tasks/main.yml b/test/integration/targets/gcp_compute_snapshot/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_snapshot/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_ssl_certificate/aliases b/test/integration/targets/gcp_compute_ssl_certificate/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_ssl_certificate/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_ssl_certificate/defaults/main.yml b/test/integration/targets/gcp_compute_ssl_certificate/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_compute_ssl_certificate/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_compute_ssl_certificate/meta/main.yml b/test/integration/targets/gcp_compute_ssl_certificate/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_ssl_certificate/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_ssl_certificate/tasks/autogen.yml b/test/integration/targets/gcp_compute_ssl_certificate/tasks/autogen.yml
deleted file mode 100644
index efc9f9961a..0000000000
--- a/test/integration/targets/gcp_compute_ssl_certificate/tasks/autogen.yml
+++ /dev/null
@@ -1,227 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a SSL certificate
- gcp_compute_ssl_certificate:
- name: "{{ resource_name }}"
- description: A certificate for testing. Do not use this certificate in production
- certificate: |-
- -----BEGIN CERTIFICATE-----
- MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG
- EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT
- BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm
- b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN
- AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2
- MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP
- BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM
- FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z
- aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH
- KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ
- 4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O
- BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn
- 0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O
- M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ
- zqGNhIPGq2ULqXKK8BY=
- -----END CERTIFICATE-----
- private_key: |-
- -----BEGIN EC PRIVATE KEY-----
- MHcCAQEEIObtRo8tkUqoMjeHhsOh2ouPpXCgBcP+EDxZCB/tws15oAoGCCqGSM49
- AwEHoUQDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ4mzkzTv0dXyB750f
- OGN02HtkpBOZzzvUARTR10JQoSe2/5PIwQ==
- -----END EC PRIVATE KEY-----
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a SSL certificate
- gcp_compute_ssl_certificate:
- name: "{{ resource_name }}"
- description: A certificate for testing. Do not use this certificate in production
- certificate: |-
- -----BEGIN CERTIFICATE-----
- MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG
- EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT
- BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm
- b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN
- AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2
- MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP
- BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM
- FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z
- aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH
- KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ
- 4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O
- BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn
- 0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O
- M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ
- zqGNhIPGq2ULqXKK8BY=
- -----END CERTIFICATE-----
- private_key: |-
- -----BEGIN EC PRIVATE KEY-----
- MHcCAQEEIObtRo8tkUqoMjeHhsOh2ouPpXCgBcP+EDxZCB/tws15oAoGCCqGSM49
- AwEHoUQDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ4mzkzTv0dXyB750f
- OGN02HtkpBOZzzvUARTR10JQoSe2/5PIwQ==
- -----END EC PRIVATE KEY-----
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that ssl_certificate was created
- gcp_compute_ssl_certificate_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a SSL certificate that already exists
- gcp_compute_ssl_certificate:
- name: "{{ resource_name }}"
- description: A certificate for testing. Do not use this certificate in production
- certificate: |-
- -----BEGIN CERTIFICATE-----
- MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG
- EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT
- BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm
- b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN
- AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2
- MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP
- BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM
- FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z
- aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH
- KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ
- 4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O
- BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn
- 0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O
- M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ
- zqGNhIPGq2ULqXKK8BY=
- -----END CERTIFICATE-----
- private_key: |-
- -----BEGIN EC PRIVATE KEY-----
- MHcCAQEEIObtRo8tkUqoMjeHhsOh2ouPpXCgBcP+EDxZCB/tws15oAoGCCqGSM49
- AwEHoUQDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ4mzkzTv0dXyB750f
- OGN02HtkpBOZzzvUARTR10JQoSe2/5PIwQ==
- -----END EC PRIVATE KEY-----
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a SSL certificate
- gcp_compute_ssl_certificate:
- name: "{{ resource_name }}"
- description: A certificate for testing. Do not use this certificate in production
- certificate: |-
- -----BEGIN CERTIFICATE-----
- MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG
- EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT
- BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm
- b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN
- AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2
- MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP
- BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM
- FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z
- aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH
- KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ
- 4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O
- BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn
- 0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O
- M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ
- zqGNhIPGq2ULqXKK8BY=
- -----END CERTIFICATE-----
- private_key: |-
- -----BEGIN EC PRIVATE KEY-----
- MHcCAQEEIObtRo8tkUqoMjeHhsOh2ouPpXCgBcP+EDxZCB/tws15oAoGCCqGSM49
- AwEHoUQDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ4mzkzTv0dXyB750f
- OGN02HtkpBOZzzvUARTR10JQoSe2/5PIwQ==
- -----END EC PRIVATE KEY-----
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that ssl_certificate was deleted
- gcp_compute_ssl_certificate_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a SSL certificate that does not exist
- gcp_compute_ssl_certificate:
- name: "{{ resource_name }}"
- description: A certificate for testing. Do not use this certificate in production
- certificate: |-
- -----BEGIN CERTIFICATE-----
- MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG
- EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT
- BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm
- b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN
- AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2
- MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP
- BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM
- FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z
- aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH
- KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ
- 4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O
- BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn
- 0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O
- M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ
- zqGNhIPGq2ULqXKK8BY=
- -----END CERTIFICATE-----
- private_key: |-
- -----BEGIN EC PRIVATE KEY-----
- MHcCAQEEIObtRo8tkUqoMjeHhsOh2ouPpXCgBcP+EDxZCB/tws15oAoGCCqGSM49
- AwEHoUQDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ4mzkzTv0dXyB750f
- OGN02HtkpBOZzzvUARTR10JQoSe2/5PIwQ==
- -----END EC PRIVATE KEY-----
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_compute_ssl_certificate/tasks/main.yml b/test/integration/targets/gcp_compute_ssl_certificate/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_ssl_certificate/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_ssl_policy/aliases b/test/integration/targets/gcp_compute_ssl_policy/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_ssl_policy/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_ssl_policy/defaults/main.yml b/test/integration/targets/gcp_compute_ssl_policy/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_compute_ssl_policy/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_compute_ssl_policy/meta/main.yml b/test/integration/targets/gcp_compute_ssl_policy/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_ssl_policy/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_ssl_policy/tasks/autogen.yml b/test/integration/targets/gcp_compute_ssl_policy/tasks/autogen.yml
deleted file mode 100644
index 455bb1b882..0000000000
--- a/test/integration/targets/gcp_compute_ssl_policy/tasks/autogen.yml
+++ /dev/null
@@ -1,127 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a SSL policy
- gcp_compute_ssl_policy:
- name: "{{ resource_name }}"
- profile: CUSTOM
- min_tls_version: TLS_1_2
- custom_features:
- - TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
- - TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a SSL policy
- gcp_compute_ssl_policy:
- name: "{{ resource_name }}"
- profile: CUSTOM
- min_tls_version: TLS_1_2
- custom_features:
- - TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
- - TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that ssl_policy was created
- gcp_compute_ssl_policy_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a SSL policy that already exists
- gcp_compute_ssl_policy:
- name: "{{ resource_name }}"
- profile: CUSTOM
- min_tls_version: TLS_1_2
- custom_features:
- - TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
- - TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a SSL policy
- gcp_compute_ssl_policy:
- name: "{{ resource_name }}"
- profile: CUSTOM
- min_tls_version: TLS_1_2
- custom_features:
- - TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
- - TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that ssl_policy was deleted
- gcp_compute_ssl_policy_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a SSL policy that does not exist
- gcp_compute_ssl_policy:
- name: "{{ resource_name }}"
- profile: CUSTOM
- min_tls_version: TLS_1_2
- custom_features:
- - TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
- - TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_compute_ssl_policy/tasks/main.yml b/test/integration/targets/gcp_compute_ssl_policy/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_ssl_policy/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_subnetwork/aliases b/test/integration/targets/gcp_compute_subnetwork/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_subnetwork/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_subnetwork/defaults/main.yml b/test/integration/targets/gcp_compute_subnetwork/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_compute_subnetwork/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_compute_subnetwork/meta/main.yml b/test/integration/targets/gcp_compute_subnetwork/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_subnetwork/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_subnetwork/tasks/autogen.yml b/test/integration/targets/gcp_compute_subnetwork/tasks/autogen.yml
deleted file mode 100644
index ff956ae6ad..0000000000
--- a/test/integration/targets/gcp_compute_subnetwork/tasks/autogen.yml
+++ /dev/null
@@ -1,141 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a network
- gcp_compute_network:
- name: network-subnetwork
- auto_create_subnetworks: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: network
-- name: delete a subnetwork
- gcp_compute_subnetwork:
- name: ansiblenet
- region: us-west1
- network: "{{ network }}"
- ip_cidr_range: 172.16.0.0/16
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a subnetwork
- gcp_compute_subnetwork:
- name: ansiblenet
- region: us-west1
- network: "{{ network }}"
- ip_cidr_range: 172.16.0.0/16
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that subnetwork was created
- gcp_compute_subnetwork_info:
- filters:
- - name = ansiblenet
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a subnetwork that already exists
- gcp_compute_subnetwork:
- name: ansiblenet
- region: us-west1
- network: "{{ network }}"
- ip_cidr_range: 172.16.0.0/16
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a subnetwork
- gcp_compute_subnetwork:
- name: ansiblenet
- region: us-west1
- network: "{{ network }}"
- ip_cidr_range: 172.16.0.0/16
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that subnetwork was deleted
- gcp_compute_subnetwork_info:
- filters:
- - name = ansiblenet
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a subnetwork that does not exist
- gcp_compute_subnetwork:
- name: ansiblenet
- region: us-west1
- network: "{{ network }}"
- ip_cidr_range: 172.16.0.0/16
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a network
- gcp_compute_network:
- name: network-subnetwork
- auto_create_subnetworks: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: network
- ignore_errors: true
diff --git a/test/integration/targets/gcp_compute_subnetwork/tasks/main.yml b/test/integration/targets/gcp_compute_subnetwork/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_subnetwork/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_target_http_proxy/aliases b/test/integration/targets/gcp_compute_target_http_proxy/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_target_http_proxy/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_target_http_proxy/defaults/main.yml b/test/integration/targets/gcp_compute_target_http_proxy/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_compute_target_http_proxy/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_compute_target_http_proxy/meta/main.yml b/test/integration/targets/gcp_compute_target_http_proxy/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_target_http_proxy/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_target_http_proxy/tasks/autogen.yml b/test/integration/targets/gcp_compute_target_http_proxy/tasks/autogen.yml
deleted file mode 100644
index 441871f521..0000000000
--- a/test/integration/targets/gcp_compute_target_http_proxy/tasks/autogen.yml
+++ /dev/null
@@ -1,200 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a instance group
- gcp_compute_instance_group:
- name: instancegroup-targethttpproxy
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: instancegroup
-- name: create a HTTP health check
- gcp_compute_http_health_check:
- name: httphealthcheck-targethttpproxy
- healthy_threshold: 10
- port: 8080
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: healthcheck
-- name: create a backend service
- gcp_compute_backend_service:
- name: backendservice-targethttpproxy
- backends:
- - group: "{{ instancegroup.selfLink }}"
- health_checks:
- - "{{ healthcheck.selfLink }}"
- enable_cdn: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: backendservice
-- name: create a URL map
- gcp_compute_url_map:
- name: urlmap-targethttpproxy
- default_service: "{{ backendservice }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: urlmap
-- name: delete a target HTTP proxy
- gcp_compute_target_http_proxy:
- name: "{{ resource_name }}"
- url_map: "{{ urlmap }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a target HTTP proxy
- gcp_compute_target_http_proxy:
- name: "{{ resource_name }}"
- url_map: "{{ urlmap }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that target_http_proxy was created
- gcp_compute_target_http_proxy_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a target HTTP proxy that already exists
- gcp_compute_target_http_proxy:
- name: "{{ resource_name }}"
- url_map: "{{ urlmap }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a target HTTP proxy
- gcp_compute_target_http_proxy:
- name: "{{ resource_name }}"
- url_map: "{{ urlmap }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that target_http_proxy was deleted
- gcp_compute_target_http_proxy_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a target HTTP proxy that does not exist
- gcp_compute_target_http_proxy:
- name: "{{ resource_name }}"
- url_map: "{{ urlmap }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a URL map
- gcp_compute_url_map:
- name: urlmap-targethttpproxy
- default_service: "{{ backendservice }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: urlmap
- ignore_errors: true
-- name: delete a backend service
- gcp_compute_backend_service:
- name: backendservice-targethttpproxy
- backends:
- - group: "{{ instancegroup.selfLink }}"
- health_checks:
- - "{{ healthcheck.selfLink }}"
- enable_cdn: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: backendservice
- ignore_errors: true
-- name: delete a HTTP health check
- gcp_compute_http_health_check:
- name: httphealthcheck-targethttpproxy
- healthy_threshold: 10
- port: 8080
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: healthcheck
- ignore_errors: true
-- name: delete a instance group
- gcp_compute_instance_group:
- name: instancegroup-targethttpproxy
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: instancegroup
- ignore_errors: true
diff --git a/test/integration/targets/gcp_compute_target_http_proxy/tasks/main.yml b/test/integration/targets/gcp_compute_target_http_proxy/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_target_http_proxy/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_target_https_proxy/aliases b/test/integration/targets/gcp_compute_target_https_proxy/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_target_https_proxy/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_target_https_proxy/defaults/main.yml b/test/integration/targets/gcp_compute_target_https_proxy/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_compute_target_https_proxy/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_compute_target_https_proxy/meta/main.yml b/test/integration/targets/gcp_compute_target_https_proxy/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_target_https_proxy/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_target_https_proxy/tasks/autogen.yml b/test/integration/targets/gcp_compute_target_https_proxy/tasks/autogen.yml
deleted file mode 100644
index b18a08ba10..0000000000
--- a/test/integration/targets/gcp_compute_target_https_proxy/tasks/autogen.yml
+++ /dev/null
@@ -1,277 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a instance group
- gcp_compute_instance_group:
- name: instancegroup-targethttpsproxy
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: instancegroup
-- name: create a HTTP health check
- gcp_compute_http_health_check:
- name: httphealthcheck-targethttpsproxy
- healthy_threshold: 10
- port: 8080
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: healthcheck
-- name: create a backend service
- gcp_compute_backend_service:
- name: backendservice-targethttpsproxy
- backends:
- - group: "{{ instancegroup.selfLink }}"
- health_checks:
- - "{{ healthcheck.selfLink }}"
- enable_cdn: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: backendservice
-- name: create a URL map
- gcp_compute_url_map:
- name: urlmap-targethttpsproxy
- default_service: "{{ backendservice }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: urlmap
-- name: create a SSL certificate
- gcp_compute_ssl_certificate:
- name: sslcert-targethttpsproxy
- description: A certificate for testing. Do not use this certificate in production
- certificate: |-
- -----BEGIN CERTIFICATE-----
- MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG
- EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT
- BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm
- b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN
- AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2
- MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP
- BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM
- FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z
- aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH
- KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ
- 4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O
- BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn
- 0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O
- M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ
- zqGNhIPGq2ULqXKK8BY=
- -----END CERTIFICATE-----
- private_key: |-
- -----BEGIN EC PRIVATE KEY-----
- MHcCAQEEIObtRo8tkUqoMjeHhsOh2ouPpXCgBcP+EDxZCB/tws15oAoGCCqGSM49
- AwEHoUQDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ4mzkzTv0dXyB750f
- OGN02HtkpBOZzzvUARTR10JQoSe2/5PIwQ==
- -----END EC PRIVATE KEY-----
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: sslcert
-- name: delete a target HTTPS proxy
- gcp_compute_target_https_proxy:
- name: "{{ resource_name }}"
- ssl_certificates:
- - "{{ sslcert }}"
- url_map: "{{ urlmap }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a target HTTPS proxy
- gcp_compute_target_https_proxy:
- name: "{{ resource_name }}"
- ssl_certificates:
- - "{{ sslcert }}"
- url_map: "{{ urlmap }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that target_https_proxy was created
- gcp_compute_target_https_proxy_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a target HTTPS proxy that already exists
- gcp_compute_target_https_proxy:
- name: "{{ resource_name }}"
- ssl_certificates:
- - "{{ sslcert }}"
- url_map: "{{ urlmap }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a target HTTPS proxy
- gcp_compute_target_https_proxy:
- name: "{{ resource_name }}"
- ssl_certificates:
- - "{{ sslcert }}"
- url_map: "{{ urlmap }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that target_https_proxy was deleted
- gcp_compute_target_https_proxy_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a target HTTPS proxy that does not exist
- gcp_compute_target_https_proxy:
- name: "{{ resource_name }}"
- ssl_certificates:
- - "{{ sslcert }}"
- url_map: "{{ urlmap }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a SSL certificate
- gcp_compute_ssl_certificate:
- name: sslcert-targethttpsproxy
- description: A certificate for testing. Do not use this certificate in production
- certificate: |-
- -----BEGIN CERTIFICATE-----
- MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG
- EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT
- BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm
- b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN
- AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2
- MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP
- BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM
- FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z
- aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH
- KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ
- 4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O
- BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn
- 0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O
- M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ
- zqGNhIPGq2ULqXKK8BY=
- -----END CERTIFICATE-----
- private_key: |-
- -----BEGIN EC PRIVATE KEY-----
- MHcCAQEEIObtRo8tkUqoMjeHhsOh2ouPpXCgBcP+EDxZCB/tws15oAoGCCqGSM49
- AwEHoUQDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ4mzkzTv0dXyB750f
- OGN02HtkpBOZzzvUARTR10JQoSe2/5PIwQ==
- -----END EC PRIVATE KEY-----
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: sslcert
- ignore_errors: true
-- name: delete a URL map
- gcp_compute_url_map:
- name: urlmap-targethttpsproxy
- default_service: "{{ backendservice }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: urlmap
- ignore_errors: true
-- name: delete a backend service
- gcp_compute_backend_service:
- name: backendservice-targethttpsproxy
- backends:
- - group: "{{ instancegroup.selfLink }}"
- health_checks:
- - "{{ healthcheck.selfLink }}"
- enable_cdn: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: backendservice
- ignore_errors: true
-- name: delete a HTTP health check
- gcp_compute_http_health_check:
- name: httphealthcheck-targethttpsproxy
- healthy_threshold: 10
- port: 8080
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: healthcheck
- ignore_errors: true
-- name: delete a instance group
- gcp_compute_instance_group:
- name: instancegroup-targethttpsproxy
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: instancegroup
- ignore_errors: true
diff --git a/test/integration/targets/gcp_compute_target_https_proxy/tasks/main.yml b/test/integration/targets/gcp_compute_target_https_proxy/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_target_https_proxy/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_target_instance/aliases b/test/integration/targets/gcp_compute_target_instance/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_target_instance/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_target_instance/meta/main.yml b/test/integration/targets/gcp_compute_target_instance/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_target_instance/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_target_instance/tasks/autogen.yml b/test/integration/targets/gcp_compute_target_instance/tasks/autogen.yml
deleted file mode 100644
index 812a706e4a..0000000000
--- a/test/integration/targets/gcp_compute_target_instance/tasks/autogen.yml
+++ /dev/null
@@ -1,173 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a network
- gcp_compute_network:
- name: network-instance
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: network
-- name: create a instance
- gcp_compute_instance:
- name: "{{ resource_name }}"
- machine_type: n1-standard-1
- disks:
- - auto_delete: 'true'
- boot: 'true'
- initialize_params:
- source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
- labels:
- environment: production
- network_interfaces:
- - network: "{{ network }}"
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: instance
-- name: delete a target instance
- gcp_compute_target_instance:
- name: target
- instance: "{{ instance }}"
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a target instance
- gcp_compute_target_instance:
- name: target
- instance: "{{ instance }}"
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that target_instance was created
- gcp_compute_target_instance_info:
- filters:
- - name = target
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a target instance that already exists
- gcp_compute_target_instance:
- name: target
- instance: "{{ instance }}"
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a target instance
- gcp_compute_target_instance:
- name: target
- instance: "{{ instance }}"
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that target_instance was deleted
- gcp_compute_target_instance_info:
- filters:
- - name = target
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a target instance that does not exist
- gcp_compute_target_instance:
- name: target
- instance: "{{ instance }}"
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a instance
- gcp_compute_instance:
- name: "{{ resource_name }}"
- machine_type: n1-standard-1
- disks:
- - auto_delete: 'true'
- boot: 'true'
- initialize_params:
- source_image: projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts
- labels:
- environment: production
- network_interfaces:
- - network: "{{ network }}"
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: instance
- ignore_errors: true
-- name: delete a network
- gcp_compute_network:
- name: network-instance
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: network
- ignore_errors: true
diff --git a/test/integration/targets/gcp_compute_target_instance/tasks/main.yml b/test/integration/targets/gcp_compute_target_instance/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_target_instance/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_target_pool/aliases b/test/integration/targets/gcp_compute_target_pool/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_target_pool/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_target_pool/defaults/main.yml b/test/integration/targets/gcp_compute_target_pool/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_compute_target_pool/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_compute_target_pool/meta/main.yml b/test/integration/targets/gcp_compute_target_pool/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_target_pool/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_target_pool/tasks/autogen.yml b/test/integration/targets/gcp_compute_target_pool/tasks/autogen.yml
deleted file mode 100644
index 756a5cccf9..0000000000
--- a/test/integration/targets/gcp_compute_target_pool/tasks/autogen.yml
+++ /dev/null
@@ -1,109 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a target pool
- gcp_compute_target_pool:
- name: "{{ resource_name }}"
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a target pool
- gcp_compute_target_pool:
- name: "{{ resource_name }}"
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that target_pool was created
- gcp_compute_target_pool_info:
- filters:
- - name = {{ resource_name }}
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a target pool that already exists
- gcp_compute_target_pool:
- name: "{{ resource_name }}"
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a target pool
- gcp_compute_target_pool:
- name: "{{ resource_name }}"
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that target_pool was deleted
- gcp_compute_target_pool_info:
- filters:
- - name = {{ resource_name }}
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a target pool that does not exist
- gcp_compute_target_pool:
- name: "{{ resource_name }}"
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_compute_target_pool/tasks/main.yml b/test/integration/targets/gcp_compute_target_pool/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_target_pool/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_target_ssl_proxy/aliases b/test/integration/targets/gcp_compute_target_ssl_proxy/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_target_ssl_proxy/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_target_ssl_proxy/defaults/main.yml b/test/integration/targets/gcp_compute_target_ssl_proxy/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_compute_target_ssl_proxy/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_compute_target_ssl_proxy/meta/main.yml b/test/integration/targets/gcp_compute_target_ssl_proxy/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_target_ssl_proxy/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_target_ssl_proxy/tasks/autogen.yml b/test/integration/targets/gcp_compute_target_ssl_proxy/tasks/autogen.yml
deleted file mode 100644
index f9da704f7e..0000000000
--- a/test/integration/targets/gcp_compute_target_ssl_proxy/tasks/autogen.yml
+++ /dev/null
@@ -1,266 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a instance group
- gcp_compute_instance_group:
- name: instancegroup-targetsslproxy
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: instancegroup
-- name: create a health check
- gcp_compute_health_check:
- name: healthcheck-targetsslproxy
- type: TCP
- tcp_health_check:
- port_name: service-health
- request: ping
- response: pong
- healthy_threshold: 10
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: healthcheck
-- name: create a backend service
- gcp_compute_backend_service:
- name: backendservice-targetsslproxy
- backends:
- - group: "{{ instancegroup.selfLink }}"
- health_checks:
- - "{{ healthcheck.selfLink }}"
- protocol: SSL
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: backendservice
-- name: create a SSL certificate
- gcp_compute_ssl_certificate:
- name: sslcert-targetsslproxy
- description: A certificate for testing. Do not use this certificate in production
- certificate: |-
- -----BEGIN CERTIFICATE-----
- MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG
- EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT
- BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm
- b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN
- AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2
- MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP
- BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM
- FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z
- aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH
- KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ
- 4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O
- BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn
- 0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O
- M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ
- zqGNhIPGq2ULqXKK8BY=
- -----END CERTIFICATE-----
- private_key: |-
- -----BEGIN EC PRIVATE KEY-----
- MHcCAQEEIObtRo8tkUqoMjeHhsOh2ouPpXCgBcP+EDxZCB/tws15oAoGCCqGSM49
- AwEHoUQDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ4mzkzTv0dXyB750f
- OGN02HtkpBOZzzvUARTR10JQoSe2/5PIwQ==
- -----END EC PRIVATE KEY-----
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: sslcert
-- name: delete a target SSL proxy
- gcp_compute_target_ssl_proxy:
- name: "{{ resource_name }}"
- ssl_certificates:
- - "{{ sslcert }}"
- service: "{{ backendservice }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a target SSL proxy
- gcp_compute_target_ssl_proxy:
- name: "{{ resource_name }}"
- ssl_certificates:
- - "{{ sslcert }}"
- service: "{{ backendservice }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that target_ssl_proxy was created
- gcp_compute_target_ssl_proxy_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a target SSL proxy that already exists
- gcp_compute_target_ssl_proxy:
- name: "{{ resource_name }}"
- ssl_certificates:
- - "{{ sslcert }}"
- service: "{{ backendservice }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a target SSL proxy
- gcp_compute_target_ssl_proxy:
- name: "{{ resource_name }}"
- ssl_certificates:
- - "{{ sslcert }}"
- service: "{{ backendservice }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that target_ssl_proxy was deleted
- gcp_compute_target_ssl_proxy_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a target SSL proxy that does not exist
- gcp_compute_target_ssl_proxy:
- name: "{{ resource_name }}"
- ssl_certificates:
- - "{{ sslcert }}"
- service: "{{ backendservice }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a SSL certificate
- gcp_compute_ssl_certificate:
- name: sslcert-targetsslproxy
- description: A certificate for testing. Do not use this certificate in production
- certificate: |-
- -----BEGIN CERTIFICATE-----
- MIICqjCCAk+gAwIBAgIJAIuJ+0352Kq4MAoGCCqGSM49BAMCMIGwMQswCQYDVQQG
- EwJVUzETMBEGA1UECAwKV2FzaGluZ3RvbjERMA8GA1UEBwwIS2lya2xhbmQxFTAT
- BgNVBAoMDEdvb2dsZSwgSW5jLjEeMBwGA1UECwwVR29vZ2xlIENsb3VkIFBsYXRm
- b3JtMR8wHQYDVQQDDBZ3d3cubXktc2VjdXJlLXNpdGUuY29tMSEwHwYJKoZIhvcN
- AQkBFhJuZWxzb25hQGdvb2dsZS5jb20wHhcNMTcwNjI4MDQ1NjI2WhcNMjcwNjI2
- MDQ1NjI2WjCBsDELMAkGA1UEBhMCVVMxEzARBgNVBAgMCldhc2hpbmd0b24xETAP
- BgNVBAcMCEtpcmtsYW5kMRUwEwYDVQQKDAxHb29nbGUsIEluYy4xHjAcBgNVBAsM
- FUdvb2dsZSBDbG91ZCBQbGF0Zm9ybTEfMB0GA1UEAwwWd3d3Lm15LXNlY3VyZS1z
- aXRlLmNvbTEhMB8GCSqGSIb3DQEJARYSbmVsc29uYUBnb29nbGUuY29tMFkwEwYH
- KoZIzj0CAQYIKoZIzj0DAQcDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ
- 4mzkzTv0dXyB750fOGN02HtkpBOZzzvUARTR10JQoSe2/5PIwaNQME4wHQYDVR0O
- BBYEFKIQC3A2SDpxcdfn0YLKineDNq/BMB8GA1UdIwQYMBaAFKIQC3A2SDpxcdfn
- 0YLKineDNq/BMAwGA1UdEwQFMAMBAf8wCgYIKoZIzj0EAwIDSQAwRgIhALs4vy+O
- M3jcqgA4fSW/oKw6UJxp+M6a+nGMX+UJR3YgAiEAvvl39QRVAiv84hdoCuyON0lJ
- zqGNhIPGq2ULqXKK8BY=
- -----END CERTIFICATE-----
- private_key: |-
- -----BEGIN EC PRIVATE KEY-----
- MHcCAQEEIObtRo8tkUqoMjeHhsOh2ouPpXCgBcP+EDxZCB/tws15oAoGCCqGSM49
- AwEHoUQDQgAEHGzpcRJ4XzfBJCCPMQeXQpTXwlblimODQCuQ4mzkzTv0dXyB750f
- OGN02HtkpBOZzzvUARTR10JQoSe2/5PIwQ==
- -----END EC PRIVATE KEY-----
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: sslcert
- ignore_errors: true
-- name: delete a backend service
- gcp_compute_backend_service:
- name: backendservice-targetsslproxy
- backends:
- - group: "{{ instancegroup.selfLink }}"
- health_checks:
- - "{{ healthcheck.selfLink }}"
- protocol: SSL
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: backendservice
- ignore_errors: true
-- name: delete a health check
- gcp_compute_health_check:
- name: healthcheck-targetsslproxy
- type: TCP
- tcp_health_check:
- port_name: service-health
- request: ping
- response: pong
- healthy_threshold: 10
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: healthcheck
- ignore_errors: true
-- name: delete a instance group
- gcp_compute_instance_group:
- name: instancegroup-targetsslproxy
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: instancegroup
- ignore_errors: true
diff --git a/test/integration/targets/gcp_compute_target_ssl_proxy/tasks/main.yml b/test/integration/targets/gcp_compute_target_ssl_proxy/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_target_ssl_proxy/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_target_tcp_proxy/aliases b/test/integration/targets/gcp_compute_target_tcp_proxy/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_target_tcp_proxy/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_target_tcp_proxy/defaults/main.yml b/test/integration/targets/gcp_compute_target_tcp_proxy/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_compute_target_tcp_proxy/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_compute_target_tcp_proxy/meta/main.yml b/test/integration/targets/gcp_compute_target_tcp_proxy/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_target_tcp_proxy/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_target_tcp_proxy/tasks/autogen.yml b/test/integration/targets/gcp_compute_target_tcp_proxy/tasks/autogen.yml
deleted file mode 100644
index 8385d591b7..0000000000
--- a/test/integration/targets/gcp_compute_target_tcp_proxy/tasks/autogen.yml
+++ /dev/null
@@ -1,194 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a instance group
- gcp_compute_instance_group:
- name: instancegroup-targettcpproxy
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: instancegroup
-- name: create a health check
- gcp_compute_health_check:
- name: healthcheck-targettcpproxy
- type: TCP
- tcp_health_check:
- port_name: service-health
- request: ping
- response: pong
- healthy_threshold: 10
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: healthcheck
-- name: create a backend service
- gcp_compute_backend_service:
- name: backendservice-targettcpproxy
- backends:
- - group: "{{ instancegroup.selfLink }}"
- health_checks:
- - "{{ healthcheck.selfLink }}"
- protocol: TCP
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: backendservice
-- name: delete a target TCP proxy
- gcp_compute_target_tcp_proxy:
- name: "{{ resource_name }}"
- proxy_header: PROXY_V1
- service: "{{ backendservice }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a target TCP proxy
- gcp_compute_target_tcp_proxy:
- name: "{{ resource_name }}"
- proxy_header: PROXY_V1
- service: "{{ backendservice }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that target_tcp_proxy was created
- gcp_compute_target_tcp_proxy_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a target TCP proxy that already exists
- gcp_compute_target_tcp_proxy:
- name: "{{ resource_name }}"
- proxy_header: PROXY_V1
- service: "{{ backendservice }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a target TCP proxy
- gcp_compute_target_tcp_proxy:
- name: "{{ resource_name }}"
- proxy_header: PROXY_V1
- service: "{{ backendservice }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that target_tcp_proxy was deleted
- gcp_compute_target_tcp_proxy_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a target TCP proxy that does not exist
- gcp_compute_target_tcp_proxy:
- name: "{{ resource_name }}"
- proxy_header: PROXY_V1
- service: "{{ backendservice }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a backend service
- gcp_compute_backend_service:
- name: backendservice-targettcpproxy
- backends:
- - group: "{{ instancegroup.selfLink }}"
- health_checks:
- - "{{ healthcheck.selfLink }}"
- protocol: TCP
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: backendservice
- ignore_errors: true
-- name: delete a health check
- gcp_compute_health_check:
- name: healthcheck-targettcpproxy
- type: TCP
- tcp_health_check:
- port_name: service-health
- request: ping
- response: pong
- healthy_threshold: 10
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: healthcheck
- ignore_errors: true
-- name: delete a instance group
- gcp_compute_instance_group:
- name: instancegroup-targettcpproxy
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: instancegroup
- ignore_errors: true
diff --git a/test/integration/targets/gcp_compute_target_tcp_proxy/tasks/main.yml b/test/integration/targets/gcp_compute_target_tcp_proxy/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_target_tcp_proxy/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_target_vpn_gateway/aliases b/test/integration/targets/gcp_compute_target_vpn_gateway/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_target_vpn_gateway/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_target_vpn_gateway/defaults/main.yml b/test/integration/targets/gcp_compute_target_vpn_gateway/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_compute_target_vpn_gateway/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_compute_target_vpn_gateway/meta/main.yml b/test/integration/targets/gcp_compute_target_vpn_gateway/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_target_vpn_gateway/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_target_vpn_gateway/tasks/autogen.yml b/test/integration/targets/gcp_compute_target_vpn_gateway/tasks/autogen.yml
deleted file mode 100644
index 6fd3d01dd0..0000000000
--- a/test/integration/targets/gcp_compute_target_vpn_gateway/tasks/autogen.yml
+++ /dev/null
@@ -1,153 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a address
- gcp_compute_address:
- name: address-vpngateway
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: address
-- name: create a network
- gcp_compute_network:
- name: network-vpngateway
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: network
-- name: delete a target vpn gateway
- gcp_compute_target_vpn_gateway:
- name: "{{ resource_name }}"
- region: us-west1
- network: "{{ network }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a target vpn gateway
- gcp_compute_target_vpn_gateway:
- name: "{{ resource_name }}"
- region: us-west1
- network: "{{ network }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that target_vpn_gateway was created
- gcp_compute_target_vpn_gateway_info:
- filters:
- - name = {{ resource_name }}
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a target vpn gateway that already exists
- gcp_compute_target_vpn_gateway:
- name: "{{ resource_name }}"
- region: us-west1
- network: "{{ network }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a target vpn gateway
- gcp_compute_target_vpn_gateway:
- name: "{{ resource_name }}"
- region: us-west1
- network: "{{ network }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that target_vpn_gateway was deleted
- gcp_compute_target_vpn_gateway_info:
- filters:
- - name = {{ resource_name }}
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a target vpn gateway that does not exist
- gcp_compute_target_vpn_gateway:
- name: "{{ resource_name }}"
- region: us-west1
- network: "{{ network }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a network
- gcp_compute_network:
- name: network-vpngateway
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: network
- ignore_errors: true
-- name: delete a address
- gcp_compute_address:
- name: address-vpngateway
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: address
- ignore_errors: true
diff --git a/test/integration/targets/gcp_compute_target_vpn_gateway/tasks/main.yml b/test/integration/targets/gcp_compute_target_vpn_gateway/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_target_vpn_gateway/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_url_map/aliases b/test/integration/targets/gcp_compute_url_map/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_url_map/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_url_map/defaults/main.yml b/test/integration/targets/gcp_compute_url_map/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_compute_url_map/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_compute_url_map/meta/main.yml b/test/integration/targets/gcp_compute_url_map/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_url_map/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_url_map/tasks/autogen.yml b/test/integration/targets/gcp_compute_url_map/tasks/autogen.yml
deleted file mode 100644
index b05a23a18b..0000000000
--- a/test/integration/targets/gcp_compute_url_map/tasks/autogen.yml
+++ /dev/null
@@ -1,181 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a instance group
- gcp_compute_instance_group:
- name: instancegroup-urlmap
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: instancegroup
-- name: create a HTTP health check
- gcp_compute_http_health_check:
- name: httphealthcheck-urlmap
- healthy_threshold: 10
- port: 8080
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: healthcheck
-- name: create a backend service
- gcp_compute_backend_service:
- name: backendservice-urlmap
- backends:
- - group: "{{ instancegroup.selfLink }}"
- health_checks:
- - "{{ healthcheck.selfLink }}"
- enable_cdn: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: backendservice
-- name: delete a URL map
- gcp_compute_url_map:
- name: "{{ resource_name }}"
- default_service: "{{ backendservice }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a URL map
- gcp_compute_url_map:
- name: "{{ resource_name }}"
- default_service: "{{ backendservice }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that url_map was created
- gcp_compute_url_map_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a URL map that already exists
- gcp_compute_url_map:
- name: "{{ resource_name }}"
- default_service: "{{ backendservice }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a URL map
- gcp_compute_url_map:
- name: "{{ resource_name }}"
- default_service: "{{ backendservice }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that url_map was deleted
- gcp_compute_url_map_info:
- filters:
- - name = {{ resource_name }}
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a URL map that does not exist
- gcp_compute_url_map:
- name: "{{ resource_name }}"
- default_service: "{{ backendservice }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a backend service
- gcp_compute_backend_service:
- name: backendservice-urlmap
- backends:
- - group: "{{ instancegroup.selfLink }}"
- health_checks:
- - "{{ healthcheck.selfLink }}"
- enable_cdn: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: backendservice
- ignore_errors: true
-- name: delete a HTTP health check
- gcp_compute_http_health_check:
- name: httphealthcheck-urlmap
- healthy_threshold: 10
- port: 8080
- timeout_sec: 2
- unhealthy_threshold: 5
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: healthcheck
- ignore_errors: true
-- name: delete a instance group
- gcp_compute_instance_group:
- name: instancegroup-urlmap
- zone: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: instancegroup
- ignore_errors: true
diff --git a/test/integration/targets/gcp_compute_url_map/tasks/main.yml b/test/integration/targets/gcp_compute_url_map/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_url_map/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_compute_vpn_tunnel/aliases b/test/integration/targets/gcp_compute_vpn_tunnel/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_compute_vpn_tunnel/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_compute_vpn_tunnel/defaults/main.yml b/test/integration/targets/gcp_compute_vpn_tunnel/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_compute_vpn_tunnel/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_compute_vpn_tunnel/meta/main.yml b/test/integration/targets/gcp_compute_vpn_tunnel/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_compute_vpn_tunnel/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_compute_vpn_tunnel/tasks/autogen.yml b/test/integration/targets/gcp_compute_vpn_tunnel/tasks/autogen.yml
deleted file mode 100644
index abd5dbb6d2..0000000000
--- a/test/integration/targets/gcp_compute_vpn_tunnel/tasks/autogen.yml
+++ /dev/null
@@ -1,202 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a network
- gcp_compute_network:
- name: network-vpn-tunnel
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: network
-- name: create a router
- gcp_compute_router:
- name: router-vpn-tunnel
- network: "{{ network }}"
- bgp:
- asn: 64514
- advertise_mode: CUSTOM
- advertised_groups:
- - ALL_SUBNETS
- advertised_ip_ranges:
- - range: 1.2.3.4
- - range: 6.7.0.0/16
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: router
-- name: create a target vpn gateway
- gcp_compute_target_vpn_gateway:
- name: gateway-vpn-tunnel
- region: us-west1
- network: "{{ network }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: gateway
-- name: delete a vpn tunnel
- gcp_compute_vpn_tunnel:
- name: "{{ resource_name }}"
- region: us-west1
- target_vpn_gateway: "{{ gateway }}"
- router: "{{ router }}"
- shared_secret: super secret
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a vpn tunnel
- gcp_compute_vpn_tunnel:
- name: "{{ resource_name }}"
- region: us-west1
- target_vpn_gateway: "{{ gateway }}"
- router: "{{ router }}"
- shared_secret: super secret
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that vpn_tunnel was created
- gcp_compute_vpn_tunnel_info:
- filters:
- - name = {{ resource_name }}
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a vpn tunnel that already exists
- gcp_compute_vpn_tunnel:
- name: "{{ resource_name }}"
- region: us-west1
- target_vpn_gateway: "{{ gateway }}"
- router: "{{ router }}"
- shared_secret: super secret
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a vpn tunnel
- gcp_compute_vpn_tunnel:
- name: "{{ resource_name }}"
- region: us-west1
- target_vpn_gateway: "{{ gateway }}"
- router: "{{ router }}"
- shared_secret: super secret
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that vpn_tunnel was deleted
- gcp_compute_vpn_tunnel_info:
- filters:
- - name = {{ resource_name }}
- region: us-west1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/compute
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a vpn tunnel that does not exist
- gcp_compute_vpn_tunnel:
- name: "{{ resource_name }}"
- region: us-west1
- target_vpn_gateway: "{{ gateway }}"
- router: "{{ router }}"
- shared_secret: super secret
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a target vpn gateway
- gcp_compute_target_vpn_gateway:
- name: gateway-vpn-tunnel
- region: us-west1
- network: "{{ network }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: gateway
- ignore_errors: true
-- name: delete a router
- gcp_compute_router:
- name: router-vpn-tunnel
- network: "{{ network }}"
- bgp:
- asn: 64514
- advertise_mode: CUSTOM
- advertised_groups:
- - ALL_SUBNETS
- advertised_ip_ranges:
- - range: 1.2.3.4
- - range: 6.7.0.0/16
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: router
- ignore_errors: true
-- name: delete a network
- gcp_compute_network:
- name: network-vpn-tunnel
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: network
- ignore_errors: true
diff --git a/test/integration/targets/gcp_compute_vpn_tunnel/tasks/main.yml b/test/integration/targets/gcp_compute_vpn_tunnel/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_compute_vpn_tunnel/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_container_cluster/aliases b/test/integration/targets/gcp_container_cluster/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_container_cluster/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_container_cluster/defaults/main.yml b/test/integration/targets/gcp_container_cluster/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_container_cluster/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_container_cluster/meta/main.yml b/test/integration/targets/gcp_container_cluster/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_container_cluster/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_container_cluster/tasks/autogen.yml b/test/integration/targets/gcp_container_cluster/tasks/autogen.yml
deleted file mode 100644
index 1581a30fbb..0000000000
--- a/test/integration/targets/gcp_container_cluster/tasks/autogen.yml
+++ /dev/null
@@ -1,140 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a cluster
- gcp_container_cluster:
- name: my-cluster
- initial_node_count: 2
- master_auth:
- username: cluster_admin
- password: my-secret-password
- node_config:
- machine_type: n1-standard-4
- disk_size_gb: 500
- location: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a cluster
- gcp_container_cluster:
- name: my-cluster
- initial_node_count: 2
- master_auth:
- username: cluster_admin
- password: my-secret-password
- node_config:
- machine_type: n1-standard-4
- disk_size_gb: 500
- location: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that cluster was created
- gcp_container_cluster_info:
- location: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloud-platform
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - "'my-cluster' in \"{{ results['resources'] | map(attribute='name') | list }}\""
-# ----------------------------------------------------------------------------
-- name: create a cluster that already exists
- gcp_container_cluster:
- name: my-cluster
- initial_node_count: 2
- master_auth:
- username: cluster_admin
- password: my-secret-password
- node_config:
- machine_type: n1-standard-4
- disk_size_gb: 500
- location: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a cluster
- gcp_container_cluster:
- name: my-cluster
- initial_node_count: 2
- master_auth:
- username: cluster_admin
- password: my-secret-password
- node_config:
- machine_type: n1-standard-4
- disk_size_gb: 500
- location: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that cluster was deleted
- gcp_container_cluster_info:
- location: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloud-platform
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - "'my-cluster' not in \"{{ results['resources'] | map(attribute='name') | list }}\""
-# ----------------------------------------------------------------------------
-- name: delete a cluster that does not exist
- gcp_container_cluster:
- name: my-cluster
- initial_node_count: 2
- master_auth:
- username: cluster_admin
- password: my-secret-password
- node_config:
- machine_type: n1-standard-4
- disk_size_gb: 500
- location: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_container_cluster/tasks/main.yml b/test/integration/targets/gcp_container_cluster/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_container_cluster/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_container_node_pool/aliases b/test/integration/targets/gcp_container_node_pool/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_container_node_pool/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_container_node_pool/defaults/main.yml b/test/integration/targets/gcp_container_node_pool/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_container_node_pool/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_container_node_pool/meta/main.yml b/test/integration/targets/gcp_container_node_pool/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_container_node_pool/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_container_node_pool/tasks/autogen.yml b/test/integration/targets/gcp_container_node_pool/tasks/autogen.yml
deleted file mode 100644
index d62b747059..0000000000
--- a/test/integration/targets/gcp_container_node_pool/tasks/autogen.yml
+++ /dev/null
@@ -1,141 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a cluster
- gcp_container_cluster:
- name: cluster-nodepool
- initial_node_count: 4
- location: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: cluster
-- name: delete a node pool
- gcp_container_node_pool:
- name: my-pool
- initial_node_count: 4
- cluster: "{{ cluster }}"
- location: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a node pool
- gcp_container_node_pool:
- name: my-pool
- initial_node_count: 4
- cluster: "{{ cluster }}"
- location: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that node_pool was created
- gcp_container_node_pool_info:
- cluster: "{{ cluster }}"
- location: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloud-platform
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - "'my-pool' in \"{{ results['resources'] | map(attribute='name') | list }}\""
-# ----------------------------------------------------------------------------
-- name: create a node pool that already exists
- gcp_container_node_pool:
- name: my-pool
- initial_node_count: 4
- cluster: "{{ cluster }}"
- location: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a node pool
- gcp_container_node_pool:
- name: my-pool
- initial_node_count: 4
- cluster: "{{ cluster }}"
- location: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that node_pool was deleted
- gcp_container_node_pool_info:
- cluster: "{{ cluster }}"
- location: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloud-platform
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - "'my-pool' not in \"{{ results['resources'] | map(attribute='name') | list }}\""
-# ----------------------------------------------------------------------------
-- name: delete a node pool that does not exist
- gcp_container_node_pool:
- name: my-pool
- initial_node_count: 4
- cluster: "{{ cluster }}"
- location: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a cluster
- gcp_container_cluster:
- name: cluster-nodepool
- initial_node_count: 4
- location: us-central1-a
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: cluster
- ignore_errors: true
diff --git a/test/integration/targets/gcp_container_node_pool/tasks/main.yml b/test/integration/targets/gcp_container_node_pool/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_container_node_pool/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_dns_managed_zone/aliases b/test/integration/targets/gcp_dns_managed_zone/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_dns_managed_zone/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_dns_managed_zone/defaults/main.yml b/test/integration/targets/gcp_dns_managed_zone/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_dns_managed_zone/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_dns_managed_zone/meta/main.yml b/test/integration/targets/gcp_dns_managed_zone/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_dns_managed_zone/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_dns_managed_zone/tasks/autogen.yml b/test/integration/targets/gcp_dns_managed_zone/tasks/autogen.yml
deleted file mode 100644
index 21ce21009f..0000000000
--- a/test/integration/targets/gcp_dns_managed_zone/tasks/autogen.yml
+++ /dev/null
@@ -1,110 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a managed zone
- gcp_dns_managed_zone:
- name: "{{ resource_name }}"
- dns_name: test.somewild2.example.com.
- description: test zone
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a managed zone
- gcp_dns_managed_zone:
- name: "{{ resource_name }}"
- dns_name: test.somewild2.example.com.
- description: test zone
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that managed_zone was created
- gcp_dns_managed_zone_info:
- dns_name: test.somewild2.example.com.
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/ndev.clouddns.readwrite
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 1
-# ----------------------------------------------------------------------------
-- name: create a managed zone that already exists
- gcp_dns_managed_zone:
- name: "{{ resource_name }}"
- dns_name: test.somewild2.example.com.
- description: test zone
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a managed zone
- gcp_dns_managed_zone:
- name: "{{ resource_name }}"
- dns_name: test.somewild2.example.com.
- description: test zone
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that managed_zone was deleted
- gcp_dns_managed_zone_info:
- dns_name: test.somewild2.example.com.
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/ndev.clouddns.readwrite
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a managed zone that does not exist
- gcp_dns_managed_zone:
- name: "{{ resource_name }}"
- dns_name: test.somewild2.example.com.
- description: test zone
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_dns_managed_zone/tasks/main.yml b/test/integration/targets/gcp_dns_managed_zone/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_dns_managed_zone/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_dns_resource_record_set/aliases b/test/integration/targets/gcp_dns_resource_record_set/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_dns_resource_record_set/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_dns_resource_record_set/defaults/main.yml b/test/integration/targets/gcp_dns_resource_record_set/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_dns_resource_record_set/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_dns_resource_record_set/meta/main.yml b/test/integration/targets/gcp_dns_resource_record_set/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_dns_resource_record_set/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_dns_resource_record_set/tasks/autogen.yml b/test/integration/targets/gcp_dns_resource_record_set/tasks/autogen.yml
deleted file mode 100644
index 8b5529656a..0000000000
--- a/test/integration/targets/gcp_dns_resource_record_set/tasks/autogen.yml
+++ /dev/null
@@ -1,154 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a managed zone
- gcp_dns_managed_zone:
- name: managedzone-rrs
- dns_name: testzone-4.com.
- description: test zone
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: managed_zone
-- name: delete a resource record set
- gcp_dns_resource_record_set:
- name: www.testzone-4.com.
- managed_zone: "{{ managed_zone }}"
- type: A
- ttl: 600
- target:
- - 10.1.2.3
- - 40.5.6.7
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a resource record set
- gcp_dns_resource_record_set:
- name: www.testzone-4.com.
- managed_zone: "{{ managed_zone }}"
- type: A
- ttl: 600
- target:
- - 10.1.2.3
- - 40.5.6.7
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that resource_record_set was created
- gcp_dns_resource_record_set_info:
- managed_zone: "{{ managed_zone }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/ndev.clouddns.readwrite
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - "'www.testzone-4.com.'in \"{{ results['resources'] | map(attribute='name') | list }}\""
-# ----------------------------------------------------------------------------
-- name: create a resource record set that already exists
- gcp_dns_resource_record_set:
- name: www.testzone-4.com.
- managed_zone: "{{ managed_zone }}"
- type: A
- ttl: 600
- target:
- - 10.1.2.3
- - 40.5.6.7
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a resource record set
- gcp_dns_resource_record_set:
- name: www.testzone-4.com.
- managed_zone: "{{ managed_zone }}"
- type: A
- ttl: 600
- target:
- - 10.1.2.3
- - 40.5.6.7
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that resource_record_set was deleted
- gcp_dns_resource_record_set_info:
- managed_zone: "{{ managed_zone }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/ndev.clouddns.readwrite
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - "'www.testzone-4.com.'not in \"{{ results['resources'] | map(attribute='name') | list }}\""
-# ----------------------------------------------------------------------------
-- name: delete a resource record set that does not exist
- gcp_dns_resource_record_set:
- name: www.testzone-4.com.
- managed_zone: "{{ managed_zone }}"
- type: A
- ttl: 600
- target:
- - 10.1.2.3
- - 40.5.6.7
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a managed zone
- gcp_dns_managed_zone:
- name: managedzone-rrs
- dns_name: testzone-4.com.
- description: test zone
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: managed_zone
- ignore_errors: true
diff --git a/test/integration/targets/gcp_dns_resource_record_set/tasks/main.yml b/test/integration/targets/gcp_dns_resource_record_set/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_dns_resource_record_set/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_filestore_instance/aliases b/test/integration/targets/gcp_filestore_instance/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_filestore_instance/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_filestore_instance/defaults/main.yml b/test/integration/targets/gcp_filestore_instance/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_filestore_instance/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_filestore_instance/meta/main.yml b/test/integration/targets/gcp_filestore_instance/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_filestore_instance/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_filestore_instance/tasks/autogen.yml b/test/integration/targets/gcp_filestore_instance/tasks/autogen.yml
deleted file mode 100644
index 4713f094b0..0000000000
--- a/test/integration/targets/gcp_filestore_instance/tasks/autogen.yml
+++ /dev/null
@@ -1,145 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a instance
- gcp_filestore_instance:
- name: "{{ resource_name }}"
- zone: us-central1-b
- tier: PREMIUM
- file_shares:
- - capacity_gb: 2660
- name: share1
- networks:
- - network: default
- modes:
- - MODE_IPV4
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a instance
- gcp_filestore_instance:
- name: "{{ resource_name }}"
- zone: us-central1-b
- tier: PREMIUM
- file_shares:
- - capacity_gb: 2660
- name: share1
- networks:
- - network: default
- modes:
- - MODE_IPV4
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that instance was created
- gcp_filestore_instance_info:
- zone: us-central1-b
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloud-platform
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 1
-# ----------------------------------------------------------------------------
-- name: create a instance that already exists
- gcp_filestore_instance:
- name: "{{ resource_name }}"
- zone: us-central1-b
- tier: PREMIUM
- file_shares:
- - capacity_gb: 2660
- name: share1
- networks:
- - network: default
- modes:
- - MODE_IPV4
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a instance
- gcp_filestore_instance:
- name: "{{ resource_name }}"
- zone: us-central1-b
- tier: PREMIUM
- file_shares:
- - capacity_gb: 2660
- name: share1
- networks:
- - network: default
- modes:
- - MODE_IPV4
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that instance was deleted
- gcp_filestore_instance_info:
- zone: us-central1-b
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloud-platform
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a instance that does not exist
- gcp_filestore_instance:
- name: "{{ resource_name }}"
- zone: us-central1-b
- tier: PREMIUM
- file_shares:
- - capacity_gb: 2660
- name: share1
- networks:
- - network: default
- modes:
- - MODE_IPV4
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_filestore_instance/tasks/main.yml b/test/integration/targets/gcp_filestore_instance/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_filestore_instance/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_iam_role/aliases b/test/integration/targets/gcp_iam_role/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_iam_role/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_iam_role/defaults/main.yml b/test/integration/targets/gcp_iam_role/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_iam_role/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_iam_role/meta/main.yml b/test/integration/targets/gcp_iam_role/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_iam_role/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_iam_role/tasks/autogen.yml b/test/integration/targets/gcp_iam_role/tasks/autogen.yml
deleted file mode 100644
index 04779f9489..0000000000
--- a/test/integration/targets/gcp_iam_role/tasks/autogen.yml
+++ /dev/null
@@ -1,128 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a role
- gcp_iam_role:
- name: myCustomRole2
- title: My Custom Role
- description: My custom role description
- included_permissions:
- - iam.roles.list
- - iam.roles.create
- - iam.roles.delete
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a role
- gcp_iam_role:
- name: myCustomRole2
- title: My Custom Role
- description: My custom role description
- included_permissions:
- - iam.roles.list
- - iam.roles.create
- - iam.roles.delete
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that role was created
- gcp_iam_role_info:
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/iam
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*myCustomRole2.*") | list | length == 1
-# ----------------------------------------------------------------------------
-- name: create a role that already exists
- gcp_iam_role:
- name: myCustomRole2
- title: My Custom Role
- description: My custom role description
- included_permissions:
- - iam.roles.list
- - iam.roles.create
- - iam.roles.delete
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a role
- gcp_iam_role:
- name: myCustomRole2
- title: My Custom Role
- description: My custom role description
- included_permissions:
- - iam.roles.list
- - iam.roles.create
- - iam.roles.delete
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that role was deleted
- gcp_iam_role_info:
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/iam
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*myCustomRole2.*") | list | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a role that does not exist
- gcp_iam_role:
- name: myCustomRole2
- title: My Custom Role
- description: My custom role description
- included_permissions:
- - iam.roles.list
- - iam.roles.create
- - iam.roles.delete
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_iam_role/tasks/main.yml b/test/integration/targets/gcp_iam_role/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_iam_role/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_iam_service_account/aliases b/test/integration/targets/gcp_iam_service_account/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_iam_service_account/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_iam_service_account/defaults/main.yml b/test/integration/targets/gcp_iam_service_account/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_iam_service_account/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_iam_service_account/meta/main.yml b/test/integration/targets/gcp_iam_service_account/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_iam_service_account/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_iam_service_account/tasks/autogen.yml b/test/integration/targets/gcp_iam_service_account/tasks/autogen.yml
deleted file mode 100644
index 1911ad9c27..0000000000
--- a/test/integration/targets/gcp_iam_service_account/tasks/autogen.yml
+++ /dev/null
@@ -1,103 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a service account
- gcp_iam_service_account:
- name: sa-{{ resource_name.split("-")[-1] }}@graphite-playground.google.com.iam.gserviceaccount.com
- display_name: My Ansible test key
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a service account
- gcp_iam_service_account:
- name: sa-{{ resource_name.split("-")[-1] }}@graphite-playground.google.com.iam.gserviceaccount.com
- display_name: My Ansible test key
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that service_account was created
- gcp_iam_service_account_info:
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/iam
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*sa-{{ resource_name.split("-")[-1] }}@graphite-playground.google.com.iam.gserviceaccount.com.*") | list | length == 1
-# ----------------------------------------------------------------------------
-- name: create a service account that already exists
- gcp_iam_service_account:
- name: sa-{{ resource_name.split("-")[-1] }}@graphite-playground.google.com.iam.gserviceaccount.com
- display_name: My Ansible test key
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a service account
- gcp_iam_service_account:
- name: sa-{{ resource_name.split("-")[-1] }}@graphite-playground.google.com.iam.gserviceaccount.com
- display_name: My Ansible test key
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that service_account was deleted
- gcp_iam_service_account_info:
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/iam
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*sa-{{ resource_name.split("-")[-1] }}@graphite-playground.google.com.iam.gserviceaccount.com.*") | list | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a service account that does not exist
- gcp_iam_service_account:
- name: sa-{{ resource_name.split("-")[-1] }}@graphite-playground.google.com.iam.gserviceaccount.com
- display_name: My Ansible test key
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_iam_service_account/tasks/main.yml b/test/integration/targets/gcp_iam_service_account/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_iam_service_account/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_iam_service_account_key/aliases b/test/integration/targets/gcp_iam_service_account_key/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_iam_service_account_key/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_iam_service_account_key/defaults/main.yml b/test/integration/targets/gcp_iam_service_account_key/defaults/main.yml
deleted file mode 100644
index aa87a2a8e0..0000000000
--- a/test/integration/targets/gcp_iam_service_account_key/defaults/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
----
-# defaults file
-resource_name: '{{resource_prefix}}'
diff --git a/test/integration/targets/gcp_iam_service_account_key/meta/main.yml b/test/integration/targets/gcp_iam_service_account_key/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_iam_service_account_key/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_kms_crypto_key/aliases b/test/integration/targets/gcp_kms_crypto_key/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_kms_crypto_key/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_kms_crypto_key/defaults/main.yml b/test/integration/targets/gcp_kms_crypto_key/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_kms_crypto_key/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_kms_crypto_key/meta/main.yml b/test/integration/targets/gcp_kms_crypto_key/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_kms_crypto_key/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_kms_crypto_key/tasks/autogen.yml b/test/integration/targets/gcp_kms_crypto_key/tasks/autogen.yml
deleted file mode 100644
index ef2252c863..0000000000
--- a/test/integration/targets/gcp_kms_crypto_key/tasks/autogen.yml
+++ /dev/null
@@ -1,73 +0,0 @@
-# Copyright 2019 Google Inc.
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
----
-# Pre-test setup
-- name: create a key ring
- gcp_kms_key_ring:
- name: key-key-ring
- location: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: keyring
-- name: delete a crypto key
- gcp_kms_crypto_key:
- name: "{{ resource_name }}"
- key_ring: projects/{{ gcp_project }}/locations/us-central1/keyRings/key-key-ring
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a crypto key
- gcp_kms_crypto_key:
- name: "{{ resource_name }}"
- key_ring: projects/{{ gcp_project }}/locations/us-central1/keyRings/key-key-ring
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that crypto_key was created
- gcp_kms_crypto_key_info:
- key_ring: "projects/{{ gcp_project }}/locations/us-central1/keyRings/key-key-ring"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloudkms
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 1
-# ----------------------------------------------------------------------------
-- name: create a crypto key that already exists
- gcp_kms_crypto_key:
- name: "{{ resource_name }}"
- key_ring: projects/{{ gcp_project }}/locations/us-central1/keyRings/key-key-ring
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_kms_crypto_key/tasks/main.yml b/test/integration/targets/gcp_kms_crypto_key/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_kms_crypto_key/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_kms_key_ring/aliases b/test/integration/targets/gcp_kms_key_ring/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_kms_key_ring/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_kms_key_ring/defaults/main.yml b/test/integration/targets/gcp_kms_key_ring/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_kms_key_ring/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_kms_key_ring/meta/main.yml b/test/integration/targets/gcp_kms_key_ring/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_kms_key_ring/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_kms_key_ring/tasks/autogen.yml b/test/integration/targets/gcp_kms_key_ring/tasks/autogen.yml
deleted file mode 100644
index 34999ab1bb..0000000000
--- a/test/integration/targets/gcp_kms_key_ring/tasks/autogen.yml
+++ /dev/null
@@ -1,63 +0,0 @@
-# Copyright 2019 Google Inc.
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Pre-test setup
-- name: delete a key ring
- gcp_kms_key_ring:
- name: "{{ resource_name }}"
- location: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a key ring
- gcp_kms_key_ring:
- name: "{{ resource_name }}"
- location: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that key_ring was created
- gcp_kms_key_ring_info:
- location: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloudkms
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 1
-# ----------------------------------------------------------------------------
-- name: create a key ring that already exists
- gcp_kms_key_ring:
- name: "{{ resource_name }}"
- location: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_kms_key_ring/tasks/main.yml b/test/integration/targets/gcp_kms_key_ring/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_kms_key_ring/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_logging_metric/aliases b/test/integration/targets/gcp_logging_metric/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_logging_metric/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_logging_metric/meta/main.yml b/test/integration/targets/gcp_logging_metric/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_logging_metric/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_logging_metric/tasks/autogen.yml b/test/integration/targets/gcp_logging_metric/tasks/autogen.yml
deleted file mode 100644
index d06830694e..0000000000
--- a/test/integration/targets/gcp_logging_metric/tasks/autogen.yml
+++ /dev/null
@@ -1,183 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a metric
- gcp_logging_metric:
- name: "{{ resource_name }}"
- filter: resource.type=gae_app AND severity>=ERROR
- metric_descriptor:
- metric_kind: DELTA
- value_type: DISTRIBUTION
- unit: '1'
- labels:
- - key: mass
- value_type: STRING
- description: amount of matter
- value_extractor: EXTRACT(jsonPayload.request)
- label_extractors:
- mass: EXTRACT(jsonPayload.request)
- bucket_options:
- linear_buckets:
- num_finite_buckets: 3
- width: 1
- offset: 1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a metric
- gcp_logging_metric:
- name: "{{ resource_name }}"
- filter: resource.type=gae_app AND severity>=ERROR
- metric_descriptor:
- metric_kind: DELTA
- value_type: DISTRIBUTION
- unit: '1'
- labels:
- - key: mass
- value_type: STRING
- description: amount of matter
- value_extractor: EXTRACT(jsonPayload.request)
- label_extractors:
- mass: EXTRACT(jsonPayload.request)
- bucket_options:
- linear_buckets:
- num_finite_buckets: 3
- width: 1
- offset: 1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that metric was created
- gcp_logging_metric_info:
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloud-platform
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 1
-# ----------------------------------------------------------------------------
-- name: create a metric that already exists
- gcp_logging_metric:
- name: "{{ resource_name }}"
- filter: resource.type=gae_app AND severity>=ERROR
- metric_descriptor:
- metric_kind: DELTA
- value_type: DISTRIBUTION
- unit: '1'
- labels:
- - key: mass
- value_type: STRING
- description: amount of matter
- value_extractor: EXTRACT(jsonPayload.request)
- label_extractors:
- mass: EXTRACT(jsonPayload.request)
- bucket_options:
- linear_buckets:
- num_finite_buckets: 3
- width: 1
- offset: 1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a metric
- gcp_logging_metric:
- name: "{{ resource_name }}"
- filter: resource.type=gae_app AND severity>=ERROR
- metric_descriptor:
- metric_kind: DELTA
- value_type: DISTRIBUTION
- unit: '1'
- labels:
- - key: mass
- value_type: STRING
- description: amount of matter
- value_extractor: EXTRACT(jsonPayload.request)
- label_extractors:
- mass: EXTRACT(jsonPayload.request)
- bucket_options:
- linear_buckets:
- num_finite_buckets: 3
- width: 1
- offset: 1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that metric was deleted
- gcp_logging_metric_info:
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloud-platform
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a metric that does not exist
- gcp_logging_metric:
- name: "{{ resource_name }}"
- filter: resource.type=gae_app AND severity>=ERROR
- metric_descriptor:
- metric_kind: DELTA
- value_type: DISTRIBUTION
- unit: '1'
- labels:
- - key: mass
- value_type: STRING
- description: amount of matter
- value_extractor: EXTRACT(jsonPayload.request)
- label_extractors:
- mass: EXTRACT(jsonPayload.request)
- bucket_options:
- linear_buckets:
- num_finite_buckets: 3
- width: 1
- offset: 1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_logging_metric/tasks/main.yml b/test/integration/targets/gcp_logging_metric/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_logging_metric/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_mlengine_model/aliases b/test/integration/targets/gcp_mlengine_model/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_mlengine_model/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_mlengine_model/defaults/main.yml b/test/integration/targets/gcp_mlengine_model/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_mlengine_model/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_mlengine_model/meta/main.yml b/test/integration/targets/gcp_mlengine_model/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_mlengine_model/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_mlengine_model/tasks/autogen.yml b/test/integration/targets/gcp_mlengine_model/tasks/autogen.yml
deleted file mode 100644
index c30bd524a8..0000000000
--- a/test/integration/targets/gcp_mlengine_model/tasks/autogen.yml
+++ /dev/null
@@ -1,113 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a model
- gcp_mlengine_model:
- name: "{{ resource_name | replace('-', '_') }}"
- description: My model
- regions:
- - us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a model
- gcp_mlengine_model:
- name: "{{ resource_name | replace('-', '_') }}"
- description: My model
- regions:
- - us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that model was created
- gcp_mlengine_model_info:
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloud-platform
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name | replace('-', '_') }}.*") | list | length == 1
-# ----------------------------------------------------------------------------
-- name: create a model that already exists
- gcp_mlengine_model:
- name: "{{ resource_name | replace('-', '_') }}"
- description: My model
- regions:
- - us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a model
- gcp_mlengine_model:
- name: "{{ resource_name | replace('-', '_') }}"
- description: My model
- regions:
- - us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that model was deleted
- gcp_mlengine_model_info:
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloud-platform
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name | replace('-', '_') }}.*") | list | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a model that does not exist
- gcp_mlengine_model:
- name: "{{ resource_name | replace('-', '_') }}"
- description: My model
- regions:
- - us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_mlengine_model/tasks/main.yml b/test/integration/targets/gcp_mlengine_model/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_mlengine_model/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_mlengine_version/aliases b/test/integration/targets/gcp_mlengine_version/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_mlengine_version/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_mlengine_version/defaults/main.yml b/test/integration/targets/gcp_mlengine_version/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_mlengine_version/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_mlengine_version/meta/main.yml b/test/integration/targets/gcp_mlengine_version/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_mlengine_version/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_mlengine_version/tasks/autogen.yml b/test/integration/targets/gcp_mlengine_version/tasks/autogen.yml
deleted file mode 100644
index c84d3a5e9e..0000000000
--- a/test/integration/targets/gcp_mlengine_version/tasks/autogen.yml
+++ /dev/null
@@ -1,155 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a model
- gcp_mlengine_model:
- name: model_version
- description: My model
- regions:
- - us-central1
- online_prediction_logging: 'true'
- online_prediction_console_logging: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: model
-- name: delete a version
- gcp_mlengine_version:
- name: "{{ resource_name | replace('-', '_') }}"
- model: "{{ model }}"
- runtime_version: 1.13
- python_version: 3.5
- is_default: 'true'
- deployment_uri: gs://ansible-cloudml-bucket/
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a version
- gcp_mlengine_version:
- name: "{{ resource_name | replace('-', '_') }}"
- model: "{{ model }}"
- runtime_version: 1.13
- python_version: 3.5
- is_default: 'true'
- deployment_uri: gs://ansible-cloudml-bucket/
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that version was created
- gcp_mlengine_version_info:
- model: "{{ model }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloud-platform
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name | replace('-', '_') }}.*") | list | length == 1
-# ----------------------------------------------------------------------------
-- name: create a version that already exists
- gcp_mlengine_version:
- name: "{{ resource_name | replace('-', '_') }}"
- model: "{{ model }}"
- runtime_version: 1.13
- python_version: 3.5
- is_default: 'true'
- deployment_uri: gs://ansible-cloudml-bucket/
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a version
- gcp_mlengine_version:
- name: "{{ resource_name | replace('-', '_') }}"
- model: "{{ model }}"
- runtime_version: 1.13
- python_version: 3.5
- is_default: 'true'
- deployment_uri: gs://ansible-cloudml-bucket/
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that version was deleted
- gcp_mlengine_version_info:
- model: "{{ model }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloud-platform
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name | replace('-', '_') }}.*") | list | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a version that does not exist
- gcp_mlengine_version:
- name: "{{ resource_name | replace('-', '_') }}"
- model: "{{ model }}"
- runtime_version: 1.13
- python_version: 3.5
- is_default: 'true'
- deployment_uri: gs://ansible-cloudml-bucket/
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a model
- gcp_mlengine_model:
- name: model_version
- description: My model
- regions:
- - us-central1
- online_prediction_logging: 'true'
- online_prediction_console_logging: 'true'
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: model
- ignore_errors: true
diff --git a/test/integration/targets/gcp_mlengine_version/tasks/main.yml b/test/integration/targets/gcp_mlengine_version/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_mlengine_version/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_pubsub_subscription/aliases b/test/integration/targets/gcp_pubsub_subscription/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_pubsub_subscription/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_pubsub_subscription/defaults/main.yml b/test/integration/targets/gcp_pubsub_subscription/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_pubsub_subscription/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_pubsub_subscription/meta/main.yml b/test/integration/targets/gcp_pubsub_subscription/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_pubsub_subscription/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_pubsub_subscription/tasks/autogen.yml b/test/integration/targets/gcp_pubsub_subscription/tasks/autogen.yml
deleted file mode 100644
index c7babda72e..0000000000
--- a/test/integration/targets/gcp_pubsub_subscription/tasks/autogen.yml
+++ /dev/null
@@ -1,128 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a topic
- gcp_pubsub_topic:
- name: topic-subscription
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: topic
-- name: delete a subscription
- gcp_pubsub_subscription:
- name: "{{ resource_name }}"
- topic: "{{ topic }}"
- ack_deadline_seconds: 300
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a subscription
- gcp_pubsub_subscription:
- name: "{{ resource_name }}"
- topic: "{{ topic }}"
- ack_deadline_seconds: 300
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that subscription was created
- gcp_pubsub_subscription_info:
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/pubsub
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - "\"{{resource_name}}\" in \"{{ results['resources'] | map(attribute='name') | list }}\""
-# ----------------------------------------------------------------------------
-- name: create a subscription that already exists
- gcp_pubsub_subscription:
- name: "{{ resource_name }}"
- topic: "{{ topic }}"
- ack_deadline_seconds: 300
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a subscription
- gcp_pubsub_subscription:
- name: "{{ resource_name }}"
- topic: "{{ topic }}"
- ack_deadline_seconds: 300
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that subscription was deleted
- gcp_pubsub_subscription_info:
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/pubsub
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - "\"{{resource_name}}\" not in \"{{ results['resources'] | map(attribute='name') | list }}\""
-# ----------------------------------------------------------------------------
-- name: delete a subscription that does not exist
- gcp_pubsub_subscription:
- name: "{{ resource_name }}"
- topic: "{{ topic }}"
- ack_deadline_seconds: 300
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a topic
- gcp_pubsub_topic:
- name: topic-subscription
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: topic
- ignore_errors: true
diff --git a/test/integration/targets/gcp_pubsub_subscription/tasks/main.yml b/test/integration/targets/gcp_pubsub_subscription/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_pubsub_subscription/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_pubsub_topic/aliases b/test/integration/targets/gcp_pubsub_topic/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_pubsub_topic/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_pubsub_topic/defaults/main.yml b/test/integration/targets/gcp_pubsub_topic/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_pubsub_topic/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_pubsub_topic/meta/main.yml b/test/integration/targets/gcp_pubsub_topic/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_pubsub_topic/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_pubsub_topic/tasks/autogen.yml b/test/integration/targets/gcp_pubsub_topic/tasks/autogen.yml
deleted file mode 100644
index 9dff2b2d71..0000000000
--- a/test/integration/targets/gcp_pubsub_topic/tasks/autogen.yml
+++ /dev/null
@@ -1,98 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a topic
- gcp_pubsub_topic:
- name: test-topic1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a topic
- gcp_pubsub_topic:
- name: test-topic1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that topic was created
- gcp_pubsub_topic_info:
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/pubsub
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - "'test-topic1' in \"{{ results['resources'] | map(attribute='name') | list }}\""
-# ----------------------------------------------------------------------------
-- name: create a topic that already exists
- gcp_pubsub_topic:
- name: test-topic1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a topic
- gcp_pubsub_topic:
- name: test-topic1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that topic was deleted
- gcp_pubsub_topic_info:
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/pubsub
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - "'test-topic1' not in \"{{ results['resources'] | map(attribute='name') | list }}\""
-# ----------------------------------------------------------------------------
-- name: delete a topic that does not exist
- gcp_pubsub_topic:
- name: test-topic1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_pubsub_topic/tasks/main.yml b/test/integration/targets/gcp_pubsub_topic/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_pubsub_topic/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_redis_instance/aliases b/test/integration/targets/gcp_redis_instance/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_redis_instance/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_redis_instance/defaults/main.yml b/test/integration/targets/gcp_redis_instance/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_redis_instance/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_redis_instance/meta/main.yml b/test/integration/targets/gcp_redis_instance/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_redis_instance/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_redis_instance/tasks/autogen.yml b/test/integration/targets/gcp_redis_instance/tasks/autogen.yml
deleted file mode 100644
index b859625b98..0000000000
--- a/test/integration/targets/gcp_redis_instance/tasks/autogen.yml
+++ /dev/null
@@ -1,170 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a network
- gcp_compute_network:
- name: network-instance
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: network
-- name: delete a instance
- gcp_redis_instance:
- name: instance37
- tier: STANDARD_HA
- memory_size_gb: 1
- region: us-central1
- location_id: us-central1-a
- redis_version: REDIS_3_2
- display_name: Ansible Test Instance
- reserved_ip_range: 192.168.0.0/29
- labels:
- my_key: my_val
- other_key: other_val
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a instance
- gcp_redis_instance:
- name: instance37
- tier: STANDARD_HA
- memory_size_gb: 1
- region: us-central1
- location_id: us-central1-a
- redis_version: REDIS_3_2
- display_name: Ansible Test Instance
- reserved_ip_range: 192.168.0.0/29
- labels:
- my_key: my_val
- other_key: other_val
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that instance was created
- gcp_redis_instance_info:
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloud-platform
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*instance37.*") | list | length == 1
-# ----------------------------------------------------------------------------
-- name: create a instance that already exists
- gcp_redis_instance:
- name: instance37
- tier: STANDARD_HA
- memory_size_gb: 1
- region: us-central1
- location_id: us-central1-a
- redis_version: REDIS_3_2
- display_name: Ansible Test Instance
- reserved_ip_range: 192.168.0.0/29
- labels:
- my_key: my_val
- other_key: other_val
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a instance
- gcp_redis_instance:
- name: instance37
- tier: STANDARD_HA
- memory_size_gb: 1
- region: us-central1
- location_id: us-central1-a
- redis_version: REDIS_3_2
- display_name: Ansible Test Instance
- reserved_ip_range: 192.168.0.0/29
- labels:
- my_key: my_val
- other_key: other_val
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that instance was deleted
- gcp_redis_instance_info:
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloud-platform
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*instance37.*") | list | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a instance that does not exist
- gcp_redis_instance:
- name: instance37
- tier: STANDARD_HA
- memory_size_gb: 1
- region: us-central1
- location_id: us-central1-a
- redis_version: REDIS_3_2
- display_name: Ansible Test Instance
- reserved_ip_range: 192.168.0.0/29
- labels:
- my_key: my_val
- other_key: other_val
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a network
- gcp_compute_network:
- name: network-instance
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: network
- ignore_errors: true
diff --git a/test/integration/targets/gcp_redis_instance/tasks/main.yml b/test/integration/targets/gcp_redis_instance/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_redis_instance/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_resourcemanager_project/aliases b/test/integration/targets/gcp_resourcemanager_project/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_resourcemanager_project/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_resourcemanager_project/defaults/main.yml b/test/integration/targets/gcp_resourcemanager_project/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_resourcemanager_project/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_resourcemanager_project/meta/main.yml b/test/integration/targets/gcp_resourcemanager_project/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_resourcemanager_project/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_resourcemanager_project/tasks/autogen.yml b/test/integration/targets/gcp_resourcemanager_project/tasks/autogen.yml
deleted file mode 100644
index 083660a9d2..0000000000
--- a/test/integration/targets/gcp_resourcemanager_project/tasks/autogen.yml
+++ /dev/null
@@ -1,113 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a project
- gcp_resourcemanager_project:
- name: My Sample Project
- id: alextest-{{ 10000000000 | random }}
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- parent:
- type: organization
- id: 636173955921
- state: absent
-#----------------------------------------------------------
-- name: create a project
- gcp_resourcemanager_project:
- name: My Sample Project
- id: alextest-{{ 10000000000 | random }}
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- parent:
- type: organization
- id: 636173955921
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that project was created
- gcp_resourcemanager_project_info:
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloud-platform
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*My Sample Project.*") | list | length == 1
-# ----------------------------------------------------------------------------
-- name: create a project that already exists
- gcp_resourcemanager_project:
- name: My Sample Project
- id: alextest-{{ 10000000000 | random }}
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- parent:
- type: organization
- id: 636173955921
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a project
- gcp_resourcemanager_project:
- name: My Sample Project
- id: alextest-{{ 10000000000 | random }}
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- parent:
- type: organization
- id: 636173955921
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that project was deleted
- gcp_resourcemanager_project_info:
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloud-platform
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*My Sample Project.*") | list | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a project that does not exist
- gcp_resourcemanager_project:
- name: My Sample Project
- id: alextest-{{ 10000000000 | random }}
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- parent:
- type: organization
- id: 636173955921
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_resourcemanager_project/tasks/main.yml b/test/integration/targets/gcp_resourcemanager_project/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_resourcemanager_project/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_runtimeconfig_config/aliases b/test/integration/targets/gcp_runtimeconfig_config/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_runtimeconfig_config/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_runtimeconfig_config/meta/main.yml b/test/integration/targets/gcp_runtimeconfig_config/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_runtimeconfig_config/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_runtimeconfig_config/tasks/autogen.yml b/test/integration/targets/gcp_runtimeconfig_config/tasks/autogen.yml
deleted file mode 100644
index 9b2e8b58fa..0000000000
--- a/test/integration/targets/gcp_runtimeconfig_config/tasks/autogen.yml
+++ /dev/null
@@ -1,103 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a config
- gcp_runtimeconfig_config:
- name: "{{ resource_name }}"
- description: My config
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a config
- gcp_runtimeconfig_config:
- name: "{{ resource_name }}"
- description: My config
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that config was created
- gcp_runtimeconfig_config_info:
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloudruntimeconfig
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 1
-# ----------------------------------------------------------------------------
-- name: create a config that already exists
- gcp_runtimeconfig_config:
- name: "{{ resource_name }}"
- description: My config
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a config
- gcp_runtimeconfig_config:
- name: "{{ resource_name }}"
- description: My config
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that config was deleted
- gcp_runtimeconfig_config_info:
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloudruntimeconfig
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a config that does not exist
- gcp_runtimeconfig_config:
- name: "{{ resource_name }}"
- description: My config
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_runtimeconfig_config/tasks/main.yml b/test/integration/targets/gcp_runtimeconfig_config/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_runtimeconfig_config/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_runtimeconfig_variable/aliases b/test/integration/targets/gcp_runtimeconfig_variable/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_runtimeconfig_variable/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_runtimeconfig_variable/meta/main.yml b/test/integration/targets/gcp_runtimeconfig_variable/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_runtimeconfig_variable/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_runtimeconfig_variable/tasks/autogen.yml b/test/integration/targets/gcp_runtimeconfig_variable/tasks/autogen.yml
deleted file mode 100644
index c3b71716e8..0000000000
--- a/test/integration/targets/gcp_runtimeconfig_variable/tasks/autogen.yml
+++ /dev/null
@@ -1,132 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a config
- gcp_runtimeconfig_config:
- name: my-config
- description: My config
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: config
-- name: delete a variable
- gcp_runtimeconfig_variable:
- name: prod-variables/hostname
- config: my-config
- text: example.com
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a variable
- gcp_runtimeconfig_variable:
- name: prod-variables/hostname
- config: my-config
- text: example.com
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that variable was created
- gcp_runtimeconfig_variable_info:
- config: my-config
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloudruntimeconfig
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*prod-variables/hostname.*") | list | length == 1
-# ----------------------------------------------------------------------------
-- name: create a variable that already exists
- gcp_runtimeconfig_variable:
- name: prod-variables/hostname
- config: my-config
- text: example.com
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a variable
- gcp_runtimeconfig_variable:
- name: prod-variables/hostname
- config: my-config
- text: example.com
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that variable was deleted
- gcp_runtimeconfig_variable_info:
- config: my-config
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloudruntimeconfig
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*prod-variables/hostname.*") | list | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a variable that does not exist
- gcp_runtimeconfig_variable:
- name: prod-variables/hostname
- config: my-config
- text: example.com
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a config
- gcp_runtimeconfig_config:
- name: my-config
- description: My config
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: config
- ignore_errors: true
diff --git a/test/integration/targets/gcp_runtimeconfig_variable/tasks/main.yml b/test/integration/targets/gcp_runtimeconfig_variable/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_runtimeconfig_variable/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_serviceusage_service/aliases b/test/integration/targets/gcp_serviceusage_service/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_serviceusage_service/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_serviceusage_service/meta/main.yml b/test/integration/targets/gcp_serviceusage_service/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_serviceusage_service/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_serviceusage_service/tasks/autogen.yml b/test/integration/targets/gcp_serviceusage_service/tasks/autogen.yml
deleted file mode 100644
index 54fd54a6d5..0000000000
--- a/test/integration/targets/gcp_serviceusage_service/tasks/autogen.yml
+++ /dev/null
@@ -1,98 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a service
- gcp_serviceusage_service:
- name: spanner.googleapis.com
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a service
- gcp_serviceusage_service:
- name: spanner.googleapis.com
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that service was created
- gcp_serviceusage_service_info:
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloud-platform
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - "'{{ (results['resources'] | selectattr('name', 'search', 'spanner.googleapis.com') | list | first).state }}' == 'ENABLED'"
-# ----------------------------------------------------------------------------
-- name: create a service that already exists
- gcp_serviceusage_service:
- name: spanner.googleapis.com
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a service
- gcp_serviceusage_service:
- name: spanner.googleapis.com
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that service was deleted
- gcp_serviceusage_service_info:
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloud-platform
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - "'{{ (results['resources'] | selectattr('name', 'search', 'spanner.googleapis.com') | list | first).state }}' == 'DISABLED'"
-# ----------------------------------------------------------------------------
-- name: delete a service that does not exist
- gcp_serviceusage_service:
- name: spanner.googleapis.com
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_serviceusage_service/tasks/main.yml b/test/integration/targets/gcp_serviceusage_service/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_serviceusage_service/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_sourcerepo_repository/aliases b/test/integration/targets/gcp_sourcerepo_repository/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_sourcerepo_repository/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_sourcerepo_repository/defaults/main.yml b/test/integration/targets/gcp_sourcerepo_repository/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_sourcerepo_repository/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_sourcerepo_repository/meta/main.yml b/test/integration/targets/gcp_sourcerepo_repository/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_sourcerepo_repository/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_sourcerepo_repository/tasks/autogen.yml b/test/integration/targets/gcp_sourcerepo_repository/tasks/autogen.yml
deleted file mode 100644
index 5ae6e34945..0000000000
--- a/test/integration/targets/gcp_sourcerepo_repository/tasks/autogen.yml
+++ /dev/null
@@ -1,98 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a repository
- gcp_sourcerepo_repository:
- name: "{{ resource_name }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a repository
- gcp_sourcerepo_repository:
- name: "{{ resource_name }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that repository was created
- gcp_sourcerepo_repository_info:
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloud-platform
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 1
-# ----------------------------------------------------------------------------
-- name: create a repository that already exists
- gcp_sourcerepo_repository:
- name: "{{ resource_name }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a repository
- gcp_sourcerepo_repository:
- name: "{{ resource_name }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that repository was deleted
- gcp_sourcerepo_repository_info:
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloud-platform
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a repository that does not exist
- gcp_sourcerepo_repository:
- name: "{{ resource_name }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_sourcerepo_repository/tasks/main.yml b/test/integration/targets/gcp_sourcerepo_repository/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_sourcerepo_repository/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_spanner_database/aliases b/test/integration/targets/gcp_spanner_database/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_spanner_database/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_spanner_database/defaults/main.yml b/test/integration/targets/gcp_spanner_database/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_spanner_database/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_spanner_database/meta/main.yml b/test/integration/targets/gcp_spanner_database/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_spanner_database/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_spanner_database/tasks/autogen.yml b/test/integration/targets/gcp_spanner_database/tasks/autogen.yml
deleted file mode 100644
index 3fda4e4397..0000000000
--- a/test/integration/targets/gcp_spanner_database/tasks/autogen.yml
+++ /dev/null
@@ -1,135 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a instance
- gcp_spanner_instance:
- name: instance-database
- display_name: My Spanner Instance
- node_count: 2
- labels:
- cost_center: ti-1700004
- config: regional-us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: instance
-- name: delete a database
- gcp_spanner_database:
- name: webstore
- instance: "{{ instance }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a database
- gcp_spanner_database:
- name: webstore
- instance: "{{ instance }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that database was created
- gcp_spanner_database_info:
- instance: "{{ instance }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/spanner.admin
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*webstore.*") | list | length == 1
-# ----------------------------------------------------------------------------
-- name: create a database that already exists
- gcp_spanner_database:
- name: webstore
- instance: "{{ instance }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a database
- gcp_spanner_database:
- name: webstore
- instance: "{{ instance }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that database was deleted
- gcp_spanner_database_info:
- instance: "{{ instance }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/spanner.admin
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*webstore.*") | list | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a database that does not exist
- gcp_spanner_database:
- name: webstore
- instance: "{{ instance }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a instance
- gcp_spanner_instance:
- name: instance-database
- display_name: My Spanner Instance
- node_count: 2
- labels:
- cost_center: ti-1700004
- config: regional-us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: instance
- ignore_errors: true
diff --git a/test/integration/targets/gcp_spanner_database/tasks/main.yml b/test/integration/targets/gcp_spanner_database/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_spanner_database/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_spanner_instance/aliases b/test/integration/targets/gcp_spanner_instance/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_spanner_instance/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_spanner_instance/defaults/main.yml b/test/integration/targets/gcp_spanner_instance/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_spanner_instance/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_spanner_instance/meta/main.yml b/test/integration/targets/gcp_spanner_instance/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_spanner_instance/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_spanner_instance/tasks/autogen.yml b/test/integration/targets/gcp_spanner_instance/tasks/autogen.yml
deleted file mode 100644
index 8fb40459a8..0000000000
--- a/test/integration/targets/gcp_spanner_instance/tasks/autogen.yml
+++ /dev/null
@@ -1,123 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a instance
- gcp_spanner_instance:
- name: testinstance
- display_name: My Spanner Instance
- node_count: 2
- labels:
- cost_center: ti-1700004
- config: regional-us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a instance
- gcp_spanner_instance:
- name: testinstance
- display_name: My Spanner Instance
- node_count: 2
- labels:
- cost_center: ti-1700004
- config: regional-us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that instance was created
- gcp_spanner_instance_info:
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/spanner.admin
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*testinstance.*") | list | length == 1
-# ----------------------------------------------------------------------------
-- name: create a instance that already exists
- gcp_spanner_instance:
- name: testinstance
- display_name: My Spanner Instance
- node_count: 2
- labels:
- cost_center: ti-1700004
- config: regional-us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a instance
- gcp_spanner_instance:
- name: testinstance
- display_name: My Spanner Instance
- node_count: 2
- labels:
- cost_center: ti-1700004
- config: regional-us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that instance was deleted
- gcp_spanner_instance_info:
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/spanner.admin
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*testinstance.*") | list | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a instance that does not exist
- gcp_spanner_instance:
- name: testinstance
- display_name: My Spanner Instance
- node_count: 2
- labels:
- cost_center: ti-1700004
- config: regional-us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_spanner_instance/tasks/main.yml b/test/integration/targets/gcp_spanner_instance/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_spanner_instance/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_sql_database/aliases b/test/integration/targets/gcp_sql_database/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_sql_database/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_sql_database/defaults/main.yml b/test/integration/targets/gcp_sql_database/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_sql_database/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_sql_database/meta/main.yml b/test/integration/targets/gcp_sql_database/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_sql_database/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_sql_database/tasks/autogen.yml b/test/integration/targets/gcp_sql_database/tasks/autogen.yml
deleted file mode 100644
index ebe9cbdc06..0000000000
--- a/test/integration/targets/gcp_sql_database/tasks/autogen.yml
+++ /dev/null
@@ -1,144 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a instance
- gcp_sql_instance:
- name: "{{resource_name}}-3"
- settings:
- ip_configuration:
- authorized_networks:
- - name: google dns server
- value: 8.8.8.8/32
- tier: db-n1-standard-1
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: instance
-- name: delete a database
- gcp_sql_database:
- name: "{{ resource_name }}"
- charset: utf8
- instance: "{{ instance.name }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a database
- gcp_sql_database:
- name: "{{ resource_name }}"
- charset: utf8
- instance: "{{ instance.name }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that database was created
- gcp_sql_database_info:
- instance: "{{ instance.name }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/sqlservice.admin
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - "\"{{resource_name}}\" in \"{{ results['resources'] | map(attribute='name') | list }}\""
-# ----------------------------------------------------------------------------
-- name: create a database that already exists
- gcp_sql_database:
- name: "{{ resource_name }}"
- charset: utf8
- instance: "{{ instance.name }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a database
- gcp_sql_database:
- name: "{{ resource_name }}"
- charset: utf8
- instance: "{{ instance.name }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that database was deleted
- gcp_sql_database_info:
- instance: "{{ instance.name }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/sqlservice.admin
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - "\"{{resource_name}}\" not in \"{{ results['resources'] | map(attribute='name') | list }}\""
-# ----------------------------------------------------------------------------
-- name: delete a database that does not exist
- gcp_sql_database:
- name: "{{ resource_name }}"
- charset: utf8
- instance: "{{ instance.name }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a instance
- gcp_sql_instance:
- name: "{{resource_name}}-3"
- settings:
- ip_configuration:
- authorized_networks:
- - name: google dns server
- value: 8.8.8.8/32
- tier: db-n1-standard-1
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: instance
- ignore_errors: true
diff --git a/test/integration/targets/gcp_sql_database/tasks/main.yml b/test/integration/targets/gcp_sql_database/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_sql_database/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_sql_instance/aliases b/test/integration/targets/gcp_sql_instance/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_sql_instance/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_sql_instance/defaults/main.yml b/test/integration/targets/gcp_sql_instance/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_sql_instance/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_sql_instance/meta/main.yml b/test/integration/targets/gcp_sql_instance/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_sql_instance/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_sql_instance/tasks/autogen.yml b/test/integration/targets/gcp_sql_instance/tasks/autogen.yml
deleted file mode 100644
index 1ddcda92ad..0000000000
--- a/test/integration/targets/gcp_sql_instance/tasks/autogen.yml
+++ /dev/null
@@ -1,133 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a instance
- gcp_sql_instance:
- name: "{{resource_name}}-2"
- settings:
- ip_configuration:
- authorized_networks:
- - name: google dns server
- value: 8.8.8.8/32
- tier: db-n1-standard-1
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a instance
- gcp_sql_instance:
- name: "{{resource_name}}-2"
- settings:
- ip_configuration:
- authorized_networks:
- - name: google dns server
- value: 8.8.8.8/32
- tier: db-n1-standard-1
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that instance was created
- gcp_sql_instance_info:
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/sqlservice.admin
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*{{resource_name}}-2.*") | list | length == 1
-# ----------------------------------------------------------------------------
-- name: create a instance that already exists
- gcp_sql_instance:
- name: "{{resource_name}}-2"
- settings:
- ip_configuration:
- authorized_networks:
- - name: google dns server
- value: 8.8.8.8/32
- tier: db-n1-standard-1
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a instance
- gcp_sql_instance:
- name: "{{resource_name}}-2"
- settings:
- ip_configuration:
- authorized_networks:
- - name: google dns server
- value: 8.8.8.8/32
- tier: db-n1-standard-1
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that instance was deleted
- gcp_sql_instance_info:
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/sqlservice.admin
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*{{resource_name}}-2.*") | list | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a instance that does not exist
- gcp_sql_instance:
- name: "{{resource_name}}-2"
- settings:
- ip_configuration:
- authorized_networks:
- - name: google dns server
- value: 8.8.8.8/32
- tier: db-n1-standard-1
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_sql_instance/tasks/main.yml b/test/integration/targets/gcp_sql_instance/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_sql_instance/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_sql_user/aliases b/test/integration/targets/gcp_sql_user/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_sql_user/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_sql_user/defaults/main.yml b/test/integration/targets/gcp_sql_user/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_sql_user/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_sql_user/meta/main.yml b/test/integration/targets/gcp_sql_user/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_sql_user/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_sql_user/tasks/autogen.yml b/test/integration/targets/gcp_sql_user/tasks/autogen.yml
deleted file mode 100644
index d7f6d09daf..0000000000
--- a/test/integration/targets/gcp_sql_user/tasks/autogen.yml
+++ /dev/null
@@ -1,149 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a instance
- gcp_sql_instance:
- name: "{{resource_name}}-1"
- settings:
- ip_configuration:
- authorized_networks:
- - name: google dns server
- value: 8.8.8.8/32
- tier: db-n1-standard-1
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: instance
-- name: delete a user
- gcp_sql_user:
- name: test-user
- host: 10.1.2.3
- password: secret-password
- instance: "{{ instance }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a user
- gcp_sql_user:
- name: test-user
- host: 10.1.2.3
- password: secret-password
- instance: "{{ instance }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that user was created
- gcp_sql_user_info:
- instance: "{{ instance }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/sqlservice.admin
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - "'test-user' in \"{{ results['resources'] | map(attribute='name') | list }}\""
-# ----------------------------------------------------------------------------
-- name: create a user that already exists
- gcp_sql_user:
- name: test-user
- host: 10.1.2.3
- password: secret-password
- instance: "{{ instance }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a user
- gcp_sql_user:
- name: test-user
- host: 10.1.2.3
- password: secret-password
- instance: "{{ instance }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that user was deleted
- gcp_sql_user_info:
- instance: "{{ instance }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/sqlservice.admin
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - "'test-user' not in \"{{ results['resources'] | map(attribute='name') | list }}\""
-# ----------------------------------------------------------------------------
-- name: delete a user that does not exist
- gcp_sql_user:
- name: test-user
- host: 10.1.2.3
- password: secret-password
- instance: "{{ instance }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a instance
- gcp_sql_instance:
- name: "{{resource_name}}-1"
- settings:
- ip_configuration:
- authorized_networks:
- - name: google dns server
- value: 8.8.8.8/32
- tier: db-n1-standard-1
- region: us-central1
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: instance
- ignore_errors: true
diff --git a/test/integration/targets/gcp_sql_user/tasks/main.yml b/test/integration/targets/gcp_sql_user/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_sql_user/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_storage_bucket/aliases b/test/integration/targets/gcp_storage_bucket/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_storage_bucket/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_storage_bucket/defaults/main.yml b/test/integration/targets/gcp_storage_bucket/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_storage_bucket/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_storage_bucket/meta/main.yml b/test/integration/targets/gcp_storage_bucket/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_storage_bucket/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_storage_bucket/tasks/autogen.yml b/test/integration/targets/gcp_storage_bucket/tasks/autogen.yml
deleted file mode 100644
index d49ec899c1..0000000000
--- a/test/integration/targets/gcp_storage_bucket/tasks/autogen.yml
+++ /dev/null
@@ -1,74 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a bucket
- gcp_storage_bucket:
- name: ansible-storage-module
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a bucket
- gcp_storage_bucket:
- name: ansible-storage-module
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-# ----------------------------------------------------------------------------
-- name: create a bucket that already exists
- gcp_storage_bucket:
- name: ansible-storage-module
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a bucket
- gcp_storage_bucket:
- name: ansible-storage-module
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-# ----------------------------------------------------------------------------
-- name: delete a bucket that does not exist
- gcp_storage_bucket:
- name: ansible-storage-module
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_storage_bucket/tasks/main.yml b/test/integration/targets/gcp_storage_bucket/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_storage_bucket/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_storage_bucket_access_control/aliases b/test/integration/targets/gcp_storage_bucket_access_control/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_storage_bucket_access_control/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_storage_bucket_access_control/defaults/main.yml b/test/integration/targets/gcp_storage_bucket_access_control/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_storage_bucket_access_control/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_storage_bucket_access_control/meta/main.yml b/test/integration/targets/gcp_storage_bucket_access_control/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_storage_bucket_access_control/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_storage_bucket_access_control/tasks/autogen.yml b/test/integration/targets/gcp_storage_bucket_access_control/tasks/autogen.yml
deleted file mode 100644
index 5a78a87e7a..0000000000
--- a/test/integration/targets/gcp_storage_bucket_access_control/tasks/autogen.yml
+++ /dev/null
@@ -1,104 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: create a bucket
- gcp_storage_bucket:
- name: "{{ resource_name }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: bucket
-- name: delete a bucket access control
- gcp_storage_bucket_access_control:
- bucket: "{{ bucket }}"
- entity: user-alexstephen@google.com
- role: WRITER
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a bucket access control
- gcp_storage_bucket_access_control:
- bucket: "{{ bucket }}"
- entity: user-alexstephen@google.com
- role: WRITER
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-# ----------------------------------------------------------------------------
-- name: create a bucket access control that already exists
- gcp_storage_bucket_access_control:
- bucket: "{{ bucket }}"
- entity: user-alexstephen@google.com
- role: WRITER
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a bucket access control
- gcp_storage_bucket_access_control:
- bucket: "{{ bucket }}"
- entity: user-alexstephen@google.com
- role: WRITER
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-# ----------------------------------------------------------------------------
-- name: delete a bucket access control that does not exist
- gcp_storage_bucket_access_control:
- bucket: "{{ bucket }}"
- entity: user-alexstephen@google.com
- role: WRITER
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#---------------------------------------------------------
-# Post-test teardown
-# If errors happen, don't crash the playbook!
-- name: delete a bucket
- gcp_storage_bucket:
- name: "{{ resource_name }}"
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: bucket
- ignore_errors: true
diff --git a/test/integration/targets/gcp_storage_bucket_access_control/tasks/main.yml b/test/integration/targets/gcp_storage_bucket_access_control/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_storage_bucket_access_control/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/integration/targets/gcp_storage_object/aliases b/test/integration/targets/gcp_storage_object/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_storage_object/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_storage_object/defaults/main.yml b/test/integration/targets/gcp_storage_object/defaults/main.yml
deleted file mode 100644
index aa87a2a8e0..0000000000
--- a/test/integration/targets/gcp_storage_object/defaults/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
----
-# defaults file
-resource_name: '{{resource_prefix}}'
diff --git a/test/integration/targets/gcp_storage_object/meta/main.yml b/test/integration/targets/gcp_storage_object/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_storage_object/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_tpu_node/aliases b/test/integration/targets/gcp_tpu_node/aliases
deleted file mode 100644
index 9812f019ca..0000000000
--- a/test/integration/targets/gcp_tpu_node/aliases
+++ /dev/null
@@ -1,2 +0,0 @@
-cloud/gcp
-unsupported
diff --git a/test/integration/targets/gcp_tpu_node/defaults/main.yml b/test/integration/targets/gcp_tpu_node/defaults/main.yml
deleted file mode 100644
index ba66644fc1..0000000000
--- a/test/integration/targets/gcp_tpu_node/defaults/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-resource_name: "{{ resource_prefix }}"
diff --git a/test/integration/targets/gcp_tpu_node/meta/main.yml b/test/integration/targets/gcp_tpu_node/meta/main.yml
deleted file mode 100644
index e69de29bb2..0000000000
--- a/test/integration/targets/gcp_tpu_node/meta/main.yml
+++ /dev/null
diff --git a/test/integration/targets/gcp_tpu_node/tasks/autogen.yml b/test/integration/targets/gcp_tpu_node/tasks/autogen.yml
deleted file mode 100644
index ed4803d422..0000000000
--- a/test/integration/targets/gcp_tpu_node/tasks/autogen.yml
+++ /dev/null
@@ -1,120 +0,0 @@
----
-# ----------------------------------------------------------------------------
-#
-# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
-#
-# ----------------------------------------------------------------------------
-#
-# This file is automatically generated by Magic Modules and manual
-# changes will be clobbered when the file is regenerated.
-#
-# Please read more about how to change this file at
-# https://www.github.com/GoogleCloudPlatform/magic-modules
-#
-# ----------------------------------------------------------------------------
-# Pre-test setup
-- name: delete a node
- gcp_tpu_node:
- name: "{{ resource_name }}"
- zone: us-central1-b
- accelerator_type: v3-8
- tensorflow_version: '1.11'
- cidr_block: 10.2.0.0/29
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
-#----------------------------------------------------------
-- name: create a node
- gcp_tpu_node:
- name: "{{ resource_name }}"
- zone: us-central1-b
- accelerator_type: v3-8
- tensorflow_version: '1.11'
- cidr_block: 10.2.0.0/29
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that node was created
- gcp_tpu_node_info:
- zone: us-central1-b
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloud-platform
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 1
-# ----------------------------------------------------------------------------
-- name: create a node that already exists
- gcp_tpu_node:
- name: "{{ resource_name }}"
- zone: us-central1-b
- accelerator_type: v3-8
- tensorflow_version: '1.11'
- cidr_block: 10.2.0.0/29
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: present
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
-#----------------------------------------------------------
-- name: delete a node
- gcp_tpu_node:
- name: "{{ resource_name }}"
- zone: us-central1-b
- accelerator_type: v3-8
- tensorflow_version: '1.11'
- cidr_block: 10.2.0.0/29
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is true
- assert:
- that:
- - result.changed == true
-- name: verify that node was deleted
- gcp_tpu_node_info:
- zone: us-central1-b
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- scopes:
- - https://www.googleapis.com/auth/cloud-platform
- register: results
-- name: verify that command succeeded
- assert:
- that:
- - results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name }}.*") | list | length == 0
-# ----------------------------------------------------------------------------
-- name: delete a node that does not exist
- gcp_tpu_node:
- name: "{{ resource_name }}"
- zone: us-central1-b
- accelerator_type: v3-8
- tensorflow_version: '1.11'
- cidr_block: 10.2.0.0/29
- project: "{{ gcp_project }}"
- auth_kind: "{{ gcp_cred_kind }}"
- service_account_file: "{{ gcp_cred_file }}"
- state: absent
- register: result
-- name: assert changed is false
- assert:
- that:
- - result.changed == false
diff --git a/test/integration/targets/gcp_tpu_node/tasks/main.yml b/test/integration/targets/gcp_tpu_node/tasks/main.yml
deleted file mode 100644
index 45d6e49178..0000000000
--- a/test/integration/targets/gcp_tpu_node/tasks/main.yml
+++ /dev/null
@@ -1,2 +0,0 @@
----
-- include_tasks: autogen.yml
diff --git a/test/sanity/ignore.txt b/test/sanity/ignore.txt
index 6d7ca43060..ef3fc3cf0a 100644
--- a/test/sanity/ignore.txt
+++ b/test/sanity/ignore.txt
@@ -80,8 +80,6 @@ lib/ansible/module_utils/facts/sysctl.py metaclass-boilerplate
lib/ansible/module_utils/facts/system/distribution.py pylint:ansible-bad-function
lib/ansible/module_utils/facts/utils.py future-import-boilerplate
lib/ansible/module_utils/facts/utils.py metaclass-boilerplate
-lib/ansible/module_utils/gcp_utils.py future-import-boilerplate
-lib/ansible/module_utils/gcp_utils.py metaclass-boilerplate
lib/ansible/module_utils/json_utils.py future-import-boilerplate
lib/ansible/module_utils/json_utils.py metaclass-boilerplate
lib/ansible/module_utils/network/vyos/vyos.py future-import-boilerplate
@@ -772,237 +770,6 @@ lib/ansible/modules/cloud/azure/azure_rm_webappslot.py validate-modules:doc-requ
lib/ansible/modules/cloud/azure/azure_rm_webappslot.py validate-modules:parameter-type-not-in-doc
lib/ansible/modules/cloud/azure/azure_rm_webappslot.py validate-modules:required_if-requirements-unknown
lib/ansible/modules/cloud/azure/azure_rm_webappslot.py validate-modules:required_if-unknown-key
-lib/ansible/modules/cloud/google/gcp_appengine_firewall_rule.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_appengine_firewall_rule_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_bigquery_dataset.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_bigquery_dataset.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_bigquery_dataset_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_bigquery_table.py validate-modules:doc-default-does-not-match-spec
-lib/ansible/modules/cloud/google/gcp_bigquery_table.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_bigquery_table.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_bigquery_table_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_cloudbuild_trigger.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_cloudbuild_trigger.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_cloudbuild_trigger_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_cloudfunctions_cloud_function.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_cloudfunctions_cloud_function_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_cloudscheduler_job.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_cloudscheduler_job_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_cloudtasks_queue.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_cloudtasks_queue_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_address.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_address_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_address_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_autoscaler.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_autoscaler.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_autoscaler_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_autoscaler_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_backend_bucket.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_backend_bucket_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_backend_bucket_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_backend_service.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_backend_service.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_backend_service_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_backend_service_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_disk.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_disk.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_disk_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_disk_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_firewall.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_firewall.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_firewall_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_firewall_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_forwarding_rule.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_forwarding_rule.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_forwarding_rule_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_forwarding_rule_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_global_address.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_global_address_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_global_address_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_global_forwarding_rule.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_global_forwarding_rule.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_global_forwarding_rule_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_global_forwarding_rule_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_health_check.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_health_check_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_health_check_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_http_health_check.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_http_health_check_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_http_health_check_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_https_health_check.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_https_health_check_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_https_health_check_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_image.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_image.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_image_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_image_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_instance.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_instance.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_instance_group.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_instance_group.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_instance_group_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_instance_group_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_instance_group_manager.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_instance_group_manager.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_instance_group_manager_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_instance_group_manager_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_instance_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_instance_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_instance_template.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_instance_template.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_instance_template_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_instance_template_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_interconnect_attachment.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_interconnect_attachment.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_interconnect_attachment_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_interconnect_attachment_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_network.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_network_endpoint_group.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_network_endpoint_group_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_network_endpoint_group_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_network_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_network_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_node_group.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_node_group_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_node_group_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_node_template.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_node_template_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_node_template_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_region_backend_service.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_region_backend_service.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_region_backend_service_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_region_backend_service_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_region_disk.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_region_disk.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_region_disk_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_region_disk_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_reservation.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_reservation.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_reservation_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_reservation_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_route.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_route.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_route_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_route_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_router.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_router.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_router_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_router_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_snapshot.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_snapshot_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_snapshot_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_ssl_certificate.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_ssl_certificate_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_ssl_certificate_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_ssl_policy.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_ssl_policy.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_ssl_policy_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_ssl_policy_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_subnetwork.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_subnetwork.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_subnetwork_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_subnetwork_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_target_http_proxy.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_target_http_proxy_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_target_http_proxy_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_target_https_proxy.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_target_https_proxy.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_target_https_proxy_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_target_https_proxy_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_target_instance.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_target_instance_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_target_instance_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_target_pool.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_target_pool.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_target_pool_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_target_pool_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_target_ssl_proxy.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_target_ssl_proxy.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_target_ssl_proxy_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_target_ssl_proxy_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_target_tcp_proxy.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_target_tcp_proxy_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_target_tcp_proxy_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_target_vpn_gateway.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_target_vpn_gateway_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_target_vpn_gateway_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_url_map.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_url_map.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_url_map_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_url_map_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_vpn_tunnel.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_vpn_tunnel.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_compute_vpn_tunnel_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_compute_vpn_tunnel_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_container_cluster.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_container_cluster.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_container_cluster_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_container_node_pool.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_container_node_pool.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_container_node_pool_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_dns_managed_zone.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_dns_managed_zone.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_dns_managed_zone_info.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_dns_managed_zone_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_dns_resource_record_set.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_dns_resource_record_set.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_dns_resource_record_set_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_filestore_instance.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_filestore_instance.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_filestore_instance_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_iam_role.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_iam_role.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_iam_role_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_iam_service_account.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_iam_service_account_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_iam_service_account_key.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_kms_crypto_key.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_kms_crypto_key_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_kms_key_ring.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_kms_key_ring_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_logging_metric.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_logging_metric.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_logging_metric_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_mlengine_model.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_mlengine_model.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_mlengine_model_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_mlengine_version.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_mlengine_version_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_pubsub_subscription.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_pubsub_subscription_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_pubsub_topic.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_pubsub_topic.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_pubsub_topic_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_redis_instance.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_redis_instance_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_resourcemanager_project.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_resourcemanager_project_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_runtimeconfig_config.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_runtimeconfig_config_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_runtimeconfig_variable.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_runtimeconfig_variable_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_serviceusage_service.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_serviceusage_service_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_sourcerepo_repository.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_sourcerepo_repository_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_spanner_database.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_spanner_database.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_spanner_database_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_spanner_instance.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_spanner_instance_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_sql_database.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_sql_database_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_sql_instance.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_sql_instance.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_sql_instance_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_sql_user.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_sql_user_info.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_storage_bucket.py validate-modules:doc-elements-mismatch
-lib/ansible/modules/cloud/google/gcp_storage_bucket.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_storage_bucket_access_control.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_storage_object.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_tpu_node.py validate-modules:parameter-list-no-elements
-lib/ansible/modules/cloud/google/gcp_tpu_node_info.py validate-modules:parameter-list-no-elements
lib/ansible/modules/commands/command.py validate-modules:doc-missing-type
lib/ansible/modules/commands/command.py validate-modules:nonexistent-parameter-documented
lib/ansible/modules/commands/command.py validate-modules:parameter-list-no-elements