command "/opt/wp-cli/wp --path=#{site_directory} plugin activate #{new_resource.plugin}"
user node[:wordpress][:user]
group node[:wordpress][:group]
- only_if { ::File.exist?("#{site_directory}/wp-config.php") }
+ not_if "/opt/wp-cli/wp --path=#{site_directory} plugin is-active #{new_resource.plugin}"
end
end
command "/opt/wp-cli/wp --path=#{site_directory} plugin deactivate #{new_resource.plugin}"
user node[:wordpress][:user]
group node[:wordpress][:group]
- only_if { ::File.exist?("#{site_directory}/wp-config.php") }
+ only_if "/opt/wp-cli/wp --path=#{site_directory} plugin is-active #{new_resource.plugin}"
end
directory plugin_directory do
property :site, :kind_of => String, :name_property => true
property :aliases, :kind_of => [String, Array]
+property :title, :kind_of => String
+property :admin_user, :kind_of => String, :default => "osm_admin"
+property :admin_email, :kind_of => String, :default => "admins@openstreetmap.org"
property :directory, :kind_of => String
property :version, :kind_of => String
property :database_name, :kind_of => String, :required => true
backup false
end
+ # Setup wordpress database and create admin user with random password
+ execute "wp core install" do
+ command "/opt/wp-cli/wp --path=#{site_directory} core install --url=#{new_resource.site} --title='#{new_resource.title}' --admin_user=#{new_resource.admin_user} --admin_email=#{new_resource.admin_email} --skip-email"
+ user node[:wordpress][:user]
+ group node[:wordpress][:group]
+ only_if { ::File.exist?("#{site_directory}/wp-config.php") }
+ not_if "/opt/wp-cli/wp --path=#{site_directory} core is-installed"
+ end
+
ssl_certificate new_resource.site do
domains [new_resource.site] + Array(new_resource.aliases)
end
--- /dev/null
+
+require "serverspec"
+
+# Required by serverspec
+set :backend, :exec
+
+describe command("/opt/wp-cli/wp --allow-root --path=/srv/blog.openstreetmap.org/wp/ core is-installed") do
+ its("exit_status") { should eq 0 }
+end
+
+describe command("/opt/wp-cli/wp --allow-root --path=/srv/blog.openstreetmap.org/wp/ plugin is-active wp-fail2ban") do
+ its("exit_status") { should eq 0 }
+end