pve-cloud-schemas 0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (23) hide show
  1. pve_cloud_schemas-0.0.1/PKG-INFO +7 -0
  2. pve_cloud_schemas-0.0.1/README.md +3 -0
  3. pve_cloud_schemas-0.0.1/pyproject.toml +25 -0
  4. pve_cloud_schemas-0.0.1/setup.cfg +4 -0
  5. pve_cloud_schemas-0.0.1/src/pve_cloud_schemas/_version.py +1 -0
  6. pve_cloud_schemas-0.0.1/src/pve_cloud_schemas/definitions/awx_cloud_inv_schema.yaml +39 -0
  7. pve_cloud_schemas-0.0.1/src/pve_cloud_schemas/definitions/kubespray_inv_schema.yaml +242 -0
  8. pve_cloud_schemas-0.0.1/src/pve_cloud_schemas/definitions/lxc_inv_schema.yaml +105 -0
  9. pve_cloud_schemas-0.0.1/src/pve_cloud_schemas/definitions/pve_cloud_inv_schema.yaml +162 -0
  10. pve_cloud_schemas-0.0.1/src/pve_cloud_schemas/definitions/pve_inventory_schema.yaml +55 -0
  11. pve_cloud_schemas-0.0.1/src/pve_cloud_schemas/definitions/qemu_inv_schema.yaml +91 -0
  12. pve_cloud_schemas-0.0.1/src/pve_cloud_schemas/definitions/test_env_schema.yaml +127 -0
  13. pve_cloud_schemas-0.0.1/src/pve_cloud_schemas/extensions/setup_bind_schema_ext.yaml +17 -0
  14. pve_cloud_schemas-0.0.1/src/pve_cloud_schemas/extensions/setup_ceph_kea_schema_ext.yaml +31 -0
  15. pve_cloud_schemas-0.0.1/src/pve_cloud_schemas/extensions/setup_haproxy_schema_ext.yaml +28 -0
  16. pve_cloud_schemas-0.0.1/src/pve_cloud_schemas/extensions/setup_kea_schema_ext.yaml +23 -0
  17. pve_cloud_schemas-0.0.1/src/pve_cloud_schemas/validate.py +102 -0
  18. pve_cloud_schemas-0.0.1/src/pve_cloud_schemas.egg-info/PKG-INFO +7 -0
  19. pve_cloud_schemas-0.0.1/src/pve_cloud_schemas.egg-info/SOURCES.txt +21 -0
  20. pve_cloud_schemas-0.0.1/src/pve_cloud_schemas.egg-info/dependency_links.txt +1 -0
  21. pve_cloud_schemas-0.0.1/src/pve_cloud_schemas.egg-info/entry_points.txt +3 -0
  22. pve_cloud_schemas-0.0.1/src/pve_cloud_schemas.egg-info/requires.txt +2 -0
  23. pve_cloud_schemas-0.0.1/src/pve_cloud_schemas.egg-info/top_level.txt +1 -0
