Skip to content

Commit 85abc3d

Browse files
lexxxellae
andauthored
feature: add btrfs as valid storage type (#229)
* feature: add btrfs as valid storage type * feature: add new module argument to flag externally managed mountpoints --------- Co-authored-by: Musee Ullah <[email protected]>
1 parent 569a203 commit 85abc3d

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ Refer to `library/proxmox_role.py` [link][user-module] and
545545

546546
You can use this role to manage storage within Proxmox VE (both in
547547
single server deployments and cluster deployments). For now, the only supported
548-
types are `dir`, `rbd`, `nfs`, `cephfs`, `lvm`,`lvmthin`, and `zfspool`.
548+
types are `dir`, `rbd`, `nfs`, `cephfs`, `lvm`,`lvmthin`, `zfspool` and `btrfs`.
549549
Here are some examples.
550550

551551
```
@@ -594,8 +594,16 @@ pve_storages:
594594
content: [ "images", "rootdir" ]
595595
pool: rpool/data
596596
sparse: true
597+
- name: btrfs1
598+
type: btrfs
599+
content: [ "images", "rootdir" ]
600+
nodes: [ "lab-node01.local", "lab-node02.local" ]
601+
path: /mnt/proxmox_storage
602+
is_mountpoint: true
597603
```
598604

605+
Refer to https://pve.proxmox.com/pve-docs/api-viewer/index.html for more information.
606+
599607
Currently the `zfspool` type can be used only for `images` and `rootdir` contents.
600608
If you want to store the other content types on a ZFS volume, you need to specify
601609
them with type `dir`, path `/<POOL>/<VOLUME>` and add an entry in

library/proxmox_storage.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
type:
2323
required: true
2424
aliases: [ "storagetype" ]
25-
choices: [ "dir", "nfs", "rbd", "lvm", "lvmthin", "cephfs", "zfspool" ]
25+
choices: [ "dir", "nfs", "rbd", "lvm", "lvmthin", "cephfs", "zfspool", "btrfs" ]
2626
description:
2727
- Type of storage, must be supported by Proxmox.
2828
disable:
@@ -98,6 +98,11 @@
9898
required: false
9999
description:
100100
- Use ZFS thin-provisioning.
101+
is_mountpoint:
102+
required: false
103+
description:
104+
- Specifies whether or not the given path is an externally managed
105+
mountpoint.
101106
102107
author:
103108
- Fabien Brachere (@fbrachere)
@@ -192,6 +197,7 @@ def __init__(self, module):
192197
self.vgname = module.params['vgname']
193198
self.thinpool = module.params['thinpool']
194199
self.sparse = module.params['sparse']
200+
self.is_mountpoint = module.params['is_mountpoint']
195201

196202
try:
197203
self.existing_storages = pvesh.get("storage")
@@ -251,6 +257,8 @@ def prepare_storage_args(self):
251257
args['thinpool'] = self.thinpool
252258
if self.sparse is not None:
253259
args['sparse'] = 1 if self.sparse else 0
260+
if self.is_mountpoint is not None:
261+
args['is_mountpoint'] = 1 if self.is_mountpoint else 0
254262

255263
if self.maxfiles is not None and 'backup' not in self.content:
256264
self.module.fail_json(msg="maxfiles is not allowed when there is no 'backup' in content")
@@ -325,7 +333,7 @@ def main():
325333
nodes=dict(type='list', required=False, default=None),
326334
type=dict(default=None, type='str', required=True,
327335
choices=["dir", "nfs", "rbd", "lvm", "lvmthin", "cephfs",
328-
"zfspool"]),
336+
"zfspool", "btrfs"]),
329337
disable=dict(required=False, type='bool', default=False),
330338
state=dict(default='present', choices=['present', 'absent'], type='str'),
331339
path=dict(default=None, required=False, type='str'),
@@ -340,6 +348,7 @@ def main():
340348
vgname=dict(default=None, type='str', required=False),
341349
thinpool=dict(default=None, type='str', required=False),
342350
sparse=dict(default=None, type='bool', required=False),
351+
is_mountpoint=dict(default=None, type='bool', required=False),
343352
)
344353

345354
module = AnsibleModule(
@@ -353,6 +362,7 @@ def main():
353362
["type", "lvm", ["vgname", "content"]],
354363
["type", "lvmthin", ["vgname", "thinpool", "content"]],
355364
["type", "zfspool", ["pool", "content"]],
365+
["type", "btrfs", ["path", "content"]],
356366
]
357367
)
358368
storage = ProxmoxStorage(module)

0 commit comments

Comments
 (0)