From: Grant Slater Date: Thu, 15 Jun 2023 15:55:40 +0000 (+0100) Subject: wordpress: add 2fa and last-login plugins X-Git-Url: https://git.openstreetmap.org./chef.git/commitdiff_plain/1670bf67670d031aa64d09ca99a718861106cf1d?hp=52a5ec535e5a578e8450c94ac19a4e8681b88140 wordpress: add 2fa and last-login plugins --- 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