Skip to content

Commit 72a7fb6

Browse files
authored
Merge pull request #58 from raspbeguy/rbd-fix
network storage fix
2 parents 497acd1 + 428d117 commit 72a7fb6

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

README.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ Role Variables
103103
`libvirt_volume_default_device` are valid here. Default is
104104
`libvirt_volume_default_type`.
105105
- `capacity`: volume capacity, can be suffixed with k, M, G, T, P or E when type is `network` or MB,GB,TB, etc when type is `disk` (required when type is `disk` or `network`)
106-
- `auth`: Authentication details should they be required. If auth is required, `name`, `type`, `token` will need to be supplied.
107-
- `source`: Where the remote volume comes from when type is `network`. `protocol`, `name`, `hostname` and `port` should be supplied.
106+
- `auth`: Authentication details should they be required. If auth is required, `username`, `type`, and `uuid` or `usage` will need to be supplied. `uuid` and `usage` should not be both supplied.
107+
- `source`: Where the remote volume comes from when type is `network`. `protocol`, `name` and `hosts_list` should be supplied. `port` is optional.
108108
- `format`: Format of the volume. All options for
109109
`libvirt_volume_default_format` are valid here. Default is
110110
`libvirt_volume_default_format`.
@@ -199,14 +199,17 @@ Example Playbook
199199
format: 'raw'
200200
capacity: '50G'
201201
auth:
202-
name: 'admin'
202+
username: 'admin'
203203
type: 'ceph'
204-
token: ''
204+
usage: 'rbd-pool'
205205
source:
206206
protocol: 'rbd'
207-
name: 'rbd/bigstore'
208-
hostname: 'ceph.example.org'
209-
port: '6789'
207+
name: 'rbd/volume'
208+
hosts_list:
209+
- 'mon1.example.org'
210+
- 'mon2.example.org'
211+
- 'mon3.example.org'
212+
210213
interfaces:
211214
- network: 'br-datacentre'
212215

tasks/volumes.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
{% endif %}
2828
-a {{ ansible_check_mode }}
2929
with_items: "{{ volumes }}"
30-
when: item.type | default(libvirt_volume_default_type) in ['volume', 'network']
30+
when: item.type | default(libvirt_volume_default_type) == 'volume'
3131
environment: "{{ libvirt_vm_script_env }}"
3232
register: volume_result
3333
changed_when:

templates/vm.xml.j2

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,16 @@
4141
{% if volume.type | default(libvirt_volume_default_type) == 'file' %}
4242
<source file='{{ volume.file_path |default(libvirt_volume_default_images_path) }}/{{ volume.name}}'/>
4343
{% elif volume.type is defined and volume.type == 'network' %}
44-
{% if volume.auth.name is defined %}
45-
<auth username='{{ volume.auth.name }}'>
46-
<secret type='{{ volume.auth.type }}' uuid='{{ volume.auth.token }}'/>
44+
{% if volume.auth.username is defined %}
45+
<auth username='{{ volume.auth.username }}'>
46+
<secret type='{{ volume.auth.type }}' {% if volume.auth.uuid is defined and volume.auth.uuid is not none %} uuid='{{ volume.auth.uuid }}' {% else %} usage='{{ volume.auth.usage }}' {% endif %}/>
4747
</auth>
48-
{% endif %} {# End volume.auth.name check #}
48+
{% endif %} {# End volume.auth.username check #}
4949
{% if volume.source.name is defined %}
5050
<source protocol='{{ volume.source.protocol }}' name='{{ volume.source.name }}'>
51-
<host name='{{ volume.source.hostname }}' port='{{ volume.source.port }}'/>
51+
{% for host in volume.source.hosts_list %}
52+
<host name='{{ host }}' {% if volume.source.port is defined and volume.source.port is not none %} port='{{ volume.source.port }}' {% endif %}/>
53+
{% endfor %}
5254
</source>
5355
{% endif %} {# End volume.source.name check #}
5456
{% else %} {# End elif volume.type is defined #}

0 commit comments

Comments
 (0)