Closed ctreatma closed 3 weeks ago
looks like the tags
field isn't passed by the LIST function in the api:
https://developer.equinix.com/catalog/metalv1#operation/findMetalGatewaysByProject
while trying to retrieve it in the module, we get this:
"msg": "Error in metal_gateway: attribute 'tags' (to map to 'tags') not found in response_dict:
can confirm that even when using include=tags
in the queries (for both listing and getting metal gateways) the tags field is not included in the response
- name: "Retrieve metal gateway"
ansible.builtin.uri:
url: https://api.equinix.com/metal/v1/metal-gateways/4f9f9082-68c8-4809-afe6-6ae56f680549?include=tags
method: GET
headers:
x-auth-token: "{{ METAL_API_TOKEN }}"
status_code: [200]
- name: "List metal gateways"
ansible.builtin.uri:
url: https://api.equinix.com/metal/v1/projects/{{ METAL_PROJECT_ID }}/metal-gateways?include=tags
method: GET
headers:
x-auth-token: "{{ METAL_API_TOKEN }}"
status_code: [200]
response:
// GET
"json": {
"created_at": "2024-07-22T11:25:19Z",
"created_by": {
"href": "abcd"
},
"href": "/metal/v1/metal-gateways/4f9f9082-68c8-4809-afe6-6ae56f680549",
"id": "4f9f9082-68c8-4809-afe6-6ae56f680549",
"ip_reservation": {
"href": "abcd"
},
"project": {
"href": "abcd"
},
"state": "active",
"updated_at": "2024-07-22T11:25:26Z",
"virtual_network": {
"href": "abcd"
}
},
"msg": "OK (531 bytes)",
"redirected": false,
"referrer_policy": "strict-origin-when-cross-origin",
"status": 200,
"strict_transport_security": "max-age=31536000; includeSubDomains",
"url": "https://api.equinix.com/metal/v1/metal-gateways/4f9f9082-68c8-4809-afe6-6ae56f680549?include=tags",
// LIST
{
"created_at": "2024-07-22T11:25:19Z",
"created_by": {
"href": "abcd"
},
"href": "/metal/v1/metal-gateways/4f9f9082-68c8-4809-afe6-6ae56f680549",
"id": "4f9f9082-68c8-4809-afe6-6ae56f680549",
"ip_reservation": {
"href": "abcd"
},
"project": {
"href": "abcd"
},
"state": "active",
"updated_at": "2024-07-22T11:25:26Z",
"virtual_network": {
"href": "abcd"
}
},
SUMMARY
While reviewing an unrelated PR, I spotted this comment in the integration tests: https://github.com/equinix-labs/ansible-collection-equinix/blob/08b3ffdf8057f0a17dd2da68af346d6d4ea5c224/tests/integration/targets/metal_gateway/tasks/main.yml#L42-L43
If the
metal_gateway
module is indeed not idempotent, a parameter should be added to it to make it idempotent. If there is a description or label property, that should be used to enable idempotence in cases where theid
is not specified in config; if those properties don't exist, thentags
can be used in a pinch, with the caveat that using tags for idempotence means that tags cannot be updated via Ansible unless theid
is specified in config.If, for some reason, there is no way to make the
metal_gateway
module idempotent, then that risk should be called out more visibly than in a comment in a test file.ISSUE TYPE
COMPONENT NAME
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
STEPS TO REPRODUCE
EXPECTED RESULTS
ACTUAL RESULTS