From c724aa22bf66b288c0a8b69243102f09f8ed9733 Mon Sep 17 00:00:00 2001 From: Olli Helenius Date: Wed, 2 Oct 2019 21:19:10 +0300 Subject: [PATCH] hcloud_volume: add linux_device to return values (#62865) --- lib/ansible/modules/cloud/hcloud/hcloud_volume.py | 7 +++++++ lib/ansible/modules/cloud/hcloud/hcloud_volume_info.py | 7 +++++++ test/integration/targets/hcloud_volume/tasks/main.yml | 1 + test/integration/targets/hcloud_volume_info/tasks/main.yml | 6 ++++++ 4 files changed, 21 insertions(+) diff --git a/lib/ansible/modules/cloud/hcloud/hcloud_volume.py b/lib/ansible/modules/cloud/hcloud/hcloud_volume.py index 0e7896991ec..7c94beffd79 100644 --- a/lib/ansible/modules/cloud/hcloud/hcloud_volume.py +++ b/lib/ansible/modules/cloud/hcloud/hcloud_volume.py @@ -130,6 +130,12 @@ hcloud_volume: type: int returned: Always sample: 1337 + linux_device: + description: Path to the device that contains the volume. + returned: always + type: src + sample: /dev/disk/by-id/scsi-0HC_Volume_12345 + version_added: "2.10" location: description: Location name where the volume is located at type: string @@ -178,6 +184,7 @@ class AnsibleHcloudVolume(Hcloud): "location": to_native(self.hcloud_volume.location.name), "labels": self.hcloud_volume.labels, "server": to_native(server_name), + "linux_device": to_native(self.hcloud_volume.linux_device), } def _get_volume(self): diff --git a/lib/ansible/modules/cloud/hcloud/hcloud_volume_info.py b/lib/ansible/modules/cloud/hcloud/hcloud_volume_info.py index 5dcc6b556ab..1d578e5ddc9 100644 --- a/lib/ansible/modules/cloud/hcloud/hcloud_volume_info.py +++ b/lib/ansible/modules/cloud/hcloud/hcloud_volume_info.py @@ -73,6 +73,12 @@ hcloud_volume_info: returned: always type: str sample: 10 + linux_device: + description: Path to the device that contains the volume. + returned: always + type: src + sample: /dev/disk/by-id/scsi-0HC_Volume_12345 + version_added: "2.10" location: description: Name of the location where the volume resides in returned: always @@ -119,6 +125,7 @@ class AnsibleHcloudVolumeInfo(Hcloud): "location": to_native(volume.location.name), "labels": volume.labels, "server": to_native(server_name), + "linux_device": to_native(volume.linux_device), }) return tmp diff --git a/test/integration/targets/hcloud_volume/tasks/main.yml b/test/integration/targets/hcloud_volume/tasks/main.yml index 76e04b5dc83..d949b5cadd6 100644 --- a/test/integration/targets/hcloud_volume/tasks/main.yml +++ b/test/integration/targets/hcloud_volume/tasks/main.yml @@ -52,6 +52,7 @@ - volume.hcloud_volume.location == "fsn1" - volume.hcloud_volume.size == 10 - volume.hcloud_volume.server != "{{hcloud_server_name}}" + - volume.hcloud_volume.linux_device is defined - name: test create volume idempotence hcloud_volume: diff --git a/test/integration/targets/hcloud_volume_info/tasks/main.yml b/test/integration/targets/hcloud_volume_info/tasks/main.yml index 7e74bb9a8f8..ecea7ad3179 100644 --- a/test/integration/targets/hcloud_volume_info/tasks/main.yml +++ b/test/integration/targets/hcloud_volume_info/tasks/main.yml @@ -26,9 +26,15 @@ check_mode: yes - name: verify test gather hcloud volume infos in check mode + vars: + volume: "{{ hcloud_volume.hcloud_volume_info|selectattr('name','equalto',hcloud_volume_name) | first }}" assert: that: - hcloud_volume.hcloud_volume_info|selectattr('name','equalto','{{ hcloud_volume_name }}') | list | count == 1 + - volume.name == "{{hcloud_volume_name}}" + - volume.location == "fsn1" + - volume.size == 10 + - volume.linux_device is defined - name: test gather hcloud volume infos with correct label selector hcloud_volume_info: