From cac3fe554d7b7636fe48a2a20271cd19fed1a257 Mon Sep 17 00:00:00 2001 From: Dan Bode Date: Mon, 5 Nov 2012 22:46:53 -0800 Subject: [PATCH] Add Redhat support - move hosts.pp to setup/precise64.pp - create a setup manifest for redhat - do not use apache module for red hat - allow config of vagrant based on ENV VAR --- Vagrantfile | 25 ++++++++++++--- manifests/setup/centos.pp | 36 ++++++++++++++++++++++ manifests/setup/hosts.pp | 19 ++++++++++++ manifests/{hosts.pp => setup/precise64.pp} | 22 ++----------- manifests/site.pp | 12 +++++++- 5 files changed, 88 insertions(+), 26 deletions(-) create mode 100644 manifests/setup/centos.pp create mode 100644 manifests/setup/hosts.pp rename manifests/{hosts.pp => setup/precise64.pp} (62%) diff --git a/Vagrantfile b/Vagrantfile index 61cf3f1..2a9ef29 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -1,7 +1,5 @@ Vagrant::Config.run do |config| - config.vm.box = 'precise64' - config.vm.box_url = 'http://files.vagrantup.com/precise64.box' if ENV['OPENSTACK_GUI_MODE'] gui_mode = ENV['OPENSTACK_GUI_MODE'].to_bool @@ -9,6 +7,20 @@ Vagrant::Config.run do |config| gui_mode = true end + if ENV['OPERATINGSYSTEM'] + if ENV['OPERATINGSYSTEM'].downcase == 'redhat' + os_name = 'centos' + config.vm.box = 'centos' + config.vm.box_url = 'https://dl.dropbox.com/u/7225008/Vagrant/CentOS-6.3-x86_64-minimal.box' + else + raise(Exception, "undefined operatingsystem: #{ENV['OPERATINGSYSTEM']}") + end + else + os_name = 'precise64' + config.vm.box = 'precise64' + config.vm.box_url = 'http://files.vagrantup.com/precise64.box' + end + ssh_forward_port = 2244 [ @@ -106,12 +118,15 @@ Vagrant::Config.run do |config| node_name = "#{name.gsub('_', '-')}-#{Time.now.strftime('%Y%m%d%m%s')}" - agent.vm.provision :shell, :inline => "apt-get update" - #agent.vm.provision :shell, :inline => "apt-get -y upgrade" + if os_name =~ /precise/ + agent.vm.provision :shell, :inline => "apt-get update" + elsif os_name =~ /centos/ + agent.vm.provision :shell, :inline => "yum clean all" + end agent.vm.provision :puppet do |puppet| puppet.manifests_path = 'manifests' - puppet.manifest_file = 'hosts.pp' + puppet.manifest_file = "setup/#{os_name}.pp" puppet.module_path = 'modules' puppet.options = ['--verbose', '--debug', '--show_diff', "--certname=#{node_name}"] end diff --git a/manifests/setup/centos.pp b/manifests/setup/centos.pp new file mode 100644 index 0000000..afbe890 --- /dev/null +++ b/manifests/setup/centos.pp @@ -0,0 +1,36 @@ +import 'hosts.pp' + +file { '/etc/yum.repos.d': + ensure => directory, +} + +file { '/tmp/setup_epel.sh': + content => +' +#!/bin/bash +wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-7.noarch.rpm +rpm -Uvh epel-release-6*.rpm' +} + +exec { '/bin/bash /tmp/setup_epel.sh': + refreshonly => true, + subscribe => File['/tmp/setup_epel.sh'] +} + +ini_setting { 'enable_epel_testing': + path => '/etc/yum.repos.d/epel-testing.repo', + section => 'epel-testing', + setting => 'enabled', + value => '1', + ensure => present, + require => Exec['/bin/bash /tmp/setup_epel.sh'], +} + +ini_setting { 'yum_proxy': + path => '/etc/yum.conf', + section => 'main', + setting => 'proxy', + value => 'http://172.16.0.1:3128', + ensure => present, + require => Exec['/bin/bash /tmp/setup_epel.sh'], +} diff --git a/manifests/setup/hosts.pp b/manifests/setup/hosts.pp new file mode 100644 index 0000000..66a1353 --- /dev/null +++ b/manifests/setup/hosts.pp @@ -0,0 +1,19 @@ +# +# specify a connection to the hardcoded puppet master +# +host { + 'puppet': ip => '172.16.0.2'; + 'openstackcontroller': ip => '172.16.0.3'; + 'compute1': ip => '172.16.0.4'; + 'compute2': ip => '172.16.0.14'; + 'novacontroller': ip => '172.16.0.5'; + 'glance': ip => '172.16.0.6'; + 'keystone': ip => '172.16.0.7'; + 'mysql': ip => '172.16.0.8'; + 'cinderclient': ip => '172.16.0.9'; + 'quantumagent': ip => '172.16.0.10'; +} + +group { 'puppet': + ensure => 'present', +} diff --git a/manifests/hosts.pp b/manifests/setup/precise64.pp similarity index 62% rename from manifests/hosts.pp rename to manifests/setup/precise64.pp index 552422e..c448af0 100644 --- a/manifests/hosts.pp +++ b/manifests/setup/precise64.pp @@ -1,3 +1,5 @@ +import 'hosts.pp' + # # This puppet manifest is already applied first to do some environment specific things # @@ -28,26 +30,6 @@ exec { '/usr/bin/apt-get update': logoutput => true, } -# -# specify a connection to the hardcoded puppet master -# -host { - 'puppet': ip => '172.16.0.2'; - 'openstackcontroller': ip => '172.16.0.3'; - 'compute1': ip => '172.16.0.4'; - 'compute2': ip => '172.16.0.14'; - 'novacontroller': ip => '172.16.0.5'; - 'glance': ip => '172.16.0.6'; - 'keystone': ip => '172.16.0.7'; - 'mysql': ip => '172.16.0.8'; - 'cinderclient': ip => '172.16.0.9'; - 'quantumagent': ip => '172.16.0.10'; -} - -group { 'puppet': - ensure => 'present', -} - # bring up the bridging interface explicitly #exec { '/sbin/ifconfig eth2 up': } diff --git a/manifests/site.pp b/manifests/site.pp index 2a69942..084b1ca 100644 --- a/manifests/site.pp +++ b/manifests/site.pp @@ -73,7 +73,17 @@ node /openstack-controller/ { quantum => $use_quantum, } - include apache + if $::osfamily == 'Debian' { + include 'apache' + } else { + package { 'httpd': + ensure => present + }~> + service { 'httpd': + ensure => running, + enable => true + } + } class { 'openstack::controller': #floating_range => $floating_network_range,