UNPKG

@muhlba91/pulumi-proxmoxve

Version:

A Pulumi package for creating and managing Proxmox Virtual Environment cloud resources.

266 lines 11 kB
"use strict"; // *** WARNING: this file was generated by pulumi-language-nodejs. *** // *** Do not edit by hand unless you're certain you know what you are doing! *** var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.FileLegacy = void 0; const pulumi = __importStar(require("@pulumi/pulumi")); const utilities = __importStar(require("./utilities")); /** * Use this resource to upload files to a Proxmox VE node. The file can be a backup, an ISO image, a Disk Image, a snippet, or a container template depending on the `contentType` attribute. * * ## Example Usage * * ### Backups (`backup`) * * > The resource with this content type uses SSH access to the node. You might need to configure the `ssh` option in the `provider` section. * * > The provider currently does not support restoring backups. You can use the Proxmox VE web interface or the `qmrestore` / `pct restore` command to restore VM / Container from a backup. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as proxmoxve from "@muhlba91/pulumi-proxmoxve"; * * const backup = new proxmoxve.FileLegacy("backup", { * contentType: "backup", * datastoreId: "local", * nodeName: "pve", * sourceFile: { * path: "vzdump-lxc-100-2023_11_08-23_10_05.tar.zst", * }, * }); * ``` * * ### Images * * > Consider using `proxmoxve.download.FileLegacy` resource instead. Using this resource for images is less efficient (requires to transfer uploaded image to node) though still supported. * * > The `import` content type is not enabled by default on Proxmox VE storages. To use this resource with `contentType = "import"`, first add `Import` to the allowed content types on the target storage under 'Datacenter > Storage' in the Proxmox web interface. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as proxmoxve from "@muhlba91/pulumi-proxmoxve"; * * const ubuntuContainerTemplate = new proxmoxve.FileLegacy("ubuntu_container_template", { * contentType: "iso", * datastoreId: "local", * nodeName: "pve", * sourceFile: { * path: "https://cloud-images.ubuntu.com/jammy/20230929/jammy-server-cloudimg-amd64-disk-kvm.img", * }, * }); * ``` * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as proxmoxve from "@muhlba91/pulumi-proxmoxve"; * * const ubuntuContainerTemplate = new proxmoxve.FileLegacy("ubuntu_container_template", { * contentType: "import", * datastoreId: "local", * nodeName: "pve", * sourceFile: { * path: "https://cloud-images.ubuntu.com/jammy/20230929/jammy-server-cloudimg-amd64-disk-kvm.img", * }, * }); * ``` * * ### Snippets * * > Snippets are not enabled by default in new Proxmox installations. You need to enable them in the 'Datacenter>Storage' section of the proxmox interface before first using this resource. * * > The resource with this content type uses SSH access to the node. You might need to configure the `ssh` option in the `provider` section. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as proxmoxve from "@muhlba91/pulumi-proxmoxve"; * import * as std from "@pulumi/std"; * * const cloudConfig = new proxmoxve.FileLegacy("cloud_config", { * contentType: "snippets", * datastoreId: "local", * nodeName: "pve", * sourceRaw: { * data: std.trimspace({ * input: example.publicKeyOpenssh, * }).then(invoke => `#cloud-config * chpasswd: * list: | * ubuntu:example * expire: false * hostname: example-hostname * packages: * - qemu-guest-agent * users: * - default * - name: ubuntu * groups: sudo * shell: /bin/bash * ssh-authorized-keys: * - ${invoke.result} * sudo: ALL=(ALL) NOPASSWD:ALL * `), * fileName: "example.cloud-config.yaml", * }, * }); * ``` * * The `fileMode` attribute can be used to make a script file executable, e.g. when referencing the file in the `hookScriptFileId` attribute of [a container](https://bpg.sh/docs/resources/virtual_environment_container#hook-script-file-id) or [a VM](https://bpg.sh/docs/resources/virtual_environment_vm#hook-script-file-id) resource which is a requirement enforced by the Proxmox VE API. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as proxmoxve from "@muhlba91/pulumi-proxmoxve"; * * const hookScript = new proxmoxve.FileLegacy("hook_script", { * contentType: "snippets", * datastoreId: "local", * nodeName: "pve", * fileMode: "0700", * sourceRaw: { * data: `#!/usr/bin/env bash * * echo \\"Running hook script\\" * `, * fileName: "prepare-hook.sh", * }, * }); * ``` * * ### Container Template (`vztmpl`) * * > Consider using `proxmoxve.download.FileLegacy` resource instead. Using this resource for container images is less efficient (requires to transfer uploaded image to node) though still supported. * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as proxmoxve from "@muhlba91/pulumi-proxmoxve"; * * const ubuntuContainerTemplate = new proxmoxve.FileLegacy("ubuntu_container_template", { * contentType: "vztmpl", * datastoreId: "local", * nodeName: "first-node", * sourceFile: { * path: "http://download.proxmox.com/images/system/ubuntu-20.04-standard_20.04-1_amd64.tar.gz", * }, * }); * ``` * * ## Important Notes * * The Proxmox VE API endpoint for file uploads does not support chunked transfer * encoding, which means that we must first store the source file as a temporary * file locally before uploading it. * * You must ensure that you have at least `Size-in-MB * 2 + 1` MB of storage space * available (twice the size plus overhead because a multipart payload needs to be * created as another temporary file). * * By default, if the specified file already exists, the resource will * unconditionally replace it and take ownership of the resource. On destruction, * the file will be deleted as if it did not exist before. If you want to prevent * the resource from replacing the file, set `overwrite` to `false`. * * ## Import * * Instances can be imported using the `nodeName`, `datastoreId`, `contentType` * and the `fileName` in the following format: * * Example: * * ```sh * $ pulumi import proxmoxve:index/fileLegacy:FileLegacy cloud_config pve/local:snippets/example.cloud-config.yaml * ``` */ class FileLegacy extends pulumi.CustomResource { /** * Get an existing FileLegacy resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state Any extra arguments used during the lookup. * @param opts Optional settings to control the behavior of the CustomResource. */ static get(name, id, state, opts) { return new FileLegacy(name, state, { ...opts, id: id }); } /** @internal */ static __pulumiType = 'proxmoxve:index/fileLegacy:FileLegacy'; /** * Returns true if the given object is an instance of FileLegacy. This is designed to work even * when multiple copies of the Pulumi SDK have been loaded into the same process. */ static isInstance(obj) { if (obj === undefined || obj === null) { return false; } return obj['__pulumiType'] === FileLegacy.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["contentType"] = state?.contentType; resourceInputs["datastoreId"] = state?.datastoreId; resourceInputs["fileMode"] = state?.fileMode; resourceInputs["fileModificationDate"] = state?.fileModificationDate; resourceInputs["fileName"] = state?.fileName; resourceInputs["fileSize"] = state?.fileSize; resourceInputs["fileTag"] = state?.fileTag; resourceInputs["nodeName"] = state?.nodeName; resourceInputs["overwrite"] = state?.overwrite; resourceInputs["sourceFile"] = state?.sourceFile; resourceInputs["sourceRaw"] = state?.sourceRaw; resourceInputs["timeoutUpload"] = state?.timeoutUpload; resourceInputs["uploadMode"] = state?.uploadMode; } else { const args = argsOrState; if (args?.datastoreId === undefined && !opts.urn) { throw new Error("Missing required property 'datastoreId'"); } if (args?.nodeName === undefined && !opts.urn) { throw new Error("Missing required property 'nodeName'"); } resourceInputs["contentType"] = args?.contentType; resourceInputs["datastoreId"] = args?.datastoreId; resourceInputs["fileMode"] = args?.fileMode; resourceInputs["nodeName"] = args?.nodeName; resourceInputs["overwrite"] = args?.overwrite; resourceInputs["sourceFile"] = args?.sourceFile; resourceInputs["sourceRaw"] = args?.sourceRaw; resourceInputs["timeoutUpload"] = args?.timeoutUpload; resourceInputs["uploadMode"] = args?.uploadMode; resourceInputs["fileModificationDate"] = undefined /*out*/; resourceInputs["fileName"] = undefined /*out*/; resourceInputs["fileSize"] = undefined /*out*/; resourceInputs["fileTag"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(FileLegacy.__pulumiType, name, resourceInputs, opts); } } exports.FileLegacy = FileLegacy; //# sourceMappingURL=fileLegacy.js.map