falkorlib 0.7.9 → 0.7.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4044cdff596230756f97b5f314ca6eb070bca2b7
4
- data.tar.gz: 7471302188008c453c5779c472e02b05291dcdd3
3
+ metadata.gz: 76ac30acb34753aee392761a3d3d3bb779a0e40e
4
+ data.tar.gz: 0fbb0c3f20f1ac99e8e070a3e4eafadf2606f044
5
5
  SHA512:
6
- metadata.gz: 095e102b8251833b0cd687a8e1a90381e18b4fbcf3fb5d31eab8b2dfcdc0e4e3a5b2faa59cfc0b6e0f0f585bd55e657d33d71932b2779967c7f45632e830db4e
7
- data.tar.gz: 266198ac0d9be7c6edf2b0a7ed12a1e37508fea1da6a9e510722845273ed1a3e347b367f71a8da860b07570284090f3cd710392e303a998c9894ff5fa75bccfd
6
+ metadata.gz: 7dc680e984085557b1ef548c755f3362a4095c50408548d67d9e0d55b578347b31611cb95baecd3d79936d2174908abb1cff9c436d2d582b7e66ff518c02bfa1
7
+ data.tar.gz: 4ec409045636b70f04d067b13bea17cfddfda02f7c5fc89f1aa520f135b17a85717ff766a79306730aa6a8a71417b1047b0277ce3df6d5c1f44a4e58ce1a914f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- falkorlib (0.7.9)
4
+ falkorlib (0.7.11)
5
5
  activesupport (~> 4.0)
6
6
  artii (>= 2.1)
7
7
  awesome_print (~> 1.2)
@@ -22,7 +22,6 @@ PATH
22
22
  GEM
23
23
  remote: http://rubygems.org/
24
24
  specs:
25
- CFPropertyList (2.2.8)
26
25
  activesupport (4.2.7.1)
27
26
  i18n (~> 0.7)
28
27
  json (~> 1.7, >= 1.7.7)
@@ -45,8 +44,7 @@ GEM
45
44
  docile (1.1.5)
46
45
  ethon (0.9.1)
47
46
  ffi (>= 1.3.0)
48
- facter (2.4.6-universal-darwin)
49
- CFPropertyList (~> 2.2.6)
47
+ facter (2.4.6)
50
48
  faraday (0.10.0)
51
49
  multipart-post (>= 1.2, < 3)
52
50
  faraday_middleware (0.10.1)
@@ -142,10 +140,11 @@ GEM
142
140
  thread_safe (~> 0.1)
143
141
  unicode-display_width (1.1.1)
144
142
  websocket (1.2.3)
145
- yard (0.8.7.4)
143
+ yard (0.9.12)
146
144
 
147
145
  PLATFORMS
148
146
  ruby
147
+ x86_64-darwin-16
149
148
 
150
149
  DEPENDENCIES
151
150
  bundler
@@ -159,7 +158,7 @@ DEPENDENCIES
159
158
  simplecov
160
159
  travis (~> 1.6)
161
160
  travis-lint (~> 1.8)
162
- yard (~> 0.8)
161
+ yard (~> 0.9.11)
163
162
 
164
163
  BUNDLED WITH
165
164
  1.14.3
data/falkorlib.gemspec CHANGED
@@ -100,8 +100,8 @@ Gem::Specification.new do |s|
100
100
  s.add_development_dependency("bundler", "~> 1.0")
101
101
  s.add_development_dependency 'rspec', '~> 3.0' #, '>= 2.7.0'
102
102
  s.add_development_dependency("pry", "~> 0.9")
103
- s.add_development_dependency("yard", "~> 0.8")
104
- s.add_development_dependency('rubocop', '~> 0.45.0')
103
+ s.add_development_dependency("yard", "~> 0.9.11")
104
+ s.add_development_dependency('rubocop', '~> 0.49.0')
105
105
  s.add_development_dependency("rubygems-tasks", "~> 0.2")
106
106
  s.add_development_dependency("travis", "~> 1.6")
107
107
  s.add_development_dependency("travis-lint", "~> 1.8")
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  ################################################################################
3
- # Time-stamp: <Sun 2017-01-15 16:25 svarrette>
3
+ # Time-stamp: <Fri 2018-04-27 13:46 svarrette>
4
4
  ################################################################################
5
5
  # Management of Bootstrapping operations
6
6
 
@@ -16,5 +16,6 @@ require "falkorlib/bootstrap/ruby"
16
16
  require "falkorlib/bootstrap/git"
17
17
  require "falkorlib/bootstrap/latex"
18
18
  require "falkorlib/bootstrap/mkdocs"
19
+ require "falkorlib/bootstrap/vagrant"
19
20
 
20
21
  #require "falkorlib/bootstrap/repo"
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  ################################################################################
3
- # Time-stamp: <Tue 2017-04-04 12:00 svarrette>
3
+ # Time-stamp: <Fri 2018-04-27 13:51 svarrette>
4
4
  ################################################################################
5
5
  # Interface for the main Bootstrapping operations
6
6
  #
@@ -114,6 +114,18 @@ module FalkorLib #:nodoc:
114
114
  :gforge => { :url => 'gforge.uni.lu', :name => 'GForge @ Uni.lu' },
115
115
  :github => { :url => 'github.com', :name => 'Github', :login => (`whoami`.chomp.capitalize).to_s },
116
116
  :gitlab => { :url => 'gitlab.uni.lu', :name => 'Gitlab @ Uni.lu', :login => (`whoami`.chomp.capitalize).to_s }
117
+ },
118
+ :vagrant => {
119
+ :os => :centos7,
120
+ :ram => 1024,
121
+ :vcpus => 4,
122
+ :domain => 'vagrant.dev',
123
+ :range => '10.10.1.0/24',
124
+ :boxes => {
125
+ :centos7 => 'centos/7',
126
+ :debian8 => 'debian/contrib-jessie64',
127
+ :ubuntu14 => 'ubuntu/trusty64'
128
+ },
117
129
  }