@@ -0,0 +1,7 @@
1
+ Metadata-Version: 2.4
2
+ Name: pve-cloud-schemas
3
+ Version: 0.0.1
4
+ Author-email: Tobias Huebner <tobias.huebner@vmzberlin.com>
5
+ License-Expression: GPL-3.0-or-later
6
+ Requires-Dist: PyYAML==6.0.2
7
+ Requires-Dist: jsonschema==4.23.0
@@ -0,0 +1,3 @@
1
+ # Python pkg - pve-cloud-schemas
2
+
3
+ Contains schema definitions for custom ansible inventories and extensions for various core pve cloud playbooks.
@@ -0,0 +1,25 @@
1
+ [build-system]
2
+ requires = ["setuptools", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "pve-cloud-schemas"
7
+ authors = [{ name = "Tobias Huebner", email = "tobias.huebner@vmzberlin.com" }]
8
+ license = "GPL-3.0-or-later"
9
+ license-files = ["LICENSE"]
10
+ dependencies = [
11
+ "PyYAML==6.0.2",
12
+ "jsonschema==4.23.0",
13
+ ]
14
+ dynamic = ["version"]
15
+
16
+ [tool.setuptools.dynamic]
17
+ version = {attr = "pve_cloud_schemas._version.__version__"}
18
+
19
+ [tool.setuptools.package-data]
20
+ "pve_cloud_schemas.definitions" = ["*.yml", "*.yaml"]
21
+ "pve_cloud_schemas.extensions" = ["*.yml", "*.yaml"]
22
+
23
+ [project.scripts]
24
+ pcval = "pve_cloud_schemas.validate:validate_inventory_file"
25
+ pcval-dump = "pve_cloud_schemas.validate:dump_schemas"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1 @@
1
+ __version__ = "0.0.1"
@@ -0,0 +1,39 @@
1
+ type: object
2
+ additionalProperties: false
3
+ title: "AWX Cron Inventory"
4
+ required:
5
+ - target_pve
6
+ - plugin
7
+ - pve_clusters
8
+ properties:
9
+ target_pve:
10
+ type: string
11
+ plugin:
12
+ type: string
13
+ description: Id of ansible inventory plugin.
14
+ enum:
15
+ - pve.cloud.awx_cloud_inv
16
+ pve_clusters:
17
+ type: object
18
+ description: "Copy of the inventory file located in user home directory ~/.pve-cloud-dyn-inv.yaml, containing all the pve clusters the user has access to via ssh."
19
+ additionalProperties: false
20
+ patternProperties:
21
+ "^.*$":
22
+ type: object
23
+ title: "PVE cluster fqdn"
24
+ additionalProperties: false
25
+ description: "The identifying cluster domain. Synonymous with target_pve. Will be appended to stack_name(s)."
26
+ patternProperties:
27
+ "^.*$":
28
+ type: object
29
+ title: "PVE Node Hostname"
30
+ additionalProperties: false
31
+ description: "Hostname of a pve host (short)."
32
+ required:
33
+ - ansible_user
34
+ - ansible_host
35
+ properties:
36
+ ansible_user:
37
+ type: string
38
+ ansible_host:
39
+ type: string
@@ -0,0 +1,242 @@
1
+ type: object
2
+ description: "Inventory for deploying k8s clusters via kubespray on PVE."
3
+ title: "K8S Kubespray Inv."
4
+ additionalProperties: false
5
+ required:
6
+ - target_pve
7
+ - stack_name
8
+ - cluster_cert_entries
9
+ - tcp_proxies
10
+ - static_includes
11
+ - qemus
12
+ - ceph_csi_sc_pools
13
+ - root_ssh_pub_key
14
+ properties:
15
+ target_pve:
16
+ type: string
17
+ description: "The pve cluster this stack should reside in, defined in ~/.pve-cloud-dyn-inv.yaml via `pvcli connect-cluster`"
18
+ stack_name:
19
+ type: string
20
+ description: "Your stack name, needs to be unique within the cloud domain. Will create its own sub zone."
21
+ extra_control_plane_sans:
22
+ type: array
23
+ description: |
24
+ Extra sans that kubespray will put in kubeapi generated certificates. Original kubespray variable is named supplementary_addresses_in_ssl_keys,
25
+ but is set via kubespray custom inventory. Read kubernetes page in pve cloud docs for more details.
26
+ items:
27
+ type: string
28
+ external_domains:
29
+ type: array
30
+ description: "Domains that will be exposed to the public proxies floating ip via haproxy routing rules."
31
+ items:
32
+ type: object
33
+ additionalProperties: false
34
+ required:
35
+ - zone
36
+ - names
37
+ properties:
38
+ zone:
39
+ type: string
40
+ description: "DNS parent zone, should also be the zone that external records are made under in AWS for example."
41
+ expose_tld:
42
+ type: boolean
43
+ description: "Expose the top level domain itself."
44
+ names:
45
+ type: array
46
+ items:
47
+ type: string
48
+ description: "Hostname part (host + zone)"
49
+ cluster_cert_entries:
50
+ type: array
51
+ description: "Content for the clusters certificate. Internal routing is handled by ingress dns!"
52
+ items:
53
+ type: object
54
+ additionalProperties: false
55
+ required:
56
+ - zone
57
+ - names
58
+ properties:
59
+ zone:
60
+ type: string
61
+ description: "DNS parent zone, should coincide with tld for dns01 challenge."
62
+ names:
63
+ type: array
64
+ items:
65
+ type: string
66
+ description: "Hostname part (host + zone)"
67
+ authoritative_zone:
68
+ type: boolean
69
+ description: "Create authoritative zone inside of pve cloud bind dns."
70
+ apex_zone_san:
71
+ type: boolean
72
+ description: "Creates additional SAN for the zone, if you have *.example.com you will also get example.com in your certificate. Defaults to false."
73
+ tcp_proxies:
74
+ type: array
75
+ description: "TCP forwards to this cluster on the pve cluster proxy."
76
+ items:
77
+ type: object
78
+ additionalProperties: false
79
+ required:
80
+ - proxy_name
81
+ - haproxy_port
82
+ - node_port
83
+ properties:
84
+ proxy_name:
85
+ type: string
86
+ description: "Name of the proxy port. Should be unique for the stack."
87
+ haproxy_port:
88
+ type: number
89
+ description: "Port on the haproxy frontend that listens."
90
+ node_port:
91
+ type: number
92
+ description: "Port on the nodes, usually via K8S NodePort"
93
+ proxy_snippet:
94
+ type: string
95
+ description: "additional snippet that will be inserted into the haproxy listen block. Can be used for custom logic."
96
+ external:
97
+ type: boolean
98
+ description: "Will bind to the external floating ip aswell."
99
+ static_includes:
100
+ type: object
101
+ additionalProperties: false
102
+ required:
103
+ - dhcp_stack
104
+ - proxy_stack
105
+ - postgres_stack
106
+ - bind_stack
107
+ properties:
108
+ dhcp_stack:
109
+ type: string
110
+ description: "Stack fqdn of dhcp stack where reservations for node ips should be made."
111
+ proxy_stack:
112
+ type: string
113
+ description: "Stack fqdn of haproxy stack where ingress and proxy rules should be configured."
114
+ postgres_stack:
115
+ type: string
116
+ description: "Stack fqdn of postgres stack where state and general configuration of our pve cloud is stored."
117
+ bind_stack:
118
+ type: string
119
+ description: "Stack fqdn of bind servers, where create_bind_zone: true ingress_domain zones will be created."
120
+ cache_stack:
121
+ type: string
122
+ description: "Cache stack to mount nfs for kubespray cache and apt cache. Assumes the cache lxc to have the hostname \"main\"." # todo: implement keepalived cache instead
123
+ include_stacks:
124
+ type: array
125
+ description: "Include other stacks into the ansible inventory, from any PVE cluster you like."
126
+ items:
127
+ type: object
128
+ required:
129
+ - stack_fqdn
130
+ - host_group
131
+ additionalProperties: false
132
+ properties:
133
+ stack_fqdn:
134
+ type: string
135
+ description: "Target stack fqdn to include (stack name + pve_cloud_domain). Will automatically include it from the right pve cluster."
136
+ host_group:
137
+ type: string
138
+ description: "This is the name of the hosts group of our ansible inventory the included vms will be under."
139
+ qemu_ansible_user:
140
+ type: string
141
+ description: User ansible will use to connect, defaults to admin.
142
+ qemus:
143
+ type: array
144
+ description: "Nodes for the cluster in form of qemu vms."
145
+ items:
146
+ type: object
147
+ additionalProperties: false
148
+ required:
149
+ - k8s_roles
150
+ - disk
151
+ - parameters
152
+ properties:
153
+ hostname:
154
+ type: string
155
+ description: "Optional unique hostname for this node, otherwise pet name random name will be generated."
156
+ vars:
157
+ type: object
158
+ description: "Custom variables for this node specifically."
159
+ k8s_roles:
160
+ type: array
161
+ description: "String array of k8s roles (master/worker)"
162
+ target_host:
163
+ type: string
164
+ description: "Pve host to tie this vm to."
165
+ parameters:
166
+ type: object
167
+ description: "In accordance with pve qm cli tool, creation args."
168
+ network_config:
169
+ type: string
170
+ description: "Cinit network config yaml string. Will be the last cfg piece that gets merged into the final cloudinit network config."
171
+ disk:
172
+ type: object
173
+ additionalProperties: false
174
+ required:
175
+ - size
176
+ - pool
177
+ properties:
178
+ size:
179
+ type: string
180
+ description: "Size of the vms disk."
181
+ example: 25G
182
+ options:
183
+ type: object
184
+ description: "Mount options"
185
+ pool:
186
+ type: string
187
+ description: "Ceph pool name the vms disk will be created in."
188
+ ceph_csi_sc_pools:
189
+ type: array
190
+ description: "Ceph pools that will be made available to the cluster CSI driver."
191
+ items:
192
+ type: object
193
+ additionalProperties: false
194
+ required:
195
+ - name
196
+ - default
197
+ - mount_options
198
+ properties:
199
+ name:
200
+ type: string
201
+ description: "Name of the pool in the ceph of our PVE cluster."
202
+ default:
203
+ type: boolean
204
+ description: "Whether or not the pool is the default storage class."
205
+ mount_options:
206
+ type: array
207
+ description: "String array of mount options that will be set in the storage class and applied to pvs."
208
+ root_ssh_pub_key:
209
+ type: string
210
+ description: trusted root key for the cloud init image.
211
+ pve_ha_group:
212
+ type: string
213
+ description: PVE HA group this vm should be assigned to (optional).
214
+ qemu_hashed_pw:
215
+ type: string
216
+ description: Pw for default user defaults to hashed 'password' for debian cloud init image.
217
+ qemu_base_parameters:
218
+ type: object
219
+ description: Base parameters passed to the proxmox qm cli tool for creating vm
220
+ qemu_image_url:
221
+ type: string
222
+ description: http(s) download link for cloud init image.
223
+ qemu_keyboard_layout:
224
+ type: string
225
+ description: Keyboard layout for cloudinit.
226
+ qemu_network_config:
227
+ type: string
228
+ description: Optional qemu network config as a yaml string that is merged into the cloudinit network config of all qemus.
229
+ acme_staging:
230
+ type: boolean
231
+ description: "If set to true will use acme staging directory for issueing certs."
232
+ plugin:
233
+ type: string
234
+ description: Id of ansible inventory plugin.
235
+ enum:
236
+ - pve.cloud.kubespray_inv
237
+ pve_cloud_pytest:
238
+ type: object
239
+ description: Variables object used only in e2e tests.
240
+ qemu_global_vars:
241
+ type: object
242
+ description: "Variables that will be applied to all lxc hosts."
@@ -0,0 +1,105 @@
1
+ type: object
2
+ title: "LXC Inventory"
3
+ description: "Base inventory for creating lxcs for a single stack on PVE."
4
+ additionalProperties: false
5
+ required:
6
+ - target_pve
7
+ - stack_name
8
+ - lxcs
9
+ - root_ssh_pub_key
10
+ properties:
11
+ target_pve:
12
+ type: string
13
+ description: "Proxmox cluster name + cloud domain, this is where the lxcs will be created."
14
+ stack_name:
15
+ type: string
16
+ description: "Your stack name, needs to be unique within the cloud."
17
+ static_includes:
18
+ type: object
19
+ lxcs:
20
+ type: array
21
+ description: "List of lxcs that will be created for the stack."
22
+ items:
23
+ type: object
24
+ required:
25
+ - parameters
26
+ properties:
27
+ hostname:
28
+ type: string
29
+ description: "Optional unique hostname for this lxc, otherwise pet name random name will be generated."
30
+ target_host:
31
+ type: string
32
+ description: "Pve host to tie this vm to. This is useful to always deploy specifically on a proxmox host."
33
+ vars:
34
+ type: object
35
+ description: "Custom variables for this lxc specifically. Will be usable in playbooks."
36
+ parameters:
37
+ type: object
38
+ description: "Parameters that will be passed to pve pct cli tool for lxc creation."
39
+ required:
40
+ - rootfs
41
+ - cores
42
+ - memory
43
+ - net0
44
+ properties:
45
+ rootfs:
46
+ type: string
47
+ description: "PVE storage for the container disk."
48
+ cores:
49
+ type: integer
50
+ description: "Number of virtual CPU cores."
51
+ memory:
52
+ type: integer
53
+ description: "Memory in bytes, use POW 2."
54
+ net0:
55
+ type: string
56
+ description: "Configuration for primary network interface."
57
+ examples:
58
+ - "name=eth0,bridge=vmbr0,tag=120,firewall=1,ip=dhcp"
59
+ include_stacks:
60
+ type: array
61
+ description: "Include other cloud stacks into the ansible inventory, from any PVE cluster within the cloud you like."
62
+ items:
63
+ type: object
64
+ properties:
65
+ stack_fqdn:
66
+ type: string
67
+ description: "Target stack fqdn to include (stack name + pve_cloud_domain). Will automatically include it from the right pve cluster."
68
+ host_group:
69
+ type: string
70
+ description: "This is the name of the hosts group of our ansible inventory the included vms will be under."
71
+ qemu_ansible_user:
72
+ type: string
73
+ description: "User ansible will use to connect if its a vm, defaults to admin. LXCs are always root."
74
+ lxc_global_vars:
75
+ type: object
76
+ description: "Variables that will be applied to all lxc hosts and are available in playbooks."
77
+ properties:
78
+ use_alternate_ssh_port:
79
+ type: boolean
80
+ description: "Will use 2222 instead of 22 for ssh."
81
+ install_prom_systemd_exporter:
82
+ type: boolean
83
+ description: "Will install prometheus metrics exporter for systemd. This implements with pve cloud terraform monitoring modules."
84
+ additionalProperties: true
85
+ pve_ha_group:
86
+ type: string
87
+ description: "When set the stack will be added to the corresponding PVE high availability group."
88
+ lxc_base_parameters:
89
+ type: object
90
+ description: "PVE pct cli parameters that will be used for all lxcs."
91
+ lxc_os_template:
92
+ type: string
93
+ description: "`pveam available --section system` / run `pveam update` for newest, PVE available LXC template (will be downloaded)."
94
+ example: debian-11-standard_11.7-1_amd64.tar.zst
95
+ root_ssh_pub_key:
96
+ type: string
97
+ description: "Public key that will be installed for the root user of all lxcs in the stack."
98
+ pve_cloud_pytest:
99
+ type: object
100
+ description: Variables object used only in e2e tests.
101
+ plugin:
102
+ type: string
103
+ description: Id of ansible inventory plugin.
104
+ enum:
105
+ - pve.cloud.lxc_inv
@@ -0,0 +1,162 @@
1
+ type: object
2
+ title: "Cloud Inventory"
3
+ description: "Definitions for a proxmox cloud."
4
+ additionalProperties: false
5
+ required:
6
+ - pve_cloud_domain
7
+ - pve_clusters
8
+ - pve_vm_subnet
9
+ - bind_master_ip
10
+ - bind_slave_ip
11
+ - bind_arpa_zone_service_lxcs
12
+ - bind_additional_arpa_zones
13
+ - bind_zone_admin_email
14
+ - kea_dhcp_main_ip
15
+ - kea_dhcp_failover_ip
16
+ - kea_dhcp_routers
17
+ - kea_dhcp_pools
18
+ - kea_dhcp_static_routes
19
+ properties:
20
+ pve_vm_subnet:
21
+ type: string
22
+ description: "Subnet this PVE cluster uses for its VMs."
23
+ pve_cloud_domain:
24
+ type: string
25
+ description: "The overarching domain for the cloud. Will also be used for ddns."
26
+ pve_clusters:
27
+ type: object
28
+ additionalProperties: false
29
+ description: "Definitions for specific Proxmox clusters that will be part of the cloud. Keys are hostnames."
30
+ patternProperties:
31
+ '^.*$':
32
+ type: object
33
+ title: "PVE cluster fqdn"
34
+ additionalProperties: false
35
+ description: "Fully quantified name for the cluster."
36
+ required:
37
+ - pve_unique_cloud_services
38
+ properties:
39
+ pve_haproxy_floating_ip:
40
+ type: string
41
+ description: "Floating ip of our central cluster HAProxy."
42
+ pve_haproxy_floating_ip_internal:
43
+ type: string
44
+ description: "Floating ip that is exclusively accessible from inside the cloud / location. External forwardings should be made to pve_haproxy_floating_ip."
45
+ pve_unique_cloud_services:
46
+ type: array
47
+ description: "Unique service the cluster provides for its cloud. Unique in the sense that only one cluster may provide each of the services."
48
+ items:
49
+ type: string
50
+ enum:
51
+ - dns
52
+ - dhcp
53
+ - psql-state
54
+ pve_host_vars:
55
+ type: object
56
+ description: "Optional variables that will be specifically set for a pve host. Key is the simple host name."
57
+ properties:
58
+ wol_iface:
59
+ type: string
60
+ description: "Inteface wol should be enabled using ethtool."
61
+ tso_gso_fix:
62
+ type: array
63
+ description: "Will turn of network optimizations on old network cards, this assures they can run indefinetly. Will only take effect with the e1000_driver_fix playbook."
64
+ mac_iface_mapping:
65
+ type: array
66
+ description: "Map mac addresses to interface names, will be picked up by setup playbooks. This will actually change the interfaces names on the host aswell as try to replace /etc/network/interfaces."
67
+ items:
68
+ type: object
69
+ additionalProperties: false
70
+ required:
71
+ - mac_addr
72
+ - iface
73
+ properties:
74
+ mac_addr:
75
+ type: string
76
+ description: "Network device mac address."
77
+ iface:
78
+ type: string
79
+ description: "Interface name that will be assigned to the device. Default name will be removed!"
80
+ bind_master_ip:
81
+ type: string
82
+ description: "IP of the primary bind dns for this cluster, will be statically assigned."
83
+ bind_slave_ip:
84
+ type: string
85
+ description: "IP of the slave bind dns for this cluster."
86
+ bind_arpa_zone_service_lxcs:
87
+ type: string
88
+ description: "Arpa zone in which service lxcs with static ips will manuall get their reverse dns entries."
89
+ bind_additional_arpa_zones:
90
+ type: array
91
+ description: "Additional arpa zones which should be created and managed in the dns / dhcp ddns."
92
+ examples:
93
+ - "1.168.192.in-addr.arpa"
94
+ bind_zone_admin_email:
95
+ type: string
96
+ description: "Required adminstrator email in bind format for bind zones."
97
+ examples:
98
+ - admin.example.com.
99
+ bind_forward_zones:
100
+ type: array
101
+ description: "Creates zone in bind and delegation ns records to the specified nameservers."
102
+ items:
103
+ type: object
104
+ properties:
105
+ zone:
106
+ type: string
107
+ nameservers:
108
+ type: array
109
+ items:
110
+ type: string
111
+ kea_dhcp_main_ip:
112
+ type: string
113
+ description: "Static assigned ip for the main dhcp server."
114
+ kea_dhcp_failover_ip:
115
+ type: string
116
+ description: "Static ip for slave dhcp server."
117
+ kea_dhcp_routers:
118
+ type: string
119
+ description: "option-data for kea dhcp routers. The default route router that the dhcp will communicate."
120
+ exaxmples:
121
+ - "192.168.1.1"
122
+ kea_dhcp_pools:
123
+ type: array
124
+ description: "Address pools that the dhcp allocates from. Has to be within pve_vm_subnet cidr."
125
+ items:
126
+ type: string
127
+ description: "IPV4 Address range in keas format."
128
+ examples:
129
+ - "192.168.1.2 - 192.168.1.199"
130
+ kea_dhcp_static_routes:
131
+ type: string
132
+ description: "classless-static-routes for kea option-data. Extra routes you want the dhcp to communicate, for example to a custom VPN gateway."
133
+ # todo: check if this overwrites the default dhcp router option, document why this was set
134
+ examples:
135
+ - "0.0.0.0/0 - 192.168.1.1, 10.0.2.0/24 - 192.168.1.217"
136
+ kea_dhcp_ceph_frontend_subnet:
137
+ type: string
138
+ description: "Optional cidr definition for a seperate dhcp if the ceph frontend resides on a different interface (map it inside the dhcp lxcs to pve0)."
139
+ examples:
140
+ - "10.255.42.0/23"
141
+ kea_dhcp_ceph_frontend_pool:
142
+ type: string
143
+ description: "Pool kea definition for ceph frontend ip allocations, this way monitors can have their static block."
144
+ examples:
145
+ - "10.255.42.17 - 10.255.43.254"
146
+ acme_contact:
147
+ type: string
148
+ description: "Email address to use for acme account creation."
149
+ acme_method:
150
+ type: string
151
+ enum:
152
+ - route53
153
+ - ionos
154
+ description: "PVE Cloud included method for solving dns01 challenges."
155
+ pve_cloud_pytest:
156
+ type: object
157
+ description: Variables object used only in e2e tests.
158
+ plugin:
159
+ type: string
160
+ description: "Id of ansible inventory plugin, needs to be set exactly."
161
+ enum:
162
+ - pve.cloud.pve_cloud_inv
@@ -0,0 +1,55 @@
1
+ type: object
2
+ description: "Inventory file located in user home directory ~/.pve-inventory.yaml, containing all the pve clusters the user has access to via ssh."
3
+ additionalProperties: false
4
+ properties:
5
+ # dummy for schema lib
6
+ plugin:
7
+ type: string
8
+ description: "Id of ansible inventory plugin, needs to be set exactly."
9
+ enum:
10
+ - pve.cloud.pve_cloud_dyn_inv
11
+ patternProperties:
12
+ "^.*$":
13
+ type: object
14
+ description: "The overarching pve cloud domain. Contains multiple pve clusters."
15
+ patternProperties:
16
+ "^.*$":
17
+ type: object
18
+ additionalProperties: false
19
+ description: "The identifying pve cluster domain. Synonymous with target_pve."
20
+ patternProperties:
21
+ "^.*$":
22
+ type: object
23
+ additionalProperties: false
24
+ description: "Hostname of a pve host (short)."
25
+ required:
26
+ - ansible_user
27
+ - ansible_host
28
+ properties:
29
+ ansible_user:
30
+ type: string
31
+ ansible_host:
32
+ type: string
33
+ vars:
34
+ type: object
35
+ properties:
36
+ wol_iface:
37
+ type: string
38
+ description: Inteface wol should be enabled using ethtool.
39
+ tso_gso_fix:
40
+ type: array
41
+ description: Will turn of network optimizations on old network cards, this assures they can run indefinetly.
42
+ mac_iface_mapping:
43
+ type: array
44
+ description: Will setup the pve hosts networkdevices with a fixed name mapped for specified mac addresses.
45
+ items:
46
+ type: object
47
+ additionalProperties: false
48
+ required:
49
+ - mac_addr
50
+ - iface
51
+ properties:
52
+ mac_addr:
53
+ type: string
54
+ iface:
55
+ type: string
@@ -0,0 +1,91 @@
1
+ title: "VM Inventory"
2
+ type: object
3
+ description: "Inventory for deploying k8s clusters via kubespray on PVE."
4
+ additionalProperties: false
5
+ required:
6
+ - stack_name
7
+ - qemus
8
+ - target_pve
9
+ - root_ssh_pub_key
10
+ properties:
11
+ stack_name:
12
+ type: string
13
+ description: "Your stack name, needs to be unique within the parent_domain. Will create its own sub zone."
14
+ target_pve:
15
+ type: string
16
+ description: "The pve cluster this stack should reside in, defined in ~/.pve-cloud-dyn-inv.yaml via `pvcli connect-cluster`"
17
+ qemus:
18
+ type: array
19
+ description: "Nodes for the cluster in form of qemu vms."
20
+ items:
21
+ type: object
22
+ properties:
23
+ parameters:
24
+ type: object
25
+ description: "In accordance with pve qm cli tool, creation args."
26
+ disk:
27
+ type: object
28
+ additionalProperties: false
29
+ required:
30
+ - size
31
+ - pool
32
+ properties:
33
+ size:
34
+ type: string
35
+ description: "Size of the vms disk."
36
+ example: 25G
37
+ options:
38
+ type: object
39
+ description: "Mount options"
40
+ pool:
41
+ type: string
42
+ description: "Ceph pool name the vms disk will be created in."
43
+ include_stacks:
44
+ type: array
45
+ items:
46
+ type: object
47
+ description: "Include other stacks into the ansible inventory, from any PVE cluster you like."
48
+ properties:
49
+ stack_fqdn:
50
+ type: string
51
+ description: "Target stack fqdn to include (stack name + pve_cloud_domain)" # todo: same replace as lxc inv
52
+ host_group:
53
+ type: string
54
+ description: "This is the name of the hosts group of our ansible inventory the included vms will be under."
55
+ qemu_ansible_user:
56
+ type: string
57
+ description: User ansible will use to connect, defaults to admin.
58
+ static_includes:
59
+ type: object
60
+ root_ssh_pub_key:
61
+ type: string
62
+ description: "Ssh key for qemu_default_user"
63
+ pve_ha_group:
64
+ type: string
65
+ description: "PVE HA Group this qemu instance should be assigned to."
66
+ qemu_default_user:
67
+ type: string
68
+ description: "User for cinit."
69
+ qemu_hashed_pw:
70
+ type: string
71
+ description: "The hashed password that will be passed to cloudinit. Use `mkpasswd --method=SHA-512` with the fitting method for your cinit image."
72
+ qemu_base_parameters:
73
+ type: object
74
+ description: "Parameters from qm create proxmox cli tool that will be passed to all created qemus."
75
+ qemu_image_url:
76
+ type: string
77
+ description: "http(s) download link to the cinit image you want to use."
78
+ qemu_keyboard_layout:
79
+ type: string
80
+ description: "The keyboard layout, can be and of de, en ...."
81
+ qemu_global_vars:
82
+ type: object
83
+ description: "Variables that will be applied to all lxc hosts"
84
+ pve_cloud_pytest:
85
+ type: object
86
+ description: Variables object used only in e2e tests.
87
+ plugin:
88
+ type: string
89
+ description: Id of ansible inventory plugin
90
+ enum:
91
+ - pve.cloud.qemu_inv
@@ -0,0 +1,127 @@
1
+ type: object
2
+ description: "Config / Inventory file for pve cloud e2e tests. Schema is merely a merge from the main schemas of the pve_cloud collection."
3
+ additionalProperties: false
4
+ required:
5
+ - pve_test_hosts
6
+ - pve_test_cloud_domain
7
+ - pve_test_deployments_domain
8
+ - pve_test_cluster_name
9
+ - pve_test_disk_storage_id
10
+ - pve_test_ceph_csi_storage_id
11
+ - pve_test_service_lxcs_nameserver
12
+ - pve_test_service_lxcs_gateway
13
+ - pve_test_ssh_pub_key
14
+ - pve_test_cloud_inv
15
+ - pve_test_cloud_inv_cluster
16
+ properties:
17
+ # dummy for schema lib
18
+ plugin:
19
+ type: string
20
+ description: "Id of ansible inventory plugin, needs to be set exactly."
21
+ enum:
22
+ - pve.cloud.pve_cloud_test_env
23
+ pve_test_hosts:
24
+ type: object
25
+ additionalProperties: false
26
+ patternProperties:
27
+ "^.*$":
28
+ type: object
29
+ title: "PVE Host name"
30
+ additionalProperties: false
31
+ required:
32
+ - ansible_user
33
+ - ansible_host
34
+ properties:
35
+ ansible_user:
36
+ type: string
37
+ ansible_host:
38
+ type: string
39
+ pve_test_cloud_domain:
40
+ type: string
41
+ pve_test_deployments_domain:
42
+ type: string
43
+ pve_test_cluster_name:
44
+ type: string
45
+ pve_test_disk_storage_id:
46
+ type: string
47
+ pve_test_ceph_csi_storage_id:
48
+ type: string
49
+ pve_test_service_lxcs_nameserver:
50
+ type: string
51
+ pve_slop_firewall_ip:
52
+ type: string
53
+ pve_test_service_lxcs_gateway:
54
+ type: string
55
+ pve_test_ssh_pub_key:
56
+ type: string
57
+ pve_test_cloud_inv:
58
+ type: object
59
+ additionalProperties: false
60
+ required:
61
+ - pve_vm_subnet
62
+ - bind_master_ip
63
+ - bind_slave_ip
64
+ - bind_arpa_zone_service_lxcs
65
+ - bind_additional_arpa_zones
66
+ - bind_zone_admin_email
67
+ - kea_dhcp_main_ip
68
+ - kea_dhcp_failover_ip
69
+ - kea_dhcp_routers
70
+ - kea_dhcp_pools
71
+ - kea_dhcp_static_routes
72
+ properties:
73
+ pve_vm_subnet:
74
+ type: string
75
+ bind_master_ip:
76
+ type: string
77
+ bind_slave_ip:
78
+ type: string
79
+ bind_arpa_zone_service_lxcs:
80
+ type: string
81
+ bind_additional_arpa_zones:
82
+ type: array
83
+ items:
84
+ type: string
85
+ bind_zone_admin_email:
86
+ type: string
87
+ bind_forward_zones:
88
+ type: array
89
+ items:
90
+ type: object
91
+ properties:
92
+ zone:
93
+ type: string
94
+ nameservers:
95
+ type: array
96
+ items:
97
+ type: string
98
+ kea_dhcp_main_ip:
99
+ type: string
100
+ kea_dhcp_failover_ip:
101
+ type: string
102
+ kea_dhcp_routers:
103
+ type: string
104
+ kea_dhcp_pools:
105
+ type: array
106
+ items:
107
+ type: string
108
+ kea_dhcp_static_routes:
109
+ type: string
110
+ pve_test_host_vars:
111
+ patternProperties:
112
+ "^.*$":
113
+ type: object
114
+ title: "PVE Host name"
115
+ pve_test_cloud_inv_cluster:
116
+ type: object
117
+ additionalProperties: False
118
+ required:
119
+ - pve_haproxy_floating_ip
120
+ - pve_haproxy_floating_ip_internal
121
+ properties:
122
+ pve_haproxy_floating_ip:
123
+ type: string
124
+ pve_haproxy_floating_ip_internal:
125
+ type: string
126
+ pve_test_tf_parameters:
127
+ type: object
@@ -0,0 +1,17 @@
1
+ properties:
2
+ plugin:
3
+ type: string
4
+ description: Id of ansible inventory plugin.
5
+ enum:
6
+ - pve.cloud.lxc_inv # merge key
7
+ lxcs:
8
+ items:
9
+ required:
10
+ - vars
11
+ properties:
12
+ vars:
13
+ required:
14
+ - bind_master
15
+ properties:
16
+ bind_master:
17
+ type: boolean
@@ -0,0 +1,31 @@
1
+ title: "Schema ext setup_ceph_kea playbook"
2
+ properties:
3
+ plugin:
4
+ type: string
5
+ description: Id of ansible inventory plugin.
6
+ enum:
7
+ - pve.cloud.lxc_inv
8
+ lxcs:
9
+ items:
10
+ required:
11
+ - vars
12
+ properties:
13
+ parameters:
14
+ properties:
15
+ net0:
16
+ pattern: "\\bname=pve\\b"
17
+ net1:
18
+ pattern: "\\bname=cephfe\\b"
19
+ vars:
20
+ required:
21
+ - kea_dhcp_ceph_frontend_subnet
22
+ - kea_dhcp_ceph_frontend_pool
23
+ properties:
24
+ kea_dhcp_ceph_frontend_subnet:
25
+ type: string
26
+ description: "Optional definition for a seperate dhcp if the ceph frontend resides on a different interface (map it inside the dhcp lxcs to pve0)."
27
+ kea_dhcp_ceph_frontend_pool:
28
+ type: string
29
+ description: "Pool for ceph frontend ip allocations, this way monitors can have their static block."
30
+ examples:
31
+ - "10.255.22.17 - 10.255.23.254"
@@ -0,0 +1,28 @@
1
+ required:
2
+ - static_includes
3
+ properties:
4
+ plugin:
5
+ type: string
6
+ description: Id of ansible inventory plugin.
7
+ enum:
8
+ - pve.cloud.lxc_inv
9
+ static_includes:
10
+ additionalProperties: false
11
+ required:
12
+ - postgres_stack
13
+ properties:
14
+ postgres_stack:
15
+ type: string
16
+ description: Stack fqdn for postgres patroni stack.
17
+ lxcs:
18
+ items:
19
+ required:
20
+ - vars
21
+ properties:
22
+ vars:
23
+ required:
24
+ - keepalived_master
25
+ properties:
26
+ keepalived_master:
27
+ description: One LXC should have this set to true the other to false.
28
+ type: boolean
@@ -0,0 +1,23 @@
1
+ title: "Schema ext setup_kea playbook"
2
+ properties:
3
+ plugin:
4
+ type: string
5
+ description: Id of ansible inventory plugin.
6
+ enum:
7
+ - pve.cloud.lxc_inv
8
+ lxcs:
9
+ items:
10
+ required:
11
+ - vars
12
+ properties:
13
+ parameters:
14
+ properties:
15
+ net0:
16
+ pattern: "\\bname=pve\\b"
17
+ vars:
18
+ required:
19
+ - kea_dhcp_main
20
+ properties:
21
+ kea_dhcp_main:
22
+ description: "Determines the lxc that will be the dhcp master instance. One lxc should be set to true, the other to false."
23
+ type: boolean
@@ -0,0 +1,102 @@
1
+ import os
2
+ import sys
3
+ import jsonschema
4
+ from importlib.resources import files
5
+ import yaml
6
+ from pathlib import Path
7
+ import shutil
8
+ import copy
9
+
10
+
11
+ def recursive_merge(dict1, dict2):
12
+ result = copy.deepcopy(dict1)
13
+
14
+ for key, value in dict2.items():
15
+ if key in result:
16
+ if isinstance(result[key], dict) and isinstance(value, dict):
17
+ result[key] = recursive_merge(result[key], value)
18
+
19
+ elif isinstance(result[key], list) and isinstance(value, list):
20
+ # merge lists uniquely while keeping order
21
+ seen = set()
22
+ new_list = []
23
+ for item in result[key] + value:
24
+ if item not in seen:
25
+ seen.add(item)
26
+ new_list.append(item)
27
+ result[key] = new_list
28
+
29
+ else:
30
+ result[key] = copy.deepcopy(value)
31
+ else:
32
+ result[key] = copy.deepcopy(value)
33
+
34
+ return result
35
+
36
+
37
+ # this method gets called indirectly via the pve_cloud ansible collection
38
+ # if there is a pve.cloud collection playbook is passed in the system args
39
+ # we can load a schema extension aswell
40
+ def validate_inventory(inventory):
41
+ # load base schema
42
+ base_schema_name = inventory["plugin"].removeprefix("pve.cloud.")
43
+
44
+ with (files("pve_cloud_schemas.definitions") / f"{base_schema_name}_schema.yaml").open("r") as f:
45
+ schema = yaml.safe_load(f)
46
+
47
+ called_pve_cloud_playbook = None
48
+ for arg in sys.argv:
49
+ if arg.startswith("pve.cloud."):
50
+ called_pve_cloud_playbook = arg.split('.')[-1].removeprefix("pve.cloud.")
51
+
52
+ if called_pve_cloud_playbook:
53
+ # playbook call look for schema extension
54
+ extension_file = files("pve_cloud_schemas.extensions") / f"{called_pve_cloud_playbook}_schema_ext.yaml"
55
+
56
+ if extension_file.is_file(): # schema extension exists
57
+ with extension_file.open("r") as f:
58
+ schema_ext = yaml.safe_load(f)
59
+
60
+ # merge with base schema
61
+ schema = recursive_merge(schema, schema_ext)
62
+
63
+
64
+ jsonschema.validate(instance=inventory, schema=schema)
65
+
66
+
67
+
68
+ def validate_inventory_file():
69
+ with open(sys.argv[1], "r") as f:
70
+ inventory = yaml.safe_load(f)
71
+
72
+ validate_inventory(inventory)
73
+
74
+
75
+ def dump_schemas():
76
+ dump_po = Path(sys.argv[1])
77
+ dump_po.mkdir(parents=True, exist_ok=True)
78
+
79
+ schemas = files("pve_cloud_schemas.definitions")
80
+ for schema in schemas.iterdir():
81
+ with schema.open("rb") as src, (dump_po / schema.name).open("wb") as dest:
82
+ shutil.copyfileobj(src, dest)
83
+
84
+ # map schemas to their plugin id
85
+ schema_map = {}
86
+
87
+ for schema in schemas.iterdir():
88
+ with schema.open("r") as f:
89
+ schema_loaded = yaml.safe_load(f)
90
+
91
+ schema_map[schema_loaded["properties"]["plugin"]["enum"][0]] = schema_loaded
92
+
93
+ # load schema extensions, merge and dump
94
+ for schema_ext in files("pve_cloud_schemas.extensions").iterdir():
95
+ with schema_ext.open("r") as f:
96
+ schema_ext_loaded = yaml.safe_load(f)
97
+
98
+ schema_merged = recursive_merge(schema_map[schema_ext_loaded["properties"]["plugin"]["enum"][0]], schema_ext_loaded)
99
+
100
+ # write it
101
+ with (dump_po / schema_ext.name).open("w") as f:
102
+ yaml.dump(schema_merged, f, sort_keys=False, indent=2)
@@ -0,0 +1,7 @@
1
+ Metadata-Version: 2.4
2
+ Name: pve-cloud-schemas
3
+ Version: 0.0.1
4
+ Author-email: Tobias Huebner <tobias.huebner@vmzberlin.com>
5
+ License-Expression: GPL-3.0-or-later
6
+ Requires-Dist: PyYAML==6.0.2
7
+ Requires-Dist: jsonschema==4.23.0
@@ -0,0 +1,21 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/pve_cloud_schemas/_version.py
4
+ src/pve_cloud_schemas/validate.py
5
+ src/pve_cloud_schemas.egg-info/PKG-INFO
6
+ src/pve_cloud_schemas.egg-info/SOURCES.txt
7
+ src/pve_cloud_schemas.egg-info/dependency_links.txt
8
+ src/pve_cloud_schemas.egg-info/entry_points.txt
9
+ src/pve_cloud_schemas.egg-info/requires.txt
10
+ src/pve_cloud_schemas.egg-info/top_level.txt
11
+ src/pve_cloud_schemas/definitions/awx_cloud_inv_schema.yaml
12
+ src/pve_cloud_schemas/definitions/kubespray_inv_schema.yaml
13
+ src/pve_cloud_schemas/definitions/lxc_inv_schema.yaml
14
+ src/pve_cloud_schemas/definitions/pve_cloud_inv_schema.yaml
15
+ src/pve_cloud_schemas/definitions/pve_inventory_schema.yaml
16
+ src/pve_cloud_schemas/definitions/qemu_inv_schema.yaml
17
+ src/pve_cloud_schemas/definitions/test_env_schema.yaml
18
+ src/pve_cloud_schemas/extensions/setup_bind_schema_ext.yaml
19
+ src/pve_cloud_schemas/extensions/setup_ceph_kea_schema_ext.yaml
20
+ src/pve_cloud_schemas/extensions/setup_haproxy_schema_ext.yaml
21
+ src/pve_cloud_schemas/extensions/setup_kea_schema_ext.yaml
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ pcval = pve_cloud_schemas.validate:validate_inventory_file
3
+ pcval-dump = pve_cloud_schemas.validate:dump_schemas
@@ -0,0 +1,2 @@
1
+ PyYAML==6.0.2
2
+ jsonschema==4.23.0
@@ -0,0 +1 @@
1
+ pve_cloud_schemas