├── Berksfile ├── templates └── default │ ├── ssh.erb │ ├── httpd.erb │ ├── dhcp_port.erb │ ├── isc-dhcp-server.erb │ ├── default.erb │ ├── dhcpd.conf.erb │ ├── upstart-apache2.conf.erb │ └── ks │ └── Centos6-5.minimal.ks ├── test └── integration │ └── default │ └── serverspec │ ├── spec_helper.rb │ └── localhost │ ├── httpd_spec.rb │ └── pxe_spec.rb ├── .travis.yml ├── files └── default │ └── centos_minimal_dl.sh ├── .gitignore ├── Thorfile ├── recipes ├── default.rb ├── deb.rb ├── rhel.rb ├── common.rb └── prepare_minimal_centos.rb ├── CHANGELOG.md ├── metadata.rb ├── Gemfile ├── attributes ├── default_centos_pxe_image.rb └── default.rb ├── .kitchen.yml ├── chefignore ├── .kitchen.cloud.yml ├── README.md ├── Vagrantfile └── LICENSE /Berksfile: -------------------------------------------------------------------------------- 1 | source "https://supermarket.getchef.com" 2 | 3 | metadata 4 | -------------------------------------------------------------------------------- /templates/default/ssh.erb: -------------------------------------------------------------------------------- 1 | # open ssh 2 | -A FWR -p tcp -m tcp --dport 22 -j ACCEPT 3 | -------------------------------------------------------------------------------- /test/integration/default/serverspec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | require 'serverspec' 2 | 3 | set :backend, :exec 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | rvm: 3 | - 1.9.3 4 | script: 5 | - bundle exec foodcritic -f any . 6 | branches: 7 | only: 8 | - master -------------------------------------------------------------------------------- /files/default/centos_minimal_dl.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | URL="http://centos.itt-consulting.com/6.5/isos/x86_64/CentOS-6.5-x86_64-minimal.iso" 3 | 4 | wget -c ${URL} || curl -O ${URL} -------------------------------------------------------------------------------- /templates/default/httpd.erb: -------------------------------------------------------------------------------- 1 | # open apache port 2 | -A FWR -i <%= node['dhcp']['eth'] %> -s <%= node['dhcp']['subnet'] %>/24 -p tcp --dport <%= node['http-chef-pxe']['port'] %> -j ACCEPT 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | *# 3 | .#* 4 | \#*# 5 | .*.sw[a-z] 6 | *.un~ 7 | pkg/ 8 | 9 | # Berkshelf 10 | .vagrant 11 | /cookbooks 12 | Berksfile.lock 13 | 14 | # Bundler 15 | Gemfile.lock 16 | bin/* 17 | .bundle/* 18 | 19 | .kitchen/ 20 | .kitchen.local.yml 21 | -------------------------------------------------------------------------------- /Thorfile: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | 3 | require 'bundler' 4 | require 'bundler/setup' 5 | require 'berkshelf/thor' 6 | 7 | begin 8 | require 'kitchen/thor_tasks' 9 | Kitchen::ThorTasks.new 10 | rescue LoadError 11 | puts ">>>>> Kitchen gem not loaded, omitting tasks" unless ENV['CI'] 12 | end 13 | -------------------------------------------------------------------------------- /recipes/default.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: pxe 3 | # Recipe:: default 4 | # 5 | # Copyright (C) 2014 Denis Chekirda 6 | # 7 | # All rights reserved - Do Not Redistribute 8 | # 9 | 10 | if platform_family?("rhel") 11 | include_recipe 'pxe::rhel' 12 | elsif platform_family?("debian") 13 | include_recipe 'pxe::deb' 14 | end 15 | -------------------------------------------------------------------------------- /templates/default/dhcp_port.erb: -------------------------------------------------------------------------------- 1 | # open UDP port 2 | -A FWR -i <%= node['dhcp']['eth'] %> -s <%= node['dhcp']['subnet'] %>/24 -p udp --dport 69 -m state --state NEW,ESTABLISHED -j ACCEPT 3 | # open TCP port 4 | -A FWR -i <%= node['dhcp']['eth'] %> -s <%= node['dhcp']['subnet'] %>/24 -p tcp --dport 69 -m state --state NEW,ESTABLISHED -j ACCEPT 5 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 1.0.5 2 | * Bug fixing. 3 | * Serverspec tests. 4 | 5 | # 1.0.4 6 | * Added checks to prevent multiple executions of mount/umount while converge. 7 | * Added support for Ubuntu 14.04 8 | 9 | # 1.0.3 10 | Chef cookbook to install PXE network booting server. 11 | * Small fixes 12 | * Added support of CentOS 6.5 and Ubuntu 12.04 13 | 14 | # 1.0.0 15 | * Initial release of pxe. 16 | -------------------------------------------------------------------------------- /templates/default/isc-dhcp-server.erb: -------------------------------------------------------------------------------- 1 | # Defaults for dhcp initscript 2 | # sourced by /etc/init.d/dhcp 3 | # installed at /etc/default/isc-dhcp-server by the maintainer scripts 4 | 5 | # 6 | # This is a POSIX shell fragment 7 | # 8 | 9 | # On what interfaces should the DHCP server (dhcpd) serve DHCP requests? 10 | # Separate multiple interfaces with spaces, e.g. "eth0 eth1". 11 | INTERFACES="<%= @eth %>" -------------------------------------------------------------------------------- /templates/default/default.erb: -------------------------------------------------------------------------------- 1 | default menu.c32 2 | prompt 0 3 | 4 | menu title PXE Special Boot Menu 5 | menu INCLUDE pxelinux.cfg/graphics.conf 6 | MENU AUTOBOOT Starting Local System in # seconds 7 | 8 | LABEL install 9 | MENU LABEL ^Install Minimal CentOS 6.5 x86_64 10 | KERNEL centos/x86_64/vmlinuz 11 | APPEND initrd=centos/x86_64/initrd.img ks=http://<%= @config %>:<%= @port %>/ks/Centos6-5.minimal.ks -------------------------------------------------------------------------------- /templates/default/dhcpd.conf.erb: -------------------------------------------------------------------------------- 1 | default-lease-time 600; 2 | max-lease-time 7200; 3 | subnet <%= @config['subnet'] %> netmask <%= @config['subnet_mask'] %> { 4 | range <%= @config['dynamic_range'] %>; 5 | option subnet-mask <%= @config['subnet_mask'] %>; 6 | option routers <%= @config['routers'] %>; 7 | option broadcast-address <%= @config['broadcast'] %>; 8 | filename "pxelinux.0"; 9 | next-server <%= @config['next_server'] %>; 10 | } -------------------------------------------------------------------------------- /recipes/deb.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: pxe 3 | # Recipe:: deb 4 | # Description:: Recipe for all Debian/Ubuntu based OS. 5 | # Copyright (C) 2014 Denis Chekirda 6 | # 7 | # All rights reserved - Do Not Redistribute 8 | # 9 | 10 | include_recipe 'apt' 11 | include_recipe 'tftp' 12 | 13 | # Installing all necesary packages 14 | node['packages'].each do |pkgs| 15 | package pkgs do 16 | action :upgrade 17 | end 18 | end 19 | 20 | include_recipe 'pxe::common' 21 | -------------------------------------------------------------------------------- /recipes/rhel.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: pxe 3 | # Recipe:: rhel 4 | # Description:: Recipe for all RHEL based OS. 5 | # Copyright (C) 2014 Denis Chekirda 6 | # 7 | # All rights reserved - Do Not Redistribute 8 | # 9 | 10 | include_recipe 'tftp' 11 | include_recipe 'iptables' 12 | 13 | node['packages'].each do |pkgs| 14 | package pkgs do 15 | action :upgrade 16 | end 17 | end 18 | 19 | iptables_rule "ssh" 20 | iptables_rule "dhcp_port" 21 | iptables_rule "httpd" 22 | 23 | include_recipe 'pxe::common' 24 | -------------------------------------------------------------------------------- /metadata.rb: -------------------------------------------------------------------------------- 1 | name 'pxe' 2 | maintainer 'Denis Chekirda' 3 | maintainer_email 'dchekirda@gmail.com' 4 | license 'All rights reserved' 5 | description 'Installs local bootstraping and installation system via PXE booting.' 6 | long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) 7 | version '1.0.5' 8 | 9 | depends "apt" 10 | depends "yum" 11 | depends "tftp" 12 | depends "apache2" 13 | depends "iptables", "~> 0.14.0" 14 | 15 | %w{rhel centos debian ubuntu}.each do |os| 16 | supports os 17 | end 18 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gem 'berkshelf' 4 | 5 | # Uncomment these lines if you want to live on the Edge: 6 | # 7 | # group :development do 8 | # gem "berkshelf", github: "berkshelf/berkshelf" 9 | # gem "vagrant", github: "mitchellh/vagrant", tag: "v1.6.3" 10 | # end 11 | # 12 | # group :plugins do 13 | # gem "vagrant-berkshelf", github: "berkshelf/vagrant-berkshelf" 14 | # gem "vagrant-omnibus", github: "schisamo/vagrant-omnibus" 15 | # end 16 | 17 | gem 'test-kitchen' 18 | gem 'kitchen-vagrant' 19 | gem 'kitchen-digitalocean' 20 | gem 'foodcritic' -------------------------------------------------------------------------------- /templates/default/upstart-apache2.conf.erb: -------------------------------------------------------------------------------- 1 | # apache2 - http server 2 | # 3 | # Apache is a web server that responds to HTTP and HTTPS requests. 4 | # Required-Start: $local_fs $remote_fs $network $syslog 5 | # Required-Stop: $local_fs $remote_fs $network $syslog 6 | 7 | description "apache2 http server" 8 | 9 | start on runlevel [2345] 10 | stop on runlevel [!2345] 11 | 12 | pre-start script 13 | mkdir -p /var/run/apache2 || true 14 | install -d -o www-data /var/lock/apache2 || true 15 | # ssl_scache shouldn't be here if we're just starting up. 16 | # (this is bad if there are several apache2 instances running) 17 | rm -f /var/run/apache2/*ssl_scache* || true 18 | end script 19 | 20 | # Give up if restart occurs 10 times in 30 seconds. 21 | respawn limit 10 30 22 | 23 | exec /usr/sbin/apache2 -D NO_DETACH 24 | respawn -------------------------------------------------------------------------------- /attributes/default_centos_pxe_image.rb: -------------------------------------------------------------------------------- 1 | default['pxe']['hostname'] = '192.168.56.5' 2 | 3 | # HTTP image dir 4 | default['http-chef-pxe']['image_name'] = 'centos' 5 | default['http-chef-pxe']['http_dir'] = '/var/www/html/' 6 | default['http-chef-pxe']['image_dir'] = "#{node['http-chef-pxe']['http_dir']}#{node['http-chef-pxe']['image_name']}" 7 | default['http-chef-pxe']['image_ks_dir'] = '/var/www/html/ks' 8 | default['http-chef-pxe']['ks_filename'] = 'Centos6-5.minimal.ks' 9 | default['http-chef-pxe']['port'] = 90 10 | default['apache']['listen_ports'] = [node['http-chef-pxe']['port']] 11 | 12 | # ISO Configuration 13 | default['iso']['name'] = 'CentOS-6.5-x86_64-minimal.iso' 14 | default['iso']['tmp_dir'] = "/tmp/#{node['iso']['name']}" 15 | default['iso']['mount_dir'] = "/tmp/mnt" 16 | 17 | # TFTP directory for netboot 18 | default['tftp']['centos_dir'] = '/var/lib/tftpboot/centos' 19 | default['tftp']['centos_arch_dir'] = "#{node['tftp']['centos_dir']}/x86_64" 20 | default['image']['url'] = 'http://ftp.tlk-l.net/pub/mirrors/centos.org/6.5/isos/x86_64/CentOS-6.5-x86_64-minimal.iso' #http://ftp.tlk-l.net/pub/mirrors/centos.org/6.5/isos/x86_64/CentOS-6.5-x86_64-minimal.iso 21 | default['download']['from_web'] = true -------------------------------------------------------------------------------- /test/integration/default/serverspec/localhost/httpd_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | if ['debian', 'ubuntu'].include?(os[:family]) 4 | 5 | describe package('apache2') do 6 | it { should be_installed } 7 | end 8 | 9 | describe service('apache2') do 10 | it { should be_enabled } 11 | it { should be_running } 12 | end 13 | 14 | describe file('/etc/apache2/sites-available/pxe-image-host.conf') do 15 | it { should be_file } 16 | it { should contain 'DocumentRoot /var/www/html/' } 17 | end 18 | 19 | describe file('/etc/apache2/ports.conf') do 20 | it { should contain 'Listen *:90' } 21 | end 22 | 23 | elsif os[:family] == 'redhat' 24 | 25 | describe package('httpd') do 26 | it { should be_installed } 27 | end 28 | 29 | describe service('httpd') do 30 | it { should be_enabled } 31 | it { should be_running } 32 | end 33 | 34 | describe file('/etc/httpd/sites-available/pxe-image-host.conf') do 35 | it { should be_file } 36 | it { should contain 'DocumentRoot /var/www/html/' } 37 | end 38 | 39 | describe file('/etc/httpd/ports.conf') do 40 | it { should contain 'Listen *:90' } 41 | end 42 | end 43 | 44 | describe file('/var/www/html') do 45 | it { should be_directory } 46 | it { should be_mode '755' } 47 | end -------------------------------------------------------------------------------- /.kitchen.yml: -------------------------------------------------------------------------------- 1 | --- 2 | driver: 3 | name: vagrant 4 | 5 | provisioner: 6 | name: chef_solo 7 | 8 | platforms: 9 | - name: ubuntu-14.04 10 | driver: 11 | customize: 12 | memory: 384 13 | cpus: 1 14 | network: 15 | - ["private_network", {'ip': '192.168.56.5'}] 16 | - name: ubuntu-12.04 17 | driver: 18 | customize: 19 | memory: 384 20 | cpus: 1 21 | network: 22 | - ["private_network", {'ip': '192.168.56.5'}] 23 | - name: centos-6.5 24 | driver: 25 | customize: 26 | memory: 384 27 | cpus: 1 28 | network: 29 | - ["private_network", {'ip': '192.168.56.5'}] 30 | - name: centos-7.0 31 | driver: 32 | customize: 33 | memory: 384 34 | cpus: 1 35 | network: 36 | - ["private_network", {'ip': '192.168.56.5'}] 37 | - name: debian-7.6 38 | driver: 39 | customize: 40 | memory: 384 41 | cpus: 1 42 | network: 43 | - ["private_network", {'ip': '192.168.56.5'}] 44 | - name: debian-6.0.10 45 | driver: 46 | customize: 47 | memory: 384 48 | cpus: 1 49 | network: 50 | - ["private_network", {'ip': '192.168.56.5'}] 51 | 52 | suites: 53 | - name: default 54 | run_list: 55 | - recipe[pxe] 56 | attributes: 57 | -------------------------------------------------------------------------------- /chefignore: -------------------------------------------------------------------------------- 1 | # Put files/directories that should be ignored in this file when uploading 2 | # or sharing to the community site. 3 | # Lines that start with '# ' are comments. 4 | 5 | # OS generated files # 6 | ###################### 7 | .DS_Store 8 | Icon? 9 | nohup.out 10 | ehthumbs.db 11 | Thumbs.db 12 | 13 | # SASS # 14 | ######## 15 | .sass-cache 16 | 17 | # EDITORS # 18 | ########### 19 | \#* 20 | .#* 21 | *~ 22 | *.sw[a-z] 23 | *.bak 24 | REVISION 25 | TAGS* 26 | tmtags 27 | *_flymake.* 28 | *_flymake 29 | *.tmproj 30 | .project 31 | .settings 32 | mkmf.log 33 | 34 | ## COMPILED ## 35 | ############## 36 | a.out 37 | *.o 38 | *.pyc 39 | *.so 40 | *.com 41 | *.class 42 | *.dll 43 | *.exe 44 | */rdoc/ 45 | 46 | # Testing # 47 | ########### 48 | .watchr 49 | .rspec 50 | spec/* 51 | spec/fixtures/* 52 | test/* 53 | features/* 54 | Guardfile 55 | Procfile 56 | 57 | # SCM # 58 | ####### 59 | .git 60 | */.git 61 | .gitignore 62 | .gitmodules 63 | .gitconfig 64 | .gitattributes 65 | .svn 66 | */.bzr/* 67 | */.hg/* 68 | */.svn/* 69 | 70 | # Berkshelf # 71 | ############# 72 | cookbooks/* 73 | tmp 74 | 75 | # Cookbooks # 76 | ############# 77 | CONTRIBUTING 78 | CHANGELOG* 79 | 80 | # Strainer # 81 | ############ 82 | Colanderfile 83 | Strainerfile 84 | .colander 85 | .strainer 86 | 87 | # Vagrant # 88 | ########### 89 | .vagrant 90 | Vagrantfile 91 | 92 | # Travis # 93 | ########## 94 | .travis.yml 95 | -------------------------------------------------------------------------------- /test/integration/default/serverspec/localhost/pxe_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | if ['debian', 'ubuntu'].include?(os[:family]) 4 | # Checks installed packages 5 | describe package('tftpd-hpa') do 6 | it { should be_installed } 7 | end 8 | 9 | describe package('isc-dhcp-server') do 10 | it { should be_installed } 11 | end 12 | 13 | describe package('syslinux') do 14 | it { should be_installed } 15 | end 16 | 17 | # Checks enabled and running services. 18 | describe service('isc-dhcp-server') do 19 | it { should be_enabled } 20 | it { should be_running } 21 | end 22 | 23 | describe service('tftpd-hpa') do 24 | it { should be_enabled } 25 | it { should be_running } 26 | end 27 | 28 | elsif os[:family] == 'redhat' 29 | # Check installed packages. 30 | describe package('tftp-server') do 31 | it { should be_installed } 32 | end 33 | 34 | describe package('dhcp') do 35 | it { should be_installed } 36 | end 37 | 38 | describe package('syslinux') do 39 | it { should be_installed } 40 | end 41 | 42 | describe package('xinetd') do 43 | it { should be_installed } 44 | end 45 | 46 | # Checks enabled and running services. 47 | describe service('dhcpd') do 48 | it { should be_enabled } 49 | it { should be_running } 50 | end 51 | 52 | describe service('xinetd') do 53 | it { should be_enabled } 54 | it { should be_running } 55 | end 56 | end 57 | 58 | describe port(69) do 59 | it { should be_listening } 60 | end 61 | 62 | describe file('/var/lib/tftpboot/pxelinux.cfg') do 63 | it { should be_directory } 64 | end 65 | 66 | describe file('/var/lib/tftpboot/pxelinux.0') do 67 | it { should be_file } 68 | end 69 | 70 | describe file('/var/lib/tftpboot/menu.c32') do 71 | it { should be_file } 72 | end 73 | 74 | describe file('/etc/dhcp/dhcpd.conf') do 75 | it { should be_file } 76 | it { should contain 'filename "pxelinux.0";' } 77 | end -------------------------------------------------------------------------------- /.kitchen.cloud.yml: -------------------------------------------------------------------------------- 1 | --- 2 | driver_config: 3 | digitalocean_api_key: <%= ENV['DIGITALOCEAN_ACCESS_TOKEN'] %> 4 | 5 | provisioner: 6 | name: chef_zero 7 | require_chef_omnibus: true 8 | 9 | platforms: 10 | - name: ubuntu-12-04-x64 11 | driver_plugin: digitalocean 12 | driver_config: 13 | image: ubuntu-12-04-x64 14 | size: 512mb 15 | region: nyc3 16 | ssh_key_ids: <%= ENV['DIGITALOCEAN_SSH_KEY_IDS'] %> 17 | ssh_key: <%= ENV['DIGITALOCEAN_SSH_KEY_PATH'] %> 18 | - name: centos-6-5-x64 19 | driver_plugin: digitalocean 20 | driver_config: 21 | image: centos-6-5-x64 22 | size: 512mb 23 | region: nyc3 24 | ssh_key_ids: <%= ENV['DIGITALOCEAN_SSH_KEY_IDS'] %> 25 | ssh_key: <%= ENV['DIGITALOCEAN_SSH_KEY_PATH'] %> 26 | - name: ubuntu-14-04-x64 27 | driver_plugin: digitalocean 28 | driver_config: 29 | image: ubuntu-14-04-x64 30 | size: 512mb 31 | region: nyc3 32 | ssh_key_ids: <%= ENV['DIGITALOCEAN_SSH_KEY_IDS'] %> 33 | ssh_key: <%= ENV['DIGITALOCEAN_SSH_KEY_PATH'] %> 34 | - name: debian-7-0-x64 35 | driver_plugin: digitalocean 36 | driver_config: 37 | image: debian-7-0-x64 38 | size: 512mb 39 | region: nyc3 40 | ssh_key_ids: <%= ENV['DIGITALOCEAN_SSH_KEY_IDS'] %> 41 | ssh_key: <%= ENV['DIGITALOCEAN_SSH_KEY_PATH'] %> 42 | - name: centos-7-0-x64 43 | driver_plugin: digitalocean 44 | driver_config: 45 | image: centos-6-5-x64 46 | size: 512mb 47 | region: nyc3 48 | ssh_key_ids: <%= ENV['DIGITALOCEAN_SSH_KEY_IDS'] %> 49 | ssh_key: <%= ENV['DIGITALOCEAN_SSH_KEY_PATH'] %> 50 | - name: debian-6-0-x64 51 | driver_plugin: digitalocean 52 | driver_config: 53 | image: debian-7-0-x64 54 | size: 512mb 55 | region: nyc3 56 | ssh_key_ids: <%= ENV['DIGITALOCEAN_SSH_KEY_IDS'] %> 57 | ssh_key: <%= ENV['DIGITALOCEAN_SSH_KEY_PATH'] %> 58 | 59 | suites: 60 | - name: default 61 | run_list: 62 | - recipe[pxe] 63 | attributes: {} 64 | -------------------------------------------------------------------------------- /attributes/default.rb: -------------------------------------------------------------------------------- 1 | if platform_family?('debian') 2 | default['packages'] = %w(dhcp3-server syslinux) 3 | elsif platform_family?('rhel') 4 | default['packages'] = %w(dhcp syslinux) 5 | end 6 | 7 | if platform?('ubuntu') && node['platform_version'] >= '14.04' 8 | set['apache']['version'] = '2.4' 9 | end 10 | 11 | # TTFP configuration. 12 | default['tftpd']['config'] = '/etc/default/tftpd-hpa' 13 | default['tftpd']['pxe_cfg'] = '/var/lib/tftpboot/pxelinux.cfg' 14 | default['tftpd']['pxelinux'] = '/var/lib/tftpboot/pxelinux.0' 15 | default['tftpd']['menu_c32'] = '/var/lib/tftpboot/menu.c32' 16 | 17 | # Files needed to TFTP. 18 | if platform_family?('debian') 19 | default['syslinux']['pxelinux'] = '/usr/lib/syslinux/pxelinux.0' 20 | default['syslinux']['menu_c32'] = '/usr/lib/syslinux/menu.c32' 21 | elsif platform_family?('rhel') 22 | default['syslinux']['pxelinux'] = '/usr/share/syslinux/pxelinux.0' 23 | default['syslinux']['menu_c32'] = '/usr/share/syslinux/menu.c32' 24 | end 25 | default['pxelinux']['menu'] = '/var/lib/tftpboot/pxelinux.cfg/default' 26 | 27 | # DHCP configuration 28 | default['dhcp']['config'] = '/etc/dhcp/dhcpd.conf' 29 | default['dhcp']['isc_dhcp'] = '/etc/default/isc-dhcp-server' 30 | default['dhcp']['subnet'] = '192.168.56.0' 31 | default['dhcp']['subnet_mask'] = '255.255.255.0' 32 | default['dhcp']['dynamic_range'] = '192.168.56.100 192.168.56.200' 33 | default['dhcp']['routers'] = '192.168.56.5' 34 | default['dhcp']['broadcast'] = '192.168.56.255' 35 | default['dhcp']['next_server'] = '192.168.56.5' 36 | default['dhcp']['eth'] = 'eth1' 37 | 38 | # Services 39 | if platform_family?('debian') 40 | if platform?('ubuntu') && node['platform_version'] >= '14.04' 41 | default['services'] = ['isc-dhcp-server', 'tftpd-hpa', 'apache2'] 42 | else 43 | default['services'] = ['isc-dhcp-server', 'tftpd-hpa'] 44 | end 45 | elsif platform_family?('rhel') 46 | default['services'] = ['dhcpd', 'xinetd'] 47 | end 48 | 49 | # Default ISO 50 | default['download']['default_image'] = true 51 | default['apache2']['upstart_init'] = '/etc/init/apache2.conf' -------------------------------------------------------------------------------- /recipes/common.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: pxe 3 | # Recipe:: common 4 | # Description:: Common recipe for RedHat and Debian based OS. 5 | # Copyright (C) 2014 Denis Chekirda 6 | # 7 | # All rights reserved - Do Not Redistribute 8 | # 9 | include_recipe 'apache2' 10 | 11 | template node['apache2']['upstart_init'] do 12 | source 'upstart-apache2.conf.erb' 13 | owner 'root' 14 | group 'root' 15 | 16 | action :create 17 | only_if { platform?('ubuntu') && node['platform_version'] >= '14.04' } 18 | end 19 | 20 | template node['dhcp']['config'] do 21 | source 'dhcpd.conf.erb' 22 | owner 'root' 23 | group 'root' 24 | 25 | variables( 26 | "config" => node['dhcp'] 27 | ) 28 | action :create 29 | end 30 | 31 | template node['dhcp']['isc_dhcp'] do 32 | source 'isc-dhcp-server.erb' 33 | owner 'root' 34 | group 'root' 35 | 36 | variables( 37 | "eth" => node['dhcp']['eth'] 38 | ) 39 | action :create 40 | end 41 | 42 | remote_file "pxelinux.0" do 43 | not_if { File.exist?('/var/lib/tftpboot/pxelinux.0') } 44 | path node['tftpd']['pxelinux'] 45 | source "file://#{node['syslinux']['pxelinux']}" 46 | action :delete 47 | end 48 | 49 | directory node['tftpd']['pxe_cfg'] do 50 | action :delete 51 | action :create 52 | end 53 | 54 | template node['pxelinux']['menu'] do 55 | source 'default.erb' 56 | action :create 57 | 58 | variables( 59 | 'config' => node['pxe']['hostname'], 60 | 'port' => node['http-chef-pxe']['port'] 61 | ) 62 | end 63 | 64 | remote_file "copy_pxelinux.0" do 65 | path node['tftpd']['pxelinux'] 66 | source "file://#{node['syslinux']['pxelinux']}" 67 | end 68 | 69 | remote_file "copy_menu.c32" do 70 | path node['tftpd']['menu_c32'] 71 | source "file://#{node['syslinux']['menu_c32']}" 72 | end 73 | 74 | if node['download']['default_image'] 75 | include_recipe 'pxe::prepare_minimal_centos' 76 | end 77 | 78 | node['services'].each do |srvs| 79 | service srvs do 80 | provider Chef::Provider::Service::Upstart if platform?("ubuntu") && node["platform_version"].to_f >= 14.04 81 | supports :restart => true, :status => true, :reload => true 82 | #if platform?("ubuntu") && node["platform_version"].to_f >= 14.04 83 | # action [:restart] 84 | #else 85 | action [:enable, :restart] 86 | #end 87 | end 88 | end 89 | -------------------------------------------------------------------------------- /recipes/prepare_minimal_centos.rb: -------------------------------------------------------------------------------- 1 | # 2 | # Cookbook Name:: pxe 3 | # Recipe:: prepare_minimal_centos 4 | # Description:: Prepare CentOS 6.5 minimal as default netboot image. 5 | # Copyright (C) 2014 Denis Chekirda 6 | # 7 | # All rights reserved - Do Not Redistribute 8 | # 9 | listdirs = [ 10 | node['iso']['mount_dir'], 11 | node['tftp']['centos_dir'], 12 | node['tftp']['centos_arch_dir'], 13 | node['http-chef-pxe']['http_dir'], 14 | node['http-chef-pxe']['image_dir'], 15 | node['http-chef-pxe']['image_ks_dir'] 16 | ] 17 | 18 | listdirs.each do |dirs| 19 | directory dirs do 20 | recursive true 21 | action :create 22 | end 23 | end 24 | 25 | web_app "pxe-image-host" do 26 | server_name node['pxe']['hostname'] 27 | server_port node['http-chef-pxe']['port'] 28 | docroot node['http-chef-pxe']['http_dir'] 29 | allow_override 'All' 30 | directory_options '+FollowSymLinks' 31 | cookbook 'apache2' 32 | notifies :restart, "service['apache2']" 33 | end 34 | 35 | if node['download']['from_web'] 36 | remote_file node['iso']['name'] do 37 | source node['image']['url'] 38 | path node['iso']['tmp_dir'] 39 | end 40 | else 41 | cookbook_file node['iso']['name'] do 42 | path node['iso']['tmp_dir'] 43 | action :create_if_missing 44 | end 45 | end 46 | 47 | mount node['iso']['mount_dir'] do 48 | device node['iso']['tmp_dir'] 49 | fstype 'iso9660' 50 | options 'loop,ro' 51 | action [:mount] 52 | not_if {::File.exists?("#{node['http-chef-pxe']['image_dir']}/images/pxeboot/vmlinuz")} 53 | end 54 | 55 | execute 'Copy' do 56 | command "cp -ar #{node['iso']['mount_dir']}/. #{node['http-chef-pxe']['image_dir']}" 57 | not_if {::File.exists?("#{node['http-chef-pxe']['image_dir']}/images/pxeboot/vmlinuz")} 58 | end 59 | 60 | mount node['iso']['mount_dir'] do 61 | device node['iso']['tmp_dir'] 62 | action [:umount] 63 | not_if {::File.exists?("#{node['http-chef-pxe']['image_dir']}/images/pxeboot/vmlinuz")} 64 | end 65 | 66 | remote_file "initrd.img" do 67 | path "#{node['tftp']['centos_arch_dir']}/initrd.img" 68 | source "file://#{node['http-chef-pxe']['image_dir']}/images/pxeboot/initrd.img" 69 | end 70 | 71 | remote_file "vmlinuz" do 72 | path "#{node['tftp']['centos_arch_dir']}/vmlinuz" 73 | source "file:///#{node['http-chef-pxe']['image_dir']}/images/pxeboot/vmlinuz" 74 | end 75 | 76 | template "#{node['http-chef-pxe']['image_ks_dir']}/#{node['http-chef-pxe']['ks_filename']}" do 77 | source "ks/Centos6-5.minimal.ks" 78 | 79 | variables( 80 | 'hostname' => node['pxe']['hostname'], 81 | 'port' => node['http-chef-pxe']['port'] 82 | ) 83 | action :create 84 | end 85 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/Rocklviv/pxe.svg?branch=master)](https://travis-ci.org/Rocklviv/pxe) 2 | # pxe 3 | [![Gitter](https://badges.gitter.im/Join Chat.svg)](https://gitter.im/Rocklviv/pxe?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) 4 | 5 | PXE boot cookbook. 6 | * Depends on [apt](https://supermarket.getchef.com/cookbooks/apt) cookbook. 7 | * Depends on [yum](https://supermarket.getchef.com/cookbooks/yum) cookbook. 8 | * Depends on [tftp](https://supermarket.getchef.com/cookbooks/tftp) cookbook. 9 | * Depends on [apache2](https://supermarket.getchef.com/cookbooks/apache2) cookbook. 10 | 11 | ## Supported Platforms 12 | Supported systems: 13 |
    14 |
  1. Ubuntu 12.04
  2. 15 |
  3. Ubuntu 14.04
  4. 16 |
  5. Centos 6.5
  6. 17 |