118
130
  }
119
131
 
@@ -0,0 +1,59 @@
1
+ # -*- encoding: utf-8 -*-
2
+ ################################################################################
3
+ # Time-stamp: <Fri 2018-04-27 13:57 svarrette>
4
+ ################################################################################
5
+ # Interface for Bootstrapping MkDocs
6
+ #
7
+
8
+ require "falkorlib"
9
+ require "falkorlib/common"
10
+ require "falkorlib/bootstrap"
11
+
12
+ require 'erb' # required for module generation
13
+ require 'artii'
14
+ require 'facter'
15
+
16
+ include FalkorLib::Common
17
+
18
+ module FalkorLib
19
+ module Bootstrap #:nodoc:
20
+
21
+ module_function
22
+
23
+ ###### vagrant ######
24
+ # Initialize Vagrant in the current directory
25
+ # Supported options:
26
+ # * :force [boolean] force overwritting
27
+ ##
28
+ def vagrant(dir = Dir.pwd, options = {})
29
+ info "Initialize Vagrant (see https://www.vagrantup.com/)"
30
+ path = normalized_path(dir)
31
+ use_git = FalkorLib::Git.init?(path)
32
+ rootdir = (use_git) ? FalkorLib::Git.rootdir(path) : path
33
+ templatedir = File.join( FalkorLib.templates, 'vagrant')
34
+ config = FalkorLib::Config::Bootstrap::DEFAULTS[:vagrant].clone
35
+ if options[:os]
36
+ config[:os] = options[:os]
37
+ else
38
+ config[:os] = select_from(config[:boxes].keys,
39
+ "Select OS to configure within your vagrant boxes by default",
40
+ (config[:boxes].keys.find_index(config[:os]) + 1))
41
+ end
42
+ [ :ram, :vcpus, :domain, :range ].each do |k|
43
+ config[k.to_sym] = ask("\tDefault #{k.capitalize}:", config[k.to_sym])
44
+ end
45
+ puts config.to_yaml
46
+ FalkorLib::GitFlow.start('feature', 'vagrant', rootdir) if (use_git && FalkorLib::GitFlow.init?(rootdir))
47
+ init_from_template(templatedir, rootdir, config,
48
+ :no_interaction => true,
49
+ :no_commit => true)
50
+ # Dir.chdir( File.join(rootdir, 'docs')) do
51
+ # run %(ln -s README.md index.md )
52
+ # run %(ln -s README.md contributing/index.md )
53
+ # run %(ln -s README.md setup/index.md )
54
+ # end
55
+ #exit_status.to_i
56
+ end # vagrant
57
+
58
+ end # module Bootstrap
59
+ end # module FalkorLib
data/lib/falkorlib/cli.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  ################################################################################
3
- # Time-stamp: <Sun 2017-01-15 23:13 svarrette>
3
+ # Time-stamp: <Fri 2018-04-27 13:39 svarrette>
4
4
  ################################################################################
5
5
  # Interface for the CLI
6
6
  #
@@ -143,6 +143,14 @@ By default, <PATH> is '.' meaning that the repository will be initialized in the
143
143
  desc "new <type> [<path>]", "Initialize the directory PATH with one of FalkorLib's template(s)"
144
144
  subcommand "new", FalkorLib::CLI::New
145
145
 
146
+ ###### vagrant ######
147
+ method_option :force, :aliases => '-f', :default => false, :type => :boolean,
148
+ :desc => "Force generation (might overwrite files)"
149
+ #......................................
150
+ desc "vagrant [options]", "Initialize vagrant for the current project"
151
+ def vagrant(path = '.')
152
+ FalkorLib::Bootstrap.vagrant(path, options)
153
+ end # vagrant
146
154
 
147
155
  ###### version ######
148
156
  desc "--version, -V", "Print the version number"
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  ################################################################################
3
- # Time-stamp: <Fri 2016-11-11 14:21 svarrette>
3
+ # Time-stamp: <Fri 2018-04-27 13:52 svarrette>
4
4
  ################################################################################
5
5
  # FalkorLib Configuration
6
6
  #
@@ -55,8 +55,8 @@ module FalkorLib #:nodoc:
55
55
  },
56
56
  #:custom_cfg => '.falkorlib.yaml',
57
57
  :rvm => {
58
- :rubies => [ '2.3.1', '2.2.5', '2.1.10', '2.0.0', '1.9.3' ],
59
- :version => '2.1.10',
58
+ :rubies => [ '2.4.1', '2.3.4', '2.2.7', '2.1.10', '2.0.0', '1.9.3' ],
59
+ :version => '2.3.4',
60
60
  :versionfile => '.ruby-version',
61
61
  :gemsetfile => '.ruby-gemset'
62
62
  },
@@ -65,7 +65,7 @@ module FalkorLib #:nodoc:
65
65
  :puppet => {}
66
66
  },
67
67
  :tokens => { :code_climate => '' },
68
- :project => {}
68
+ :project => {},
69
69
  }
70
70
 
71
71
  module_function
@@ -48,5 +48,25 @@ else
48
48
  FalkorLib::GitFlow.init
49
49
  end
50
50
  end # namespace git:flow
