Skip to content

Instantly share code, notes, and snippets.

View johnfitzpatrick's full-sized avatar

John Fitzpatrick johnfitzpatrick

  • Kong
  • Belfast, Northern Ireland
View GitHub Profile
#
# Cookbook Name:: apache
# Recipe:: default
#
# Copyright (c) 2014 The Authors, All Rights Reserved.
#
package "httpd"
execute "mv /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf.disabled" do
only_if do
Listen 8080
<VirtualHost *:8080>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/web01
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
Listen 8081
<VirtualHost *:8081>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/web02
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
#
# Cookbook Name:: apache
# Recipe:: default
#
# Copyright (c) 2014 The Authors, All Rights Reserved.
#
package "httpd"
execute "mv /etc/httpd/conf.d/welcome.conf /etc/httpd/conf.d/welcome.conf.disabled" do
only_if do
<% if @port != node["apache"]["port"] %>
Listen <%= @port %>
<% end %>
<VirtualHost *:<%= @port %>>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/web0<%= @web_server_id %>
<Directory />
Options FollowSymLinks
@johnfitzpatrick
johnfitzpatrick / httpd.conf.erb
Last active October 29, 2015 10:44
httpd.conf.erb
#
# This is the main Apache server configuration file. It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.2/> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.2/mod/directives.html>
# for a discussion of each configuration directive.
#
#
# Do NOT simply read the instructions in here without understanding
<h1>Hello, <%= node["myapache"]["greeting"] %></h1>
<p>
This is a <%= node["platform"] %> <%= node["platform_version"] %> server with <%= node["memory"]["total"] %> RAM.
<br><br>
The CentOS servers in your organization have the following FQDN/IP Addresses:-
<ul>
<% @nodes.each do |node| %>
<li><%= node['fqdn'] %> / <%= node['cloud']['public_ipv4'] %></li>
<% end %>
global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
#log loghost local0 info
maxconn 4096
user haproxy
group haproxy
stats socket /var/run/haproxy.sock user haproxy group haproxy
defaults
mydirectory = "/Users/YOU/training/chef-repo"
git "previous-repo" do
destination "#{mydirectory}"
repository "git://github.com/johnfitzpatrick/cheffundamentals3.git"
reference "v1"
action :export
end
execute "chown -R YOU #{mydirectory}" do
package 'haproxy' do
action :install
end
pool_members = search("node","role:webserver")
template "/etc/haproxy/haproxy.cfg" do
source "haproxy.cfg.erb"
owner "root"
group "root"