muhlba91/pulumi-proxmoxve

[AUTH] Problem with authentication

Opened this issue · 3 comments

Hello, this is my first time trying pulumi, i have proxmox server laying around and decided to give this a try.

i have check that

  • i have followed the configuration steps ✔️
  • no similar post in the issue section ✔️

I have an issue while trying to run the pulumi, i got this error

> pulumi up 
Please choose a stack, or create a new one: dev
Enter your passphrase to unlock config/secrets
    (set PULUMI_CONFIG_PASSPHRASE or PULUMI_CONFIG_PASSPHRASE_FILE to remember):  
Enter your passphrase to unlock config/secrets
Previewing update (dev):
     Type                            Name   Plan     Info
     pulumi:pulumi:Stack             a-dev           
     └─ proxmoxve:VM:VirtualMachine  vm              1 error

Diagnostics:
  proxmoxve:VM:VirtualMachine (vm):
    error: 2 errors occurred:
        * 1 error occurred:
        * must provide either user credentials, an API token, or a ticket
    
    
        * Unable to create Proxmox VE API credentials: must provide either user credentials, an API token, or a ticket

I have problem resolving this issue as I tried to console.log the content of the env var and it was set correctly

to reproduce

  1. run pulumi login --local
  2. run pulumi new typescript
  3. run yarn add @muhlba91/pulumi-proxmoxve
  4. update index.ts
  5. run pulumi up

for more context this was my env config and my index.ts file

export PROXMOX_VE_ENDPOINT=https://192.168.1.100:8006/
export PROXMOX_VE_USERNAME=root
export PROXMOX_VE_PASSWORD=*******
export PROXMOX_VE_INSECURE=true
import * as pulumi from "@pulumi/pulumi";
import * as proxmox from "@muhlba91/pulumi-proxmoxve";

const provider = new proxmox.Provider("proxmoxve", {
  endpoint: process.env.PROXMOX_VE_ENDPOINT,
  insecure: true,
  username: process.env.PROXMOX_VE_USERNAME,
  password: process.env.PROXMOX_VE_PASSWORD,
});

const virtualMachine = new proxmox.vm.VirtualMachine(
  "vm",
  {
    nodeName: "pve1",
    agent: {
      enabled: false,
      trim: true,
      type: "virtio",
    },
    bios: "seabios",
    cpu: {
      cores: 1,
      sockets: 1,
    },
    clone: {
      nodeName: "pve1",
      vmId: 9000,
      full: true,
    },
    disks: [
      {
        interface: "scsi0",
        datastoreId: "local-lvm",
        size: 32,
        fileFormat: "qcow2",
      },
    ],
    memory: {
      dedicated: 1024,
    },
    name: "proxmox-vm",
    networkDevices: [
      {
        bridge: "vmbr0",
        model: "virtio",
      },
    ],
    onBoot: true,
    initialization: {
      type: "nocloud",
      datastoreId: "local-lvm",
      dns: {
        domain: "example.com",
        server: "1.1.1.1 1.0.0.1",
      },
    },
  },
  { provider },
);

versions

  • pulumi v3.137.0
  • proxmoxve plugin v6.15.1
  • node v18.20.0

would appreciate any kind of help, thanks!

hi,

Your environment variables look good to me. theoretically, you can omit initializing and passing in a new provider. these environment variables will be considered by default when the provider is used.

did you check printing (console.log) the environment variables to ensure they are correct during the execution of the program?

...
console.log(process.env.PROXMOX_VE_ENDPOINT);
console.log(process.env.PROXMOX_VE_USERNAME);
console.log(process.env.PROXMOX_VE_PASSWORD);
console.log(process.env.PROXMOX_VE_INSECURE);
...

if they are set correctly, can you try to omit the initialization and passing of the provider?

import * as pulumi from "@pulumi/pulumi";
import * as proxmox from "@muhlba91/pulumi-proxmoxve";

const virtualMachine = new proxmox.vm.VirtualMachine(
  "vm",
  {
    nodeName: "pve1",
    agent: {
      enabled: false,
      trim: true,
      type: "virtio",
    },
    bios: "seabios",
    cpu: {
      cores: 1,
      sockets: 1,
    },
    clone: {
      nodeName: "pve1",
      vmId: 9000,
      full: true,
    },
    disks: [
      {
        interface: "scsi0",
        datastoreId: "local-lvm",
        size: 32,
        fileFormat: "qcow2",
      },
    ],
    memory: {
      dedicated: 1024,
    },
    name: "proxmox-vm",
    networkDevices: [
      {
        bridge: "vmbr0",
        model: "virtio",
      },
    ],
    onBoot: true,
    initialization: {
      type: "nocloud",
      datastoreId: "local-lvm",
      dns: {
        domain: "example.com",
        server: "1.1.1.1 1.0.0.1",
      },
    },
  },
);

I'm getting the same issue with both reproduction

@ndabwn can you try with

export PROXMOX_VE_USERNAME=root@pam

@tanguc well spotted - i agree that this could be the cause.
@ndabwn any updates with this suggestion?