Added apt::repo recipe.
Move vpc::apt to vpc::apt_config. Updated vpc::apt_config so that it waits for the local APT repo to load and adds the local repo's sources.list.d config file.
This commit is contained in:
parent
7d18856a45
commit
0a0aa44065
3
cookbooks/apt/attributes/apt.rb
Normal file
3
cookbooks/apt/attributes/apt.rb
Normal file
@ -0,0 +1,3 @@
|
||||
default[:apt][:repo_codename] = "maverick"
|
||||
default[:apt][:repo_name] = "ubuntu"
|
||||
default[:apt][:repo_archs] = "amd64"
|
18
cookbooks/apt/definitions/reprepro.rb
Normal file
18
cookbooks/apt/definitions/reprepro.rb
Normal file
@ -0,0 +1,18 @@
|
||||
define :add_deb_to_repo do
|
||||
|
||||
filename=params[:name] # use name param as the repo name
|
||||
codename=params[:codename]
|
||||
repo_dir=params[:repo_dir]
|
||||
|
||||
bash "reprepro deb: #{filename}" do
|
||||
cwd "/tmp"
|
||||
user "root"
|
||||
code <<-EOH
|
||||
cd #{repo_dir}
|
||||
reprepro includedeb "#{codename}" "#{filename}"
|
||||
rm "#{filename}"
|
||||
EOH
|
||||
only_if { File.exists?(filename) }
|
||||
end
|
||||
|
||||
end
|
1
cookbooks/apt/files/default/apt-noauth.conf
Normal file
1
cookbooks/apt/files/default/apt-noauth.conf
Normal file
@ -0,0 +1 @@
|
||||
APT::Get::AllowUnauthenticated 1;
|
@ -1,8 +1,8 @@
|
||||
#
|
||||
# Cookbook Name:: Rackspace
|
||||
# Recipe:: packages
|
||||
# Cookbook Name:: apt
|
||||
# Recipe:: noauth
|
||||
#
|
||||
# Copyright 2011, Rackspace
|
||||
# Copyright 2011, Dan Prince
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@ -16,14 +16,9 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
include_recipe 'apt'
|
||||
|
||||
apt_repository "openstack" do
|
||||
key "2A2356C9"
|
||||
keyserver "keyserver.ubuntu.com"
|
||||
uri "http://ppa.launchpad.net/nova-core/trunk/ubuntu"
|
||||
distribution node[:apt][:distro]
|
||||
components(["main"])
|
||||
action :add
|
||||
cookbook_file "/etc/apt/apt.conf.d/02noauth" do
|
||||
source "apt-noauth.conf"
|
||||
owner "root"
|
||||
group "root"
|
||||
mode 0644
|
||||
end
|
114
cookbooks/apt/recipes/repo.rb
Normal file
114
cookbooks/apt/recipes/repo.rb
Normal file
@ -0,0 +1,114 @@
|
||||
#
|
||||
# Cookbook Name:: apt
|
||||
# Recipe:: repo
|
||||
#
|
||||
# Copyright 2011, Dan Prince.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
package "reprepro" do
|
||||
action :install
|
||||
end
|
||||
|
||||
["/var/packages", "/var/packages/#{node[:apt][:repo_name]}", "/var/packages/#{node[:apt][:repo_name]}/conf", "/var/packages/#{node[:apt][:repo_name]}/dists", "/var/packages/#{node[:apt][:repo_name]}/dists/#{node[:apt][:repo_codename]}", "/var/packages/#{node[:apt][:repo_name]}/dists/#{node[:apt][:repo_codename]}/main"].each do |dirname|
|
||||
directory dirname do
|
||||
owner "root"
|
||||
group "root"
|
||||
mode 0755
|
||||
action :create
|
||||
end
|
||||
end
|
||||
|
||||
template "/var/packages/#{node[:apt][:repo_name]}/conf/distributions" do
|
||||
source "distributions.erb"
|
||||
mode 0644
|
||||
variables(
|
||||
:repo_archs => node[:apt][:repo_archs],
|
||||
:repo_name => node[:apt][:repo_name],
|
||||
:code_name => node[:apt][:repo_codename]
|
||||
)
|
||||
end
|
||||
|
||||
file "/var/packages/#{node[:apt][:repo_name]}/conf/override.#{node[:apt][:repo_codename]}" do
|
||||
action :touch
|
||||
end
|
||||
|
||||
template "/var/packages/#{node[:apt][:repo_name]}/conf/options" do
|
||||
source "options.erb"
|
||||
mode 0644
|
||||
end
|
||||
|
||||
if node[:apt][:upload_package_dir] then
|
||||
rbfiles = File.join(node[:apt][:upload_package_dir], "*.deb")
|
||||
Dir.glob(rbfiles).each do |deb|
|
||||
add_deb_to_repo deb do
|
||||
repo_dir "/var/packages/#{node[:apt][:repo_name]}"
|
||||
codename node[:apt][:repo_codename]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# create default Release file (also created by reprepro
|
||||
release_file="/var/packages/#{node[:apt][:repo_name]}/dists/#{node[:apt][:repo_codename]}/Release"
|
||||
template release_file do
|
||||
source "Release.erb"
|
||||
mode 0644
|
||||
variables(
|
||||
:repo_archs => node[:apt][:repo_archs],
|
||||
:repo_name => node[:apt][:repo_name],
|
||||
:code_name => node[:apt][:repo_codename]
|
||||
)
|
||||
not_if { File.exists?(release_file) }
|
||||
end
|
||||
|
||||
# create empty Packages.gz files if needed
|
||||
node[:apt][:repo_archs].each do |arch|
|
||||
directory "/var/packages/#{node[:apt][:repo_name]}/dists/#{node[:apt][:repo_codename]}/main/binary-#{arch}/" do
|
||||
owner "root"
|
||||
group "root"
|
||||
mode 0755
|
||||
action :create
|
||||
end
|
||||
packages_list = "/var/packages/#{node[:apt][:repo_name]}/dists/#{node[:apt][:repo_codename]}/main/binary-#{arch}/Packages.gz"
|
||||
execute "echo -n | gzip > #{packages_list}" do
|
||||
not_if { File.exists?(packages_list) }
|
||||
end
|
||||
end
|
||||
|
||||
package "nginx" do
|
||||
action :install
|
||||
end
|
||||
|
||||
template "/etc/nginx/conf.d/server_names_hash_bucket_size.conf" do
|
||||
source "server_names_hash_bucket_size.conf.erb"
|
||||
mode 0644
|
||||
end
|
||||
|
||||
vhost_conf="/etc/nginx/sites-available/vhost-#{node[:apt][:repo_name]}.conf"
|
||||
template vhost_conf do
|
||||
source "nginx.conf.erb"
|
||||
variables(
|
||||
:server_name => node[:fqdn]
|
||||
)
|
||||
mode 0644
|
||||
end
|
||||
|
||||
link "/etc/nginx/sites-enabled/vhost-#{node[:apt][:repo_name]}.conf" do
|
||||
to vhost_conf
|
||||
end
|
||||
|
||||
service "nginx" do
|
||||
action :start
|
||||
subscribes :restart, resources(:template => vhost_conf)
|
||||
end
|
6
cookbooks/apt/templates/default/Release.erb
Normal file
6
cookbooks/apt/templates/default/Release.erb
Normal file
@ -0,0 +1,6 @@
|
||||
Origin: <%= @repo_name %>
|
||||
Label: <%= @repo_name %>
|
||||
Codename: <%= @code_name %>
|
||||
Architectures: <%= @repo_archs %>
|
||||
Components: main
|
||||
Description: <%= @repo_name %> Apt Repo
|
8
cookbooks/apt/templates/default/distributions.erb
Normal file
8
cookbooks/apt/templates/default/distributions.erb
Normal file
@ -0,0 +1,8 @@
|
||||
Origin: <%= @repo_name %>
|
||||
Label: <%= @repo_name %>
|
||||
Codename: <%= @code_name %>
|
||||
Architectures: <%= @repo_archs %>
|
||||
Components: main
|
||||
Description: <%= @repo_name %> Apt Repo
|
||||
DebOverride: override.<%= @code_name %>
|
||||
DscOverride: override.<%= @code_name %>
|
20
cookbooks/apt/templates/default/nginx.conf.erb
Normal file
20
cookbooks/apt/templates/default/nginx.conf.erb
Normal file
@ -0,0 +1,20 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name <%= @server_name %>;
|
||||
|
||||
access_log /var/log/nginx/packages-error.log;
|
||||
error_log /var/log/nginx/packages-error.log;
|
||||
|
||||
location / {
|
||||
root /var/packages;
|
||||
index index.html;
|
||||
}
|
||||
|
||||
location ~ /(.*)/conf {
|
||||
deny all;
|
||||
}
|
||||
|
||||
location ~ /(.*)/db {
|
||||
deny all;
|
||||
}
|
||||
}
|
1
cookbooks/apt/templates/default/options.erb
Normal file
1
cookbooks/apt/templates/default/options.erb
Normal file
@ -0,0 +1 @@
|
||||
basedir .
|
@ -0,0 +1 @@
|
||||
server_names_hash_bucket_size 64;
|
@ -1 +1,3 @@
|
||||
default[:apt][:distro] = "maverick"
|
||||
default[:vpc][:apt][:distro] = "maverick"
|
||||
default[:vpc][:apt][:ppa_url] = "http://ppa.launchpad.net/nova-core/trunk/ubuntu"
|
||||
default[:vpc][:apt][:local_url] = "http://login.vpc/openstack"
|
||||
|
61
cookbooks/vpc/recipes/apt_config.rb
Normal file
61
cookbooks/vpc/recipes/apt_config.rb
Normal file
@ -0,0 +1,61 @@
|
||||
#
|
||||
# Cookbook Name:: vpc
|
||||
# Recipe:: apt_config
|
||||
#
|
||||
# Copyright 2011, Rackspace
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
include_recipe 'apt'
|
||||
|
||||
ruby_block "block until local APT repo is online" do
|
||||
block do
|
||||
require 'net/http'
|
||||
|
||||
repo_loaded=false
|
||||
until repo_loaded == true do
|
||||
|
||||
begin
|
||||
if Net::HTTP.get_response(URI.parse("#{node[:vpc][:apt][:local_url]}/dists/#{node[:vpc][:apt][:distro]}/Release")).class == Net::HTTPOK
|
||||
repo_loaded=true
|
||||
Chef::Log.info("APT repo is online.")
|
||||
else
|
||||
Chef::Log.info("Waiting on APT repo to load...")
|
||||
sleep 5
|
||||
end
|
||||
rescue
|
||||
Chef::Log.info("Waiting on APT repo to load...")
|
||||
sleep 5
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
not_if do File.exists?("/etc/apt/sources.list.d/local-source.list") end
|
||||
end
|
||||
|
||||
apt_repository "local" do
|
||||
uri node[:vpc][:apt][:local_url]
|
||||
distribution node[:vpc][:apt][:distro]
|
||||
components(["main"])
|
||||
action :add
|
||||
end
|
||||
|
||||
apt_repository "ppa" do
|
||||
key "2A2356C9"
|
||||
keyserver "keyserver.ubuntu.com"
|
||||
uri node[:vpc][:apt][:ppa_url]
|
||||
distribution node[:vpc][:apt][:distro]
|
||||
components(["main"])
|
||||
action :add
|
||||
end
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Cookbook Name:: rackspace
|
||||
# Cookbook Name:: vpc
|
||||
# Recipe:: default
|
||||
#
|
||||
# Copyright 2011, Rackspace
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Cookbook Name:: rackspace
|
||||
# Cookbook Name:: vpc
|
||||
# Recipe:: def_setup
|
||||
#
|
||||
# Copyright 2011, Rackspace
|
||||
|
@ -1,14 +1,6 @@
|
||||
# This recipe contains setup steps required for Nova Compute to work
|
||||
# correctly on our Stock Ubuntu Cloud Servers images
|
||||
|
||||
# NOTE: (dprince) Inside of our VPC environments we already have a virbr0
|
||||
# bridge interface so we can use that
|
||||
|
||||
#package "bridge-utils"
|
||||
#execute "brctl addbr br100" do
|
||||
#not_if "brctl show | grep br100"
|
||||
#end
|
||||
|
||||
directory "/dev/cgroup" do
|
||||
owner "root"
|
||||
group "root"
|
||||
|
14
roles/apt-repo.rb
Normal file
14
roles/apt-repo.rb
Normal file
@ -0,0 +1,14 @@
|
||||
name "apt-repo"
|
||||
|
||||
run_list(
|
||||
"recipe[apt::repo]"
|
||||
)
|
||||
|
||||
default_attributes(
|
||||
"apt" => {
|
||||
"repo_name" => "openstack",
|
||||
"repo_codename" => "maverick",
|
||||
"repo_archs" => "amd64",
|
||||
"upload_package_dir" => "/root/openstack-packages"
|
||||
}
|
||||
)
|
@ -1,6 +1,7 @@
|
||||
name "glance-api"
|
||||
|
||||
run_list(
|
||||
"recipe[vpc::apt]",
|
||||
"recipe[apt::noauth]",
|
||||
"recipe[vpc::apt_config]",
|
||||
"recipe[glance::api]"
|
||||
)
|
||||
|
@ -1,6 +1,7 @@
|
||||
name "glance-registry"
|
||||
|
||||
run_list(
|
||||
"recipe[vpc::apt]",
|
||||
"recipe[apt::noauth]",
|
||||
"recipe[vpc::apt_config]",
|
||||
"recipe[glance::registry]"
|
||||
)
|
||||
|
@ -1,7 +1,8 @@
|
||||
name "nova-base"
|
||||
|
||||
run_list(
|
||||
"recipe[vpc::apt]",
|
||||
"recipe[apt::noauth]",
|
||||
"recipe[vpc::apt_config]",
|
||||
"recipe[nova::common]"
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user