18 | 19 | ## Attributes 20 | 21 | | Key | Type | Description | Value | 22 | |-----|------|-------------|-------| 23 | | default['dhcp']['eth'] | text | Ethernet adapter name for dhcp server. | E.g "eth1" | 24 | | default['dhcp']['configs']['subnet'] | text | Subnet IP | E.g. '192.168.56.0' | 25 | | default['dhcp']['configs']['routers'] | text | IP of dhcp router | E.g. '192.168.56.5' | 26 | | default['dhcp']['configs']['next_server'] | text | IP that points to TFTPD server | E.g. "192.168.56.5" | 27 | | default['dhcp']['configs']['dynamic_range'] | text | Range of IP for clients | E.g. "192.168.56.100 192.168.56.200" | 28 | | default['dhcp']['configs']['subnet_mask'] | text | Subnet mask | E.g. "255.255.255.0" | 29 | | default['download']['default_image'] | boolean | Prepare default PXE netboot image. True will download a minimal centos. | true/false | 30 | | default['pxe']['hostname'] | text | IP or hostname for apache virtual host | E.g. "192.168.56.5" | 31 | 32 | 33 | ## TODO: 34 | * Complete the documentation. 35 | 36 | ## Usage 37 | 38 | ### pxe::default 39 | 40 | Include `pxe` in your node's `run_list`: 41 | 42 | ```json 43 | { 44 | "run_list": [ 45 | "recipe[pxe::default]" 46 | ] 47 | } 48 | ``` 49 | 50 | If you have a restrict access to internet, change attribute value 51 | ``` default['download']['from_web'] = 'false' ```. 52 | Then put downloaded by yourself CentOS 6.5 minimal image to files, to be able import ISO as a default netboot image. 53 | To download an iso, please use the ``` files/default/centos_minimal_dl.sh ``` 54 | 55 | ## Contributing 56 | 57 | 1. Fork the repository on Github 58 | 2. Create a named feature branch (i.e. `add-new-recipe`) 59 | 3. Write your change 60 | 4. Write tests for your change (if applicable) 61 | 5. Run the tests, ensuring they all pass 62 | 6. Submit a Pull Request 63 | 64 | ## License and Authors 65 | 66 | Author:: Denis Chekirda (dchekirda@gmail.com) 67 | -------------------------------------------------------------------------------- /templates/default/ks/Centos6-5.minimal.ks: -------------------------------------------------------------------------------- 1 | 2 | # Example kickstart configuration file 3 | # 4 | 5 | install 6 | 7 | # Specifies the language 8 | lang en_US.UTF-8 9 | 10 | # Specifies the keyboard layout 11 | keyboard us 12 | 13 | # Skip Red Hat subscriber key input 14 | key --skip 15 | 16 | # Forces the text installer to be used (saves time) 17 | text 18 | 19 | # Forces the cmdline installer to be used (debugging) 20 | #cmdline 21 | 22 | # Skips the display of any GUI during install (saves time) 23 | skipx 24 | 25 | # Used with an HTTP install to specify where the install files are located 26 | url --url http://<%= @hostname%>:<%= @port%>/centos 27 | 28 | # Assign a static IP address upon first boot & set the hostname 29 | network --onboot yes --bootproto dhcp --hostname centos65 30 | 31 | # Give the second interface a DHCP address (if you are not using a second interface comment this line out) 32 | #network --device eth1 --bootproto=dhcp 33 | 34 | # Set the root password 35 | rootpw r00tp@55w0rd 36 | 37 | # Enable the firewall and open port 22 for SSH remote administration 38 | firewall --enabled --port=22:tcp 39 | 40 | # Setup security and SELinux levels 41 | #authconfig --enableshadow --enablemd5 42 | authconfig --enableshadow --passalgo=sha512 43 | 44 | selinux --disabled 45 | 46 | # Set the timezone 47 | timezone --utc Etc/UTC 48 | 49 | # Create the bootloader in the MBR with drive sda being the drive to install it on 50 | bootloader --location=mbr --driveorder=sda,sdb --append=audit=1 51 | 52 | # Wipe all partitions and build them with the info below 53 | clearpart --all --initlabel 54 | 55 | #Disk partitioning information 56 | zerombr 57 | 58 | # Create primary partitions 59 | part /boot --fstype ext4 --size=500 --asprimary --ondisk=sda 60 | part swap --size=4096 --asprimary --ondisk=sda 61 | part pv.01 --size=100 --grow --asprimary --ondisk=sda 62 | # use the entire second disk for swap 63 | #part swap --size=100 --grow --ondisk=sdb 64 | 65 | # Create LVM logical volumes 66 | volgroup system --pesize=32768 pv.01 67 | logvol /var --vgname=system --size=8196 --name=var_vol 68 | logvol /tmp --vgname=system --size=2048 --name=tmp_vol 69 | logvol / --vgname=system --size=100 --grow --name=root_vol 70 | 71 | # reboot when installation completes 72 | reboot 73 | 74 | # Install the Core software packages, aka "minimal", plus a couple extras 75 | %packages 76 | # minimal 77 | @core 78 | @server-policy 79 | #@base 80 | #@network-file-system-client 81 | #@server-policy 82 | %end 83 | 84 | %pre 85 | # redirect debugging output to tty3 86 | #exec < /dev/tty3 > /dev/tty3 87 | #chvt 3 88 | 89 | %post --log=/var/tmp/install.log 90 | # redirect debugging output to tty3 91 | #exec < /dev/tty3 > /dev/tty3 92 | #chvt 3 93 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! 5 | VAGRANTFILE_API_VERSION = "2" 6 | 7 | Vagrant.require_version ">= 1.5.0" 8 | 9 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 10 | # All Vagrant configuration is done here. The most common configuration 11 | # options are documented and commented below. For a complete reference, 12 | # please see the online documentation at vagrantup.com. 13 | 14 | config.vm.hostname = "chef-pxe-berkshelf" 15 | 16 | # Set the version of chef to install using the vagrant-omnibus plugin 17 | config.omnibus.chef_version = :latest 18 | 19 | # Every Vagrant virtual environment requires a box to build off of. 20 | # If this value is a shorthand to a box in Vagrant Cloud then 21 | # config.vm.box_url doesn't need to be specified. 22 | config.vm.box = "chef/ubuntu-14.04" 23 | 24 | # The url from where the 'config.vm.box' box will be fetched if it 25 | # is not a Vagrant Cloud box and if it doesn't already exist on the 26 | # user's system. 27 | # config.vm.box_url = "https://vagrantcloud.com/chef/ubuntu-14.04/version/1/provider/virtualbox.box" 28 | 29 | # Assign this VM to a host-only network IP, allowing you to access it 30 | # via the IP. Host-only networks can talk to the host machine as well as 31 | # any other machines on the same network, but cannot be accessed (through this 32 | # network interface) by any external networks. 33 | config.vm.network :private_network, type: "dhcp" 34 | 35 | # Create a forwarded port mapping which allows access to a specific port 36 | # within the machine from a port on the host machine. In the example below, 37 | # accessing "localhost:8080" will access port 80 on the guest machine. 38 | 39 | # Share an additional folder to the guest VM. The first argument is 40 | # the path on the host to the actual folder. The second argument is 41 | # the path on the guest to mount the folder. And the optional third 42 | # argument is a set of non-required options. 43 | # config.vm.synced_folder "../data", "/vagrant_data" 44 | 45 | # Provider-specific configuration so you can fine-tune various 46 | # backing providers for Vagrant. These expose provider-specific options. 47 | # Example for VirtualBox: 48 | # 49 | # config.vm.provider :virtualbox do |vb| 50 | # # Don't boot with headless mode 51 | # vb.gui = true 52 | # 53 | # # Use VBoxManage to customize the VM. For example to change memory: 54 | # vb.customize ["modifyvm", :id, "--memory", "1024"] 55 | # end 56 | # 57 | # View the documentation for the provider you're using for more 58 | # information on available options. 59 | 60 | # The path to the Berksfile to use with Vagrant Berkshelf 61 | # config.berkshelf.berksfile_path = "./Berksfile" 62 | 63 | # Enabling the Berkshelf plugin. To enable this globally, add this configuration 64 | # option to your ~/.vagrant.d/Vagrantfile file 65 | config.berkshelf.enabled = true 66 | 67 | # An array of symbols representing groups of cookbook described in the Vagrantfile 68 | # to exclusively install and copy to Vagrant's shelf. 69 | # config.berkshelf.only = [] 70 | 71 | # An array of symbols representing groups of cookbook described in the Vagrantfile 72 | # to skip installing and copying to Vagrant's shelf. 73 | # config.berkshelf.except = [] 74 | 75 | config.vm.provision :chef_solo do |chef| 76 | chef.json = { 77 | mysql: { 78 | server_root_password: 'rootpass', 79 | server_debian_password: 'debpass', 80 | server_repl_password: 'replpass' 81 | } 82 | } 83 | 84 | chef.run_list = [ 85 | "recipe[chef-pxe::default]" 86 | ] 87 | end 88 | end 89 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | --------------------------------------------------------------------------------