Skip to content

Commit cbac32d

Browse files
authored
Merge pull request #21 from t2d/lvm2
Add handling of volume groups
2 parents fc24b7e + 139286b commit cbac32d

File tree

3 files changed

+28
-6
lines changed

3 files changed

+28
-6
lines changed

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,15 @@ Role Variables
1515
`libvirt_host_pools` is a list of pools to define and start. Each item
1616
should be a dict containing the following items:
1717
- `name` The name of the pool.
18-
- `type` The type of the pool, currently only `dir` is supported.
19-
- `capacity` The capacity, in bytes, of the pool.
18+
- `type` The type of the pool, currently only `dir` and `lvm2` are supported.
19+
- `capacity` The capacity, in bytes, of the pool. (optional)
2020
- `path` The absolute path to the pool's backing directory.
2121
- `mode` The access mode of the pool. N.B.: This should be specified as an
22-
integer **without** a leading zero; for example: `mode: 755`.
23-
- `owner` The owner of the pool.
24-
- `group` The group of the pool.
22+
integer **without** a leading zero; for example: `mode: 755`. (only `dir`)
23+
- `owner` The owner of the pool. (only `dir`)
24+
- `group` The group of the pool. (only `dir`)
25+
- `source` The name of the volume group. (only `lvm2`)
26+
- `pvs` A list of physical volumes the volume group consists of. (only `lvm2`)
2527

2628
`libvirt_host_networks` is a list of networks to define and start. Each item
2729
should be a dict containing the following items:
@@ -97,6 +99,12 @@ Example Playbook
9799
mode: 755
98100
owner: my-user
99101
group: my-group
102+
- name: lvm_pool
103+
type: lvm2
104+
source: vg1
105+
target: /dev/vg1
106+
pvs:
107+
- /dev/sda3
100108
libvirt_host_networks:
101109
- name: br-example
102110
mode: bridge

tasks/pools.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
- name: Ensure libvirt storage pool directories exist
2+
- name: Ensure libvirt dir storage pool directories exist
33
file:
44
path: "{{ item.path }}"
55
owner: "{{ item.owner }}"
@@ -10,6 +10,14 @@
1010
with_items: "{{ libvirt_host_pools }}"
1111
become: True
1212

13+
- name: Ensure libvirt lvm2 storage pool directories exist
14+
lvg:
15+
vg: "{{ item.source }}"
16+
pvs: "{{ item.pvs }}"
17+
when: item.type == "lvm2"
18+
with_items: "{{ libvirt_host_pools }}"
19+
become: True
20+
1321
- name: Ensure libvirt storage pools are defined
1422
virt_pool:
1523
name: "{{ item.name }}"

templates/pool.xml.j2

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
{% if 'capacity' in item %}
44
<capacity>{{ item.capacity }}</capacity>
55
{% endif %}
6+
{% if item.type == 'lvm2' %}
7+
<source>
8+
<name>{{ item.source }}</name>
9+
<format type='lvm2'/>
10+
</source>
11+
{% endif %}
612
<target>
713
<path>{{ item.path | default('placeholder_value') }}</path>
814
</target>

0 commit comments

Comments
 (0)