Experimental Proxmox / Docker compose tool
compose proxmox docker
0

Configure Feed

Select the types of activity you want to include in your feed.

stuff n thigns

author
ollie
date (Jul 23, 2026, 9:31 PM +0200) commit e80259d1 parent 0bf6537e change-id pnrpynkl
+78 -7
+78 -7
src/proxpose.gleam
··· 21 21 import proxpose/configuration 22 22 import proxpose/humanise as prox_humanise 23 23 import proxpose/proxmox 24 + import proxpose/proxmox/lxc 24 25 import proxpose/ssh 25 26 import simplifile 26 27 import snag ··· 539 540 ) -> glint.Command(Result(String, Error)) { 540 541 use <- glint.command_help("Deploy a new machine.") 541 542 543 + use ignore_tls <- glint.flag(ignore_tls_flag()) 542 544 use name <- glint.named_arg("name") 543 545 544 - use named, _, _ <- glint.command() 546 + use named, _, flags <- glint.command() 545 547 546 548 use config <- with_configuration(env) 549 + use ignore_tls <- with_flag(ignore_tls(flags)) 550 + let verify_tls = !ignore_tls 547 551 548 552 let name = name(named) 549 553 550 - use _ <- result.try(do_new_machine(config, name)) 554 + use _ <- result.try(do_new_machine(config, verify_tls, name)) 551 555 552 556 Ok( 553 557 "Successfully deployed machine {{name}}" ··· 557 561 558 562 fn do_new_machine( 559 563 config: configuration.Configuration, 564 + verify_tls: Bool, 560 565 name: String, 561 - ) -> Result(a, Error) { 566 + ) -> Result(_, Error) { 567 + use machines <- result.try(all_machines(config, verify_tls)) 568 + 562 569 // check if machine already exists 570 + case list.find(machines, fn(machine) { machine.name == name }) { 571 + Ok(container) -> Error(MachineExists(container)) 572 + Error(_) -> { 573 + // create machine 574 + use vmid <- result.try(next_vmid(config, verify_tls)) 563 575 564 - // create machine 576 + default_lxc(vmid, name, storage: todo, filename: todo, memory: todo) 577 + 578 + todo as "create machine" 579 + todo as "wait for container to be created" 580 + } 581 + } 582 + } 583 + 584 + fn next_vmid( 585 + config: configuration.Configuration, 586 + verify_tls: Bool, 587 + ) -> Result(Int, Error) { 588 + let credentials = credentials_from_configuration(config) 589 + 590 + do_request( 591 + proxmox.vmid_next(host: config.proxmox_host, credentials:), 592 + verify_tls, 593 + proxmox.vmid_next_response, 594 + ) 595 + } 596 + 597 + fn default_lxc( 598 + vmid vmid: Int, 599 + name name: String, 600 + storage storage: option.Option(String), 601 + filename filename: option.Option(String), 602 + memory memory: option.Option(Int), 603 + ) { 604 + lxc.new( 605 + vmid, 606 + lxc.Template( 607 + storage: option.unwrap(storage, "local"), 608 + filename: option.unwrap( 609 + filename, 610 + "nixos-image-lxc-proxmox-25.11.x86_64.tar.xz", 611 + ), 612 + ), 613 + ) 614 + |> lxc.with_hostname(name) 615 + } 565 616 566 - // 617 + fn all_machines(config: configuration.Configuration, verify_tls: Bool) { 618 + let credentials = credentials_from_configuration(config) 567 619 568 - todo 620 + use nodes <- result.try(do_request( 621 + proxmox.nodes(host: config.proxmox_host, credentials:), 622 + verify_tls, 623 + proxmox.nodes_response, 624 + )) 625 + 626 + list.map(nodes, fn(node) { 627 + do_request( 628 + proxmox.containers( 629 + host: config.proxmox_host, 630 + credentials:, 631 + node: node.name, 632 + ), 633 + verify_tls, 634 + proxmox.containers_response, 635 + ) 636 + }) 637 + |> result.all() 638 + |> result.map(list.flatten) 569 639 } 570 640 571 641 fn show_config_command( ··· 742 812 ApiError(proxmox.ApiError) 743 813 RequestFailed(httpc.HttpError) 744 814 NoMatch 815 + MachineExists(proxmox.Container) 745 816 } 746 817 747 818 type File { ··· 781 852 782 853 Ok( 783 854 "Successfully created {{name}} 784 - You can now configure the compose file and .env in {{compose_directory}}/{{name}}. 855 + You can now configure the compose file and .env in {{compose_directory}}{{name}}. 785 856 786 857 Then once you have it configured run the 'deploy' command" 787 858 |> string.replace("{{compose_directory}}", config.compose_directory)