Permalink
Browse files

initial version of a jruby devbox

currently installs jdk version 1.7.0_13 and jruby via rvm
  • Loading branch information...
Xylakant committed Feb 2, 2013
1 parent 3515d66 commit 31bedb1d9ea2ad9febb49c9c58bd9a1c9a881fe6
View
@@ -0,0 +1,2 @@
+.vagrant
+modules/java/files/rpms/*
View
@@ -0,0 +1,6 @@
+[submodule "modules/stdlib"]
+ path = modules/stdlib
+ url = git@github.com:puppetlabs/puppetlabs-stdlib.git
+[submodule "modules/rvm"]
+ path = modules/rvm
+ url = git@github.com:blt04/puppet-rvm.git
View
@@ -1,2 +1,16 @@
vagrant-tomcat-box
-==================
+==================
+
+A vagrant box to develop in jruby/tomcat.
+
+## Java-Installation
+
+Since oracle requires to accept the java TOS, you need to download the jre and place it in
+`modules/java/files/rpms`.
+
+## Box-Setup
+
+The box is set to accept GIT_* variables over SSH, so that you can export your local
+git env into the box.
+
+The box uses and requires the vagrant-dns plugin.
View
@@ -0,0 +1,95 @@
+# -*- mode: ruby -*-
+# vi: set ft=ruby :
+
+Vagrant::Config.run do |config|
+ # All Vagrant configuration is done here. The most common configuration
+ # options are documented and commented below. For a complete reference,
+ # please see the online documentation at vagrantup.com.
+
+ # Every Vagrant virtual environment requires a box to build off of.
+ config.vm.box = "centos-6.3-base"
+
+ # The url from where the 'config.vm.box' box will be fetched if it
+ # doesn't already exist on the user's system.
+ config.vm.box_url = "http://asq-vagrant-boxes.s3.amazonaws.com/centos/centos-6.3-base.box"
+
+ # Boot with a GUI so you can see the screen. (Default is headless)
+ # config.vm.boot_mode = :gui
+
+ # Assign this VM to a host-only network IP, allowing you to access it
+ # via the IP. Host-only networks can talk to the host machine as well as
+ # any other machines on the same network, but cannot be accessed (through this
+ # network interface) by any external networks.
+ config.vm.network :hostonly, "192.168.33.10"
+
+ config.dns.tld = "dev"
+ config.vm.host_name = "tomcat"
+ config.dns.patterns = [/^.*tomcat.dev$/]
+
+ # Share an additional folder to the guest VM. The first argument is
+ # an identifier, the second is the path on the guest to mount the
+ # folder, and the third is the path on the host to the actual folder.
+ # config.vm.share_folder "v-data", "/vagrant_data", "../data"
+
+ # Enable provisioning with Puppet stand alone. Puppet manifests
+ # are contained in a directory path relative to this Vagrantfile.
+ # You will need to create the manifests directory and a manifest in
+ # the file centos-6.3-base.pp in the manifests_path directory.
+ #
+ # An example Puppet manifest to provision the message of the day:
+ #
+ # # group { "puppet":
+ # # ensure => "present",
+ # # }
+ # #
+ # # File { owner => 0, group => 0, mode => 0644 }
+ # #
+ # # file { '/etc/motd':
+ # # content => "Welcome to your Vagrant-built virtual machine!
+ # # Managed by Puppet.\n"
+ # # }
+ #
+ config.vm.provision :puppet do |puppet|
+ puppet.manifests_path = "manifests"
+ puppet.manifest_file = "tomcat-server.pp"
+ puppet.module_path = "modules/"
+ end
+
+ # Enable provisioning with chef solo, specifying a cookbooks path, roles
+ # path, and data_bags path (all relative to this Vagrantfile), and adding
+ # some recipes and/or roles.
+ #
+ # config.vm.provision :chef_solo do |chef|
+ # chef.cookbooks_path = "../my-recipes/cookbooks"
+ # chef.roles_path = "../my-recipes/roles"
+ # chef.data_bags_path = "../my-recipes/data_bags"
+ # chef.add_recipe "mysql"
+ # chef.add_role "web"
+ #
+ # # You may also specify custom JSON attributes:
+ # chef.json = { :mysql_password => "foo" }
+ # end
+
+ # Enable provisioning with chef server, specifying the chef server URL,
+ # and the path to the validation key (relative to this Vagrantfile).
+ #
+ # The Opscode Platform uses HTTPS. Substitute your organization for
+ # ORGNAME in the URL and validation key.
+ #
+ # If you have your own Chef Server, use the appropriate URL, which may be
+ # HTTP instead of HTTPS depending on your configuration. Also change the
+ # validation key to validation.pem.
+ #
+ # config.vm.provision :chef_client do |chef|
+ # chef.chef_server_url = "https://api.opscode.com/organizations/ORGNAME"
+ # chef.validation_key_path = "ORGNAME-validator.pem"
+ # end
+ #
+ # If you're using the Opscode platform, your validator client is
+ # ORGNAME-validator, replacing ORGNAME with your organization name.
+ #
+ # IF you have your own Chef Server, the default validation client name is
+ # chef-validator, unless you changed the configuration.
+ #
+ # chef.validation_client_name = "ORGNAME-validator"
+end
View
@@ -0,0 +1,79 @@
+class requirements {
+ include sysconfig
+ include sysconfig::sudoers
+ include ssh::server
+
+ group { "vagrant":
+ ensure => 'present',
+ }
+ user { "vagrant":
+ ensure => 'present',
+ gid => 'vagrant',
+ require => Group['vagrant']
+ } -> file { "/home/vagrant":
+ ensure => directory,
+ owner => vagrant
+ }
+
+ ssh::user { "vagrant": }
+
+ # user and group puppet necessary for rvm
+ group { "puppet":
+ ensure => 'present',
+ }
+ user { "puppet":
+ ensure => 'present',
+ gid => 'puppet',
+ require => Group['puppet']
+ }
+}
+
+class installrvm {
+ include rvm
+
+ # ruby version to use
+ $rubyversion = 'jruby'
+
+ Exec {
+ path => [ "/bin/", "/sbin/", "/usr/bin/", "/usr/sbin/", "/usr/local/rvm/bin" ]
+ }
+
+ rvm::system_user { vagrant: ; }
+
+ rvm_system_ruby { $rubyversion:
+ ensure => 'present',
+ default_use => true;
+ }
+}
+
+class projects {
+ # set permissions on dev directory where all projects reside
+ file { "/home/vagrant/dev":
+ ensure => 'directory',
+ owner => 'vagrant',
+ group => 'vagrant',
+ mode => 750
+ }
+}
+
+stage { 'requirementsstage': before => Stage['main'] }
+
+class doinstall {
+
+ package {"vim-enhanced":
+ ensure => installed
+ }
+
+ include projects
+ include installrvm
+ include java::jdk
+
+ class { requirements: stage => 'requirementsstage' }
+
+ Class['java::jdk'] -> Class['installrvm'] -> Class['projects']
+}
+
+# start and set up everything
+include doinstall
+
+
@@ -0,0 +1,26 @@
+define git::clone(
+ $repository_name = '',
+ $repository_url,
+ $cwd = './',
+ $user,
+ $group
+) {
+ require git
+
+ Exec { path => [ "/bin/", "/sbin/" , "/usr/bin/", "/usr/sbin/" ] }
+
+ if $repository_name == '' {
+ $repo_name = $name
+ } else {
+ $repo_name = $repository_name
+ }
+
+ $command = "git clone --recursive --quiet ${repository_url} ${repo_name}"
+
+ exec { "git-clone-${repository_url}":
+ command => $command,
+ cwd => $cwd,
+ user => $user,
+ group => $group,
+ }
+}
@@ -0,0 +1,3 @@
+class git {
+ require git::install
+}
@@ -0,0 +1,6 @@
+class git::install {
+ case $::operatingsystem {
+ Ubuntu,Debian: { require git::install::ubuntu }
+ Gentoo: { require git::install::gentoo }
+ }
+}
@@ -0,0 +1,3 @@
+class git::install::ubuntu {
+# if ! defined(Package['git']) { package { 'git': ensure => installed } }
+}
@@ -0,0 +1,3 @@
+class git::install::ubuntu {
+ if ! defined(Package['git-core']) { package { 'git-core': ensure => installed } }
+}
@@ -0,0 +1,20 @@
+# installs the jdk from an rpm
+# you need to drop the rpm into the files folder
+
+class java::jdk {
+
+ $jdk = "jdk.x86_64"
+
+ # fetch the jdk tarball.
+ file { "/root/$jdk.rpm":
+ source => "puppet:///modules/java/rpms/jdk-7u13-linux-x64.rpm", # fetch from the puppet server.
+ }
+
+ package {"$jdk":
+ source => "/root/$jdk.rpm",
+ ensure => installed,
+ require => File["/root/$jdk.rpm"],
+ provider => "rpm", # the yum provider can't install from file.
+ }
+
+}
Submodule rvm added at ce10a0
No changes.
@@ -0,0 +1,20 @@
+
+class ssh::server {
+
+ file { "/etc/ssh/sshd_config":
+ content => template("ssh/server/sshd_config.erb"),
+ ensure => present,
+ notify => Service['sshd']
+ }
+
+ service { "sshd":
+ require => Package['openssh-server'],
+ ensure => running,
+ enable => true
+ }
+
+ package { "openssh-server":
+ ensure => present
+ }
+
+}
@@ -0,0 +1,13 @@
+define ssh::user($user = "${name}", $home = "/home/${name}") {
+
+
+ User[$user] -> File[$home] -> file { "$home/.ssh/":
+ ensure => directory,
+ } -> file { "$home/.ssh/known_hosts":
+ ensure => present,
+ content => template("ssh/user/known_hosts.erb"),
+ owner => $user,
+ mode => "0420"
+ }
+
+}
@@ -0,0 +1,80 @@
+# Package generated configuration file
+# See the sshd(8) manpage for details
+
+# What ports, IPs and protocols we listen for
+Port 22
+# Use these options to restrict which interfaces/protocols sshd will bind to
+#ListenAddress ::
+#ListenAddress 0.0.0.0
+Protocol 2
+# HostKeys for protocol version 2
+HostKey /etc/ssh/ssh_host_rsa_key
+HostKey /etc/ssh/ssh_host_dsa_key
+#Privilege Separation is turned on for security
+UsePrivilegeSeparation yes
+
+# Lifetime and size of ephemeral version 1 server key
+KeyRegenerationInterval 3600
+ServerKeyBits 768
+
+# Logging
+SyslogFacility AUTH
+LogLevel INFO
+
+# Authentication:
+LoginGraceTime 120
+PermitRootLogin yes
+StrictModes yes
+
+RSAAuthentication yes
+PubkeyAuthentication yes
+#AuthorizedKeysFile %h/.ssh/authorized_keys
+
+# Don't read the user's ~/.rhosts and ~/.shosts files
+IgnoreRhosts yes
+# For this to work you will also need host keys in /etc/ssh_known_hosts
+RhostsRSAAuthentication no
+# similar for protocol version 2
+HostbasedAuthentication no
+# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
+#IgnoreUserKnownHosts yes
+
+# To enable empty passwords, change to yes (NOT RECOMMENDED)
+PermitEmptyPasswords no
+
+# Change to yes to enable challenge-response passwords (beware issues with
+# some PAM modules and threads)
+ChallengeResponseAuthentication no
+
+# Change to no to disable tunnelled clear text passwords
+PasswordAuthentication no
+
+# Kerberos options
+#KerberosAuthentication no
+#KerberosGetAFSToken no
+#KerberosOrLocalPasswd yes
+#KerberosTicketCleanup yes
+
+# GSSAPI options
+#GSSAPIAuthentication no
+#GSSAPICleanupCredentials yes
+
+X11Forwarding yes
+X11DisplayOffset 10
+PrintMotd no
+PrintLastLog yes
+TCPKeepAlive yes
+#UseLogin no
+
+#MaxStartups 10:30:60
+#Banner /etc/issue.net
+
+# Allow client to pass locale environment variables
+AcceptEnv LANG LC_*
+
+# Accept git variables as well
+AcceptEnv GIT_*
+
+Subsystem sftp /usr/lib/openssh/sftp-server
+
+UsePAM yes
Oops, something went wrong.

0 comments on commit 31bedb1

Please sign in to comment.