]> git.openstreetmap.org Git - chef.git/commitdiff
wordpress: add 2fa and last-login plugins
authorGrant Slater <github@firefishy.com>
Thu, 15 Jun 2023 15:55:40 +0000 (16:55 +0100)
committerGrant <github@firefishy.com>
Wed, 28 Jun 2023 13:28:45 +0000 (14:28 +0100)
cookbooks/wordpress/resources/plugin.rb
cookbooks/wordpress/resources/site.rb

index 881caee6389d3046c4cce4890dc8002a9f0df991..03aadec28d40a2ecc587b3f0889fb2fcc5437686 100644 (file)
@@ -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
index 393c47578101213ed8ca9baf94cd65d7fac0a04d..5a47a8e0ca6976c722be2aa74ea6a760be87e255 100644 (file)
@@ -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