stephrobert.scaleway.compute inventory – Scaleway compute dynamic inventory
Note
This inventory 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 inventory plugin,
see Requirements for details.
To use it in a playbook, specify: stephrobert.scaleway.compute.
New in stephrobert.scaleway 0.1.0
Synopsis
Builds an Ansible inventory from a Scaleway account.
Discovers hosts product by product, then enriches them with their private networks and VPCs by listing IPAM once per region rather than once per network interface.
Uses a configuration file whose name ends with
scaleway.ymlorscw.yml.
Requirements
The below requirements are needed on the local controller node that executes this inventory.
scaleway >= 2.9.0
Parameters
Parameter |
Comments |
|---|---|
Restrict Accepts Default: |
|
Address families to try, in order, when setting Default: |
|
Reach the endpoint without verifying its TLS certificate. Choices:
|
|
URL of the Scaleway API endpoint. Point it at a local emulator to build an inventory without credentials. Falls back to the Scaleway configuration file, then to Configuration:
|
|
Toggle to enable/disable the caching of the inventory’s source data, requires a cache plugin setup to work. Choices:
Configuration:
|
|
Cache connection data or path, read cache plugin documentation for specifics. Configuration:
|
|
Cache plugin to use for the inventory’s source data. Default: Configuration:
|
|
Prefix to use for cache plugin files/tables. Default: Configuration:
|
|
Cache duration in seconds. Default: Configuration:
|
|
Create vars from jinja2 expressions. Default: |
|
Drop hosts matching these tags or states, after every other filter. Default: |
|
Axes used to build the native Choices:
Default: |
|
Add hosts to group based on Jinja2 conditionals. Default: |
|
Sources for Accepts The names Collisions are resolved by appending the zone, then the resource ID. Default: |
|
Expose the raw API object as Choices:
|
|
Add hosts to group based on the values of a variable. Default: |
|
The default value when the host variable’s value is This option is mutually exclusive with |
|
The key from input dictionary used to generate groups. |
|
parent group for keyed group. |
|
A keyed group name will start with this prefix. Default: |
|
separator used to build the keyed group name. Default: |
|
Set this option to This option is mutually exclusive with Choices:
|
|
Use in conjunction with By default, a keyed group that does not have a prefix or a separator provided will have a name that starts with an underscore. This is because the default prefix is Set this option to If the group name is derived from a mapping the separator is still used to concatenate the items. To not use a separator in the group name at all, set the separator for the keyed group to an empty string instead. Choices:
|
|
Organization IDs to restrict discovery to. Default: |
|
The name of this plugin. Choices:
|
|
Products to discover hosts from.
Default: |
|
Name of the profile to read in the Scaleway configuration file. Configuration:
|
|
Project IDs to restrict discovery to. Empty means the profile default. Default: |
|
Regions used to build the network index. Derived from the zones when empty. Default: |
|
Drop hosts for which no address could be selected. False keeps them without Choices:
|
|
Only keep hosts in these states. Default: |
|
Fail the inventory when a provider fails, instead of returning an incomplete fleet. Refused credentials are fatal immediately; a product absent from a zone stays a warning, because that is not an outage. Ansible downgrades an inventory failure to a warning and exits zero, so on its own this option writes the reason and stops nothing. To make it stop a run, set Choices:
|
|
Only keep hosts carrying these tags. Default: |
|
Whether a host must carry any or all of the requested tags. Choices:
|
|
Merge extra vars into the available variables for composition (highest precedence). Choices:
Configuration:
|
|
Value of the User-Agent header sent to the API. |
|
Zones to query. Empty means every zone the product declares. Default: |
Note
Configuration entries listed above for each entry type (Ansible variable, environment variable, and so on) have a low to high priority order. For example, a variable that is lower in the list will override a variable that is higher up. The entry types are also ordered by precedence from low to high priority order. For example, an ansible.cfg entry (further up in the list) is overwritten by an Ansible variable (further down in the list).
Notes
Note
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 run meant for a local emulator would reach the real Scaleway API instead.Inventories are not finalized at this stage, so the auto populated
allandungroupedgroups will only reflect what previous inventory sources explicitly added to them.Runtime ‘magic variables’ are not available during inventory construction. For example,
groupsandhostvarsdo not exist yet.
Examples
# Four inventory files, each complete and each meant to be copied whole. Save
# one as `scaleway.yml` and run `ansible-inventory -i scaleway.yml --graph`.
# 1. The smallest thing that works: the usual Scaleway profile decides the rest.
plugin: stephrobert.scaleway.compute
---
# 2. Production: one project, one region, the machines that are running.
plugin: stephrobert.scaleway.compute
projects:
- 11111111-1111-1111-1111-111111111111
products:
- instance
regions:
- fr-par
states:
- running
tags:
- production
address_priority:
- private_ipv4
- public_ipv4
group_by:
- product
- project
- zone
- tags
cache: true
---
# 3. Reach the machines over one named private network. Useful when a machine
# sits on several: without this, the first one found wins, which is not a
# decision. `require_address` then turns a machine with no address on that
# network into an error rather than a silent absence from the inventory.
plugin: stephrobert.scaleway.compute
address:
private_network: production
require_address: true
---
# 4. Groups and variables built by Ansible itself, from what the plugin
# exposes. `scaleway_instance` carries the API object, so any of its fields can
# key a group.
plugin: stephrobert.scaleway.compute
compose:
ansible_user: "'ubuntu'"
keyed_groups:
- prefix: scw_type
key: scaleway_instance.commercial_type