Created
May 15, 2012 13:52
-
-
Save kkenny/2701942 to your computer and use it in GitHub Desktop.
ms scx ubuntu.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Cookbook Name:: microsoft_scx | |
# Recipe:: default | |
# | |
# Copyright 2011, CoTweet | |
# | |
# 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. | |
# | |
tmp = Chef::Config[:file_cache_path] | |
url = Chef::Config[:chef_server_url] | |
# Make sure build requirements are met. | |
%w{unzip libssl-dev git-core debhelper devscripts dh-buildinfo dh-make pkg-config autotools-dev bison alien}.each do |pkg| | |
p = package pkg do | |
action :nothing | |
end | |
p.run_action(:install) | |
end | |
# OpenPegasus is required to build the cross platform providers library. | |
remote_file "#{tmp}/pegasus-2.11.1.zip" do | |
# http://www.openpegasus.org/uploads/40/24835/pegasus-2.11.1.zip | |
source "#{url}/tarballs/pegasus-2.11.1.zip" | |
action :create_if_missing | |
end | |
execute "extract pegasus" do | |
cwd tmp | |
command "unzip pegasus-2.11.1.zip" | |
creates "#{tmp}/pegasus" | |
end | |
directory "/usr/src/Pegasus/Provider/CMPI" do | |
action :create | |
recursive true | |
end | |
execute "copy CMPI header files" do | |
cwd "#{tmp}/pegasus/src/Pegasus/Provider/CMPI" | |
command "cp -R * /usr/src/Pegasus/Provider/CMPI" | |
creates "/usr/src/Pegasus/Provider/CMPI/CmpiArgs.h" | |
end | |
# Compile the xplatproviders library from source. | |
remote_file "#{tmp}/xplatproviders-1.0.0.tar.gz" do | |
source "#{url}/tarballs/xplatproviders-1.0.0.tar.gz" | |
action :create_if_missing | |
end | |
execute "extract xplatproviders" do | |
cwd tmp | |
command "tar xzvf xplatproviders-1.0.0.tar.gz" | |
creates "#{tmp}/xplatproviders-1.0.0" | |
end | |
cookbook_file "#{tmp}/xplatproviders-1.0.0.patch" do | |
source "xplatproviders-1.0.0.patch" | |
action :create | |
end | |
execute "patch xplatproviders" do | |
cwd tmp | |
command "patch -p0 < xplatproviders-1.0.0.patch && touch xplatproviders-1.0.0/.patched" | |
creates "#{tmp}/xplatproviders-1.0.0/.patched" | |
end | |
execute "compile xplatproviders" do | |
cwd "#{tmp}/xplatproviders-1.0.0" | |
command "make" | |
creates "#{tmp}/xplatproviders-1.0.0/target/Linux_UBUNTU_10.04_x64_64_Release/libSCXCoreProviderModule.so" | |
end | |
# Now that the xplatproviders library is compiled it's time to transform and modify the SCX agent. | |
cookbook_file "#{tmp}/scx_1.0.4-265-x64.patch" do | |
source "scx_1.0.4-265-x64.patch" | |
action :create | |
end | |
remote_file "#{tmp}/scx-1.0.4-265.rhel.5.x64.rpm" do | |
source "#{url}/rpms/centos/5/exacttarget/RPMS/x86_64/scx-1.0.4-265.rhel.5.x64.rpm" | |
action :create | |
end | |
execute "convert scx package" do | |
cwd tmp | |
command "alien -k scx-1.0.4-265.rhel.5.x64.rpm --scripts" | |
creates "#{tmp}/scx_1.0.4-265_amd64.deb" | |
end | |
directory "#{tmp}/scx_1.0.4-265-x64/debian/DEBIAN" do | |
action :create | |
recursive true | |
end | |
directory "#{tmp}/scx_1.0.4-265-x64-tmp/debian/DEBIAN" do | |
action :create | |
recursive true | |
end | |
execute "extract scx deb" do | |
cwd "#{tmp}/scx_1.0.4-265-x64-tmp" | |
command "ar -x #{tmp}/scx_1.0.4-265_amd64.deb" | |
creates "#{tmp}/scx_1.0.4-265-x64-tmp/debian-binary" | |
end | |
execute "extract control.tar.gz" do | |
cwd "#{tmp}/scx_1.0.4-265-x64/debian/DEBIAN" | |
command "tar xzf #{tmp}/scx_1.0.4-265-x64-tmp/control.tar.gz" | |
creates "#{tmp}/scx_1.0.4-265-x64/debian/DEBIAN/control" | |
end | |
cookbook_file "#{tmp}/scx_1.0.4-265-x64/debian/DEBIAN/md5sums" do | |
source "md5sums" | |
action :create | |
end | |
execute "extract data.tar.gz" do | |
cwd "#{tmp}/scx_1.0.4-265-x64/debian" | |
command "tar xzf #{tmp}/scx_1.0.4-265-x64-tmp/data.tar.gz" | |
creates "#{tmp}/scx_1.0.4-265-x64/debian/opt/microsoft/scx/lib/providers/libSCXCoreProviderModule.so" | |
end | |
execute "patch scx agent" do | |
cwd tmp | |
command "patch -p0 < scx_1.0.4-265-x64.patch && touch scx_1.0.4-265-x64/.patched" | |
creates "#{tmp}/scx_1.0.4-265-x64/.patched" | |
end | |
execute "copy libSCXCoreProviderModule.so" do | |
cwd "#{tmp}/scx_1.0.4-265-x64/debian/opt/microsoft/scx/lib/providers" | |
command "cp #{tmp}/xplatproviders-1.0.0/target/Linux_UBUNTU_10.04_x64_64_Release/libSCXCoreProviderModule.so ." | |
end | |
execute "rebuild scx deb" do | |
cwd "#{tmp}/scx_1.0.4-265-x64" | |
command "dpkg-deb --build debian scx-1.0.4-265.Ubuntu.10.04.x86_64.deb" | |
creates "#{tmp}/scx_1.0.4-265-x64/scx-1.0.4-265.Ubuntu.10.04.x86_64.deb" | |
end | |
# Yay! Install it. | |
dpkg_package "scx" do | |
action :install | |
source "#{tmp}/scx_1.0.4-265-x64/scx-1.0.4-265.Ubuntu.10.04.x86_64.deb" | |
end | |
user "scxuser" do | |
action :create | |
home "/home/scxuser" | |
shell "/bin/sh" | |
password "$6$6gl9L4mLlR5g4zw$KF6ceUCPyTGoobg8A27q78794VCwJ621.a4dZGtOAuHPI9Ikd1dzndk9gJNfwdoOV1zR.X7rISsNVivdJievi." | |
# Password: O:{^H?YH._4X | |
supports :manage_home => true | |
end | |
group "admin" do | |
members "scxuser" | |
append true | |
action :manage | |
end | |
service "scx-cimd" do | |
supports :restart => true, :status => true | |
end | |
execute "chown scx cert" do | |
command "chown -R scxuser:scxuser /etc/opt/microsoft/scx/ssl" | |
end | |
execute "chmod scx cert" do | |
command "chmod 644 /etc/opt/microsoft/scx/ssl/scx-host*" | |
notifies :restart, resources(:service => "scx-cimd"), :immediate | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment