File tree Expand file tree Collapse file tree 2 files changed +22
-6
lines changed Expand file tree Collapse file tree 2 files changed +22
-6
lines changed Original file line number Diff line number Diff line change 32
32
node . save unless Chef ::Config [ :solo ]
33
33
34
34
db = node [ 'wordpress' ] [ 'db' ]
35
+ db_ip_split = db [ 'host' ] . split ( "." )
35
36
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
39
44
40
45
#nfs share for wp-content
41
46
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"
44
49
writeable true
45
50
sync true
46
51
options [ 'no_root_squash' ]
56
61
node [ 'wordpress' ] [ 'ip_array' ] . each do |host |
57
62
user = "'#{ db [ 'user' ] } '@'#{ host } '"
58
63
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 } ' ;>
60
65
grant_privileges = %<GRANT ALL PRIVILEGES ON #{ db [ 'name' ] } .* TO #{ user } ;>
61
66
62
67
execute "Create WordPress MySQL User" do
Original file line number Diff line number Diff line change 49
49
end
50
50
51
51
#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
52
63
53
64
archive = platform_family? ( 'windows' ) ? 'wordpress.zip' : 'wordpress.tar.gz'
54
65
You can’t perform that action at this time.
0 commit comments