51
+
52
+ if FalkorLib::GitFlow.init?
53
+ ########### git:up ###########
54
+ desc "Update your local branches"
55
+ task :up do |t|
56
+ info "#{t.comment}"
57
+ FalkorLib::Git.fetch
58
+ branches = FalkorLib::Git.list_branch
59
+ #puts branches.to_yaml
60
+ unless FalkorLib::Git.dirty?
61
+ FalkorLib.config.gitflow[:branches].each do |t, br|
62
+ info "updating Git Flow #{t} branch '#{br}' with the 'origin' remote"
63
+ run %{ git checkout #{br} && git merge origin/#{br} }
64
+ end
65
+ run %{ git checkout #{branches[0]} } # Go back to the initial branch
66
+ else
67
+ warning "Unable to update -- your local repository copy is dirty"
68
+ end
69
+ end # task git:up
70
+ end
51
71
  end # namespace git
52
72
  end
@@ -19,7 +19,7 @@ module FalkorLib #:nodoc:
19
19
  # MAJOR: Defines the major version
20
20
  # MINOR: Defines the minor version
21
21
  # PATCH: Defines the patch version
22
- MAJOR, MINOR, PATCH = 0, 7, 9
22
+ MAJOR, MINOR, PATCH = 0, 7, 11
23
23
 
24
24
  module_function
25
25
 
@@ -29,10 +29,10 @@ class <%= config[:shortname] %>::common {
29
29
  # Prepare the user and group
30
30
  group { '<%= config[:shortname] %>':
31
31
  ensure => $<%= config[:shortname] %>::ensure,
32
- name => <%= config[:shortname] %>::params::group,
33
- gid => <%= config[:shortname] %>::params::gid,
32
+ name => $<%= config[:shortname] %>::params::group,
33
+ gid => $<%= config[:shortname] %>::params::gid,
34
34
  }
35
- user { 'munge':
35
+ user { '<%= config[:shortname] %>':
36
36
  ensure => $<%= config[:shortname] %>::ensure,
37
37
  name => $<%= config[:shortname] %>::params::username,
38
38
  uid => $<%= config[:shortname] %>::params::gid,
@@ -45,8 +45,8 @@ class <%= config[:shortname] %>::common {
45
45
  }
46
46
 
47
47
  package { '<%= config[:shortname] %>':
48
- name => "${<%= config[:shortname] %>::params::packagename}",
49
- ensure => "${<%= config[:shortname] %>::ensure}",
48
+ name => $<%= config[:shortname] %>::params::packagename,
49
+ ensure => $<%= config[:shortname] %>::ensure}",
50
50
  }
51
51
  package { $<%= config[:shortname] %>::params::extra_packages:
52
52
  ensure => 'present'
@@ -0,0 +1,185 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+ # Time-stamp: <Fri 2018-04-27 15:16 svarrette>
4
+ ###########################################################################################
5
+ # __ __ _ __ _ _
6
+ # \ \ / /_ _ __ _ _ __ __ _ _ __ | |_ / _(_) | ___
7
+ # \ \ / / _` |/ _` | '__/ _` | '_ \| __| |_| | |/ _ \
8
+ # \ V / (_| | (_| | | | (_| | | | | |_| _| | | __/
9
+ # \_/ \__,_|\__, |_| \__,_|_| |_|\__|_| |_|_|\___|
10
+ # |___/
11
+ ###########################################################################################
12
+ require 'yaml'
13
+ require 'ipaddr'
14
+ require 'deep_merge'
15
+ require 'pp'
16
+ require 'erb'
17
+
18
+ ###### Expected Vagrant plugins detection ######
19
+ # For more information on the below plugins:
20
+ # - https://github.com/oscar-stack/vagrant-hosts
21
+ # - https://github.com/dotless-de/vagrant-vbguest
22
+ # - https://github.com/emyl/vagrant-triggers
23
+ # - https://github.com/fgrehm/vagrant-cachier
24
+ # Terminal-table is a nice ruby gem for automatically print tables with nice layout
25
+ ###
26
+ [ 'vagrant-hosts',
27
+ 'vagrant-vbguest',
28
+ 'vagrant-triggers',
29
+ 'vagrant-cachier',
30
+ 'terminal-table' ].each do |plugin|
31
+ abort "Install the '#{plugin}' plugin with 'vagrant plugin install #{plugin}'" unless Vagrant.has_plugin?("#{plugin}")
32
+ end
33
+ require 'terminal-table'
34
+
35
+ ### Global variables ###
36
+ # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
37
+ VAGRANTFILE_API_VERSION = "2"
38
+
39
+ # Eventually a local YAML configuration for the deployment
40
+ TOP_SRCDIR = File.expand_path File.dirname(__FILE__)
41
+ TOP_CONFDIR = File.join(TOP_SRCDIR, 'vagrant')
42
+ config_file = File.join(TOP_CONFDIR, 'config.yaml')
43
+
44
+ #SHARED_DIR = File.join('vagrant', 'shared')
45
+
46
+ ### Default settings ###
47
+ DEFAULT_SETTINGS = {
48
+ # Default images settings
49
+ :defaults => {
50
+ :os => :<%= config[:os] %>,
51
+ :ram => <%= config[:ram] %>,
52
+ :vcpus => <%= config[:vcpus] %>,
53
+ :vbguest_auto_update => true,
54
+ # :nodes => 1,
55
+ },
56
+ # Default domain settings
57
+ :network => {
58
+ :domain => '<%= config[:domain] %>',
59
+ :range => '<%= config[:range] %>',
60
+ :client_ip_start_offset => 100,
61
+ },
62
+ # Default Boxes
63
+ :boxes => {
64
+ :centos7 => '<%= config[:boxes][:centos7] %>',
65
+ :debian8 => '<%= config[:boxes][:debian8] %>',
66
+ :ubuntu14 => '<%= config[:boxes][:ubuntu14] %>'
67
+ },
68
+ # virtual images to deploy
69
+ # <name>:
70
+ # :hostname: <hostname>
71
+ # :desc: <VM-description>
72
+ # :os: <os> # from the configured boxes
73
+ # :ram: <ram>
74
+ # :vcpus: <vcpus>
75
+ # :role: <role> # supported: [ 'controller', 'frontend' ]
76
+ :vms => {
77
+ # IF in single mode, below is the definition of the box to deploy
78
+ 'default' => {
79
+ :hostname => 'vm',
80
+ :desc => 'Testing Vagrant box',
81
+ },
82
+ },
83
+ }
84
+
85
+ # List of default provisioning scripts
86
+ DEFAULT_PROVISIONING_SCRIPTS = [
87
+ "vagrant/bootstrap.sh"
88
+ ]
89
+
90
+ # Load the settings (eventually overwritten using values from the yaml file 'config/vagrant.yaml')
91
+ settings = DEFAULT_SETTINGS.clone
92
+ if File.exist?(config_file)
93
+ config = YAML::load_file config_file
94
+ #puts config.to_yaml
95
+ settings.deep_merge!( config ) if config
96
+ end
97
+ #puts settings.to_yaml
98
+ # abort 'end'
99
+ #pp settings
100
+ abort "Undefined settings" if settings.nil?
101
+
102
+ ############################################################
103
+ # Complete configuration of the boxes to deploy
104
+ defaults = settings[:defaults]
105
+ network = settings[:network]
106
+
107
+
108
+ ############################################################
109
+ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
110
+
111
+ ### Common configs shared by all VMs ###
112
+ # Cache plugin -- Supports local cache, so you don't wast bandwitdh
113
+ # vagrant plugin install vagrant-cachier # see https://github.com/fgrehm/vagrant-cachier
114
+ config.cache.auto_detect = true if Vagrant.has_plugin?("vagrant-cachier")
115
+
116
+ # check if VirtualBox Guest Additions are up to date
117
+ if Vagrant.has_plugin?("vagrant-vbguest")
118
+ # set auto_update to false, if you do NOT want to check the correct
119
+ # additions version when booting these boxes
120
+ config.vbguest.auto_update = defaults[:vbguest_auto_update]
121
+ end
122
+
123
+ # Shell provisioner, to bootstrap each box with the minimal settings/packages
124
+ DEFAULT_PROVISIONING_SCRIPTS.each do |script|
125
+ config.vm.provision "shell", path: "#{script}", keep_color: true
126
+ end
127
+ config.vm.synced_folder ".", "/vagrant", type: "virtualbox"
128
+ ## Uncomment the below part if you want and additional shared directory
129
+ # config.vm.synced_folder "vagrant/shared", "/shared", mount_options: ['dmode=777','fmode=777'],
130
+ # type: "virtualbox" # Shared directory for users
131
+
132
+ # network settings
133
+ ipaddr = IPAddr.new network[:range]
134
+ ip_range = ipaddr.to_range.to_a
135
+ ip_index = {
136
+ :frontend => 2,
137
+ :controller => 11,
138
+ :node => 101,
139
+ :easybuild => 1,
140
+ }
141
+
142
+ # cosmetics for the post-up message
143
+ __table = {
144
+ :title => "Virtual environment deployed on Vagrant",
145
+ :headings => [ 'Name', 'Hostname', 'OS', 'vCPU/RAM', 'Description', 'IP' ],
146
+ :rows => [],
147
+ }
148
+
149
+
150
+ #__________________________________
151
+ settings[:vms].each do |name, node|
152
+ hostname = name
153
+ domain = network[:domain]
154
+ fqdn = "#{hostname}.#{domain}"
155
+ os = defaults[:os].to_sym
156
+ ram = defaults[:ram]
157
+ vcpus = defaults[:vcpus]
158
+ desc = 'n/a'
159
+
160
+ abort "Non-existing box OS '#{os}' for the VM '#{name}'" if settings[:boxes][os.to_sym].nil?
161
+ abort "Empty IP address range" if ip_range.empty?
162
+ abort "Unknown role '#{role}' for the VM '#{name}'" unless ip_index[role.to_sym]
163
+ ip = ip_range[ ip_index[role.to_sym].to_i ].to_s
164
+ ip_index[role.to_sym] += 1 # increment index for the next VM of this type
165
+
166
+ config.vm.define "#{name}" do |c|
167
+ c.vm.box = settings[:boxes][os.to_sym]
168
+ c.vm.hostname = "#{fqdn}"
169
+ c.vm.network :private_network, :ip => ip
170
+ c.vm.provision :hosts, :sync_hosts => true
171
+
172
+ c.vm.provider "virtualbox" do |v|
173
+ v.customize [ 'modifyvm', :id, '--name', hostname, '--memory', ram.to_s ]
174
+ v.customize [ 'modifyvm', :id, '--cpus', vcpus.to_s ] if vcpus.to_i > 1
175
+ #v.customize [ 'setextradata', :id, 'VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root', '1']
176
+ end
177
+ end
178
+ __table[:rows] << [ name, fqdn, os.to_sym, "#{vcpus}/#{ram}", desc, ip]
179
+ end # settings
180
+
181
+ config.trigger.after :up do
182
+ puts Terminal::Table.new __table
183
+ end
184
+
185
+ end
@@ -0,0 +1,288 @@
1
+ #!/usr/bin/env bash
2
+ # Time-stamp: <Fri 2018-04-27 11:57 svarrette>
3
+ ###########################################################################################
4
+ # __ __ _ ____ _ _
5
+ # \ \ / /_ _ __ _ _ __ __ _ _ __ | |_ | __ ) ___ ___ | |_ ___| |_ _ __ __ _ _ __
6
+ # \ \ / / _` |/ _` | '__/ _` | '_ \| __| | _ \ / _ \ / _ \| __/ __| __| '__/ _` | '_ \
7
+ # \ V / (_| | (_| | | | (_| | | | | |_ | |_) | (_) | (_) | |_\__ \ |_| | | (_| | |_) |
8
+ # \_/ \__,_|\__, |_| \__,_|_| |_|\__| |____/ \___/ \___/ \__|___/\__|_| \__,_| .__/
9
+ # |___/ |_|
10
+ # Copyright (c) 2017 Sebastien Varrette <sebastien.varrette@uni.lu>
11
+ ###########################################################################################
12
+ # (prefered) way to see a Vagrant box configured.
13
+ #
14
+
15
+ SETCOLOR_NORMAL=$(tput sgr0)
16
+ SETCOLOR_TITLE=$(tput setaf 6)
17
+ SETCOLOR_SUBTITLE=$(tput setaf 14)
18
+ SETCOLOR_RED=$(tput setaf 1)
19
+ SETCOLOR_BOLD=$(tput setaf 15)
20
+
21
+ ### Local variables
22
+ STARTDIR="$(pwd)"
23
+ SCRIPTFILENAME=$(basename $0)
24
+ SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
25
+
26
+
27
+ MOTD="/etc/motd"
28
+ DOTFILES_DIR='/etc/dotfiles.d'
29
+ DOTFILES_URL='https://github.com/ULHPC/dotfiles.git'
30
+ EXTRA_PACKAGES=
31
+
32
+ # List of default packages to install
33
+ COMMON_DEFAULT_PACKAGES="wget figlet git screen bash-completion rsync nmap vim python-pip htop direnv"
34
+
35
+ # Easybuild
36
+ #export EASYBUILD_MODULES_TOOL=Lmod
37
+ export EASYBUILD_MODULE_NAMING_SCHEME=CategorizedModuleNamingScheme
38
+ EB_INSTALL_SCRIPT='/tmp/bootstrap_eb.py'
39
+ EB_INSTALL_SCRIPT_URL='https://raw.githubusercontent.com/easybuilders/easybuild-framework/develop/easybuild/scripts/bootstrap_eb.py'
40
+
41
+
42
+ ######
43
+ # Print information in the following form: '[$2] $1' ($2=INFO if not submitted)
44
+ # usage: info text [title]
45
+ ##
46
+ info () {
47
+ echo
48
+ echo "${SETCOLOR_BOLD}###${SETCOLOR_NORMAL} ${SETCOLOR_TITLE}${1}${SETCOLOR_NORMAL} ${SETCOLOR_BOLD}###${SETCOLOR_NORMAL}"
49
+ }
50
+ error() {
51
+ echo
52
+ echo "${SETCOLOR_RED}*** ERROR *** $*${SETCOLOR_NORMAL}"
53
+ exit 1
54
+ }
55
+
56
+ print_usage() {
57
+ cat <<EOF
58
+ $0 [--name "vagrant box name"] \
59
+ [--title "Title"] \
60
+ [--subtitle "Subtitle"] \
61
+ [--desc "description"] \
62
+ [--support "support@mail.com"]
63
+ [-x "pkg1 pkg2 ..."]
64
+
65
+ Bootstrap a Vagrant box
66
+ This will generate the appropriate ${MOTD} file
67
+ EOF
68
+ }
69
+
70
+ ####################### Per OS Bootstrapping function ##########################
71
+ setup_redhat() {
72
+ info "Running yum update"
73
+ yum update -y >/dev/null
74
+
75
+ info "Installing default packages"
76
+ yum install -y epel-release
77
+ yum install -y ${COMMON_DEFAULT_PACKAGES} bind-utils ${EXTRA_PACKAGES} >/dev/null
78
+
79
+ info "Uninstalling (eventually) existing Puppet installation"
80
+ yum erase -y puppet puppetlabs-release >/dev/null
81
+
82
+ info "Adding repo for Puppet 4"
83
+ rpm -ivh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-$1.noarch.rpm
84
+
85
+ sleep 1
86
+ info "Installing Puppet and its dependencies"
87
+ yum install -y puppet-agent >/dev/null
88
+
89
+ info "installing Environment modules and LMod"
90
+ yum install -y environment-modules Lmod
91
+
92
+ yum groupinstall -y "Development Tools"
93
+ yum install -y openssl-devel libssl-dev libopenssl-devel ncurses-devel libibverbs-dev libibverbs-devel, rdma-core-devel bzip2-devel readline-devel libsqlite3x-devel
94
+ }
95
+
96
+ setup_apt() {
97
+ case $1 in
98
+ 3*) codename=cumulus ;;
99
+ 6) codename=squeeze ;;
100
+ 7) codename=wheezy ;;
101
+ 8) codename=jessie ;;
102
+ 9) codename=stretch ;;
103
+ 12.04) codename=precise ;;
104
+ 14.04) codename=trusty ;;
105
+ 16.04) codename=xenial ;;
106
+ *) echo "Release not supported" ;;
107
+ esac
108
+
109
+ info "Running apt-get update"
110
+ apt-get update >/dev/null 2>&1
111
+
112
+ info "Installing default packages"
113
+ apt-get install -y ${COMMON_DEFAULT_PACKAGES} git-core ${EXTRA_PACKAGES} >/dev/null
114
+
115
+ info "Installing Puppet and its dependencies"
116
+ apt-get install puppet-agent -y >/dev/null
117
+ apt-get install apt-transport-https -y >/dev/null
118
+
119
+ info "installing Environment modules and LMod"
120
+ apt-get install -y environment-modules lmod
121
+ apt-get install -y build-essentials
122
+ }
123
+
124
+ setup_linux() {
125
+ ARCH=$(uname -m | sed 's/x86_//;s/i[3-6]86/32/')
126
+ if [ -f /etc/redhat-release ]; then
127
+ OS=$(cat /etc/redhat-release | cut -d ' ' -f 1)
128
+ majver=$(cat /etc/redhat-release | sed 's/[A-Za-z]*//g' | sed 's/ //g' | cut -d '.' -f 1)
129
+ elif [ -f /etc/SuSE-release ]; then
130
+ OS=sles
131
+ majver=$(cat /etc/SuSE-release | grep VERSION | cut -d '=' -f 2 | tr -d '[:space:]')
132
+ elif [ -f /etc/os-release ]; then
133
+ . /etc/os-release
134
+ OS=$ID
135
+ majver=$VERSION_ID
136
+ elif [ -f /etc/debian_version ]; then
137
+ OS=Debian
138
+ majver=$(cat /etc/debian_version | cut -d '.' -f 1)
139
+ elif [ -f /etc/lsb-release ]; then
140
+ . /etc/lsb-release
141
+ OS=$DISTRIB_ID
142
+ majver=$DISTRIB_RELEASE
143
+ elif [ -f /etc/os-release ]; then
144
+ . /etc/os-release
145
+ OS=$ID
146
+ majver=$VERSION_ID
147
+ else
148
+ OS=$(uname -s)
149
+ majver=$(uname -r)
150
+ fi
151
+ distro=$(echo $OS | tr '[:upper:]' '[:lower:]')
152
+ info "Detected Linux distro: ${distro} version ${majver} on arch ${ARCH}"
153
+ case "$distro" in
154
+ debian|ubuntu) setup_apt $majver ;;
155
+ redhat|fedora|centos|scientific|amazon) setup_redhat $majver ;;
156
+ *) echo "Not supported distro: $distro"; exit 1;;
157
+ esac
158
+
159
+ }
160
+
161
+ setup_dotfiles () {
162
+ if [ ! -d "${DOTFILES_DIR}" ]; then
163
+ info "cloning ULHPC/dotfiles repository in '/etc/dotfiles.d"
164
+ git clone ${DOTFILES_URL} ${DOTFILES_DIR}
165
+ fi
166
+ # Correct __git_ps1
167
+ local src_git_prompt="/usr/share/git-core/contrib/completion/git-prompt.sh"
168
+ local dst_git_prompt="/etc/profile.d/git-prompt.sh"
169
+ if [ -f "${src_git_prompt}" ]; then
170
+ info "installing git-prompt to define __git_ps1"
171
+ [ ! -e "${dst_git_prompt}" ] && ln -s ${src_git_prompt} ${dst_git_prompt}
172
+ fi
173
+ local dotfile_install_cmd="${DOTFILES_DIR}/install.sh --offline --force -d ${DOTFILES_DIR} --bash --screen --git"
174
+ if [ -d "${DOTFILES_DIR}" ]; then
175
+ info "installing dotfiles for 'root' user"
176
+ ${dotfile_install_cmd}
177
+ info "installing dotfiles for 'vagrant' user"
178
+ sudo -u vagrant ${dotfile_install_cmd}
179
+ fi
180
+ }
181
+
182
+ setup_motd() {
183
+ local motd=/etc/motd
184
+ local has_figlet=$(which figlet 2>/dev/null)
185
+ info "setup ${motd}"
186
+ cat <<EOF > ${motd}
187
+ ================================================================================
188
+ Welcome to the Vagrant box $(hostname)
189
+ ================================================================================
190
+ EOF
191
+ if [ -n "${has_figlet}" ]; then
192
+ cat <<EOF >> ${motd}
193
+ $(${has_figlet} -w 80 -c "Virtual $(hostname -s)")
194
+ EOF
195
+ fi
196
+ cat <<EOF >> ${motd}
197
+ ================================================================================
198
+ Hostname.... $(hostname -f)
199
+ OS.......... $(facter os.name) $(facter os.release.full)
200
+ Docs........ Vagrant: http://docs.vagrantup.com/v2/
201
+ ================================================================================
202
+ EOF
203
+ }
204
+
205
+ setup_easybuild() {
206
+ cat <<EOF > /etc/profile.d/easybuild.sh
207
+ export EASYBUILD_PREFIX=\$HOME/.local/easybuild
208
+ export GLOBAL_EASYBUILD_PREFIX=/opt/apps/
209
+ export EASYBUILD_MODULES_TOOL=Lmod
210
+ export EASYBUILD_MODULE_NAMING_SCHEME=CategorizedModuleNamingScheme
211
+ # Use the below variable to run:
212
+ # module use $LOCAL_MODULES
213
+ # module load tools/EasyBuild
214
+ export LOCAL_MODULES=\$EASYBUILD_PREFIX/modules/all
215
+ export GLOBAL_MODULES=\$GLOBAL_EASYBUILD_PREFIX/modules/all
216
+
217
+ alias ma="module avail"
218
+ alias ml="module list"
219
+ function mu(){
220
+ module use \$GLOBAL_MODULES
221
+ module use \$LOCAL_MODULES
222
+ module load tools/EasyBuild
223
+ }
224
+
225
+ # Prepend directories holding eb file for this turorial to the robot path
226
+ # See http://easybuild.readthedocs.io/en/latest/Using_the_EasyBuild_command_line.html?highlight=EASYBUILD_ROBOT#prepending-and-or-appending-to-the-default-robot-search-path
227
+ # export EASYBUILD_ROBOT_PATHS=\$(find /vagrant/resources/ -name *.eb | xargs dirname | sort | uniq | xargs echo | tr ' ' ':'):
228
+
229
+ alias global_eb='eb --installpath=\$GLOBAL_EASYBUILD_PREFIX'
230
+
231
+ EOF
232
+ pip install --upgrade pip
233
+ pip install functools32
234
+ if [ ! -f "${EB_INSTALL_SCRIPT}" ]; then
235
+ curl -o ${EB_INSTALL_SCRIPT} ${EB_INSTALL_SCRIPT_URL}
236
+ fi
237
+
238
+ info 'Installing Easybuild'
239
+ sudo -u vagrant EASYBUILD_MODULE_NAMING_SCHEME=CategorizedModuleNamingScheme python ${EB_INSTALL_SCRIPT} ~vagrant/.local/easybuild
240
+ }
241
+
242
+ setup_pyenv() {
243
+ cat <<EOF > /etc/profile.d/pyenv.sh
244
+ if [ -d "\$HOME/.pyenv" ]; then
245
+ export PATH="\$HOME/.pyenv/bin:\$PATH"
246
+ eval "\$(pyenv init -)"
247
+ eval "\$(pyenv virtualenv-init -)"
248
+ fi
249
+ EOF
250
+ if [ ! -h "/home/vagrant/.config/direnv" ]; then
251
+ sudo -u vagrant mkdir -p /home/vagrant/.config
252
+ sudo -u vagrant ln -sf /vagrant/config/direnv /home/vagrant/.config/direnv
253
+ fi
254
+ }
255
+
256
+
257
+ ######################################################################################
258
+ [ $UID -gt 0 ] && error "You must be root to execute this script (current uid: $UID)"
259
+
260
+
261
+ # Parse the command-line options
262
+ while [ $# -ge 1 ]; do
263
+ case $1 in
264
+ -h | --help) print_usage; exit 0;;
265
+ -V | --version) print_version; exit 0;;
266
+ -n | --name) shift; NAME=$1;;
267
+ -t | --title) shift; TITLE=$1;;
268
+ -st| --subtitle) shift; SUBTITLE=$1;;
269
+ -d | --desc) shift; DESC=$1;;
270
+ -s | --support) shift; SUPPORT_MAIL=$1;;
271
+ -x | --extras) shift; EXTRA_PACKAGES=$1;;
272
+ esac
273
+ shift
274
+ done
275
+
276
+ # Let's go
277
+ case "$OSTYPE" in
278
+ linux*) setup_linux ;;
279
+ *) echo "unknown: $OSTYPE"; exit 1;;
280
+ esac
281
+
282
+ [ -f /usr/bin/puppet ] || ln -s /opt/puppetlabs/puppet/bin/puppet /usr/bin/puppet
283
+ [ -f /usr/bin/facter ] || ln -s /opt/puppetlabs/puppet/bin/facter /usr/bin/facter
284
+
285
+ setup_dotfiles
286
+ setup_motd
287
+ setup_easybuild
288
+ setup_pyenv
@@ -0,0 +1,16 @@
1
+ # -*- mode: yaml; -*-
2
+ # Time-stamp: <Fri 2018-04-27 15:14 svarrette>
3
+ ################################################################################
4
+ # Complementary configuration for Vagrant
5
+ # You can overwrite here the default settings defined in ../Vagrantfile and
6
+ # rework the vagrantconfiguration
7
+ # See the sample file or the DEFAULT_SETTING variable in ../Vagrantfile for an
8
+ # overview of the available configs
9
+ #
10
+ # /!\ a deep merge approach is used to bring the below modifications to the
11
+ # initial DEFAULT_SETTING hash. In particular, **nested hashes** are merged
12
+ # too, not replaced (might impact the :partitions: settings).
13
+ ###
14
+
15
+ # :defaults:
16
+ # :ram: 4096
@@ -0,0 +1,149 @@
1
+ # -*- mode: yaml; -*-
2
+ # Time-stamp: <Mon 2018-01-22 08:20 svarrette>
3
+ ################################################################################
4
+ # Complementary configuration for Vagrant
5
+ # You can overwrite here the default settings defined in ../Vagrantfile and
6
+ # rework the single / cluster configuratuion
7
+ ###
8
+
9
+ #___________________________________________
10
+ # Complete / re-define the default boxes below
11
+ # Format:
12
+ # :<os><version>: <username>/<box> # see https://vagrantcloud.com
13
+ # :boxes:
14
+ # :centos7: centos/7
15
+ # :debian8: debian/contrib-jessie64
16
+ # :ubuntu14: ubuntu/trusty64
17
+
18
+ #_________________
19
+ # Default settings
20
+ # :defaults:
21
+ # :os: :centos7 # Default OS from the above box definition
22
+ # :ram: 512 # Default RAM
23
+ # :vcpus: 1 # Default number of virtual CPUs
24
+ # :vbguest_auto_update: 1 # check/update box guest additions
25
+ # :nodes: 1 # Default number of compute nodes
26
+ # also recomputed from partition config in cluster mode
27
+ # :mode: single # Type of deployment. Eligible values:
28
+ # 'single' image or
29
+ # 'distributed' or
30
+ # 'cluster' (not yet implemented)
31
+
32
+ #____________________
33
+ # Network settings
34
+ # :network:
35
+ # :domain: 'vagrant.dev' # network domain to use
36
+ # :range: '10.10.1.0/24' # IP range to use
37
+ # :client_ip_start_offset: 100 # Note: compute nodes will have xx.xx.xx.254
38
+ # # client/compute nodes VMs will start on xx.xx.xx.<client_ip_start_offset+1>
39
+
40
+ #___________________________________________________________
41
+ # VMs / Vagrant boxes to define apart from the compute nodes
42
+ # Format:
43
+ # <name>:
44
+ # :hostname: <hostname>
45
+ # :desc: <VM-description>
46
+ # :os: <os> # from the configured boxes
47
+ # :ram: <ram>
48
+ # :vcpus: <vcpus>
49
+ # :role: <role> # supported: [ 'controller', 'frontend' ]
50
+ #
51
+ # :vms:
52
+ # 'slurm-backup':
53
+ # :hostname: slurm2
54
+ # :ram: 2048
55
+ # :vcpus: 2
56
+ # :desc: 'Slurm Controller #2 (backup)'
57
+ # :role: controller
58
+
59
+ #_______________________________________________________________________
60
+ # Default setting for the simulated compute nodes of the virtual cluster
61
+ # :nodes:
62
+ # :cpus: 4
63
+ # :sockets: 2
64
+ # :ram: 512
65
+ # :realmemory: 400 # has to be reported to Slurm
66
+ # :cores_per_socket: 2
67
+ # :thread_per_core: 1
68
+ # :state: UNKNOWN
69
+
70
+ #_______________________________________________________________________
71
+ # The real part: Details of the Slurm Configuration
72
+ # used later to feed slurm.conf from the ERB template
73
+ # :slurm:
74
+ # :template: slurm.conf.erb
75
+ # :clustername: thor
76
+ # :allowgroups: clusterusers
77
+ # # Default Partition / QoS. Format:
78
+ # # '<name>':
79
+ # # :nodes: n # Number of nodes
80
+ # # :default: true|false # Default partition?
81
+ # # :hidden: true|false # Hidden partition?
82
+ # # :allowgroups: 'ALL|group[,group]*'
83
+ # # :allowaccounts: 'ALL|acct[,acct]*'
84
+ # # :allowqos:'ALL|qos[,qos]*'
85
+ # # :state: 'UP|DOWN|DRAIN|INACTIVE'
86
+ # # :oversubscribe: 'EXCLUSIVE|FORCE|YES|NO' (replace :shared)
87
+ # # #=== Time Format: minutes, minutes:seconds, hours:minutes:seconds, days-hours,
88
+ # # days-hours:minutes, days-hours:minutes:seconds or "UNLIMITED"
89
+ # # :default_time: 'UNLIMITED|DD-HH:MM:SS',
90
+ # # :max_time: 'UNLIMITED|DD-HH:MM:SS'
91
+ # # #=== associated QoS config, named 'qos-<partition>' ===
92
+ # # :priority: n # QoS priority (default: 0)
93
+ # # :preempt: 'qos-<name>
94
+ # #
95
+ # :partitions:
96
+ # interactive:
97
+ # :nodes: 1
98
+ # :priority: 0
99
+ # :default_time: 0-10:00:00
100
+ # :max_time: 5-00:00:00
101
+ # batch:
102
+ # :nodes: 2
103
+ # :priority: 100
104
+ # :default: true
105
+ # :preempt: qos-interactive
106
+ # :default_time: 0-2:00:00
107
+ # :max_time: 5-00:00:00
108
+ # ### General options you may wish to customize
109
+ # :mpidefault: none
110
+ # :mpiparams: ''
111
+ # :topology: ''
112
+ # :mempercpu: 0
113
+ # :maxmempercpu: 0
114
+ # :slurmctlddebug: 3
115
+ # :slurmddebug: 3
116
+ # :slurmctldport: 6817
117
+ # :slurmdport: 6818
118
+ # :srunportrange: 50000-53000
119
+ # :jobsubmitplugins: '' #'lua'
120
+ # # job completion logging mechanism type. You can use 'jobcomp/mysql'
121
+ # :jobcomptype: jobcomp/none
122
+ # :jobcomploc: ''
123
+ # # Health checker -- Ex: NHC / see https://github.com/mej/nhc
124
+ # :healthcheckprogram: ''
125
+ # :healthcheckinterval: 30
126
+ # # What level of association-based enforcement to impose on job submissions
127
+ # :acct_storageenforce: qos,limits,associations
128
+ # # type of scheduler to be use
129
+ # :schedulertype: sched/backfill
130
+ # # Plugin used to identify which jobs can be preempted in order to start a pending job
131
+ # :preempttype: preempt/qos
132
+ # :preemptmode: requeue
133
+ # # Plugin to be used in establishing a job's scheduling priority
134
+ # :prioritytype: priority/multifactor
135
+ # :prioritydecayHL: 5-0
136
+ # :priorityweightage: 0
137
+ # :priorityweightfairshare: 0
138
+ # :priorityweightjobsize: 0
139
+ # :priorityweightpartition: 0
140
+ # :priorityweightqos: 0
141
+ # # type of resource selection algorithm to be used
142
+ # :selecttype: select/cons_res
143
+ # :selecttype_params: CR_Core_Memory,CR_CORE_DEFAULT_DIST_BLOCK
144
+ # # type of task launch plugin, typically used to provide resource management within a node
145
+ # :taskplugin: task/cgroup
146
+ # :taskplugin_params: cpusets
147
+ # # hooks
148
+ # :taskprolog: '' # program to be execute prior to initiation of each task
149
+ # :taskepilog: '' # program to be execute after termination of each task
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: falkorlib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.9
4
+ version: 0.7.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sebastien Varrette
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-23 00:00:00.000000000 Z
11
+ date: 2018-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -288,28 +288,28 @@ dependencies:
288
288
  requirements:
