Skip to content

Commit

Permalink
Merge pull request #27 from sc68cal/submodule_fix
Browse files Browse the repository at this point in the history
Convert vagrant-openstack cookbook from submodule
  • Loading branch information
sc68cal committed Sep 29, 2014
2 parents 7571d3a + c983cc3 commit aed794b
Show file tree
Hide file tree
Showing 12 changed files with 228 additions and 4 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
@@ -1,9 +1,6 @@
[submodule "cookbooks/devstack"]
path = cookbooks/devstack
url = git://github.com/sc68cal/chef-devstack.git
[submodule "cookbooks/vagrant-openstack"]
path = cookbooks/vagrant-openstack
url = git://github.com/osops/vagrant-openstack.git
[submodule "cookbooks/apt"]
path = cookbooks/apt
url = git://github.com/opscode-cookbooks/apt.git
1 change: 0 additions & 1 deletion cookbooks/vagrant-openstack
Submodule vagrant-openstack deleted from e56863
Empty file.
5 changes: 5 additions & 0 deletions cookbooks/vagrant-openstack/attributes/default.rb
@@ -0,0 +1,5 @@
default[:user] = "vagrant"
default[:my_ip] = ipaddress
default[:hostname] = "openstack"
default[:cache][:dir] = "/home/vagrant/cache"
default[:dotfiles][:repository] = "https://github.com/vishvananda/.dotfiles.git -b linux"
43 changes: 43 additions & 0 deletions cookbooks/vagrant-openstack/default.rb
@@ -0,0 +1,43 @@
#
# Cookbook Name:: nova
# Attributes:: default
#
# Copyright 2008-2009, Opscode, Inc.
#
# 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.
#

::Chef::Node.send(:include, Opscode::OpenSSL::Password)

default[:nova][:hostname] = "nova"
default[:nova][:install_type] = "binary"
default[:nova][:compute_connection_type] = "qemu"
default[:nova][:creds][:user] = "nova"
default[:nova][:creds][:group] = "nogroup"
default[:nova][:creds][:dir] = "/var/lib/nova"
default[:nova][:my_ip] = ipaddress
default[:nova][:vlan_interface] = "eth1"
default[:nova][:flatdhcp] = true
default[:nova][:flat_interface] = "eth1"
default[:nova][:public_interface] = "br100"
default[:nova][:mysql] = true
default[:nova][:images] = []
default[:nova][:floating_range] = "192.168.76.128/28"
default[:nova][:fixed_range] = "10.0.0.0/8"
default[:nova][:flat_dhcp_start] = "10.0.0.2"
default[:nova][:num_networks] = 8
default[:nova][:network_size] = 32
default[:nova][:user] = "admin"
default[:nova][:project] = "admin"
set_unless[:nova][:access_key] = secure_password
set_unless[:nova][:secret_key] = secure_password
7 changes: 7 additions & 0 deletions cookbooks/vagrant-openstack/metadata.rb
@@ -0,0 +1,7 @@
maintainer "Vishvananda Ishaya"
maintainer_email "vishvananda@gmail.com"
license "Apache 2.0"
description "OpenStack vagrant helper scripts"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.rdoc'))
version "0.1"
depends "apt"
34 changes: 34 additions & 0 deletions cookbooks/vagrant-openstack/recipes/cache.rb
@@ -0,0 +1,34 @@
#
# Cookbook Name:: vagrant-openstack
# Recipe:: cache
#
# Copyright (c) 2012, OpenStack, LLC
#
# 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.
#

d = node['cache']['dir']
u = node['user']

execute "rm -rf /var/cache/apt; mkdir -p #{d}/aptcache; ln -s #{d}/aptcache /var/cache/apt"

execute "mkdir -p #{d}/pipcache; ln -s #{d}/pipcache /var/cache/pip" do
not_if { File.directory?("/var/cache/pip") }
end

execute "ln -s /home/#{u}/.host-ssh/id_rsa /home/#{u}/.ssh/id_rsa" do
user u
group u
not_if { File.exists?("/home/#{u}/.ssh/id_rsa") }
end

27 changes: 27 additions & 0 deletions cookbooks/vagrant-openstack/recipes/devstack-cache.rb
@@ -0,0 +1,27 @@
#
# Cookbook Name:: vagrant-openstack
# Recipe:: devstack-cache
#
# Copyright (c) 2012, OpenStack, LLC
#
# 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"

package 'rsync'

d = node['cache']['dir']
u = node['user']

execute "mkdir -p #{d}/stack; rsync -vur --delete --exclude=stack/nova-volumes-backing-file --exclude=stack/glance/images/* #{d}/stack /opt; chown -R #{u} /opt/stack"
26 changes: 26 additions & 0 deletions cookbooks/vagrant-openstack/recipes/devstack-update-cache.rb
@@ -0,0 +1,26 @@
#
# Cookbook Name:: vagrant-openstack
# Recipe:: devstack-update-cache
#
# Copyright (c) 2012, OpenStack, LLC
#
# 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"

package 'rsync'

d = node['cache']['dir']

execute "rsync -vur --delete --exclude=stack/nova-volumes-backing-file --exclude=stack/glance/images/* /opt/stack #{d}"
40 changes: 40 additions & 0 deletions cookbooks/vagrant-openstack/recipes/dotfiles.rb
@@ -0,0 +1,40 @@
#
# Cookbook Name:: vagrant_devstack
# Recipe:: dotfiles
#
# Copyright 2011, Anso Labs
#
# 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"

package "bzr"
package "git"
package "vim-gtk"
package "screen"
package "tmux"
package "exuberant-ctags"

u = node['user']
execute "git clone #{node['dotfiles']['repository']} /home/#{u}/.dotfiles/" do
user u
group u
not_if { File.exists?("/home/#{u}/.dotfiles/") }
end

execute "cd /home/#{u} && .dotfiles/link.sh || true" do
user u
group u
not_if { File.exists?("/home/#{u}/.bash_profile") }
end
41 changes: 41 additions & 0 deletions cookbooks/vagrant-openstack/recipes/hostname.rb
@@ -0,0 +1,41 @@
#
# Cookbook Name:: vagrant-openstack
# Recipe:: hostname
#
# Copyright (c) 2012 OpenStack, LLC
#
# 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.
#

unless Chef::Config[:solo]
node[:nova][:hostname] = node.name
end

execute "/root/hostname.sh" do
action :nothing
end

domain = node[:fqdn].split('.')[1..-1].join('.')

template "/root/hostname.sh" do
source "hostname.erb"
owner "root"
group "root"
mode 0755
variables(
:ip => node[:my_ip],
:hostname => node[:hostname],
:domain => domain
)
notifies :run, resources(:execute => "/root/hostname.sh"), :immediately
end
5 changes: 5 additions & 0 deletions cookbooks/vagrant-openstack/templates/default/hostname.erb
@@ -0,0 +1,5 @@
#!/bin/bash
HOSTNAME="<%= @hostname %>"
hostname $HOSTNAME
echo $HOSTNAME > /etc/hostname
sed -i "s/127.0.1.1.*/<%= @ip %> $HOSTNAME.<%= @domain %> $HOSTNAME/g" /etc/hosts

0 comments on commit aed794b

Please sign in to comment.