Skip to content

Commit a55303f

Browse files
committed
wordpress: Disallow indexing staging sites
Closes: #32
1 parent b0cac28 commit a55303f

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

hieradata/environments/staging/roles/docs/wordpress.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
profile::wordpress::docs::admin_email: [email protected]
22
profile::wordpress::docs::builder_email: [email protected]
3+
profile::wordpress::docs::robots_txt_deny_all: true
34
profile::wordpress::docs::wordpress_version: ~
45

56
profile::certbot::certificates:

modules/profile/manifests/wordpress/docs.pp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
Stdlib::Email $builder_email = lookup('profile::wordpress::docs::builder_email'),
99
String[1] $wp_content_branch = lookup('profile::wordpress::docs::wp_content_branch', {default_value => 'main'}),
1010
String $append_title = lookup('profile::wordpress::docs::append_title', {default_value => ''}),
11+
Boolean $robots_txt_deny_all = lookup('profile::wordpress::docs::robots_txt_deny_all', {default_value => false}),
1112
String[1] $builder_password_seed = lookup('docs_builder_password_seed'),
1213
String $prepend_host = lookup('docs_prepend_host', {default_value => ''}),
1314
) {
@@ -96,6 +97,7 @@
9697
base_path => $dir,
9798
permalink_structure => '/%postname%/',
9899
gilded_wordpress => true,
100+
robots_txt_deny_all => $robots_txt_deny_all,
99101
config_files => [
100102
'/srv/wordpress/docs-config-shared.php',
101103
"${dir}/jquery-config.php",

modules/wordpress/manifests/site.pp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
Array[Wordpress::Plugin] $plugins = [],
2020
Array[Wordpress::Sidebar] $sidebars = [],
2121
String[1] $permalink_structure = '/%year%/%monthnum%/%day%/%postname%/',
22+
Boolean $robots_txt_deny_all = false,
2223
Boolean $gilded_wordpress = false,
2324
Stdlib::Unixpath $webroot = $base_path,
2425
) {
@@ -187,6 +188,14 @@
187188
}
188189
}
189190

191+
if $robots_txt_deny_all {
192+
file { "${base_path}/robots.txt":
193+
ensure => file,
194+
content => "User-Agent: *\nDisallow: /\n",
195+
require => Exec["wp-install-${title}"],
196+
}
197+
}
198+
190199
$php_fpm_version = $::php::fpm::version
191200
if $path == '/' {
192201
$tls_config = nginx::tls_config()

0 commit comments

Comments
 (0)