ansible-collections / google.cloud

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

Can't create URL map #571

Open dmitriy-lifanov opened 1 year ago

dmitriy-lifanov commented 1 year ago
SUMMARY

Following this manual I can't create URL map

ISSUE TYPE
COMPONENT NAME

google.cloud.gcp_compute_url_map

ANSIBLE VERSION
2.12.8
COLLECTION VERSION
google.cloud 1.0.2
OS / ENVIRONMENT

Linux elementary OS 6.1 Jólnir

STEPS TO REPRODUCE
  google.cloud.gcp_compute_url_map:
    name: 'urlmap-forwardingrule-path_matcher'
    project: '{{ gcp_project }}'
    auth_kind: '{{ gcp_cred_kind }}'
    path_matchers:
    - name: '{{ instance_name }}'

    - path_rules:
      - paths:
          - '/'
          - '/*'
    - service: '{{ backendservice }}'
    service_account_file: "{{ gcp_cred_file }}"
    state: present
EXPECTED RESULTS

Url Map is created

ACTUAL RESULTS

Got an error

fatal: [localhost]: FAILED! => {"changed": false, "msg": "missing required arguments: name found in path_matchers"}
toumorokoshi commented 1 year ago

Hello! taking a brief look, name is required in every element in the patch_matchers list.

Your second and third path_rules elements don't include a name:

    - path_rules:
      - paths:
          - '/'
          - '/*'
    - service: '{{ backendservice }}'

Perhaps you meant to have them all be the same object?

    path_matchers:
    - name: '{{ instance_name }}'
      path_rules:
      - paths:
          - '/'
          - '/*'
      service: '{{ backendservice }}'
dmitriy-lifanov commented 1 year ago

I have tried this example and it's not working:

    - name: '{{ instance_name }}'
      path_rules:
      - paths:
          - '/'
          - '/*'
      service: '{{ backendservice }}'

Also I have tried to modify it like this:


- name: create a URL map
  google.cloud.gcp_compute_url_map:
    name: 'urlmap-forwardingrule-path_matcher'
    project: '{{ gcp_project }}'
    auth_kind: '{{ gcp_cred_kind }}'
    host_rules:
      - hosts: '{{ instance_name }}'
      - path_matcher: '{{ instance_name }}-matcher'
    path_matchers:
      - name: '{{ instance_name }}-matcher'
      - path_rules:
      - paths:
          - '/'
          - '/*'
      - service: '{{ backendservice }}'

And got such an error:

TASK [gcloud/create_lb : create a URL map] ***********************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "missing required arguments: path_matcher found in host_rules"}
toumorokoshi commented 1 year ago

Can you explain the error you got with the first example?

In your second example, I believe it's failing because your split the map into list elements, and are now missing the path_matcher field in the first entry (withhosts).

That's fixed by joining the list elements:

    host_rules:
      - hosts: '{{ instance_name }}'
        path_matcher: '{{ instance_name }}-matcher'
dmitriy-lifanov commented 1 year ago

This example returns such an error:


- name: create a URL map
  google.cloud.gcp_compute_url_map:
    name: 'urlmap-forwardingrule-path_matcher'
    project: '{{ gcp_project }}'
    auth_kind: '{{ gcp_cred_kind }}'
    host_rules:
      - hosts: '{{ instance_name }}'
        path_matcher: '{{ instance_name }}-matcher'
    path_matchers:
      - name: '{{ instance_name }}'
        path_rules:
        - paths:
            - '/'
            - '/*'
        service: '{{ backendservice }}'
TASK [gcloud/create_lb : create a URL map] ***********************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "Unsupported parameters for (google.cloud.gcp_compute_url_map) module: path_matchers.service. Supported parameters include: default_service, default_url_redirect, path_matchers, service_account_email, name, tests, project, state, default_route_action, env_type, auth_kind, header_action, service_account_contents, service_account_file, host_rules, scopes, description."}

And the second one also returns another error:

- name: create a URL map
  google.cloud.gcp_compute_url_map:
    name: 'urlmap-forwardingrule-path_matcher'
    project: '{{ gcp_project }}'
    auth_kind: '{{ gcp_cred_kind }}'
    host_rules:
      - hosts: '{{ instance_name }}'
        path_matcher: '{{ instance_name }}-matcher'
    path_matchers:
      - name: '{{ instance_name }}-matcher'
      - path_rules:
      - paths:
          - '/'
          - '/*'
      - service: '{{ backendservice }}'
TASK [gcloud/create_lb : create a URL map] ***********************************************************************************
fatal: [localhost]: FAILED! => {"changed": false, "msg": "missing required arguments: name found in path_matchers"}