mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-22 20:13:59 -07:00
[GCE] [GCP] UrlMap module (#24422)
* [GCP] UrlMap module This module provides support for UrlMaps on Google Cloud Platform. UrlMaps allow users to segment requests by hostname and path and direct those requests to Backend Services. UrlMaps are a powerful and necessary part of HTTP(S) Global Load Balancing on Google Cloud Platform. UrlMap takes advantage of the python-api so the appropriate infrastructure has been added to module_utils. More about UrlMaps can be found at: https://cloud.google.com/compute/docs/load-balancing/http/url-map UrlMap API: https://cloud.google.com/compute/docs/reference/latest/ Google Cloud Platform HTTP(S) Cross-Region Load Balancer: https://cloud.google.com/compute/docs/load-balancing/http/ * updated documentation, remmoved parens * fixed tabs
This commit is contained in:
parent
728d3e6c84
commit
4a5cf0b5c1
8 changed files with 1607 additions and 17 deletions
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
# defaults file for test_gcp_url_map
|
||||
service_account_email: "{{ gce_service_account_email }}"
|
||||
credentials_file: "{{ gce_pem_file }}"
|
||||
project_id: "{{ gce_project_id }}"
|
||||
urlmap: "ans-int-urlmap-{{ resource_prefix|lower }}"
|
178
test/integration/roles/test_gcp_url_map/tasks/main.yml
Normal file
178
test/integration/roles/test_gcp_url_map/tasks/main.yml
Normal file
|
@ -0,0 +1,178 @@
|
|||
# GCP UrlMap Integration Tests.
|
||||
# Only parameter tests are currently done in this file as this module requires
|
||||
# a significant amount of infrastructure.
|
||||
######
|
||||
# ============================================================
|
||||
- name: "Create UrlMap with no default service (changed == False)"
|
||||
# ============================================================
|
||||
gcp_url_map:
|
||||
service_account_email: "{{ service_account_email }}"
|
||||
credentials_file: "{{ credentials_file }}"
|
||||
project_id: "{{ project_id }}"
|
||||
url_map_name: "{{ urlmap }}"
|
||||
host_rules:
|
||||
- hosts:
|
||||
- '*.'
|
||||
path_matcher: 'path-matcher-one'
|
||||
state: "present"
|
||||
register: result
|
||||
ignore_errors: True
|
||||
tags:
|
||||
- param-check
|
||||
- name: "assert urlmap no default service (msg error ignored, changed==False)"
|
||||
assert:
|
||||
that:
|
||||
- 'not result.changed'
|
||||
- 'result.msg == "missing required arguments: default_service"'
|
||||
|
||||
# ============================================================
|
||||
- name: "Create UrlMap with no pathmatcher (changed == False)"
|
||||
# ============================================================
|
||||
gcp_url_map:
|
||||
service_account_email: "{{ service_account_email }}"
|
||||
credentials_file: "{{ credentials_file }}"
|
||||
project_id: "{{ project_id }}"
|
||||
url_map_name: "{{ urlmap }}"
|
||||
default_service: "gfr2-bes"
|
||||
host_rules:
|
||||
- hosts:
|
||||
- '*.'
|
||||
path_matcher: 'path-matcher-one'
|
||||
state: "present"
|
||||
register: result
|
||||
ignore_errors: True
|
||||
tags:
|
||||
- param-check
|
||||
- name: "assert urlmap no path_matcher (msg error ignored, changed==False)"
|
||||
assert:
|
||||
that:
|
||||
- 'not result.changed'
|
||||
- 'result.msg == "parameters are required together: [''path_matchers'', ''host_rules'']"'
|
||||
|
||||
# ============================================================
|
||||
- name: "Create UrlMap with no hostrules (changed == False)"
|
||||
# ============================================================
|
||||
gcp_url_map:
|
||||
service_account_email: "{{ service_account_email }}"
|
||||
credentials_file: "{{ credentials_file }}"
|
||||
project_id: "{{ project_id }}"
|
||||
url_map_name: "{{ urlmap }}"
|
||||
default_service: "gfr2-bes"
|
||||
path_matchers:
|
||||
- name: 'path-matcher-one'
|
||||
description: 'path matcher one'
|
||||
default_service: 'gfr-bes'
|
||||
path_rules:
|
||||
- service: 'gfr2-bes'
|
||||
paths:
|
||||
- '/data'
|
||||
- '/aboutus'
|
||||
state: "present"
|
||||
tags:
|
||||
- param-check
|
||||
register: result
|
||||
ignore_errors: True
|
||||
- name: "assert no host_rules (msg error ignored, changed==False)"
|
||||
assert:
|
||||
that:
|
||||
- 'not result.changed'
|
||||
- 'result.msg == "parameters are required together: [''path_matchers'', ''host_rules'']"'
|
||||
|
||||
# ============================================================
|
||||
- name: "Update UrlMap with non-absolute paths (changed==False)"
|
||||
# ============================================================
|
||||
gcp_url_map:
|
||||
service_account_email: "{{ service_account_email }}"
|
||||
credentials_file: "{{ credentials_file }}"
|
||||
project_id: "{{ project_id }}"
|
||||
url_map_name: "{{ urlmap }}"
|
||||
default_service: "gfr2-bes"
|
||||
path_matchers:
|
||||
- name: 'path-matcher-one'
|
||||
description: 'path matcher one'
|
||||
default_service: 'gfr-bes'
|
||||
path_rules:
|
||||
- service: 'gfr2-bes'
|
||||
paths:
|
||||
- 'data'
|
||||
- 'aboutus'
|
||||
host_rules:
|
||||
- hosts:
|
||||
- '*.'
|
||||
path_matcher: 'path-matcher-one'
|
||||
state: "present"
|
||||
tags:
|
||||
- param-check
|
||||
ignore_errors: True
|
||||
register: result
|
||||
- name: "assert path error updated (changed==False)"
|
||||
assert:
|
||||
that:
|
||||
- 'not result.changed'
|
||||
- 'result.msg == "path for path-matcher-one must start with /"'
|
||||
|
||||
# ============================================================
|
||||
- name: "Update UrlMap with invalid wildcard host (changed==False)"
|
||||
# ============================================================
|
||||
gcp_url_map:
|
||||
service_account_email: "{{ service_account_email }}"
|
||||
credentials_file: "{{ credentials_file }}"
|
||||
project_id: "{{ project_id }}"
|
||||
url_map_name: "{{ urlmap }}"
|
||||
default_service: "gfr2-bes"
|
||||
path_matchers:
|
||||
- name: 'path-matcher-one'
|
||||
description: 'path matcher one'
|
||||
default_service: 'gfr-bes'
|
||||
path_rules:
|
||||
- service: 'gfr2-bes'
|
||||
paths:
|
||||
- '/data'
|
||||
- '/aboutus'
|
||||
host_rules:
|
||||
- hosts:
|
||||
- 'foobar*'
|
||||
path_matcher: 'path-matcher-one'
|
||||
state: "present"
|
||||
tags:
|
||||
- param-check
|
||||
ignore_errors: True
|
||||
register: result
|
||||
- name: "assert host wildcard error (error msg ignored, changed==False)"
|
||||
assert:
|
||||
that:
|
||||
- 'not result.changed'
|
||||
- 'result.msg == "wildcard must be first char in host, foobar*"'
|
||||
|
||||
# ============================================================
|
||||
- name: "Update UrlMap with invalid wildcard host second char (changed==False)"
|
||||
# ============================================================
|
||||
gcp_url_map:
|
||||
service_account_email: "{{ service_account_email }}"
|
||||
credentials_file: "{{ credentials_file }}"
|
||||
project_id: "{{ project_id }}"
|
||||
url_map_name: "{{ urlmap }}"
|
||||
default_service: "gfr2-bes"
|
||||
path_matchers:
|
||||
- name: 'path-matcher-one'
|
||||
description: 'path matcher one'
|
||||
default_service: 'gfr-bes'
|
||||
path_rules:
|
||||
- service: 'gfr2-bes'
|
||||
paths:
|
||||
- '/data'
|
||||
- '/aboutus'
|
||||
host_rules:
|
||||
- hosts:
|
||||
- '*='
|
||||
path_matcher: 'path-matcher-one'
|
||||
state: "present"
|
||||
tags:
|
||||
- param-check
|
||||
ignore_errors: True
|
||||
register: result
|
||||
- name: "assert wildcard error second char (error msg ignored, changed==False)"
|
||||
assert:
|
||||
that:
|
||||
- 'not result.changed'
|
||||
- 'result.msg == "wildcard be followed by a ''.'' or ''-'', *="'
|
Loading…
Add table
Add a link
Reference in a new issue