golang
: Install go in/usr/local/go
and/usr/local/bin
golang::from_tarball
: Install Go from a binary tarballgolang::installation
: Install Go in a local directorygolang::linked_binaries
: Link binaries from Go installation into a directory
golang::latest_version
: Get the lastest stable version number for Gogolang::state_file
: Figure out the default state file path for a given$go_dir
Golang::Ensure
: Valid ensure values forgolang::installation
Golang::Version
: A Go version
Most people will not need to change any parameter other than perhaps setting
$ensure
to latest
.
The following parameters are available in the golang
class:
Data type: Golang::Ensure
present
: Make sure any version of Go is installed.latest
: Make sure the latest stable version of Go is installed.absent
: Make sure Go is uninstalled.- version: Make sure exactly the specified version of Go is installed.
For example,
'1.19.1'
.
Default value: present
Data type: Optional[Golang::Version]
Deprecated. Use $ensure
instead. If this parameter is set it will only
be honored if $ensure
is present
.
Default value: undef
Data type: Array[String[1]]
The binaries to symlink into /usr/local/bin
.
Default value: ['go', 'gofmt']
Data type: Stdlib::HTTPUrl
URL to directory that contains the archive to download.
Default value: 'https://go.dev/dl'
Data type: String[1]
The OS to use to determine what archive to download.
Default value:
$facts['kernel'] ? {
'Linux' => 'linux',
'Darwin' => 'darwin',
default => $facts['kernel']
Data type: String[1]
The architecture to use to determine what archive to download.
Default value:
$facts['os']['hardware'] ? {
undef => 'amd64', # Assume amd64 if os.hardware is missing.
'aarch64' => 'arm64',
'armv7l' => 'armv6l',
'i686' => '386',
'x86_64' => 'amd64',
default => $facts['os']['hardware']
Data type: Optional[Stdlib::HTTPUrl]
Deprecated. Use golang::from_tarball
instead:
golang::from_tarball { '/usr/local/go':
ensure => $ensure,
source => $source,
}
golang::linked_binaries { '/usr/local/go':
ensure => $ensure,
into_bin => '/usr/local/bin',
}
If this is set it overrides everything else except $ensure == absent
.
Default value: undef
Install Go from a binary tarball
golang::from_tarball { '/usr/local/go':
source => 'https://go.dev/dl/go1.19.1.darwin-amd64.tar.gz',
}
golang::from_tarball { '/home/user/go/go':
source => 'https://go.dev/dl/go1.19.1.darwin-amd64.tar.gz',
}
The following parameters are available in the golang::from_tarball
defined type:
Data type: Stdlib::HTTPUrl
The URL to the binary tarball to install. If the URL changes and $ensure
is present
, $go_dir
will be wiped and the new tarball will be installed.
Data type: Enum[present, any_version, absent]
present
: Make sure Go is installed from$source
.any_version
: Make sure Go is installed regardless of what version it is. This will not upgrade Go if$source
changes.absent
: Make sure Go is uninstalled.
Default value: present
Data type: Stdlib::Unixpath
The path where the tarball should be installed. This path will be managed by this resource.
Default value: $name
Data type: Variant[String[1], Integer[0]]
The user that should own $go_dir
. May be a user name or a UID.
Default value: $facts['identity']['user']
Data type: Variant[String[1], Integer[0]]
The group that should own $go_dir
. May be a group name or a GID.
Default value: $facts['identity']['group']
Data type: String[1]
The mode for $go_dir
.
Default value: '0755'
Data type: Stdlib::Unixpath
Where to store state information.
This file will contain the URL to the tarball. If the file contents don’t
match the URL passed in $source
, then we know that we need to download the
tarball and replace the installation.
This defaults to a file in the same directory as $go_dir
, but with a .
prefix and a .source_url
suffix. For example, if $go_dir
is
'/usr/local/go'
, then this will default to '/usr/local/.go.source_url'
.
Default value: golang::state_file($go_dir)
Install Go in a local directory
golang::installation { '/usr/local/go': }
golang::installation { '/home/user/go/go':
ensure => latest,
owner => 'user',
group => 'user',
}
golang::installation { '/usr/local/go-1.19.1':
ensure => '1.19.1',
}
The following parameters are available in the golang::installation
defined type:
Data type: Golang::Ensure
present
: Make sure any version of Go is installed.latest
: Make sure the latest stable version of Go is installed.absent
: Make sure Go is uninstalled.- version: Make sure exactly the specified version of Go is installed.
For example,
'1.19.1'
.
Default value: present
Data type: Stdlib::Unixpath
The path where Go should be installed. This path will be managed by
golang::from_tarball
.
Default value: $name
Data type: Stdlib::HTTPUrl
URL to directory that contains the archive to download.
Default value: 'https://go.dev/dl'
Data type: String[1]
The OS to use to determine what archive to download.
Default value:
$facts['kernel'] ? {
'Linux' => 'linux',
'Darwin' => 'darwin',
default => $facts['kernel']
Data type: String[1]
The architecture to use to determine what archive to download.
Default value:
$facts['os']['hardware'] ? {
undef => 'amd64', # Assume amd64 if os.hardware is missing.
'aarch64' => 'arm64',
'armv7l' => 'armv6l',
'i686' => '386',
'x86_64' => 'amd64',
default => $facts['os']['hardware']
Data type: Variant[String[1], Integer[0]]
The user that should own $go_dir
. May be a user name or a UID.
Default value: $facts['identity']['user']
Data type: Variant[String[1], Integer[0]]
The group that should own $go_dir
. May be a group name or a GID.
Default value: $facts['identity']['group']
Data type: String[1]
The mode for $go_dir
.
Default value: '0755'
Data type: Stdlib::Unixpath
Where to store state information.
This file will contain the URL to the tarball. If the file contents don’t match the URL we generate, then we know that we need to download the tarball and replace the installation.
This defaults to a file in the same directory as $go_dir
, but with a .
prefix and a .source_url
suffix. For example, if $go_dir
is
'/usr/local/go'
, then this will default to '/usr/local/.go.source_url'
.
Default value: golang::state_file($go_dir)
Link binaries from Go installation into a directory
golang::linked_binaries { '/usr/local/go':
into_bin => '/usr/local/bin',
}
golang::linked_binaries { '/home/user/go/go':
into_bin => '/home/user/bin',
}
The following parameters are available in the golang::linked_binaries
defined type:
Data type: Stdlib::Unixpath
The directory to link the binaries into.
Data type: Enum[present, absent]
present
: Make sure links are present.absent
: Make sure links are absent.
Default value: present
Data type: Stdlib::Unixpath
The directory where Go is installed.
Default value: $name
Data type: Array[String[1]]
The binaries to link.
Default value: ['go', 'gofmt']
Type: Ruby 4.x API
Makes a request to the passed URL to find the latest stable version of Go. The request will be cached for 10 minutes, so repeated calls to this function will return the same thing for at least that amount of time.
Makes a request to the passed URL to find the latest stable version of Go. The request will be cached for 10 minutes, so repeated calls to this function will return the same thing for at least that amount of time.
Returns: Golang::Version
The version number, e.g. '1.19.1'
.
Raises:
Puppet::Error
If the URL is invalid, the request failed, it didn’t understand the returned JSON, or it couldn’t find a version that was listed as stable.
Data type: Stdlib::HTTPUrl
The URL to check. This should usually be 'https://go.dev/dl/?mode=json'
unless you are getting Go from elsewhere.
Type: Puppet Language
The location must be outside of $go_dir
, and it must be writable by the
same user (if Puppet is not being run as root).
The location must be outside of $go_dir
, and it must be writable by the
same user (if Puppet is not being run as root).
Returns: Stdlib::Absolutepath
Where to store the state file by default
Raises:
Puppet::Error
If$go_dir
is'/'
or a few other things, this will fail because there isn’t a reasonable default outside of$go_dir
itself.
Data type: Stdlib::Absolutepath
Where Go will be installed
Valid ensure values for golang::installation
Alias of Variant[Enum[present, latest, absent], Golang::Version]
Generally something like '1.8.1'
, but may also be something like '1.3rc1'
.
Alias of Pattern[/\A[1-9]\d*(\.\d+)*([a-z]+\d+)?\z/]