11
11
DOCUMENTATION = r"""
12
12
name: scaleway
13
13
author:
14
- - Nathanael Demacon (@quantumsheep)
14
+ - Nathanael Demacon (@quantumsheep)
15
15
short_description: Scaleway inventory source
16
16
version_added: "1.0.0"
17
17
requirements:
18
- - scaleway >= 0.6.0
18
+ - scaleway >= 0.6.0
19
19
description:
20
- - Scaleway inventory plugin.
21
- - Uses configuration file that ends with '(scaleway|scw).(yaml|yml)'.
20
+ - Scaleway inventory plugin.
21
+ - Uses configuration file that ends with '(scaleway|scw).(yaml|yml)'.
22
22
extends_documentation_fragment:
23
- - scaleway.scaleway.scaleway
24
- - constructed
25
- - inventory_cache
23
+ - scaleway.scaleway.scaleway
24
+ - constructed
25
+ - inventory_cache
26
26
options:
27
- plugin:
28
- description:
29
- - The name of the Scaleway Inventory Plugin, this should always be C(scaleway.scaleway.scaleway).
30
- required: true
31
- choices: ['scaleway.scaleway.scaleway']
32
- zones:
33
- description:
34
- - List of zones to filter on.
35
- type: list
36
- elements: str
37
- default:
38
- - fr-par-1
39
- - fr-par-2
40
- - fr-par-3
41
- - nl-ams-1
42
- - nl-ams-2
43
- - pl-waw-1
44
- - pl-waw-2
45
- tags:
46
- description:
47
- - List of tags to filter on.
48
- type: list
49
- elements: str
50
- default: []
51
- hostnames:
52
- description: List of preference about what to use as an hostname.
53
- type: list
54
- elements: str
55
- default:
56
- - public_ipv4
57
- choices:
58
- - public_ipv4
59
- - private_ipv4
60
- - public_ipv6
61
- - hostname
62
- - id
27
+ plugin:
28
+ description:
29
+ - The name of the Scaleway Inventory Plugin, this should always be C(scaleway.scaleway.scaleway).
30
+ required: true
31
+ choices: ['scaleway.scaleway.scaleway']
32
+ zones:
33
+ description:
34
+ - List of zones to filter on.
35
+ type: list
36
+ elements: str
37
+ default:
38
+ - fr-par-1
39
+ - fr-par-2
40
+ - fr-par-3
41
+ - nl-ams-1
42
+ - nl-ams-2
43
+ - pl-waw-1
44
+ - pl-waw-2
45
+ tags:
46
+ description:
47
+ - List of tags to filter on.
48
+ type: list
49
+ elements: str
50
+ default: []
51
+ hostnames:
52
+ description: List of preference about what to use as an hostname.
53
+ type: list
54
+ elements: str
55
+ default:
56
+ - public_ipv4
57
+ choices:
58
+ - public_ipv4
59
+ - private_ipv4
60
+ - public_ipv6
61
+ - hostname
62
+ - id
63
63
"""
64
64
65
65
EXAMPLES = r"""
@@ -177,7 +177,12 @@ def populate(self, results: List[_Host]):
177
177
178
178
for result in results :
179
179
groups = self .get_host_groups (result )
180
- hostname = self ._get_hostname (result , hostnames )
180
+
181
+ try :
182
+ hostname = self ._get_hostname (result , hostnames )
183
+ except AnsibleError as e :
184
+ self .display .warning (f"Skipping host { result .id } : { e } " )
185
+ continue
181
186
182
187
for group in groups :
183
188
self .inventory .add_group (group = group )
@@ -308,6 +313,8 @@ def _get_client(self):
308
313
profile = self .get_option ("profile" )
309
314
access_key = self .get_option ("access_key" )
310
315
secret_key = self .get_option ("secret_key" )
316
+ organization_id = self .get_option ("organization_id" )
317
+ project_id = self .get_option ("project_id" )
311
318
api_url = self .get_option ("api_url" )
312
319
api_allow_insecure = self .get_option ("api_allow_insecure" )
313
320
user_agent = self .get_option ("user_agent" )
@@ -326,6 +333,12 @@ def _get_client(self):
326
333
if secret_key :
327
334
client .secret_key = secret_key
328
335
336
+ if organization_id :
337
+ client .default_organization_id = organization_id
338
+
339
+ if project_id :
340
+ client .default_project_id = project_id
341
+
329
342
if api_url :
330
343
client .api_url = api_url
331
344
0 commit comments