1. Answers
  2. Centralized Management of On-Prem Nodes

How do I set up centralized management of on-prem nodes?

In this guide, we will set up centralized management of on-premises nodes using Pulumi. We will use Pulumi’s command provider to manage the on-prem nodes by executing remote commands and copying files to them. This setup allows you to manage your on-prem infrastructure as code, providing reproducibility, version control, and collaboration across your team.

import * as pulumi from "@pulumi/pulumi";
import * as command from "@pulumi/command";

// Define the connection details for the on-prem node
const connection = {
    host: "192.168.1.100", // Replace with your node's IP address
    user: "admin", // Replace with your node's username
    privateKey: "path/to/private/key", // Path to the private key for SSH authentication
};

// Copy a configuration file to the on-prem node
const copyConfigFile = new command.remote.CopyFile("copyConfigFile", {
    connection: connection,
    localPath: "./config.yaml", // Path to the local configuration file
    remotePath: "/etc/config.yaml", // Path on the remote node where the file will be copied
});

// Execute a command on the on-prem node to apply the configuration
const applyConfig = new command.remote.Command("applyConfig", {
    connection: connection,
    create: "sudo systemctl restart my-service", // Command to apply the new configuration
}, { dependsOn: copyConfigFile });

// Export the remote path of the copied file
export const remoteConfigPath = copyConfigFile.remotePath;

Key Points

  • Connection Details: The connection details for the on-prem node are defined using the connection object, which includes the host, user, and private key.
  • Copying Files: The command.remote.CopyFile resource is used to copy a local configuration file to the on-prem node.
  • Executing Commands: The command.remote.Command resource is used to execute a command on the on-prem node to apply the new configuration.
  • Dependencies: The applyConfig command depends on the successful completion of the copyConfigFile operation.

Summary

In this guide, we set up centralized management of on-prem nodes using Pulumi. We defined connection details for an on-prem node, copied a configuration file to the node, and executed a command to apply the configuration. This setup allows you to manage your on-prem infrastructure as code, providing a consistent and automated approach to infrastructure management.

Deploy this code

Want to deploy this code? Sign up for a free Pulumi account to deploy in a few clicks.

Sign up

New to Pulumi?

Want to deploy this code? Sign up with Pulumi to deploy in a few clicks.

Sign up