|
107 | 107 | mode 0o0644
|
108 | 108 | end
|
109 | 109 |
|
110 |
| -# for providing information on services, links, and config files |
| 110 | +# bach web document root |
111 | 111 | directory node['bcpc']['bach_web']['document_root'].to_s do
|
112 | 112 | owner 'root'
|
113 | 113 | group 'root'
|
114 | 114 | mode 0o0755
|
115 | 115 | action :create
|
116 | 116 | end
|
117 | 117 |
|
118 |
| -directory "#{node['bcpc']['bach_web']['document_root']}/files" do |
| 118 | +# bach web configs |
| 119 | +template '/etc/apache2/sites-available/bach-web.conf' do |
| 120 | + source 'bach-web.conf.erb' |
119 | 121 | owner 'root'
|
120 | 122 | group 'root'
|
121 |
| - mode 0o0755 |
122 |
| - action :create |
| 123 | + mode 0o0644 |
| 124 | + variables( |
| 125 | + 'host_ip' => node['bcpc']['floating']['ip'], |
| 126 | + 'host_port' => node['bcpc']['bach_web']['port'], |
| 127 | + 'document_root' => node['bcpc']['bach_web']['document_root'], |
| 128 | + 'json_url' => node['bcpc']['bach_web']['json_url'], |
| 129 | + 'json_file' => node['bcpc']['bach_web']['json_file'] |
| 130 | + ) |
| 131 | + notifies :restart, 'service[apache2]', :delayed |
123 | 132 | end
|
124 | 133 |
|
125 |
| -template "#{node['bcpc']['bach_web']['document_root']}/index.html" do |
| 134 | +# A portal html pages for useful links |
| 135 | +template "#{node['bcpc']['bach_web']['document_root']}/#{node['bcpc']['bach_web']['html_file']}" do |
126 | 136 | source 'bach.html.erb'
|
127 | 137 | owner 'root'
|
128 | 138 | group 'root'
|
|
136 | 146 | notifies :restart, 'service[apache2]', :delayed
|
137 | 147 | end
|
138 | 148 |
|
139 |
| -template '/etc/apache2/sites-available/bach-web.conf' do |
140 |
| - source 'bach-web.conf.erb' |
| 149 | +# A json files that expose the configs for easier consumption programatically. |
| 150 | +# NOTE: node['bcpc']['bach_web'] should NOT contain anything sensitive or confidential |
| 151 | +# otherwise a dedicated hash should be used |
| 152 | +file "#{node['bcpc']['bach_web']['document_root']}/#{node['bcpc']['bach_web']['json_file']}" do |
| 153 | + content Chef::JSONCompat.to_json_pretty(node['bcpc']['bach_web'].to_hash) |
| 154 | +end |
| 155 | + |
| 156 | + |
| 157 | +directory "#{node['bcpc']['bach_web']['document_root']}/files" do |
141 | 158 | owner 'root'
|
142 | 159 | group 'root'
|
143 |
| - mode 0o0644 |
144 |
| - variables( |
145 |
| - 'host_ip' => node['bcpc']['floating']['ip'], |
146 |
| - 'host_port' => node['bcpc']['bach_web']['port'], |
147 |
| - 'document_root' => node['bcpc']['bach_web']['document_root'], |
148 |
| - 'files' => node['bcpc']['bach_web']['files'] |
149 |
| - ) |
150 |
| - notifies :restart, 'service[apache2]', :delayed |
| 160 | + mode 0o0755 |
| 161 | + action :create |
151 | 162 | end
|
152 | 163 |
|
| 164 | +# enable bach-web |
153 | 165 | bash 'enable_bach_web' do
|
154 | 166 | user 'root'
|
155 | 167 | code 'a2ensite bach-web'
|
|
0 commit comments