Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using chef to set up apt repository

I am creating a recipe to install docker on Ubuntu 14.

How do I translate the command above to chef?}

sudo apt-key adv --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys 58118E89F3A912897C070ADBF76221572C52609D

So using apt-repository resource:

apt_repository "???" do
  uri ???
  distribution ???
  components ???
  keyserver "hkp://p80.pool.sks-keyservers.net:80"
  key "58118E89F3A912897C070ADBF76221572C52609D"
end
like image 620
p.magalhaes Avatar asked Jan 24 '26 06:01

p.magalhaes


1 Answers

In contrast to @kaboom, I would recommend the (more modern) apt cookbook maintained by Chef, which also allows to set up repos. The syntax is basically the same.

This is, how I install Docker (on Debian):

apt_repository "docker" do
  uri "https://download.docker.com/linux/ubuntu"
  distribution "#{node['lsb']['codename']}"
  components ["stable"]
  key "https://download.docker.com/linux/ubuntu/gpg"
end

EDIT: This is also available in Chef core without any cookbook as of 12.9.

EDIT2: Of course, you can also supply the keyserver and key_id parameters, if you want to specify it as such.

EDIT3: Correct docker URI and Key as of 2023-05-21

like image 136
StephenKing Avatar answered Jan 26 '26 22:01

StephenKing