Skip to content

Commit

Permalink
Merge pull request #30 from nectar-cookbooks/dev
Browse files Browse the repository at this point in the history
Fix for issue #29 + option to use RDO for openstack clients
  • Loading branch information
crawley committed Jul 11, 2014
2 parents a16a4bf + 70d5a0e commit 3f7ea63
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 19 deletions.
5 changes: 5 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Change Log for the Setup cookbook
=================================

Version 1.1.11
-------------
- Avoid issue where installing NetManager will brick networking (#29)
- Add support for installing openstack clients from the Fedora RDO repo.

Version 1.1.10
-------------
- Add the heat client to openstack-clients.
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ Attributes
* `node['setup']['openstack_rc_group']` - The owner of the credentials script. Defaults to 'root'.
* `node['setup']['openstack_try_pip']` - If true, try to install clients from Pypy, using pip. Defaults to true.
* `node['setup']['openstack_try_distro']` - If true, try to install clients from the distro's repository. Defaults to false.
* `node['setup']['openstack_use_rdo']` - If true, try to use the Fedora "RDO" repository in preference to the distro's. Defaults to false.

If the 'openstack_tenant_name' attribute is defined and non-empty, then a
credentials file will be generated containing the details.
Expand All @@ -279,6 +280,13 @@ Precise, there is no Swift client in the package repo, and the Pypy version
of the Swift client in incompatible with the Ubuntu precise version of the
Keystone client.)

The RDO repos are maintained by the RDO community
(http://openstack.redhat.com/Main_Page) and aim to provide up-to-date
builds of OpenStack related "stuff" for Fedora and RHEL-based systems.
Unfortunately, they don't provide complete coverage, so the 'openstack_clients'
recipe is designed to try to use an RDO repo if it exists, and fall back to
the standard distro (with a WARN log message).

The credentials script is created with permissions `0550`, and defaults to
having "root:root" ownership.

Expand Down
2 changes: 2 additions & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
node.default['setup']['openstack_tenant_id'] = nil
node.default['setup']['openstack_try_pip'] = true
node.default['setup']['openstack_try_distro'] = false
node.default['setup']['openstack_use_rdo'] = false
node.default['setup']['openstack_release'] = 'havana'

node.default['setup']['accounts']['generate_sudoers'] = false
node.default['setup']['accounts']['sysadmin_passwordless'] = false
Expand Down
1 change: 1 addition & 0 deletions files/default/ifcfg-eth1
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Generated by Chef (setup::mount_rdsi_collections)
DEVICE="eth1"
BOOTPROTO="dhcp"
MTU="9000"
Expand Down
2 changes: 1 addition & 1 deletion metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
maintainer_email "s.crawley at uq dot edu dot au"
license "BSD"
description "Some recipes for general NeCTAR virtual configuration"
version "1.1.10"
version "1.1.11"

depends "timezone-ii", ">= 0.2.0"
depends "hostsfile"
Expand Down
17 changes: 14 additions & 3 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,20 @@
include_recipe 'setup::set_hostname'
end

# Workaround for issue #13 ... until I can get the offending recipe fixed.
if platform_family?('rhel', 'debian') then
include_recipe 'locale'
if platform_family?('rhel', 'fedora') then
# Block the accidental installation of NetworkManager (typically
# as part of an X11 install ...) because it tends to mess up OpenStack
# networking.
yum_globalconfig '/etc/yum.conf' do
keepcache false
debuglevel '2'
exactarch true
obsoletes true
gpgcheck true
plugins true
installonly_limit '3'
exclude 'NetworkManager*'
end
end

if node['setup']['accounts'] &&
Expand Down
86 changes: 71 additions & 15 deletions recipes/openstack-clients.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,81 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Simply install the distro-supplied versions for now. (Some sources imply
# that there are version compatibility issues, and recommend building and
# installing from source. I'm not convinced ...)
try_distro = node['setup']['openstack_try_distro']
try_pip = node['setup']['openstack_try_pip']
use_rdo = node['setup']['openstack_use_rdo']

# Build dependencies for the python clients ... in case we need them.
if platform_family?('debian') then
deps = ['python-pip', 'build-essential',
'libssl-dev', 'libffi-dev', 'python-dev']
else
deps = ['python-pip', 'gcc', 'openssl-devel', 'libffi-devel', 'python-devel']
if try_distro && use_rdo && platform_family?('rhel', 'fedora') then
base = 'http://repos.fedorapeople.org/repos/openstack'
release = node['setup']['openstack_release']
if platform_family?('fedora')
platform = "fedora-#{node['platform_version']}"
name = "Fedora-#{node['platform_version']}"
else
version = /(\d+)\.\d+/.match(node['platform_version'])[1]
platform = "epel-#{version}"
name = "EPEL #{version}"
end

baseurl = "#{base}/openstack-#{release}/#{platform}/"
# Test to see if the intuited RDO repo URL is viable.
found_rdo = false
begin
redirects = 0
url_string = baseurl
while true do
raise "Redirection loop for #{url}" if redirects >= 20
url = URI.parse(url_string)
req = Net::HTTP.new(url.host, url.port)
req.use_ssl = (url.scheme == 'https')
res = req.request_head(url.path || "/")
if (! res.kind_of?(Net::HTTPRedirection) ) then
status = res.code.to_i
case status
when 404
Chef::Log.warn("There is no RDO repo for #{release} on #{platform}")
break;
when 400..499, 500..599
raise "HTTP Request failed: #{status} #{res.message}: for #{url}"
when 200..299
found_rdo = true
break;
when true
raise "Unexpected HTTP response: #{status} #{res.message}: for #{url}"
end
end
url_string = res['location']
end
rescue Errno::ENOENT
raise "Unexpected problem with url #{url_string}"
end
if found_rdo then
yum_repository "openstack-#{release}" do
description "Openstack #{release} - RDO (#{name})"
baseurl baseurl
enabled true
gpgcheck false
priority '98'
end
end
end

deps.each do |pkg|
package pkg do
action :install
# Build dependencies for the python clients ... in case we need them.
if try_pip then
if platform_family?('debian') then
deps = ['python-pip', 'build-essential',
'libssl-dev', 'libffi-dev', 'python-dev']
else
deps = ['python-pip', 'gcc', 'openssl-devel', 'libffi-devel',
'python-devel']
end

deps.each do |pkg|
package pkg do
action :install
end
end
end
try_distro = node['setup']['openstack_try_distro']
try_pip = node['setup']['openstack_try_pip']

clients = [['keystone', 'python-keystoneclient'],
['swift', 'python-swiftclient'],
Expand All @@ -58,7 +114,7 @@
if try_distro then
package client[1] do
action :install
ignore_failure true
ignore_failure try_pip
not_if "which #{client[0]}"
end
end
Expand Down
16 changes: 16 additions & 0 deletions templates/default/ifcfg-xxx.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Generated by Chef (setup::default)
IPV6INIT=no
BOOTPROTO=dhcp
DEVICE=<%= @device %>
TYPE=Ethernet
<% if @private then %>
DEFROUTE=no
PEERDNS=no
PEERROUTES=no
<% else %>
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
<% end %>
IPV4_FAILURE_FATAL=no
NAME="System <%= @device %>"

0 comments on commit 3f7ea63

Please sign in to comment.