289
289
  - - "~>"
290
290
  - !ruby/object:Gem::Version
291
- version: '0.8'
291
+ version: 0.9.11
292
292
  type: :development
293
293
  prerelease: false
294
294
  version_requirements: !ruby/object:Gem::Requirement
295
295
  requirements:
296
296
  - - "~>"
297
297
  - !ruby/object:Gem::Version
298
- version: '0.8'
298
+ version: 0.9.11
299
299
  - !ruby/object:Gem::Dependency
300
300
  name: rubocop
301
301
  requirement: !ruby/object:Gem::Requirement
302
302
  requirements:
303
303
  - - "~>"
304
304
  - !ruby/object:Gem::Version
305
- version: 0.45.0
305
+ version: 0.49.0
306
306
  type: :development
307
307
  prerelease: false
308
308
  version_requirements: !ruby/object:Gem::Requirement
309
309
  requirements:
310
310
  - - "~>"
311
311
  - !ruby/object:Gem::Version
312
- version: 0.45.0
312
+ version: 0.49.0
313
313
  - !ruby/object:Gem::Dependency
314
314
  name: rubygems-tasks
315
315
  requirement: !ruby/object:Gem::Requirement
@@ -418,6 +418,7 @@ files:
418
418
  - lib/falkorlib/bootstrap/link.rb
419
419
  - lib/falkorlib/bootstrap/mkdocs.rb
420
420
  - lib/falkorlib/bootstrap/ruby.rb
421
+ - lib/falkorlib/bootstrap/vagrant.rb
421
422
  - lib/falkorlib/cli.rb
422
423
  - lib/falkorlib/cli/config.rb
423
424
  - lib/falkorlib/cli/link.rb
@@ -550,6 +551,10 @@ files:
550
551
  - templates/puppet/modules/tests/vagrant/bootstrap.sh
551
552
  - templates/puppet/modules/tests/vagrant/config.yaml
552
553
  - templates/puppet/modules/tests/vagrant/puppet_modules_setup.rb
554
+ - templates/vagrant/Vagrantfile.erb
555
+ - templates/vagrant/vagrant/bootstrap.sh
556
+ - templates/vagrant/vagrant/config.yaml
557
+ - templates/vagrant/vagrant/config.yaml.sample
553
558
  homepage: https://github.com/Falkor/falkorlib
554
559
  licenses:
555
560
  - MIT