Skip to content

Commit 72130c0

Browse files
authored
Merge pull request #251 from edv-pi/develop
Support for CIFS storages, namespacing in PBS, and ranking interfaces for corosync
2 parents d4b7309 + 20c3be4 commit 72130c0

File tree

6 files changed

+86
-11
lines changed

6 files changed

+86
-11
lines changed

README.md

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,7 @@ pve_users: [] # List of user definitions to manage in PVE. See section on User M
422422
pve_storages: [] # List of storages to manage in PVE. See section on Storage Management.
423423
pve_datacenter_cfg: {} # Dictionary to configure the PVE datacenter.cfg config file.
424424
pve_domains_cfg: [] # List of realms to use as authentication sources in the PVE domains.cfg config file.
425+
pve_no_log: false # Set this to true in production to prevent leaking of storage credentials in run logs. (may be used in other tasks in the future)
425426
```
426427

427428
To enable clustering with this role, configure the following variables appropriately:
@@ -434,12 +435,17 @@ pve_manage_hosts_enabled : yes # Set this to no to NOT configure hosts file (cas
434435

435436
The following variables are used to provide networking information to corosync.
436437
These are known as ring0_addr/ring1_addr or link0_addr/link1_addr, depending on
437-
PVE version. They should be IPv4 or IPv6 addresses. For more information, refer
438-
to the [Cluster Manager][pvecm-network] chapter in the PVE Documentation.
438+
PVE version. They should be IPv4 or IPv6 addresses. You can also configure the
439+
[priority of these interfaces][pvecm-network-priority] to hint to corosync
440+
which interface should handle cluster traffic (lower numbers indicate higher
441+
priority). For more information, refer to the [Cluster Manager][pvecm-network]
442+
chapter in the PVE Documentation.
439443

440444
```
441445
# pve_cluster_addr0: "{{ defaults to the default interface ipv4 or ipv6 if detected }}"
442446
# pve_cluster_addr1: "another interface's IP address or hostname"
447+
# pve_cluster_addr0_priority: 255
448+
# pve_cluster_addr1_priority: 0
443449
```
444450

445451
You can set options in the datacenter.cfg configuration file:
@@ -592,9 +598,9 @@ Refer to `library/proxmox_role.py` [link][user-module] and
592598

593599
## Storage Management
594600

595-
You can use this role to manage storage within Proxmox VE (both in
596-
single server deployments and cluster deployments). For now, the only supported
597-
types are `dir`, `rbd`, `nfs`, `cephfs`, `lvm`,`lvmthin`, `zfspool`, `btrfs`,
601+
You can use this role to manage storage within Proxmox VE (both in single
602+
server deployments and cluster deployments). For now, the only supported types
603+
are `dir`, `rbd`, `nfs`, `cephfs`, `lvm`,`lvmthin`, `zfspool`, `btrfs`, `cifs`
598604
and `pbs`. Here are some examples.
599605

600606
```
@@ -645,6 +651,7 @@ pve_storages:
645651
username: user@pbs
646652
password: PBSPassword1
647653
datastore: main
654+
namespace: Top/something # Optional
648655
- name: zfs1
649656
type: zfspool
650657
content: [ "images", "rootdir" ]
@@ -656,6 +663,15 @@ pve_storages:
656663
nodes: [ "lab-node01.local", "lab-node02.local" ]
657664
path: /mnt/proxmox_storage
658665
is_mountpoint: true
666+
- name: cifs1
667+
server: cifs-host.domain.tld
668+
type: cifs
669+
content: [ "snippets", "vztmpl", "iso" ]
670+
share: sharename
671+
subdir: /subdir
672+
username: user
673+
password: supersecurepass
674+
domain: addomain.tld
659675
```
660676

661677
Refer to https://pve.proxmox.com/pve-docs/api-viewer/index.html for more information.
@@ -868,6 +884,7 @@ Adam Delo ([@ol3d](https://github.com/ol3d)) - PCIe Passthrough Support
868884
[pve-cluster]: https://pve.proxmox.com/wiki/Cluster_Manager
869885
[install-ansible]: http://docs.ansible.com/ansible/intro_installation.html
870886
[pvecm-network]: https://pve.proxmox.com/pve-docs/chapter-pvecm.html#_separate_cluster_network
887+
[pvecm-network-priority]: https://pve.proxmox.com/pve-docs/chapter-pvecm.html#_Corosync_Redundancy
871888
[pvesm]: https://pve.proxmox.com/pve-docs/chapter-pvesm.html
872889
[user-module]: https://github.com/lae/ansible-role-proxmox/blob/master/library/proxmox_user.py
873890
[group-module]: https://github.com/lae/ansible-role-proxmox/blob/master/library/proxmox_group.py

defaults/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ pve_cluster_clustername: "{{ pve_group }}"
4444
pve_manage_hosts_enabled: yes
4545
pve_cluster_addr0: "{{ ansible_default_ipv4.address if ansible_default_ipv4.address is defined else ansible_default_ipv6.address if ansible_default_ipv6.address is defined }}"
4646
# pve_cluster_addr1: "{{ ansible_eth1.ipv4.address }}
47+
# pve_cluster_addr0_priority: 0
48+
# pve_cluster_addr1_priority: 1
4749
pve_datacenter_cfg: {}
4850
pve_domains_cfg: []
4951
pve_cluster_ha_groups: []
@@ -57,3 +59,4 @@ pve_storages: []
5759
pve_ssh_port: 22
5860
pve_manage_ssh: true
5961
pve_hooks: {}
62+
pve_no_log: false

library/proxmox_storage.py

Lines changed: 52 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,22 @@
103103
description:
104104
- Specifies whether or not the given path is an externally managed
105105
mountpoint.
106+
namespace:
107+
required: false
108+
description:
109+
- Specifies the Namespace that should be used on PBS
110+
share:
111+
required: false
112+
description:
113+
- Specifies the CIFS-Share to use
114+
subdir:
115+
required: false
116+
- specifies the folder in the share dir to use for proxmox
117+
(useful to seperate proxmox content from other content)
118+
domain:
119+
required: false
120+
- Specifies Realm to use for NTLM/LDAPS Authentification if using
121+
an AD-Enabled share
106122
107123
author:
108124
- Fabien Brachere (@fbrachere)
@@ -170,13 +186,25 @@
170186
datastore: main
171187
fingerprint: f2:fb:85:76:d2:2a:c4:96:5c:6e:d8:71:37:36:06:17:09:55:f7:04:e3:74:bb:aa:9e:26:85:92:63:c8:b9:23
172188
encryption_key: autogen
189+
namespace: Top/something
173190
- name: Create a ZFS storage type
174191
proxmox_storage:
175192
name: zfs1
176193
type: zfspool
177194
content: [ "images", "rootdir" ]
178195
pool: rpool/data
179196
sparse: true
197+
- name: CIFS-Share
198+
proxmox_storage:
199+
name: cifs1
200+
server: cifs-host.domain.tld
201+
type: cifs
202+
content: [ "snippets", "vztmpl", "iso" ]
203+
share: sharename
204+
subdir: /subdir
205+
username: user
206+
password: supersecurepass
207+
domain: addomain.tld
180208
'''
181209

182210
RETURN = '''
@@ -221,6 +249,13 @@ def __init__(self, module):
221249
self.sparse = module.params['sparse']
222250
self.is_mountpoint = module.params['is_mountpoint']
223251

252+
# namespace for pbs
253+
self.namespace = module.params['namespace']
254+
# CIFS properties
255+
self.domain = module.params['domain']
256+
self.subdir = module.params['subdir']
257+
self.share = module.params['share']
258+
224259
# Validate the parameters given to us
225260
fingerprint_re = re.compile('^([A-Fa-f0-9]{2}:){31}[A-Fa-f0-9]{2}$')
226261
if self.fingerprint is not None and not fingerprint_re.match(self.fingerprint):
@@ -305,11 +340,21 @@ def prepare_storage_args(self):
305340
args['vgname'] = self.vgname
306341
if self.thinpool is not None:
307342
args['thinpool'] = self.thinpool
343+
if self.namespace is not None:
344+
args['namespace'] = self.namespace
308345
if self.sparse is not None:
309346
args['sparse'] = 1 if self.sparse else 0
310347
if self.is_mountpoint is not None:
311348
args['is_mountpoint'] = 1 if self.is_mountpoint else 0
312349

350+
# CIFS
351+
if self.subdir is not None:
352+
args['subdir'] = self.subdir
353+
if self.domain is not None:
354+
args['domain'] = self.domain
355+
if self.share is not None:
356+
args['share'] = self.share
357+
# end cifs
313358
if self.maxfiles is not None and 'backup' not in self.content:
314359
self.module.fail_json(msg="maxfiles is not allowed when there is no 'backup' in content")
315360
if self.krbd is not None and self.type != 'rbd':
@@ -386,7 +431,7 @@ def main():
386431
nodes=dict(type='list', required=False, default=None),
387432
type=dict(default=None, type='str', required=True,
388433
choices=["dir", "nfs", "rbd", "lvm", "lvmthin", "cephfs",
389-
"zfspool", "btrfs", "pbs"]),
434+
"zfspool", "btrfs", "pbs", "cifs"]),
390435
# Remaining PVE API arguments (depending on type) past this point
391436
datastore=dict(default=None, type='str', required=False),
392437
encryption_key=dict(default=None, type='str', required=False),
@@ -406,6 +451,10 @@ def main():
406451
thinpool=dict(default=None, type='str', required=False),
407452
sparse=dict(default=None, type='bool', required=False),
408453
is_mountpoint=dict(default=None, type='bool', required=False),
454+
namespace=dict(default=None, type='str', required=False),
455+
subdir=dict(default=None, type='str', required=False),
456+
domain=dict(default=None, type='str', required=False),
457+
share=dict(default=None, type='str', required=False),
409458
)
410459

411460
module = AnsibleModule(
@@ -420,7 +469,8 @@ def main():
420469
["type", "lvmthin", ["vgname", "thinpool", "content"]],
421470
["type", "zfspool", ["pool", "content"]],
422471
["type", "btrfs", ["path", "content"]],
423-
["type", "pbs", ["server", "username", "password", "datastore"]]
472+
["type", "pbs", ["server", "username", "password", "datastore"]],
473+
["type", "cifs", ["server", "share"]],
424474
],
425475
required_by={
426476
"master_pubkey": "encryption_key"

tasks/main.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,11 @@
333333
vgname: "{{ item.vgname | default(omit) }}"
334334
thinpool: "{{ item.thinpool | default(omit) }}"
335335
sparse: "{{ item.sparse | default(omit) }}"
336+
namespace: "{{ item.namespace | default(omit) }}"
337+
domain: "{{ item.domain | default(omit) }}"
338+
subdir: "{{ item.subdir | default(omit) }}"
339+
share: "{{ item.share | default(omit) }}"
340+
no_log: "{{ pve_no_log }}"
336341
with_items: "{{ pve_storages }}"
337342
when: "not pve_cluster_enabled | bool or (pve_cluster_enabled | bool and inventory_hostname == _init_node)"
338343
tags: storage

tasks/pve_add_node.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
- name: Add node to Proxmox cluster
1818
ansible.builtin.command: >-
1919
pvecm add {{ hostvars[_init_node].pve_cluster_addr0 }} -use_ssh
20-
-link0 {{ pve_cluster_addr0 }}
20+
-link0 {{ pve_cluster_addr0 }}{% if pve_cluster_addr0_priority is defined %},priority={{ pve_cluster_addr0_priority }}{% endif %}
2121
{% if pve_cluster_addr1 is defined %}
22-
-link1 {{ pve_cluster_addr1 }}
22+
-link1 {{ pve_cluster_addr1 }}{% if pve_cluster_addr1_priority is defined %},priority={{ pve_cluster_addr1_priority }}{% endif %}
2323
{% endif %}
2424
# Ensure that nodes join one-by-one because cluster joins create a lock
2525
throttle: 1

tasks/pve_cluster_config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@
4949
- name: Initialize a Proxmox cluster
5050
ansible.builtin.command: >-
5151
pvecm create {{ pve_cluster_clustername }}
52-
-link0 {{ pve_cluster_addr0 }}
52+
-link0 {{ pve_cluster_addr0 }}{% if pve_cluster_addr0_priority is defined %},priority={{ pve_cluster_addr0_priority }}{% endif %}
5353
{% if pve_cluster_addr1 is defined %}
54-
-link1 {{ pve_cluster_addr1 }}
54+
-link1 {{ pve_cluster_addr1 }}{% if pve_cluster_addr1_priority is defined %},priority={{ pve_cluster_addr1_priority }}{% endif %}
5555
{% endif %}
5656
args:
5757
creates: "{{ pve_cluster_conf }}"

0 commit comments

Comments
 (0)