Skip to content

Commit

Permalink
nfs share for wp-content
Browse files Browse the repository at this point in the history
  • Loading branch information
erth111 committed Aug 4, 2016
1 parent 4e8cc56 commit 0c74d9c
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
17 changes: 11 additions & 6 deletions recipes/database.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,20 @@
node.save unless Chef::Config[:solo]

db = node['wordpress']['db']
db_ip_split = db['host'].split(".")

### create subnet wildcard
values = db['host'].split(".")
subnet = "#{values[0]}.#{values[1]}.#{values[2]}.%"
#create dir for wp-content export
directory '/wp-content' do
action :create
owner 'root'
group 'root'
mode '00755'
end

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

execute "Create WordPress MySQL User" do
Expand Down
11 changes: 11 additions & 0 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,17 @@
end

#create wp-content dir and mount nfs share to it
directory "#{node['wordpress']['dir']}/wp-content" do
action :create
owner 'root'
group 'root'
mode '00755'
end
execute "Mount wp-config NFS share" do
action :run
command "mount #{node['wordpress']['db']['host']}:/wp-content -t nfs #{node['wordpress']['dir']}/wp-content"
not_if "mount | grep wp-content"
end

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

Expand Down

1 comment on commit 0c74d9c

@korney4eg
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good

Please sign in to comment.