VMware Workspace ONE Community
PeterFNX
Contributor
Contributor

Multiple forge dependencies when creating Linux custom puppet manifest?

When creating a Linux profile with a custom configuration there is a checkbox called 

Add Forge Module Dependency 

With it I can add puppet dependencies, but it seems I can only add one?

I have tried adding two but end up with errors.

Is there a special syntax for adding several dependencies?

My use-case: Add an apt repository using Puppet Apt-module - https://forge.puppet.com/modules/puppetlabs/apt

With the obvious choice using dependency puppetlabs-apt, this gives me error 

Error: Evaluation Error: Unknown function: 'merge'. (file: /opt/vmware/ws1-hub/data/Puppet/modules/apt/manifests/init.pp, line: 186, column: 14) on node XXXXXX.

merge-function seems to be a function in puppetlabs-stdlib but with that added as a dependency I get another error:

Error: Evaluation Error: Error while evaluating a Function Call, Could not find class ::apt for XXXXXX. (file: /opt/vmware/ws1-hub/data/Puppet/manifest/c0ebe689-6b87-4e4d-9e61-b1f1744d992e.pp, line: 1, column: 1) on node XXXXXX.

So I would like to add both stdlib and apt as a forge module dependency. 

Any idea how?

My puppet manifest is below:

include apt

# Install apt key
$chromefp = 'EB4C1BFD4F042F6DDDCCEC917721F63BD38B4796'

apt::key { 'google-chrome':
  ensure   => 'present',
  id       => "${chromefp}",
  source   => 'https://dl.google.com/linux/linux_signing_key.pub',
} ~> apt::source { 'google-chrome':
  comment  => 'Google Chrome repo',
  location => 'http://dl.google.com/linux/chrome/deb/',
  release  => 'stable',
  repos    => 'main',
} ~> exec { 'apt-update':
  command => '/usr/bin/apt-get update'
} ~> package { 'google-chrome-stable':
  ensure => 'latest',
}

 

Reply
0 Kudos
1 Reply
PeterFNX
Contributor
Contributor

For what it's worth, I gave up on this (trying to use Puppets apt-module).

 

For anyone googling this, I ended up with the following manifest which I'm pretty pleased with since it starts with the repo and then ensures the latest Chrome, instead of just punching in a .deb-file.

# Install apt key
file { '/tmp/google-chrome.pub':
 source   => 'https://dl.google.com/linux/linux_signing_key.pub',
}

exec { 'add-key':
  command  => '/usr/bin/gpg --dearmor -o - /tmp/google-chrome.pub > /etc/apt/trusted.gpg.d/google-chrome.gpg',
  require  => File['/tmp/google-chrome.pub'],
}

file { '/etc/apt/sources.list.d/google-chrome.list':
  content  => "deb [arch=amd64] https://dl.google.com/linux/chrome/deb/ stable main",
  require  => Exec['add-key'],
  notify   => Exec['apt-update'],
}

package { 'google-chrome-stable':
  ensure   => 'latest',
  require  => [ Exec['add-key'], File['/etc/apt/sources.list.d/google-chrome.list'] ],
}

exec { 'apt-update':
  command  => '/usr/bin/apt-get update || [ $? -eq 100 ]',
}

# Tidy:
exec { '/usr/bin/rm -f /tmp/google-chrome.pub':
  require  => Exec['add-key'],
}

 

Reply
0 Kudos