Defined Type: rustup::exec

Defined in:
manifests/exec.pp

Summary

Run a `rustup` command

Overview

The name should start with the username followed by a colon and a space, then the command. For example:

“‘puppet rustup::exec { ’daniel: rustup default nightly’: } “‘

[‘exec`]: puppet.com/docs/puppet/latest/types/exec.html

Parameters:

  • user (String[1]) (defaults to: $name.split(': ')[0])

    The user to run as. Automatically set if the ‘$name` of the resource follows the rules above.

  • command (String[1]) (defaults to: $name.split(': ')[1])

    The command to run, e.g. ‘rustup default stable’. Automatically set if the ‘$name` of the resource follows the rules above.

  • creates (Optional[String[1]]) (defaults to: undef)

    Only run when if this path does not exist. (See [‘exec`] documentation.)

  • environment (Array[String[1]]) (defaults to: [])

    Additional environment variables to set beyond ‘RUSTUP_HOME`, `CARGO_HOME`, and `PATH`.

  • onlyif (Rustup::OptionalStringOrArray) (defaults to: undef)

    Only run when ‘$onlyif` returns success. (See [`exec`] documentation.)

  • refreshonly (Boolean) (defaults to: false)

    Only run this when it receives an event. (See [‘exec`] documentation.)

  • unless (Rustup::OptionalStringOrArray) (defaults to: undef)

    Only run when ‘$unless` returns failure. (See [`exec`] documentation.)

  • home (Stdlib::Absolutepath) (defaults to: rustup::home($user))

    The user’s home directory. This defaults to ‘/home/$user` on Linux and `/Users/$user` on macOS. This is only used to calculate defaults for the `$rustup_home` and `$cargo_home` parameters.

  • rustup_home (Stdlib::Absolutepath) (defaults to: "${home}/.rustup")

    Where toolchains are installed. Generally you shouldn’t change this.

  • cargo_home (Stdlib::Absolutepath) (defaults to: "${home}/.cargo")

    Where ‘cargo` installs executables. Generally you shouldn’t change this.

  • bin (Stdlib::Absolutepath) (defaults to: "${cargo_home}/bin")

    Where ‘rustup` installs proxy executables. Generally you shouldn’t change this.

  • more (Hash[String[1], Any]) (defaults to: {})

    Other parameters to pass to exec. They may override any of the other parameters.



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'manifests/exec.pp', line 43

define rustup::exec (
  String[1]                     $user        = $name.split(': ')[0],
  String[1]                     $command     = $name.split(': ')[1],
  Optional[String[1]]           $creates     = undef,
  Array[String[1]]              $environment = [],
  Rustup::OptionalStringOrArray $onlyif      = undef,
  Boolean                       $refreshonly = false,
  Rustup::OptionalStringOrArray $unless      = undef,
  Stdlib::Absolutepath          $home        = rustup::home($user),
  Stdlib::Absolutepath          $rustup_home = "${home}/.rustup",
  Stdlib::Absolutepath          $cargo_home  = "${home}/.cargo",
  Stdlib::Absolutepath          $bin         = "${cargo_home}/bin",
  Hash[String[1], Any]          $more        = {},
) {
  $params = {
    command     => $command,
    creates     => $creates,
    environment => [
      "RUSTUP_HOME=${rustup_home}",
      "CARGO_HOME=${cargo_home}",
    ] + $environment,
    onlyif      => $onlyif,
    path        => "${bin}:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
    refreshonly => $refreshonly,
    'unless'    => $unless,
    user        => $user,
  }

  File <| name == $rustup_home or name == $cargo_home |>
  -> exec { "rustup::exec: ${name}":
    * => $params + $more,
  }

  # Generally exec requires an installation...
  Rustup_internal <| |> -> Exec["rustup::exec: ${name}"]
  # ...except when the installation is being deleted. In that case, the exec
  # probably doesn’t need to run. Making the exec dependent on `rustup` being
  # installed can help:
  #
  #     onlyif => "sh -c 'command -v rustup &>/dev/null' && ...",
}