Skip to content

Commit 0c74d9c

Browse files
committed
nfs share for wp-content
1 parent 4e8cc56 commit 0c74d9c

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

recipes/database.rb

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,20 @@
3232
node.save unless Chef::Config[:solo]
3333

3434
db = node['wordpress']['db']
35+
db_ip_split = db['host'].split(".")
3536

36-
### create subnet wildcard
37-
values = db['host'].split(".")
38-
subnet = "#{values[0]}.#{values[1]}.#{values[2]}.%"
37+
#create dir for wp-content export
38+
directory '/wp-content' do
39+
action :create
40+
owner 'root'
41+
group 'root'
42+
mode '00755'
43+
end
3944

4045
#nfs share for wp-content
4146
include_recipe "nfs::server"
42-
nfs_export "/exports" do
43-
network '10.0.0.0/8'
47+
nfs_export "/wp-content" do
48+
network "#{db_ip_split[0]}.#{db_ip_split[1]}.#{db_ip_split[2]}.0/8"
4449
writeable true
4550
sync true
4651
options ['no_root_squash']
@@ -56,7 +61,7 @@
5661
node['wordpress']['ip_array'].each do |host|
5762
user = "'#{db['user']}'@'#{host}'"
5863
create_user = %<CREATE USER #{user} IDENTIFIED BY '#{db['pass']}';>
59-
user_exists = %<SELECT 1 FROM mysql.user WHERE user = #{user};>
64+
user_exists = %<SELECT 1 FROM mysql.user WHERE user = '#{db['user']}' AND host = '#{host}';>
6065
grant_privileges = %<GRANT ALL PRIVILEGES ON #{db['name']}.* TO #{user};>
6166

6267
execute "Create WordPress MySQL User" do

recipes/default.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@
4949
end
5050

5151
#create wp-content dir and mount nfs share to it
52+
directory "#{node['wordpress']['dir']}/wp-content" do
53+
action :create
54+
owner 'root'
55+
group 'root'
56+
mode '00755'
57+
end
58+
execute "Mount wp-config NFS share" do
59+
action :run
60+
command "mount #{node['wordpress']['db']['host']}:/wp-content -t nfs #{node['wordpress']['dir']}/wp-content"
61+
not_if "mount | grep wp-content"
62+
end
5263

5364
archive = platform_family?('windows') ? 'wordpress.zip' : 'wordpress.tar.gz'
5465

0 commit comments

Comments
 (0)