stephrobert.scaleway.resource_id lookup – Resolve a Scaleway resource name into its identifier
Note
This lookup plugin is part of the stephrobert.scaleway collection (version 0.7.0).
It is not included in ansible-core.
To check whether it is installed, run ansible-galaxy collection list.
To install it, use: ansible-galaxy collection install stephrobert.scaleway.
You need further requirements to be able to use this lookup plugin,
see Requirements for details.
To use it in a playbook, specify: stephrobert.scaleway.resource_id.
New in stephrobert.scaleway 0.6.0
Synopsis
Half of the modules in this collection act on a sub-resource carrying its own identifier, which only the matching
_infomodule returns. This lookup returns that identifier from the name you already know, so a playbook does not have to call a module, register its result and dig a UUID out of it.The resolution table is derived from the versioned API contracts, never written by hand. A resource that stops being listable, or that loses its
namefield upstream, leaves the table at the next generation instead of staying a promise.The name must match exactly. The Scaleway
namequery filter matches by prefix, which the contract states itself for Instances:server1returns bothserver100andserver1. The filter is sent to avoid paginating a whole fleet, and the exact comparison is always done locally.
Requirements
The below requirements are needed on the local controller node that executes this lookup.
scaleway >= 2.9.0
Terms
Parameter |
Comments |
|---|---|
The identifier parameter you are trying to fill, such as Exactly one, because a lookup that resolved several at once could not say which scope belonged to which. |
Keyword parameters
This describes keyword parameters of the lookup. These are the values key1=value1, key2=value2 and so on in the following
examples: lookup('stephrobert.scaleway.resource_id', key1=value1, key2=value2, ...) and query('stephrobert.scaleway.resource_id', key1=value1, key2=value2, ...)
Parameter |
Comments |
|---|---|
Reach the endpoint without verifying its TLS certificate. Choices:
|
|
Seconds to wait for a single API call. |
|
URL of the Scaleway API endpoint. Point it at a local emulator to resolve names without credentials. Falls back to the Scaleway configuration file, then to Configuration:
|
|
Exact name of the resource to resolve. |
|
Name of the profile to read in the Scaleway configuration file. Configuration:
|
|
Region the resource lives in, for regional resources. |
|
Value of the User-Agent header sent to the API. |
|
Zone the resource lives in, for zoned resources. |
Notes
Note
When keyword and positional parameters are used together, positional parameters must be listed before keyword parameters:
lookup('stephrobert.scaleway.resource_id', term1, term2, key1=value1, key2=value2)andquery('stephrobert.scaleway.resource_id', term1, term2, key1=value1, key2=value2)Exactly one match returns the identifier. No exact match and several exact matches both fail, and the message names what was found. Returning the first of several candidates would make the playbook act on a resource nobody designated.
The credential options are declared here rather than inherited from the module documentation fragment. A module option carries no
envkey, so its default would silently win over the environment, and a lookup meant for a local emulator would reach the real Scaleway API instead.
Examples
- name: Reboot the machine named web-01 without knowing its identifier
stephrobert.scaleway.instance_server_action:
zone: fr-par-1
server_id: >-
{{ lookup('stephrobert.scaleway.resource_id', 'server_id',
zone='fr-par-1', name='web-01') }}
action: reboot
delegate_to: localhost
- name: Update the backend named api of a named load balancer
stephrobert.scaleway.lb_backend:
zone: fr-par-1
lb_id: "{{ load_balancer_id }}"
backend_id: >-
{{ lookup('stephrobert.scaleway.resource_id', 'backend_id',
zone='fr-par-1', lb_id=load_balancer_id, name='api') }}
forward_port: 8080
delegate_to: localhost
- name: Resolve the load balancer itself, then a backend inside it
ansible.builtin.set_fact:
load_balancer_id: >-
{{ lookup('stephrobert.scaleway.resource_id', 'lb_id',
zone='fr-par-1', name='public') }}
Return Value
Key |
Description |
|---|---|
The identifier of the single resource carrying that exact name. Returned: success |