Repository: ansible/ansible

Issue:
Wrong default group for Scaleway dynamic inventory script
##### ISSUE TYPE
 - Bug Report


##### COMPONENT NAME
scaleway.py

##### ANSIBLE VERSION
```
ansible 2.5.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/marcos/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python2.7/dist-packages/ansible-2.5.0-py2.7.egg/ansible
  executable location = /usr/local/bin/ansible
  python version = 2.7.14 (default, Sep 23 2017, 22:06:14) [GCC 7.2.0]
```

##### CONFIGURATION
No need.

##### OS / ENVIRONMENT
N/A

##### SUMMARY
The Scaleway dynamic inventory script returns information about VMs on Scaleway. The default group for all Scaleway machines is called 'all', but Ansible itself has this group for all machines, so may be could occur superposition. Probably would be a better idea to do the same as ec2.py script, which have a group called 'ec2' for all machines from AWS EC2, creating a "scaleway" group.


Discussion:
Files identified in the description:
* [contrib/inventory/scaleway.py](https://github.com/ansible/ansible/blob/devel/contrib/inventory/scaleway.py)

If these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
Files identified in the description:
* [lib/ansible/modules/cloud/scaleway/scaleway_compute.py](https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/cloud/scaleway/scaleway_compute.py)
* [lib/ansible/modules/cloud/scaleway/scaleway_sshkey.py](https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/cloud/scaleway/scaleway_sshkey.py)

If these files are inaccurate, please update the `component name` section of the description or use the `!component` bot command.

[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: components_banner --->
cc @sieben
[click here for bot help](https://github.com/ansible/ansibullbot/blob/master/ISSUE_HELP.md)
<!--- boilerplate: notify --->
@mhalano I'm currently working on an Ansible Dynamic inventory native plugin for Scaleway. You can find it in this MR: https://github.com/ansible/ansible/pull/38739 Could you give it a try?
@sieben 
I tried the native inventory plugin which came with Ansible 2.6 and worked very well. My only concern is oauth_token must be an environment variable. I would like to define it on scaleway.yml, like:
```
plugin: scaleway
oauth_token: <my token>
regions:  
  - ams1
```

@mhalano you should already be able to do that, that configuration option ALSO allows setting via environment variable, but that is not the only way to set it, just like `region` you can just put it in the file.


Resolving patch:
diff --git a/contrib/inventory/scaleway.py b/contrib/inventory/scaleway.py
--- a/contrib/inventory/scaleway.py
+++ b/contrib/inventory/scaleway.py
@@ -150,7 +150,7 @@ def cache_available(config):
 
 def generate_inv_from_api(config):
     try:
-        inventory['all'] = copy.deepcopy(EMPTY_GROUP)
+        inventory['scaleway'] = copy.deepcopy(EMPTY_GROUP)
 
         if config.has_option('auth', 'api_token'):
             auth_token = config.get('auth', 'api_token')
@@ -186,7 +186,7 @@ def generate_inv_from_api(config):
                 if region not in inventory:
                     inventory[region] = copy.deepcopy(EMPTY_GROUP)
                 inventory[region]['children'].append(hostname)
-                inventory['all']['children'].append(hostname)
+                inventory['scaleway']['children'].append(hostname)
                 inventory[hostname] = []
                 inventory[hostname].append(ip)
 
@@ -194,7 +194,7 @@ def generate_inv_from_api(config):
     except Exception:
         # Return empty hosts output
         traceback.print_exc()
-        return {'all': {'hosts': []}, '_meta': {'hostvars': {}}}
+        return {'scaleway': {'hosts': []}, '_meta': {'hostvars': {}}}
 
 
 def get_inventory(config):


Test patch: