Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c0623c0
First stab at putting together LWRP for installing plugins.
Azrael808 Apr 27, 2015
60e04ae
Create attribute to hold plugin list.
Azrael808 Apr 28, 2015
c2b0a59
Updated readme with new plugin.
Azrael808 Apr 28, 2015
ee6a9f2
Added recipe to handle plugin install.
Azrael808 Apr 28, 2015
208d4fc
Inlude the plugin recipe after installing application.
Azrael808 Apr 28, 2015
43e643f
Removed the code that checks for file extension - pretty much all WP …
Azrael808 May 13, 2015
145ce4e
Changing use of 'title' to 'name' for consistency.
Azrael808 May 13, 2015
7f3eec9
Ensure unzip is installed in order to be able to extract plugins.
Azrael808 May 13, 2015
066a1cc
Fixed the attempt to chdir into a non-existent directory.
Azrael808 May 13, 2015
a22c1ef
Adding all-important dash to unzip arguments.
Azrael808 May 13, 2015
0b0a2f8
Adding all-important dash to unzip arguments.
Azrael808 May 13, 2015
16f3372
Correcting the path to zip file.
Azrael808 May 13, 2015
e509e7b
Should be using 'unzip -u' instead of 'unzip -f'.
Azrael808 May 13, 2015
5c59a14
Change ownership of plugin.
Azrael808 May 13, 2015
6cf0fed
Created a find_plugin_dir method and removed (failed) attempts at mak…
Azrael808 May 20, 2015
4faf5ac
Revert "Created a find_plugin_dir method and removed (failed) attempt…
Azrael808 May 21, 2015
4ffeb37
Revert "Change ownership of plugin."
Azrael808 May 21, 2015
84df6f1
Trying to install plugin in a specific directory (based on name), usi…
Azrael808 May 21, 2015
2a9736c
Correcting call to plugin_exists function.
Azrael808 May 21, 2015
ace704c
Correcting attempt to use name variable when downloading file.
Azrael808 May 21, 2015
68b08fc
Fixing incorrect use of local variable.
Azrael808 May 21, 2015
4524fa8
Use correct variables for naming plugin directory.
Azrael808 May 21, 2015
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Attributes
* `node['wordpress']['server_name']` - Hostname used for setting up the Virtual Host configuration for your WordPress site

* `node['wordpress']['php_options']` - Additional PHP settings for the installation.
* `node['wordpress']['plugins']` - Hash of plugin names and URLs to be installed.

Usage
=====
Expand Down
3 changes: 3 additions & 0 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,6 @@
end

default['wordpress']['php_options'] = { 'php_admin_value[upload_max_filesize]' => '50M', 'php_admin_value[post_max_size]' => '55M' }

default['wordpress']['plugins'] = {}

51 changes: 51 additions & 0 deletions providers/plugin.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@

def whyrun_supported?
true
end

action :install do

if @current_resource.exists
Chef::Log.info "Plugin #{@new_resource} already exists - nothing to do."
else
converge_by("Add plugin #{@new_resource}") do
add_plugin
end
end
end

def add_plugin
# Retrieve the file
remote_file "#{Chef::Config[:file_cache_path]}/#{new_resource.plugin_name}.zip" do
source new_resource.url
end

# TODO: update/freshen the files in the plugins directory
bash "install-plugin" do
cwd "#{node['wordpress']['dir']}/wp-content/plugins"
code "temp=(mktemp -d) && unzip -d $temp #{Chef::Config[:file_cache_path]}/#{new_resource.plugin_name}.zip && mkdir #{new_resource.plugin_name} && mv $temp/*/* #{new_resource.plugin_name} && rmdir $temp/* $temp"
end
end

def load_current_resource
@current_resource = Chef::Resource::WordpressPlugin.new(@new_resource.name)
@current_resource.name(@new_resource.name)
@current_resource.plugin_name(@new_resource.plugin_name)
@current_resource.url(@new_resource.url)

if plugin_exists?(@current_resource.plugin_name)
@current_resource.exists = true
end

@current_resource
end

def plugin_exists?(name)

if Dir.exist?("#{node['wordpress']['dir']}/wp-content/plugins/#{name}")
return true
end

return false
end

3 changes: 3 additions & 0 deletions recipes/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,6 @@
group node['wordpress']['install']['group']
action :create
end

include_recipe "wordpress::plugins"

29 changes: 29 additions & 0 deletions recipes/plugins.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#
# Cookbook Name:: wordpress
# Recipe:: plugins
#
# Copyright 2009-2010, 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.
#

package "unzip"

node['wordpress']['plugins'].each do |plugin, url|

wordpress_plugin plugin do
url url
end

end

11 changes: 11 additions & 0 deletions resources/plugin.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

actions :install
default_action :install

attribute :plugin_name, :name_attribute => true, :kind_of => String,
:required => true

attribute :url, :kind_of => String, :default => nil, :required => true

attr_accessor :exists