Skip to content

Add suse package support #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Requirements
#### Platforms
- Debian, Ubuntu
- RHEL, CentOS, Oracle Linux
- SLES, OpenSUSE

#### Cookbooks
- aptitude
Expand Down Expand Up @@ -45,7 +46,7 @@ Attributes
<td><tt>['zendserver']['nginx']</tt></td>
<td>boolean</td>
<td>Set in you are using Nginx instead of Apache true or false boolean</td>
<td><tt>false</tt></td>
<td><tt>'false'</tt></td>
</tr>
<tr>
<td><tt>['zendserver']['ordernumber']</tt></td>
Expand Down
9 changes: 9 additions & 0 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@
"zendserver::install"
]

attribute "zendserver/nginx",
:display_name => "Nginx true or not",
:description => "Set if you are using Nginx instead of Apache true or false boolean",
:required => "optional",
:default => 'false',
:recipes => [
"zendserver::install"
]

attribute "zendserver/adminpassword",
:display_name => "Admin password",
:description => "Zend Server GUI admin password",
Expand Down
58 changes: 58 additions & 0 deletions providers/repository.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#
# Cookbook Name:: zend-server
# Provider:: repository
#
# Once there is build in zypper repository support in Chef we can relay of it.
# For now have to take care of it inside zendserver cookbook.
#

action :add do
if new_resource.key && (new_resource.key =~ /http/)
execute "rpm_import_#{Digest::MD5.hexdigest(new_resource.key)}" do
command "rpm --import #{new_resource.key}"
end
else
Chef::Log.error "Can't import #{new_resource.key}"
end

if ::File.exists? "/etc/zypp/repos.d/rp-#{new_resource.alias}.repo"
Chef::Log.info "Allready added #{new_resource.alias} repo config file"
else
Chef::Log.info "Adding #{new_resource.alias} repository config file"

# -g option to force GPG key enabled.
execute "zypper_addrepo_#{new_resource.alias}" do
command "zypper addrepo -g -n '#{new_resource.title}' #{new_resource.uri} rp-#{new_resource.alias}"
end

new_resource.updated_by_last_action(true)
end
end

action :remove do
if ::File.exists? "/etc/zypp/repos.d/rp-#{new_resource.alias}.repo"
Chef::Log.info "Removing #{new_resource.alias} repository"

execute "zypper_removerepo_#{new_resource.alias}" do
command "zypper removerepo rp-#{new_resource.alias}"
end

new_resource.updated_by_last_action(true)
else
Chef::Log.error "Remove failed for #{new_resource.alias}"
end
end

action :refresh do
if ::File.exists? "/etc/zypp/repos.d/rp-#{new_resource.alias}.repo"
Chef::Log.info "Refreshing #{new_resource.alias} repository"

execute "zypper_refresh_#{new_resource.alias}" do
command "zypper refresh rp-#{new_resource.alias}"
end

new_resource.updated_by_last_action(true)
else
Chef::Log.error "Refresh failed for #{new_resource.alias}"
end
end
16 changes: 12 additions & 4 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

version = node[:zendserver][:version]
phpversion = node[:zendserver][:phpversion]
cpuarch = node[:kernel][:machine]

case node[:zendserver][:nginx]
when true
Expand Down Expand Up @@ -58,10 +59,17 @@
action :add
end
when "suse"
zypper_repository "zend-server" do
uri "http://repos.zend.com/zend-server/#{version}/sles/ZendServer-x86_64"
key "http://repos.zend.com/zend.key"
title "#{version}"
zendserver_repository "zend-server" do
uri "http://repos.zend.com/zend-server/#{version}/sles/ZendServer-#{cpuarch}"
key "http://repos.zend.com/zend.key"
title "zend-server-#{version}"
action :add
end
zendserver_repository "zend-server-noarch" do
uri "http://repos.zend.com/zend-server/#{version}/sles/ZendServer-noarch"
key "http://repos.zend.com/zend.key"
title "zend-server-noarch-#{version}"
action :add
end
end

Expand Down
15 changes: 15 additions & 0 deletions resources/repository.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#
# Cookbook Name:: zend-server
# Resource:: repository
#


actions :add, :remove, :refresh

attribute :alias, :kind_of => String, :name_attribute => true
attribute :uri, :kind_of => String
attribute :title, :kind_of => String
attribute :keyserver, :kind_of => String, :default => nil
attribute :key, :kind_of => String, :default => nil

default_action :add