From 1670bf67670d031aa64d09ca99a718861106cf1d Mon Sep 17 00:00:00 2001 From: Grant Slater Date: Thu, 15 Jun 2023 16:55:40 +0100 Subject: [PATCH 1/1] wordpress: add 2fa and last-login plugins --- cookbooks/wordpress/resources/plugin.rb | 14 ++++++++++++++ cookbooks/wordpress/resources/site.rb | 22 ++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/cookbooks/wordpress/resources/plugin.rb b/cookbooks/wordpress/resources/plugin.rb index 881caee63..03aadec28 100644 --- a/cookbooks/wordpress/resources/plugin.rb +++ b/cookbooks/wordpress/resources/plugin.rb @@ -62,9 +62,23 @@ action :create do end end end + + execute "wp-cli plugin activate #{new_resource.plugin}" do + 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") } + end end action :delete do + execute "wp-cli plugin deactivate #{new_resource.plugin}" do + 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") } + end + directory plugin_directory do action :delete recursive true diff --git a/cookbooks/wordpress/resources/site.rb b/cookbooks/wordpress/resources/site.rb index 393c47578..5a47a8e0c 100644 --- a/cookbooks/wordpress/resources/site.rb +++ b/cookbooks/wordpress/resources/site.rb @@ -192,9 +192,31 @@ action :create do WP_FAIL2BAN subscribes :run, "wordpress_plugin[wp-fail2ban]" end + + wordpress_plugin "wp-2fa" do + site new_resource.site + reload_apache false + end + + wordpress_plugin "wp-last-login" do + site new_resource.site + reload_apache false + end end action :delete do + wordpress_plugin "wp-last-login" do + action :delete + site new_resource.site + reload_apache false + end + + wordpress_plugin "wp-2fa" do + action :delete + site new_resource.site + reload_apache false + end + wordpress_plugin "wp-fail2ban" do action :delete site new_resource.site -- 2.39.5