Puppet Function: gcompute_image_family

Defined in:
lib/puppet/functions/gcompute_image_family.rb
Function type:
Ruby 4.x API

Overview

gcompute_image_family(String $family_name, String $project_name)Any

Builds the family resource identifier required to uniquely identify the family, e.g. to create virtual machines based on it. You can use this function as ‘source_image` of a `gcompute_instance` resource.

Arguments:

- family_name: string
  the name of the family, e.g. ubuntu-1604-lts
- project_name: string
  the name of the project that hosts the family,
  e.g. ubuntu-os-cloud

Examples:

- gcompute_image_family('ubuntu-1604-lts', 'ubuntu-os-cloud')
- gcompute_image_family('my-web-server', 'my-project')

Note: In the case of private images, your credentials will need to have the proper permissions to access the image.

To get a list of supported families you can use the gcloud utility:

gcloud compute images list

Parameters:

  • family_name (String)
  • project_name (String)

Returns:

  • (Any)


49
50
51
52
53
54
55
56
57
58
# File 'lib/puppet/functions/gcompute_image_family.rb', line 49

Puppet::Functions.create_function(:gcompute_image_family) do
  dispatch :gcompute_image_family do
    param 'String', :family_name
    param 'String', :project_name
  end

  def gcompute_image_family(family_name, project_name)
    "projects/#{project_name}/global/images/family/#{family_name}"
  end
end