Question

When I write in my recipe:

package "openvpn" do
  action :install
end

The package is being installed, but

I want to know where my package is installing from.

I want to do it differently - I want to download the openvpn software and put it in S3 from there I want to get it back.

package "openvpn" do 
  action :install
end

remote_file "\etc\openvpn" do
  source "I want to take it from S3"
  action :install
end

Can I do it the second way if yes my package name should be openvpn or something else.

Was it helpful?

Solution

  1. Openvpn is packaged by Ubuntu, so it is coming from the Ubuntu package repository. Chef uses the apt package provider for the package resource. This means while you say package "openvpn" in your recipe, under the covers Chef looks at the node's platform (e.g., ubuntu 12.04) and uses apt-get install to install it. If you were using CentOS, it would use yum instead.

  2. If you want to use S3 to store a config file, you would specify the source as the URI to the actual file with remote file:

Example:

remote_file "/etc/openvpn/openvpn.conf" do
  source "https://your-bukket.s3.amazonaws.com/openvpn.conf"
  action :create
end

If the bucket is private, you'll need to use an alternative resource such as aws_s3_file from Opscode's "aws" cookbook. See the README for information about how to use that resource - it passes in the AWS credentials to access the item in the bucket.

If you want to provide your own openvpn package and download it from S3, you can do so with this:

remote_file "/tmp/openvpn-VERSION.deb" do
  source "https://your-bukket.s3.amazonaws.com/openvpn-VERSION.deb"
  action :create_if_missing
end

dpkg_package "openvpn" do
  source "/tmp/openvpn-VERSION.deb"
  action :install
end

(Replace VERSION with your actual version, or otherwise change the filename to suit your preferences)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top