├── .gitignore ├── .mailmap ├── CHANGELOG ├── LICENSE ├── README.md ├── bin ├── get-version-from-git └── git-log-to-changelog ├── examples ├── install-with-apply.pp └── isc-dhcpd-example.conf ├── files └── undionly.kpxe ├── manifests ├── init.pp ├── libarchive.pp ├── server.pp ├── tftp.pp └── torquebox.pp ├── metadata.json └── templates ├── bootstrap.ipxe.erb ├── install-zip.sh.erb ├── razor-binary-wrapper.erb └── razor-server.init.erb /.gitignore: -------------------------------------------------------------------------------- 1 | /pkg 2 | -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /CHANGELOG: -------------------------------------------------------------------------------- 1 | 2013-12-17 Daniel Pittman - 0.11.0 2 | =========================================================== 3 | 4 | Daniel Pittman (4): 5 | * Enforce appropriate umask and permission values 6 | * Revert Puppet file mode management 7 | * Update to the TorqueBox 3.0.1 binary distribution 8 | * Ensure correct ownership of TorqueBox deployment directory 9 | 10 | 11 | 2013-10-14 Daniel Pittman - 0.10.2 12 | =========================================================== 13 | 14 | Daniel Pittman (3): 15 | * Remove obsolete test code 16 | * Added an ISC DHCPd configuration example 17 | * Add an example manifest for installing Razor using `puppet apply` 18 | 19 | 20 | 2013-10-11 Daniel Pittman - 0.10.1 21 | =========================================================== 22 | 23 | Daniel Pittman (2): 24 | * Create `production.log` to reduce odds of permissions problems 25 | * Bind to wildcard, not loopback, when starting razor-server 26 | 27 | 28 | 2013-10-09 David Lutterkort - 0.10.0 29 | =========================================================== 30 | 31 | Daniel Pittman (9): 32 | * Handle SemVer sorting correctly in the changelog generator 33 | * Install the `net-scp` gem in addition to `net-ssh` 34 | * Fix dangling `tmpdir` reference from cache feature 35 | * Automate rebuilding the contributor list 36 | * Make `tar` installation of stable releases the default 37 | * Fix missed use of `git_version` parameter in specs 38 | * Revert "Make `tar` installation of stable releases the default" 39 | * (#136) Remove global nodejs `express` package installation 40 | * Move to `razor-server` rather than Ruby/NodeJS Razor 41 | 42 | David Calavera (4): 43 | * Cache downloaded images. 44 | * Add notice to inform that we're going to use a cached image. 45 | * Log image's md5 mismatches. 46 | * Define the new cache and md5 properties. 47 | 48 | Marc Tardif (2): 49 | * (#130) Razor providers should check return value for errors 50 | * (#133) Razor image provider should not check for errors like other 51 | providers 52 | 53 | 54 | 2013-03-12 Matthaus Owens - 0.6.1 55 | ======================================================== 56 | 57 | * no changes since the previous version. 58 | 59 | 2013-03-12 Matthaus Owens - 0.6.1-rc2 60 | ============================================================ 61 | 62 | Daniel Pittman (2): 63 | * (#114) Handle 0.6.1-rc1 style RC tags in git 64 | * Git should ignore the CHANGELOG file 65 | 66 | 67 | 2013-03-06 Daniel Pittman - 0.6.1-rc1 68 | ============================================================ 69 | 70 | Daniel Pittman (2): 71 | * (#108) Update Modulefile to work when built outside the module root 72 | * Remove duplicate headers from generated changelog 73 | 74 | Jason Parsons (1): 75 | * Quote $@ in razor.erb to avoid issue with tag matchers containing 76 | whitespace. 77 | 78 | Marc Tardif (1): 79 | * (#112) Added rubygems_update param to razor class. 80 | 81 | 82 | 2013-02-20 Daniel Pittman - 0.6.0 83 | ======================================================== 84 | 85 | Caleb Case (3): 86 | * Automatic image download for local images. 87 | * Make download fail on HTTP error. 88 | * Use the latest mk by default. 89 | 90 | Daniel Pittman (1): 91 | * (#106) Automatically generate the changelog from git commits 92 | 93 | 94 | 2013-02-12 Daniel Pittman - 0.5.0 95 | ======================================================== 96 | 97 | Daniel Pittman (2): 98 | * Update module for CVE-2013-0269 - Ruby JSON vulnerabilities 99 | * Add generated files to our gitignore 100 | 101 | 102 | 2013-02-06 Daniel Pittman - 0.4.1 103 | ======================================================== 104 | 105 | Daniel Pittman (2): 106 | * Update with new official ISO download location 107 | * Update changelog for 0.4.1 release. 108 | 109 | Marc Tardif (1): 110 | * (#98) Removed version from broker arguments. 111 | 112 | 113 | 2013-01-24 Daniel Pittman - 0.4.0 114 | ======================================================== 115 | 116 | Daniel Pittman (6): 117 | * Extract version number directly from git 118 | * Added a git mailmap to improve commit author mapping 119 | * Better error detection and discovery for git versioning 120 | * Only use annotated git tags for versioning 121 | * Add support for installing Razor using OS packages 122 | * Update the changelog for the 0.4.0 release 123 | 124 | Nan Liu (2): 125 | * Update rz_broker support for metadata. 126 | * Update README to reflect additional resources. 127 | 128 | Daniel Pittman (1): 129 | * Revert "Only use annotated git tags for versioning" 130 | 131 | 132 | 2012-11-21 Nan Liu - 0.3.0 133 | ================================================ 134 | 135 | Nan Liu (16): 136 | * Fix spec test for ruby dependency changes. 137 | * Update and simplify testing. 138 | * Allow customise razor git version and repo 139 | * Update README to reflect changes and spec. 140 | * Change razor templates to follow convention. 141 | * Fix ipxe template to match latest changes. 142 | * Fix some puppet lint warnings. 143 | * Add razor puppet resource. 144 | * Update resource for new razor cli. 145 | * Move define resource razor::system to tests. 146 | * Update spec due to ruby dev. 147 | * Add contributors list to module. 148 | * Fix gemfile for travis.ci 149 | * Fix gemfile typo. 150 | * Update vcsrepo dependency version. 151 | * Update for 0.3.0 release. 152 | 153 | geauxvirtual (5): 154 | * Adding package gcc to ruby.pp to resolve issues installing bson_ext and 155 | json gems when trying to build native extensions 156 | * Updating location of razor "executable" to /usr/bin instead of 157 | /usr/local/bin as puppet daemon does not have /usr/local/bin in it's path. 158 | * Update razor_ruby_spec.rb to include gcc package. 159 | * Update rz_broker provider and type to support feature version added in 160 | Razor issue/pull request #228 161 | * Update get_brokers to pull the broker_version when grabbing the brokers 162 | from the razor server. 163 | 164 | Pierre-Yves Ritschard (3): 165 | * fix image provisionning 166 | * use latest microkernel 167 | * typo 168 | 169 | Stephen Johnson (2): 170 | * create templates for razor config and add spec test 171 | * fix check interval 172 | 173 | Daniel Pittman (2): 174 | * Direct people to the main Razor site for help 175 | * Restructure option handling to be more script-like 176 | 177 | Chad Metcalf (2): 178 | * Install ruby::dev. 179 | * We need v0.2.0 of puppetlabs-tftp 180 | 181 | Mehdi Abaakouk (1): 182 | * Add razor broker resource. 183 | 184 | Branan Purvine-Riley (1): 185 | * Add xinetd dependency to .fixtures.yml 186 | 187 | Bill ONeill (1): 188 | * Parse out the original filename from sources that are URLs since 'razor 189 | image add' expects an os type to have an iso extension 190 | 191 | 192 | 2012-07-24 Stephen Johnson - 0.2.1 193 | =========================================================== 194 | 195 | Nan Liu (3): 196 | * Fix symlink for razor and parse empty image output. 197 | * Add mk name back to project. 198 | * Update module release. 199 | 200 | 201 | 2012-07-23 Branan Purvine-Riley - 0.2.0 202 | ================================================================ 203 | 204 | Nan Liu (6): 205 | * Change tests to not replace sudo files. 206 | * Update mongodb and spec tests. 207 | * Update razor tftp configuration. 208 | * Change ruby to use puppetlabs module ruby. 209 | * Update module release for 0.2.0. 210 | * Add rz_image resource type. 211 | 212 | 213 | 2012-07-02 Nan Liu - 0.1.4 214 | ================================================ 215 | 216 | Nan Liu (9): 217 | * Service should refresh on Vcsrepo changes. 218 | * No longer pin gem version for macaddr. 219 | * Update razor tftp service. 220 | * Update changelog for 0.1.4 release. 221 | * Update spec tests for speed. 222 | * Pin npm express version. 223 | * Update changelog and modulefile for 0.1.4. 224 | * Fix bug with service and version pin. 225 | * Fix init script issue. 226 | 227 | Branan Purvine-Riley (1): 228 | * Switch to the puppetlabs_spec_helper gem 229 | 230 | Rémi (1): 231 | * Change of the source url for Razor git repo from git to http : it's easier 232 | when using a http proxy. 233 | 234 | Street Preacher (1): 235 | * Fixed for many different network cards PXE boot. The ommision of the = 236 | causes booting to fail with the following error. “Could not fetch 237 | razor.ipxe: Operation not supported (http://ipxe.org/3c092003)" 238 | 239 | 240 | 2012-06-06 Dan Bode - 0.1.3 241 | =============================================== 242 | 243 | Nan Liu (3): 244 | * Remove files not used by razor module. 245 | * Update ipxe default config file. 246 | * Fix modulefile name to puppetlabs 247 | 248 | 249 | 2012-06-05 Branan Purvine-Riley - 0.1.2 250 | ================================================================ 251 | 252 | Nan Liu (7): 253 | * Add razor service to module. 254 | * Add ruby 1.8 support. 255 | * make package optional. 256 | * Refactor to a single ruby file. 257 | * Update spec tests for Ruby 1.8 support. 258 | * Remove unused gems from module. 259 | * Be more explicit about Ruby 1.8.7 version. 260 | 261 | Gary Larizza (4): 262 | * Provide rspec-puppet test coverage for manifests 263 | * Use modulepath if symlinks aren't in spec/fixtures 264 | * Allow Travisci to monitor the module 265 | * Add .gemfile for Travis CI 266 | 267 | 268 | 2012-05-23 Michael Stahnke - 0.1.1 269 | ============================================================ 270 | 271 | Nan Liu (2): 272 | * Add dependencies missing in build system. 273 | * Increment Modulefile release. 274 | 275 | 276 | 2012-05-23 Nan Liu - 0.1.0 277 | ================================================ 278 | 279 | * no changes since the previous version. 280 | 281 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (C) 2012 Puppet Labs Inc 2 | 3 | Puppet Labs can be contacted at: info@puppetlabs.com 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Razor Module 2 | 3 | **Note** _This module does not work as expected right now, and needs to be fixed. Until then, you need to follow the instructions for [manual installation](https://github.com/puppetlabs/razor-server/wiki/Installation)_ 4 | 5 | [Puppet Razor][razor] module will installation the Razor server on EL6, Debian 6 | 7, and Ubuntu 12.04, or newer versions of those platforms. It should be 7 | reasonably portable across platforms, and has decent support for failing well 8 | on unsupported platforms. 9 | 10 | It is considered part of the overall [Project Razor infrastructure][razor], so 11 | you can get help using the module or enhancing it over at the main 12 | [Project Razor site on GitHub][razor]. 13 | 14 | [razor]: https://github.com/puppetlabs/razor-server 15 | 16 | ## Dependencies 17 | 18 | The puppet module tool in Puppet Enterprise 2.5.0+ and Puppet 2.7.14+ resolves dependencies automatically. 19 | 20 | Puppet module dependencies for razor module: 21 | 22 | * [Java module](http://forge.puppetlabs.com/puppetlabs/java) 23 | 24 | ## Installation 25 | 26 | Install puppetlabs-razor module and dependencies into module_path: 27 | 28 | $ puppet module install puppetlabs-razor 29 | Preparing to install into /etc/puppet/modules ... 30 | Downloading from http://forge.puppetlabs.com ... 31 | Installing -- do not interrupt ... 32 | /etc/puppet/modules 33 | └─┬ puppetlabs-razor (v0.7.0) 34 | └─┬ puppetlabs-java (v1.0.1) 35 | └── puppetlabs-stdlib (v4.1.0) 36 | 37 | Then, on your Puppet master, add razor class to target node -- or just use `puppet apply` as normal: 38 | 39 | node razor_system { 40 | include razor 41 | } 42 | 43 | 44 | ## Post-Install Setup 45 | 46 | Once the Razor server is installed, you have a handful of tasks to complete: 47 | 48 | 1. Install PostgreSQL and create a Razor database. 49 | - razor-server requires a TCP connection to the database, due to JDBC driver limitations. 50 | 2. `cp /opt/razor/config.yaml.sample /opt/razor/config.yaml` 51 | 3. Edit that file to reflect your local settings. 52 | 4. Run `razor-admin -e production migrate-database` to update the database content. 53 | 5. Configure your DHCP service. 54 | - see `examples/isc-dhcpd-example.conf` for an example with the ISC DHCP daemon. 55 | - see [the wiki documentation for PXE setup for full and gory details](https://github.com/puppetlabs/razor-server/wiki/Installation#wiki-pxe) 56 | 57 | At that point everything should be working correctly. 58 | 59 | 60 | ## Razor Client 61 | 62 | This module does not install the Razor client, used to interact with the 63 | server. This is available as a Ruby gem, requiring Ruby 1.9.3, and is usually 64 | installed on developer workstations rather than the Razor server system. 65 | 66 | Installing this is left as an exercise to the reader, but: 67 | 68 | puppet resource package name=razor-client provider=gem ensure=latest 69 | 70 | 71 | ## Parameters 72 | 73 | * libarchive: set the package name for libarchive explicitly. 74 | - libarchive is require for ISO unpacking; if your system is not supported by autodetection you can set a manual package name instead. 75 | 76 | 77 | ## Contributors 78 | 79 | A wide array of folks have contributed to the Razor module, including a pile 80 | of hugely valuable external contributions. The list was getting too long to maintain inline, but you can see the full list of contributors in the `CONTRIBUTORS` file. 81 | -------------------------------------------------------------------------------- /bin/get-version-from-git: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # 3 | # manual testing, if you need to modify this: 4 | # for version in 0.6.0-1-g212920c 0.6.1-rc1 0.6.1-rc1-1-g212920c 0.6.1; do 5 | # ./bin/get-version-from-git $version; 6 | # done 7 | version = ARGV[0] || %x{git describe}.chomp 8 | 9 | # Pattern: stuff to keep, the final digit of version tag, any git tagging 10 | if md = /^(.+)(\d+)-(\d+-g[0-9a-f]+)$/i.match(version) 11 | # ...and if we match the pattern we have git commits past the last tag, so 12 | # we need to bump the last digit we found. This works on two cases: 13 | # 14 | # 0.6.1-1-deadbeef => bump the trivial version, to 0.6.2 15 | # 0.6.1-rc1-1-deadbeef => bump the RC number, to 0.6.1-rc2 16 | # 17 | # In both cases we retain the git tagging information. 18 | # 19 | # This is necessary because we are at the mercy of puppet module, and the 20 | # forge, which refuse to use sensible build numbers, and order things as if 21 | # anything with a trailing segment is *before* the relevant version. 22 | version = "#{md[1]}#{md[2].to_i(10) + 1}-#{md[3]}" 23 | end 24 | 25 | puts version 26 | exit 0 27 | -------------------------------------------------------------------------------- /bin/git-log-to-changelog: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | STDERR.puts "generate changelog: " 3 | 4 | def capture(cmd) 5 | result = %x{#{cmd}} 6 | fail "unable to execute #{cmd.inspect}: #{$?}" unless $?.success? 7 | return result 8 | end 9 | 10 | def compare_as_int(a,b) 11 | result = a.to_i <=> b.to_i 12 | result == 0 ? nil : result 13 | end 14 | 15 | def compare_as_special(a,b) 16 | # This probably only supports up to RC9 correctly. 17 | if a.nil? and not b.nil? then 1 18 | elsif not a.nil? and b.nil? then -1 19 | elsif a.nil? and b.nil? then 0 20 | else a <=> b 21 | end 22 | end 23 | 24 | tags = capture('git tag -l').split.sort do |a, b| 25 | a = a.split(/[-.]/) 26 | b = b.split(/[-.]/) 27 | 28 | compare_as_int(a[0], b[0]) || 29 | compare_as_int(a[1], b[1]) || 30 | compare_as_int(a[2], b[2]) || 31 | compare_as_special(a[3], b[3]) 32 | end.reverse 33 | 34 | # ...and insert the "base" version before the first version. 35 | tags.push nil 36 | 37 | tags.each_cons(2) do |top, bottom| 38 | STDERR.print '.' 39 | 40 | header = capture("git log -1 --date=short --format=\"%cd %cN <%cE> - #{top}\" \"#{top}\"") 41 | puts header 42 | puts '=' * header.length 43 | puts '' 44 | 45 | changes = capture("git shortlog --no-merges -n -e --format='* %s' -w77,1,3 #{bottom}..#{top}") 46 | if changes.empty? 47 | puts " * no changes since the previous version." 48 | else 49 | puts changes.gsub(/^/, ' ') 50 | end 51 | 52 | puts '' 53 | end 54 | 55 | STDERR.puts " done." 56 | exit 0 57 | -------------------------------------------------------------------------------- /examples/install-with-apply.pp: -------------------------------------------------------------------------------- 1 | if $serverversion { 2 | # You don't want to run this as-is on the master: it would install the razor 3 | # server on *every single node* in your infrastructure. Ouch! This is 4 | # basically to stop someone blindly dropping this into place rather than 5 | # putting the `include razor` line into a correct `node whatever` block. 6 | crit("looks like this was used on the master, which will install razor *everywhere") 7 | } 8 | 9 | # this is sufficient to get razor installed if you are using `puppet apply`. 10 | # as noted, everything else in this file is just noise around this. :) 11 | include razor 12 | -------------------------------------------------------------------------------- /examples/isc-dhcpd-example.conf: -------------------------------------------------------------------------------- 1 | # isc-dhcpd-example.conf 2 | # 3 | # Sample configuration file for ISC dhcpd together with razor-server 4 | 5 | # option definitions common to all supported networks... 6 | option domain-name "local"; 7 | option domain-name-servers 172.16.226.2; 8 | 9 | default-lease-time 600; 10 | max-lease-time 7200; 11 | 12 | # Use this to enble / disable dynamic dns updates globally. 13 | ddns-update-style none; 14 | 15 | # If this DHCP server is the official DHCP server for the local 16 | # network, the authoritative directive should be uncommented. 17 | authoritative; 18 | 19 | 20 | subnet 172.16.226.0 netmask 255.255.255.0 { 21 | range 172.16.226.20 172.16.226.50; 22 | option routers 172.16.226.2; 23 | 24 | # My Razor TFTP content -- and razor-server -- are running on this machine; 25 | # adjust this to reflect your network. It should be the TFTP server that 26 | # has the iPXE file, and the bootstrap.ipxe script, but does not have to 27 | # be the same physical machine as the razor-server code runs on. 28 | next-server 172.16.226.5; 29 | 30 | # iPXE double-bootstrap operation; send our script if iPXE, or the iPXE kernel 31 | # itself otherwise. Everything netboots by default, though. 32 | if exists user-class and option user-class = "iPXE" { 33 | # this branch applies only *after* we are running iPXE 34 | filename "bootstrap.ipxe"; 35 | } else { 36 | # this branch applies to the default PXE loader, and will then make another 37 | # DHCP/PXE request to get the boot file, hitting the first branch... 38 | filename "undionly.kpxe"; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /files/undionly.kpxe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/puppetlabs-toy-chest/puppetlabs-razor/5dc533db4a0ffd8228c49c072e7f465abc0c1482/files/undionly.kpxe -------------------------------------------------------------------------------- /manifests/init.pp: -------------------------------------------------------------------------------- 1 | # Class: razor 2 | # 3 | # Parameters: 4 | # 5 | # [*servername*]: the DNS name or IP address of the Razor server (default: `$fqdn`) 6 | # [*libarchive*]: the name of the libarchive package. (default: autodetect) 7 | # [*tftp*]: should TFTP services be installed and configured on this machine? (default: true) 8 | # 9 | # Actions: 10 | # 11 | # Installs and runs the razor-server, along with all dependencies. 12 | # 13 | # Usage: 14 | # 15 | # include razor 16 | # 17 | class razor ( 18 | $servername = $fqdn, 19 | $libarchive = undef, 20 | $tftp = true, 21 | $java_package = undef 22 | ) { 23 | # Ensure libarchive is installed -- the users requested custom version, or 24 | # our own guesswork as to what the version is on this platform. 25 | if $libarchive { 26 | package { $libarchive: ensure => latest } 27 | } else { 28 | include razor::libarchive 29 | } 30 | 31 | package { "unzip": ensure => latest } 32 | package { "curl": ensure => latest } 33 | 34 | # Install a JVM, since we need one 35 | if $java_package { 36 | class { 'java': 37 | package => $java_package 38 | } 39 | } else { 40 | include 'java' 41 | } 42 | Class[java] -> Class[Razor::TorqueBox] 43 | 44 | # Install our own TorqueBox bundle, quietly. This isn't intended to be 45 | # shared with anyone else, so we don't use a standard module. 46 | include 'razor::torquebox' 47 | 48 | # Once that is installed, we also need to install the server software. 49 | include 'razor::server' 50 | Class[Razor::Torquebox] -> Class[Razor::Server] 51 | 52 | if $tftp { 53 | class { 'razor::tftp': 54 | server => $servername 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /manifests/libarchive.pp: -------------------------------------------------------------------------------- 1 | class razor::libarchive { 2 | $libarchive_package = $operatingsystem ? { 3 | "Ubuntu" => $operatingsystemrelease ? { 4 | /^12/ => 'libarchive12', 5 | /^13/ => 'libarchive13', 6 | /^14/ => 'libarchive13', 7 | default => undef 8 | }, 9 | "Debian" => $operatingsystemmajrelease ? { 10 | '6' => 'libarchive1', 11 | '7' => 'libarchive12', 12 | default => 'libarchive13' 13 | }, 14 | # We need the unversioned .so, which comes from the dev package on these 15 | # platforms; without that FFI fails to load the library. This naturally 16 | # depends on the regular library package in yum. 17 | "Fedora" => 'libarchive-devel', 18 | "RedHat" => 'libarchive-devel', 19 | "CentOS" => 'libarchive-devel', 20 | default => undef 21 | } 22 | 23 | if ! $libarchive_package { 24 | fail("unable to autodetect libarchive package name for your platform") 25 | } 26 | 27 | package { $libarchive_package: ensure => latest } 28 | } 29 | -------------------------------------------------------------------------------- /manifests/server.pp: -------------------------------------------------------------------------------- 1 | class razor::server { 2 | $url = 'http://links.puppetlabs.com/razor-server-latest.zip' 3 | $dest = '/opt/razor' 4 | 5 | # Put the archive into place, if needed. 6 | exec { "install razor binary distribution to ${dest}": 7 | provider => shell, 8 | command => template('razor/install-zip.sh.erb'), 9 | path => '/bin:/usr/bin:/usr/local/bin:/opt/bin', 10 | creates => "${dest}/bin/razor-admin", 11 | require => [Package[curl], Package[unzip]], 12 | notify => Exec["deploy razor to torquebox"] 13 | } 14 | 15 | exec { "deploy razor if it was undeployed": 16 | provider => shell, 17 | unless => "test -f ${razor::torquebox::dest}/jboss/standalone/deployments/razor-knob.yml", 18 | # This is actually "notify if the file does not exist" :) 19 | command => ":", 20 | notify => Exec["deploy razor to torquebox"], 21 | require => Exec["install razor binary distribution to ${dest}"] 22 | } 23 | 24 | # deploy razor, if required. 25 | exec { "deploy razor to torquebox": 26 | command => "${razor::torquebox::dest}/jruby/bin/torquebox deploy --env production", 27 | cwd => $dest, 28 | environment => [ 29 | "TORQUEBOX_HOME=${razor::torquebox::dest}", 30 | "JBOSS_HOME=${razor::torquebox::dest}/jboss", 31 | "JRUBY_HOME=${razor::torquebox::dest}/jruby" 32 | ], 33 | path => "${razor::torquebox::dest}/jruby/bin:/bin:/usr/bin:/usr/local/bin", 34 | require => Exec["install razor binary distribution to ${dest}"], 35 | refreshonly => true 36 | } 37 | 38 | file { "${dest}/bin/razor-binary-wrapper": 39 | ensure => file, owner => root, group => root, mode => 0755, 40 | content => template('razor/razor-binary-wrapper.erb'), 41 | require => Exec["install razor binary distribution to ${dest}"] 42 | } 43 | 44 | file { "/usr/local/bin/razor-admin": 45 | ensure => link, target => "${dest}/bin/razor-binary-wrapper" 46 | } 47 | 48 | # Work around what seems very much like a bug in the package... 49 | file { "${dest}/bin/razor-admin": 50 | mode => 0755, 51 | require => Exec["install razor binary distribution to ${dest}"] 52 | } 53 | 54 | file { "/var/lib/razor": 55 | ensure => directory, owner => razor-server, group => razor-server, mode => 0775, 56 | require => Exec["install razor binary distribution to ${dest}"] 57 | } 58 | 59 | file { "/var/lib/razor/repo-store": 60 | ensure => directory, owner => razor-server, group => razor-server, mode => 0775 61 | } 62 | 63 | file { "${dest}/log": 64 | ensure => directory, owner => razor-server, group => razor-server, mode => 0775, 65 | require => Exec["install razor binary distribution to ${dest}"] 66 | } 67 | 68 | file { "${dest}/log/production.log": 69 | ensure => file, owner => razor-server, group => razor-server, mode => 0660 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /manifests/tftp.pp: -------------------------------------------------------------------------------- 1 | class razor::tftp( 2 | $server 3 | ) { 4 | include ::tftp 5 | 6 | ::tftp::file { "undionly.kpxe": } 7 | 8 | ::tftp::file { "bootstrap.ipxe": 9 | content => template('razor/bootstrap.ipxe.erb') 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /manifests/torquebox.pp: -------------------------------------------------------------------------------- 1 | class razor::torquebox { 2 | $url = 'http://torquebox.org/release/org/torquebox/torquebox-dist/3.0.1/torquebox-dist-3.0.1-bin.zip' 3 | $root = 'torquebox-3.0.1' 4 | $dest = '/opt/razor-torquebox' 5 | $user = 'razor-server' 6 | 7 | # Put the archive into place, if needed. 8 | exec { "install torquebox binary distribution to ${dest}": 9 | provider => shell, 10 | command => template('razor/install-zip.sh.erb'), 11 | path => '/bin:/usr/bin:/usr/local/bin:/opt/bin', 12 | creates => "${dest}/jruby/bin/torquebox", 13 | require => [Package[curl], Package[unzip]] 14 | } -> 15 | 16 | user { $user: 17 | ensure => present, 18 | system => true, # system -- daemon -- user, please 19 | password => '*', # no password logins, please 20 | home => $dest, 21 | shell => '/bin/bash', # if it comes up, let's be common 22 | comment => "razor-server daemon user", 23 | } -> 24 | 25 | # Make sure that the deployment directory has appropriate ownership, so that 26 | # it can be written to as the razor user. This is not as appropriate if we 27 | # deploy multiple applications in the one container, but for now we have a 28 | # dedicated install, so we go with that. 29 | file { "${dest}/jboss/standalone": 30 | recurse => true, checksum => none, owner => $user 31 | } -> 32 | 33 | # Install an init script for the Razor torquebox install 34 | file { "/etc/init.d/razor-server": 35 | owner => root, group => root, mode => 0755, 36 | content => template('razor/razor-server.init.erb') 37 | } -> 38 | 39 | file { "/var/log/razor-server": 40 | ensure => directory, owner => $user, group => 'root', mode => 0755 41 | } -> 42 | 43 | service { "razor-server": 44 | ensure => running, 45 | enable => true, 46 | hasrestart => true, 47 | hasstatus => true 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "operatingsystem_support": [ 3 | { 4 | "operatingsystem": "RedHat", 5 | "operatingsystemrelease": [ 6 | "6" 7 | ] 8 | }, 9 | { 10 | "operatingsystem": "CentOS", 11 | "operatingsystemrelease": [ 12 | "6" 13 | ] 14 | }, 15 | { 16 | "operatingsystem": "OracleLinux", 17 | "operatingsystemrelease": [ 18 | "6" 19 | ] 20 | }, 21 | { 22 | "operatingsystem": "Scientific", 23 | "operatingsystemrelease": [ 24 | "6" 25 | ] 26 | } 27 | ], 28 | "requirements": [ 29 | { 30 | "name": "pe", 31 | "version_requirement": ">= 3.2.0 < 3.4.0" 32 | }, 33 | { 34 | "name": "puppet", 35 | "version_requirement": "3.x" 36 | } 37 | ], 38 | "name": "puppetlabs-razor", 39 | "version": "0.11.0", 40 | "source": "git://github.com/puppetlabs/puppetlabs-razor.git", 41 | "author": "Puppet Labs", 42 | "license": "Apache 2.0", 43 | "summary": "Installs the Razor server on EL6, Debian 7, and Ubuntu 12.04, or newer versions of those platforms.", 44 | "description": "Razor provisioning system puppet installation module", 45 | "project_page": "http://github.com/puppetlabs/puppetlabs-razor", 46 | "dependencies": [ 47 | { 48 | "name": "puppetlabs/java", 49 | "version_requirement": ">= 1.0.1" 50 | }, 51 | { 52 | "name": "puppetlabs/tftp", 53 | "version_requirement": ">= 0.2.1" 54 | } 55 | ] 56 | } 57 | -------------------------------------------------------------------------------- /templates/bootstrap.ipxe.erb: -------------------------------------------------------------------------------- 1 | #!ipxe 2 | 3 | isset ${ip} || goto dhcp_net0 4 | set dhcp_mac ${mac:hexhyp} 5 | goto chain_boot 6 | 7 | :dhcp_net0 8 | isset ${net0/mac} && dhcp net0 || goto dhcp_net1 9 | echo net0 has DHCP 10 | set dhcp_mac net0$${net0/mac:hexhyp} 11 | 12 | :dhcp_net1 13 | isset ${net1/mac} && dhcp net1 || goto dhcp_net2 14 | echo net1 has DHCP 15 | set dhcp_mac net1$${net1/mac:hexhyp} 16 | 17 | :dhcp_net2 18 | isset ${net2/mac} && dhcp net2 || goto dhcp_net3 19 | echo net2 has DHCP 20 | set dhcp_mac net2$${net2/mac:hexhyp} 21 | 22 | :dhcp_net3 23 | isset ${net3/mac} && dhcp net3 || goto chain_boot 24 | echo net3 has DHCP 25 | set dhcp_mac net3$${net3/mac:hexhyp} 26 | 27 | 28 | :chain_boot 29 | echo chain booting the razor script from <%= @server %> 30 | chain http://<%= @server %>:8080/svc/boot?net0=${net0/mac:hexhyp}&net1=${net1/mac:hexhyp}&net2=${net2/mac:hexhyp}&net3=${net3/mac:hexhyp}&dhcp_mac=${dhcp_mac}&serial=${serial}&asset=${asset}&uuid=${uuid} || goto error 31 | echo successfully completed the chain-loaded script; booting locally with 'exit' 32 | exit 33 | 34 | :error 35 | prompt --key s --timeout 60 ERROR, hit 's' for the iPXE shell; reboot in 60 seconds && shell || reboot 36 | # just in case... 37 | reboot 38 | -------------------------------------------------------------------------------- /templates/install-zip.sh.erb: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -ex 3 | 4 | umask 0022 # allow rX for group/other 5 | 6 | tmpdir="$(dirname "<%= @dest %>")/razor-$$" # not very secure 7 | trap "rm -rf '${tmpdir}'" exit 8 | mkdir -p "${tmpdir}" 9 | 10 | # OK, we need to download and unpack the archive into the destination... 11 | curl -Lo "${tmpdir}"/scratch.zip "<%= @url %>" 12 | 13 | # Now, unpack it in the same location. 14 | unzip -d "${tmpdir}" "${tmpdir}"/scratch.zip 15 | rm -rf "${tmpdir}"/scratch.zip 16 | 17 | # Finally, move that into place overwriting the destination files, but 18 | # avoiding destroying additional files. This helps with upgrades... 19 | mkdir -p "<%= @dest %>" 20 | if ! tar cC "${tmpdir}/<%= @root %>" . | tar xC "<%= @dest %>"; then 21 | rm -rf "<%= @dest %>" 22 | exit 1 23 | fi 24 | 25 | # ...done. 26 | exit 0 27 | -------------------------------------------------------------------------------- /templates/razor-binary-wrapper.erb: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # WARNING: This is a generated file. Manual changes will be ignored. 4 | # 5 | # Data filled in by Puppet about where we are installed... 6 | razor='<%= scope.lookupvar('::razor::server::dest') %>' 7 | torquebox='<%= scope.lookupvar('::razor::torquebox::dest')%>' 8 | jruby="${torquebox}/jruby" 9 | 10 | # Make sure our path points to the right general location. 11 | export PATH="${razor}/bin:${jruby}/bin:${PATH}" 12 | 13 | # Some other environment variables we might need. 14 | export TORQUEBOX_HOME="${torquebox}" 15 | export JBOSS_HOME="${torquebox}/jboss" 16 | export JRUBY_HOME="${torquebox}/jruby" 17 | 18 | # Figure out what we were asked to execute. 19 | exe="$(basename $0)" 20 | 21 | # Find the executable, and run it directly, or fail out gracefully. 22 | if test -f "${razor}/bin/${exe}"; then 23 | exec "${razor}/bin/${exe}" "$@" 24 | elif test -f "${jruby}/bin/${exe}"; then 25 | exec "${jruby}/bin/${exe}" 26 | else 27 | echo "unable to find the ${exe} command in razor!" 28 | exit 1 29 | fi 30 | -------------------------------------------------------------------------------- /templates/razor-server.init.erb: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # razor-server startup script for CentOS et al 4 | # 5 | # chkconfig: - 80 20 6 | # description: razor-server 7 | # processname: standalone 8 | # pidfile: /var/run/razor-server.pid 9 | 10 | # Ensure we have a sensible umask 11 | umask 0027 12 | 13 | NAME="razor-server" 14 | WAIT=30 # seconds 15 | 16 | # Set defaults. 17 | TORQUEBOX_HOME="<%= @dest %>" 18 | JBOSS_HOME="${TORQUEBOX_HOME}/jboss" 19 | JRUBY_HOME="${TORQUEBOX_HOME}/jruby" 20 | export TORQUEBOX_HOME JBOSS_HOME JRUBY_HOME 21 | 22 | PATH="${JRUBY_HOME}/bin:${PATH}" 23 | export PATH 24 | 25 | JBOSS_PIDFILE="/var/run/${NAME}/torquebox.pid" 26 | export JBOSS_PIDFILE 27 | 28 | JBOSS_LOG_DIR="/var/log/${NAME}" 29 | JBOSS_CONSOLE_LOG="${JBOSS_LOG_DIR}/console.log" 30 | export JBOSS_LOG_DIR JBOSS_CONSOLE_LOG 31 | 32 | JBOSS_USER="<%= @user %>" 33 | 34 | JBOSS_CONFIG=standalone.xml 35 | JBOSS_SCRIPT="${JBOSS_HOME}/bin/standalone.sh" 36 | 37 | LAUNCH_JBOSS_IN_BACKGROUND=true 38 | export LAUNCH_JBOSS_IN_BACKGROUND 39 | 40 | start() { 41 | echo -n "Launching ${NAME}: " 42 | 43 | if status >&/dev/null; then 44 | echo "already running." 45 | return 0 46 | fi 47 | 48 | # We want to truncate the logfile, not just ensure it exists. 49 | echo >"${JBOSS_CONSOLE_LOG}" 50 | chown "${JBOSS_USER}" "${JBOSS_CONSOLE_LOG}" 51 | 52 | # We can't be sure any directory under /var/run exists after a reboot, 53 | # since some distributions put it on a ramfs -- and not unreasonably. 54 | mkdir -p --mode 0755 "$(dirname "${JBOSS_PIDFILE}")" 55 | echo >"${JBOSS_PIDFILE}" 56 | chown "${JBOSS_USER}" "${JBOSS_PIDFILE}" 57 | 58 | # Delegate to another instance of the same script, run as another user, to 59 | # actually fire off the software. This helps isolate the context between 60 | # the two, and ensures we don't depend on, eg, environment variables being 61 | # copied by su -- which is less reliable than one may hope. 62 | su - "${JBOSS_USER}" -c "$0 run" & 63 | pid=$! 64 | disown ${pid} 65 | 66 | # if the process stops running while we wait, it failed. 67 | if ! kill -0 ${pid} >&/dev/null; then 68 | echo "failed." 69 | return 1 70 | fi 71 | 72 | echo "done." 73 | echo -n "Waiting ${WAIT} seconds for start: " 74 | 75 | # Wait for startup, up to the thirty second mark. 76 | for (( count=0; count<${WAIT}; count++ )); do 77 | # if the process stops running while we wait, it failed. 78 | if ! kill -0 ${pid} >&/dev/null; then 79 | echo " failed." 80 | return 1 81 | fi 82 | 83 | # found the mark that we started, exit now. 84 | if egrep -q 'JBoss AS .* started in' "${JBOSS_CONSOLE_LOG}"; then 85 | echo " done." 86 | return 0 87 | fi 88 | 89 | # otherwise wait, and try again. 90 | echo -n '.' 91 | sleep 1 92 | done 93 | 94 | echo " timed out, starting in background." 95 | return 0 96 | } 97 | 98 | # This actually runs the software; we assume we are already running as the 99 | # subordinate user, and start in the background. 100 | run() { 101 | exec >&"${JBOSS_CONSOLE_LOG}" \ 102 | "${JBOSS_SCRIPT}" "-Djboss.server.log.dir=${JBOSS_LOG_DIR}" \ 103 | "-b" "0.0.0.0" 104 | } 105 | 106 | 107 | stop() { 108 | if status >&/dev/null; then 109 | echo -n "Stopping ${NAME}: " 110 | kill $(< "${JBOSS_PIDFILE}") 111 | 112 | # Wait for the process to terminate, which may take a little while 113 | for (( count=0; count<=${WAIT}; count++ )); do 114 | if ! status>&/dev/null; then 115 | echo " done." 116 | return 0 117 | fi 118 | 119 | echo -n '.' 120 | sleep 1 121 | done 122 | 123 | echo " timed out waiting to die." 124 | return 1 125 | else 126 | echo "${NAME} seemed to be stopped already, doing nothing" 127 | return 0 128 | fi 129 | } 130 | 131 | 132 | 133 | status() { 134 | if [ -f "${JBOSS_PIDFILE}" ]; then 135 | read pid < ${JBOSS_PIDFILE} 136 | if ps --no-headers -p${pid} -oargs | grep -qc "${JBOSS_HOME}"; then 137 | echo "${NAME} is running (pid $pid)" 138 | return 0 139 | else 140 | echo "${NAME} dead but pid file exists" 141 | return 1 142 | fi 143 | fi 144 | echo "${NAME} is not running" 145 | return 3 146 | } 147 | 148 | case "$1" in 149 | start) start ;; 150 | # used internally to manage user switching, not mentioned to user 151 | run) run ;; 152 | stop) stop ;; 153 | status) status ;; 154 | restart) 155 | $0 stop 156 | $0 start 157 | ;; 158 | *) 159 | echo "Usage: $0 {start|stop|status|restart}" 160 | exit 1 161 | ;; 162 | esac 163 | --------------------------------------------------------------------------------