Installation#

Overview#

The Rancher2 provider is used to interact with the resources supported by Rancher v2.

The provider can be configured in 2 modes:

  • Admin: this is the default mode, intended to manage rancher2 resources. It should be configured with the apiUrl of the Rancher server and API credentials, tokenKey or accessKey and secretKey.
  • Bootstrap: this mode is intended to bootstrap a rancher2 system. It is enabled if bootstrap = true. In this mode, tokenKey or accessKey and secretKey can not be provided. More info at rancher2.Bootstrap resource

Example Usage#

# Pulumi.yaml provider configuration file
name: configuration-example
runtime:
config:
    rancher2:accessKey:
        value: 'TODO: var.rancher2_access_key'
    rancher2:apiUrl:
        value: https://rancher.my-domain.com
    rancher2:secretKey:
        value: 'TODO: var.rancher2_secret_key'
 
# Pulumi.yaml provider configuration file
name: configuration-example
runtime:
config:
    rancher2:apiUrl:
        value: https://rancher.my-domain.com
    rancher2:bootstrap:
        value: true
 

{{< chooser language "typescript,python,go,csharp,java,yaml,hcl" >}} {{% choosable language typescript %}}

import * as pulumi from "@pulumi/pulumi";
import * as rancher2 from "@pulumi/rancher2";
 
// Create a new rancher2_bootstrap using bootstrap provider config
const admin = new rancher2.Bootstrap("admin", {password: "blahblah"});
// Create a new rancher2 resource using admin provider config
const foo = new rancher2.index.Catalog("foo", {
    name: "test",
    url: "http://foo.com:8080",
});

{{% /choosable %}} {{% choosable language python %}}

import pulumi
import pulumi_rancher2 as rancher2
 
# Create a new rancher2_bootstrap using bootstrap provider config
admin = rancher2.Bootstrap("admin", password="blahblah")
# Create a new rancher2 resource using admin provider config
foo = rancher2.Catalog("foo",
    name=test,
    url=http://foo.com:8080)

{{% /choosable %}} {{% choosable language csharp %}}

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Rancher2 = Pulumi.Rancher2;
 
return await Deployment.RunAsync(() =>
{
    // Create a new rancher2_bootstrap using bootstrap provider config
    var admin = new Rancher2.Bootstrap("admin", new()
    {
        Password = "blahblah",
    });
 
    // Create a new rancher2 resource using admin provider config
    var foo = new Rancher2.Catalog("foo", new()
    {
        Name = "test",
        Url = "http://foo.com:8080",
    });
 
});
 

{{% /choosable %}} {{% choosable language go %}}

package main
 
import (
	"github.com/pulumi/pulumi-rancher2/sdk/v12/go/rancher2"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
 
func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		// Create a new rancher2_bootstrap using bootstrap provider config
		_, err := rancher2.NewBootstrap(ctx, "admin", &rancher2.BootstrapArgs{
			Password: pulumi.String("blahblah"),
		})
		if err != nil {
			return err
		}
		// Create a new rancher2 resource using admin provider config
		_, err = rancher2.NewCatalog(ctx, "foo", &rancher2.CatalogArgs{
			Name: "test",
			Url:  "http://foo.com:8080",
		})
		if err != nil {
			return err
		}
		return nil
	})
}

{{% /choosable %}} {{% choosable language yaml %}}

resources:
  # Create a new rancher2_bootstrap using bootstrap provider config
  admin:
    type: rancher2:Bootstrap
    properties:
      password: blahblah
  # Create a new rancher2 resource using admin provider config
  foo:
    type: rancher2:Catalog
    properties:
      name: test
      url: http://foo.com:8080

{{% /choosable %}} {{% choosable language java %}}

package generated_program;
 
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.rancher2.Bootstrap;
import com.pulumi.rancher2.BootstrapArgs;
import com.pulumi.rancher2.Catalog;
import com.pulumi.rancher2.CatalogArgs;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
 
public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }
 
    public static void stack(Context ctx) {
        // Create a new rancher2_bootstrap using bootstrap provider config
        var admin = new Bootstrap("admin", BootstrapArgs.builder()
            .password("blahblah")
            .build());
 
        // Create a new rancher2 resource using admin provider config
        var foo = new Catalog("foo", CatalogArgs.builder()
            .name("test")
            .url("http://foo.com:8080")
            .build());
 
    }
}

{{% /choosable %}} {{% choosable language hcl %}}

pulumi {
  required_providers {
    rancher2 = {
      source = "pulumi/rancher2"
    }
  }
}
 
# Create a new rancher2_bootstrap using bootstrap provider config
resource "rancher2_bootstrap" "admin" {
  password = "blahblah"
}
# Create a new rancher2 resource using admin provider config
resource "rancher2_catalog" "foo" {
  name = "test"
  url  = "http://foo.com:8080"
}

{{% /choosable %}} {{< /chooser >}}

Configuration Reference#

The following configuration inputs are supported:

  • apiUrl - (Required) Rancher API url. It must be provided, but it can also be sourced from the RANCHER_URL environment variable.
  • accessKey - (Optional/Sensitive) Rancher API access key to connect to rancher. It can also be sourced from the RANCHER_ACCESS_KEY environment variable.
  • secretKey - (Optional/Sensitive) Rancher API secret key to connect to rancher. It can also be sourced from the RANCHER_SECRET_KEY environment variable.
  • tokenKey - (Optional/Sensitive) Rancher API token key to connect to rancher. It can also be sourced from the RANCHER_TOKEN_KEY environment variable. Could be used instead accessKey and secretKey.
  • caCerts - CA certificates used to sign Rancher server tls certificates. Mandatory if self signed tls and insecure option false. It can also be sourced from the RANCHER_CA_CERTS environment variable.
  • insecure - (Optional) Allow insecure connection to Rancher. Mandatory if self signed tls and not caCerts provided. It can also be sourced from the RANCHER_INSECURE environment variable.
  • bootstrap - (Optional) Enable bootstrap mode to manage rancher2.Bootstrap resource. It can also be sourced from the RANCHER_BOOTSTRAP environment variable. Default: false
  • retries - (Deprecated) Use timeout instead
  • timeout - (Optional) Timeout duration to retry for Rancher connectivity and resource operations. Default: "120s"

Was this page helpful?