falkorlib 0.7.8 → 0.7.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 554b1778c0f221f9e35a3d07227bb29b731607eb
4
- data.tar.gz: 684ead60778ae61ae7a4d973b0b12a3e94d7ce8a
3
+ metadata.gz: 4044cdff596230756f97b5f314ca6eb070bca2b7
4
+ data.tar.gz: 7471302188008c453c5779c472e02b05291dcdd3
5
5
  SHA512:
6
- metadata.gz: 32770c26be0b2c664b3ac5a57445e898c628a003895e6ef352fb8ebbf607e85cec326f07f09232e6b4960107c88c209b2938a5d609914586e3eccb947f34a8ec
7
- data.tar.gz: 5ac8a060f15f35838b390e2709265fc4053635833aee10cb4d156cb72163de6ea988ccc169ac791a309c269df1dbd6914261b103a0169c536f29d63f86b57216
6
+ metadata.gz: 095e102b8251833b0cd687a8e1a90381e18b4fbcf3fb5d31eab8b2dfcdc0e4e3a5b2faa59cfc0b6e0f0f585bd55e657d33d71932b2779967c7f45632e830db4e
7
+ data.tar.gz: 266198ac0d9be7c6edf2b0a7ed12a1e37508fea1da6a9e510722845273ed1a3e347b367f71a8da860b07570284090f3cd710392e303a998c9894ff5fa75bccfd
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- falkorlib (0.7.8)
4
+ falkorlib (0.7.9)
5
5
  activesupport (~> 4.0)
6
6
  artii (>= 2.1)
7
7
  awesome_print (~> 1.2)
@@ -1,6 +1,6 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  ################################################################################
3
- # Time-stamp: <Sat 2016-11-12 12:18 svarrette>
3
+ # Time-stamp: <Wed 2017-08-23 15:36 svarrette>
4
4
  ################################################################################
5
5
  # Interface for the main Puppet Module operations
6
6
  #
@@ -132,7 +132,7 @@ module FalkorLib #:nodoc:
132
132
  config[:platforms] = [ 'debian' ]
133
133
  config[:dependencies] = [{
134
134
  "name" => "puppetlabs-stdlib",
135
- "version_requirement" => ">=4.2.2 <5.0.0"
135
+ "version_requirement" => ">=4.19.0 <5.0.0"
136
136
  }]
137
137
  config[:params] = %w(ensure protocol port packagename)
138
138
  #ap config
@@ -173,7 +173,7 @@ module FalkorLib #:nodoc:
173
173
  [ 'metadata.json',
174
174
  'docs/', 'mkdocs.yml', 'LICENSE', '.gitignore', '.pmtignore',
175
175
  '.ruby-version', '.ruby-gemset', 'Gemfile',
176
- '.vagrant_init.rb', 'Rakefile', 'Vagrantfile' ].each do |f|
176
+ 'tests/vagrant/', 'Rakefile', 'Vagrantfile' ].each do |f|
177
177
  FalkorLib::Git.add(File.join(moduledir, f))
178
178
  end
179
179
  end
@@ -306,7 +306,7 @@ module FalkorLib #:nodoc:
306
306
  'docs/contributing/index.md', 'docs/contributing/layout.md', 'docs/contributing/setup.md', 'docs/contributing/versioning.md',
307
307
  'docs/index.md', 'docs/rtfd.md', 'docs/vagrant.md'
308
308
  ]
309
- (update_from_erb + [ 'Gemfile', 'Rakefile', 'Vagrantfile', '.vagrant_init.rb' ]).each do |f|
309
+ (update_from_erb + [ 'Gemfile', 'Rakefile', 'Vagrantfile', 'tests/vagrant/bootstrap.sh', 'tests/vagrant/config.yaml', 'tests/vagrant/puppet_modules_setup.rb' ]).each do |f|
310
310
  next unless options[:exclude].nil? || !options[:exclude].include?( f )
311
311
  next unless options[:only].nil? || options[:only].include?(f)
312
312
  info "Upgrade the content of #{f}"
@@ -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, 8
22
+ MAJOR, MINOR, PATCH = 0, 7, 9
23
23
 
24
24
  module_function
25
25
 
@@ -2,7 +2,7 @@
2
2
  #########################################
3
3
  # puppet_modules_spec.rb
4
4
  # @author Sebastien Varrette <Sebastien.Varrette@uni.lu>
5
- # Time-stamp: <Thu 2016-11-10 02:01 svarrette>
5
+ # Time-stamp: <Wed 2017-08-23 15:39 svarrette>
6
6
  #
7
7
  # @description Check the Puppet Modules operations
8
8
  #
@@ -156,7 +156,7 @@ describe FalkorLib::Puppet::Modules do
156
156
  # ])
157
157
  # end
158
158
 
159
- upgraded_files_default = 1
159
+ upgraded_files_default = 5
160
160
  it "#upgrade" do
161
161
  d = FalkorLib::Puppet::Modules.upgrade(moduledir, {
162
162
  :no_interaction => true
@@ -4,10 +4,45 @@ source "https://rubygems.org"
4
4
  gem 'falkorlib' #, :path => '~/git/github.com/Falkor/falkorlib'
5
5
 
6
6
  # Puppet stuff
7
- puppetversion = ENV.key?('PUPPET_VERSION') ? "= #{ENV['PUPPET_VERSION']}" : ['>= 3.3']
8
- gem "puppet", puppetversion
9
7
  #gem 'puppetlabs_spec_helper', '>= 0.1.0'
10
- gem 'puppet-lint', '>= 0.3.2'
11
- gem 'puppet-syntax'
12
- gem 'facter', '>= 1.7.0'
13
- gem 'rspec-puppet'
8
+
9
+ #gem 'puppet-syntax'
10
+ #gem 'facter', '>= 1.7.0'
11
+
12
+ group :test do
13
+ gem "rake"
14
+ gem "puppet", ENV['PUPPET_GEM_VERSION'] || '~> 4.4.0'
15
+ gem "rspec", '< 3.2.0'
16
+ gem "rspec-puppet"
17
+ gem "puppetlabs_spec_helper"
18
+ gem "metadata-json-lint"
19
+ gem "rspec-puppet-facts"
20
+ gem 'rubocop', '0.33.0'
21
+ gem 'simplecov', '>= 0.11.0'
22
+ gem 'simplecov-console'
23
+
24
+ #gem 'puppet-lint', '>= 0.3.2'
25
+ gem "puppet-lint-absolute_classname-check"
26
+ gem "puppet-lint-leading_zero-check"
27
+ gem "puppet-lint-trailing_comma-check"
28
+ gem "puppet-lint-version_comparison-check"
29
+ gem "puppet-lint-classes_and_types_beginning_with_digits-check"
30
+ gem "puppet-lint-unquoted_string-check"
31
+ gem 'puppet-lint-resource_reference_syntax'
32
+ gem 'semantic_puppet'
33
+
34
+ gem 'json_pure', '<= 2.0.1' if RUBY_VERSION < '2.0.0'
35
+ end
36
+
37
+ group :development do
38
+ gem "travis" if RUBY_VERSION >= '2.1.0'
39
+ gem "travis-lint" if RUBY_VERSION >= '2.1.0'
40
+ # gem "puppet-blacksmith"
41
+ # gem "guard-rake" if RUBY_VERSION >= '2.2.5' # per dependency https://rubygems.org/gems/ruby_dep
42
+ end
43
+
44
+ group :system_tests do
45
+ gem "beaker"
46
+ gem "beaker-rspec"
47
+ gem "beaker-puppet_install_helper"
48
+ end
@@ -1,7 +1,23 @@
1
- #
1
+ ##############################################################################
2
2
  # Rakefile - Configuration file for rake (http://rake.rubyforge.org/)
3
+ # Time-stamp: <Wed 2017-08-23 15:17 svarrette>
4
+ #
5
+ # Copyright (c) 2017 UL HPC Team <hpc-sysadmins@uni.lu>
6
+ # ____ _ __ _ _
7
+ # | _ \ __ _| | _____ / _(_) | ___
8
+ # | |_) / _` | |/ / _ \ |_| | |/ _ \
9
+ # | _ < (_| | < __/ _| | | __/
10
+ # |_| \_\__,_|_|\_\___|_| |_|_|\___|
11
+ #
12
+ # Use 'rake -T' to list the available actions
3
13
  #
14
+ # Resources:
15
+ # * http://www.stuartellis.eu/articles/rake/
16
+ #
17
+ # See also https://github.com/garethr/puppet-module-skeleton
18
+ ##############################################################################
4
19
  require 'falkorlib'
20
+ require 'puppetlabs_spec_helper/rake_tasks'
5
21
 
6
22
  ## placeholder for custom configuration of FalkorLib.config.*
7
23
  ## See https://github.com/Falkor/falkorlib
@@ -13,16 +29,15 @@ end
13
29
 
14
30
  # Adapt the Git flow aspects
15
31
  FalkorLib.config.gitflow do |c|
16
- c[:branches] = {
32
+ c[:branches] = {
17
33
  :master => 'production',
18
34
  :develop => 'devel'
19
- }
35
+ }
20
36
  end
21
37
 
22
-
38
+
23
39
  require 'falkorlib/tasks/git'
24
- require 'falkorlib/tasks/puppet'
40
+ #require 'falkorlib/tasks/puppet'
25
41
 
26
42
  ##############################################################################
27
43
  #TOP_SRCDIR = File.expand_path(File.join(File.dirname(__FILE__), "."))
28
-
@@ -1,50 +1,140 @@
1
1
  # -*- mode: ruby -*-
2
2
  # vi: set ft=ruby :
3
+ # Time-stamp: <Tue 2017-08-22 23:58 svarrette>
4
+ ###########################################################################################
5
+ # __ __ _ __ _ _
6
+ # \ \ / /_ _ __ _ _ __ __ _ _ __ | |_ / _(_) | ___
7
+ # \ \ / / _` |/ _` | '__/ _` | '_ \| __| |_| | |/ _ \
8
+ # \ V / (_| | (_| | | | (_| | | | | |_| _| | | __/
9
+ # \_/ \__,_|\__, |_| \__,_|_| |_|\__|_| |_|_|\___|
10
+ # |___/
11
+ ###########################################################################################
12
+ require 'yaml'
13
+ require 'ipaddr'
14
+ require 'deep_merge'
3
15
 
4
16
  # Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
5
17
  VAGRANTFILE_API_VERSION = "2"
18
+ TOP_SRCDIR = File.expand_path File.dirname(__FILE__)
19
+ TOP_VAGRANT_TESTDIR = File.join(TOP_SRCDIR, 'tests', 'vagrant')
20
+ config_file = File.join(TOP_VAGRANT_TESTDIR, 'config.yaml')
6
21
 
22
+ ###### Expected Vagrant plugins detection ######
23
+ # For more information on the below plugins:
24
+ # - https://github.com/oscar-stack/vagrant-hosts
25
+ # - https://github.com/dotless-de/vagrant-vbguest
26
+ # - https://github.com/emyl/vagrant-triggers
27
+ # - https://github.com/fgrehm/vagrant-cachier
28
+ # Terminal-table is a nice ruby gem for automatically print tables with nice layout
29
+ ###
30
+ [ 'vagrant-hosts', 'vagrant-vbguest', 'vagrant-triggers', 'vagrant-cachier', '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
+ ### Default settings ###
36
+ DEFAULT_SETTINGS = {
37
+ :defaults => {
38
+ :os => :centos7,
39
+ :ram => 512,
40
+ :vcpus => 4,
41
+ :vbguest_auto_update => true,
42
+ },
43
+ # Default domain settings
44
+ :network => {
45
+ :domain => 'vagrant.dev',
46
+ :range => '10.10.1.0/24',
47
+ :ip_offset => 10,
48
+ },
49
+ # Default Boxes
50
+ :boxes => {
51
+ :centos7 => 'centos/7',
52
+ :debian8 => 'debian/contrib-jessie64',
53
+ :ubuntu14 => 'ubuntu/trusty64'
54
+ },
55
+ :vms => {
56
+ 'default' => { }
57
+ },
58
+ }
59
+
60
+ # List of default provisioning scripts
61
+ DEFAULT_PROVISIONING_SCRIPTS = [
62
+ "tests/vagrant/bootstrap.sh",
63
+ "tests/vagrant/puppet_modules_setup.rb"
64
+ ]
65
+
66
+ # Load the settings (eventually overwritten using values from the yaml file 'config.yaml')
67
+ settings = DEFAULT_SETTINGS.clone
68
+ if File.exist?(config_file)
69
+ config = YAML::load_file config_file
70
+ settings.deep_merge!( config ) if config
71
+ end
72
+ abort "Undefined settings" if settings.nil?
73
+
74
+
75
+ ############################################################
7
76
  Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
8
- # Inspired by [puppet-playground](https://github.com/example42/puppet-playground/blob/master/Vagrantfile)
9
- #config.cache.auto_detect = true
10
-
11
- # (nearly) All below boxes were generated using [vagrant-vms](https://github.com/Falkor/vagrant-vms/)
12
- {
13
- :centos_7 => {
14
- :box => "svarrette/centos-7-puppet",
15
- :url => "https://atlas.hashicorp.com/svarrette/boxes/centos-7-puppet"
16
- },
17
- :debian_7 => {
18
- :box => "svarrette/debian-7-puppet",
19
- :url => "https://atlas.hashicorp.com/svarrette/debian-7-puppet",
20
- :primary => true
21
- }
22
- }.each do |name,cfg|
23
- boxname = name.to_s.downcase.gsub(/_/, '-')
24
- config.vm.define boxname, :autostart => (! cfg[:primary].nil?), :primary => cfg[:primary] do |local|
25
- #local.vm.primary = true if cfg[:primary]
26
- local.vm.box = cfg[:box]
27
- local.vm.host_name = ENV['VAGRANT_HOSTNAME'] || name.to_s.downcase.gsub(/_/, '-').concat(".vagrant.com")
28
- #config.vm.box_check_update = false
29
- local.vm.provision "shell", path: ".vagrant_init.rb"
30
- # local.vm.provision :puppet do |puppet|
31
- # puppet.hiera_config_path = 'data/hiera.yaml'
32
- # puppet.working_directory = '/vagrant'
33
- # puppet.manifests_path = "manifests"
34
- # puppet.module_path = "modules"
35
- # puppet.manifest_file = "init.pp"
36
- # puppet.options = [
37
- # '--verbose',
38
- # '--report',
39
- # '--show_diff',
40
- # '--pluginsync',
41
- # '--summarize',
42
- # # '--evaltrace',
43
- # # '--debug',
44
- # # '--parser future',
45
- # ]
46
- # end
77
+ defaults = settings[:defaults]
78
+ network = settings[:network]
79
+
80
+ ### Common configs shared by all VMs ###
81
+ # Cache plugin -- Supports local cache, so you don't wast bandwitdh
82
+ # vagrant plugin install vagrant-cachier # see https://github.com/fgrehm/vagrant-cachier
83
+ config.cache.auto_detect = true if Vagrant.has_plugin?("vagrant-cachier")
84
+
85
+ # check if VirtualBox Guest Additions are up to date
86
+ if Vagrant.has_plugin?("vagrant-vbguest")
87
+ # set auto_update to false, if you do NOT want to check the correct
88
+ # additions version when booting these boxes
89
+ config.vbguest.auto_update = defaults[:vbguest_auto_update]
90
+ end
91
+
92
+ # Shell provisioner, to setup minimal conditions for Puppet provisioning
93
+ DEFAULT_PROVISIONING_SCRIPTS.each do |script|
94
+ config.vm.provision "shell", path: "#{script}", keep_color: true
95
+ end
96
+ config.vm.synced_folder ".", "/vagrant", type: "virtualbox"
97
+
98
+ # network settings
99
+ ipaddr = IPAddr.new network[:range]
100
+ ip_range = ipaddr.to_range.to_a
101
+
102
+ # cosmetics for the post-up message
103
+ __table = {
104
+ :title => "Puppet Testing infrastructure deployed on Vagrant",
105
+ :headings => [ 'Name', 'Hostname', 'OS', 'vCPU/RAM', 'Description', 'IP' ],
106
+ :rows => [],
107
+ }
108
+ #__________________________________
109
+ settings[:vms].each do |name, node|
110
+ boxname = defaults[:os].to_s.downcase.gsub(/([^\d]+)(\d+)/, '\\1-\\2')
111
+ name = boxname if name == 'default'
112
+ hostname = node[:hostname] ? node[:hostname] : name
113
+ domain = network[:domain]
114
+ fqdn = "#{hostname}.#{domain}"
115
+ os = node[:os] ? node[:os].to_sym : defaults[:os].to_sym
116
+ ram = node[:ram] ? node[:ram] : defaults[:ram]
117
+ vcpus = node[:vcpus] ? node[:vcpus] : defaults[:vcpus]
118
+ desc = node[:desc] ? node[:desc] : 'n/a'
119
+
120
+ abort "Non-existing box OS '#{os}' for the VM '#{name}'" if settings[:boxes][os.to_sym].nil?
121
+ abort "Empty IP address range" if ip_range.empty?
122
+ ip = ip_range[ network[:ip_offset].to_i ].to_s
123
+
124
+ config.vm.define "#{name}" do |c|
125
+ c.vm.box = settings[:boxes][os.to_sym]
126
+ c.vm.hostname = "#{fqdn}"
127
+ c.vm.network :private_network, :ip => ip
128
+ c.vm.provision :hosts, :sync_hosts => true
129
+ c.vm.provider "virtualbox" do |v|
130
+ v.customize [ 'modifyvm', :id, '--name', hostname, '--memory', ram.to_s ]
131
+ v.customize [ 'modifyvm', :id, '--cpus', vcpus.to_s ] if vcpus.to_i > 1
132
+ end
133
+ __table[:rows] << [ name, fqdn, os.to_sym, "#{vcpus}/#{ram}", desc, ip]
47
134
  end
48
135
  end
49
- end
50
136
 
137
+ config.trigger.after :up do
138
+ puts Terminal::Table.new __table
139
+ end
140
+ end
@@ -9,7 +9,14 @@ to build configurable, lightweight, and portable virtual machines dynamically.
9
9
  * [Reference installation notes](http://docs.vagrantup.com/v2/installation/) -- assuming you have installed [Oracle's VirtualBox](http://www.virtualbox.org/)
10
10
  * [installation notes on Mac OS](http://sourabhbajaj.com/mac-setup/Vagrant/README.html) using [Homebrew](http://brew.sh/) and [Cask](http://sourabhbajaj.com/mac-setup/Homebrew/Cask.html)
11
11
 
12
- The `Vagrantfile` at the root of the repository pilot the provisioning of many vagrant boxes generated through the [vagrant-vms](https://github.com/falkor/vagrant-vms) repository and available on [Vagrant cloud](https://atlas.hashicorp.com/boxes/search?utf8=%E2%9C%93&sort=&provider=virtualbox&q=svarrette).
12
+ The `Vagrantfile` at the root of the repository pilot the provisioning a vagrant boxes.
13
+ It can run any OS you set in `tests/vagrant/config.yaml` as follows:
14
+
15
+ ```yaml
16
+ :vms:
17
+ 'default':
18
+ :os: :debian8
19
+ ```
13
20
 
14
21
  You can list the available vagrant box as follows:
15
22
 
@@ -17,23 +24,34 @@ You can list the available vagrant box as follows:
17
24
  $> vagrant status
18
25
  Current machine states:
19
26
 
20
- centos-7 not created (virtualbox)
21
- debian-7 not created (virtualbox)
27
+ centos-7 running (virtualbox)
22
28
 
23
- This environment represents multiple VMs. The VMs are all listed
24
- above with their current state. For more information about a specific
25
- VM, run `vagrant status NAME`.
29
+ The VM is running. To stop this VM, you can run `vagrant halt` to
30
+ shut it down forcefully, or you can run `vagrant suspend` to simply
31
+ suspend the virtual machine. In either case, to restart it again,
32
+ simply run `vagrant up`.
26
33
  ```
27
34
 
28
- As suggested, you can run a debian 7 machine for instance by issuing:
35
+ You can boot the VM and provision it (using the scripts under `tests/vagrant/`) by running:
29
36
 
30
- $> vagrant up debian-7
37
+ ```bash
38
+ $> vagrant up
39
+ ```
31
40
 
32
41
  Then you can ssh into the machine afterwards:
33
42
 
34
- $> vagrant ssh debian-7
43
+ ```bash
44
+ $> vagrant ssh
45
+ ```
46
+
47
+ When you run `vagrant up <name>` to boot the VM, the provisioning scripts are responsible for:
48
+
49
+ | Script | Description |
50
+ |---------------------------|-------------------------------------------------|
51
+ | `bootstrap.sh` | Install puppet 4 and defaults packages and gems |
52
+ | `puppet_modules_setup.rb` | pre-install the necessary puppet modules |
35
53
 
36
- When you run `vagrant up <os>` to boot the VM, it is configured to be provisioned with the `.vagrant_init.rb` script.
54
+ More precisely, the `tests/vagrant/puppet_modules_setup.rb` script.
37
55
  This script is responsible for two main tasks:
38
56
 
39
57
  1. pre-install the puppet modules listed as dependencies in `metadata.json`
@@ -41,7 +59,7 @@ This script is responsible for two main tasks:
41
59
 
42
60
  So you can test the manifests of the `tests/` directory within the VM:
43
61
 
44
- $> vagrant ssh <os>
62
+ $> vagrant ssh [<os>]
45
63
  [...]
46
64
  (vagrant)$> sudo puppet apply -t /vagrant/tests/init.pp
47
65
 
@@ -1,3 +1,6 @@
1
+ ################################################################################
2
+ # Time-stamp: <Wed 2017-08-23 14:42 svarrette>
3
+ #
1
4
  # File:: <tt>common/debian.pp</tt>
2
5
  # Author:: <%= config[:author] %> (<%= config[:mail] %>)
3
6
  # Copyright:: Copyright (c) <%= Time.now.year %> <%= config[:author] %>
@@ -1,3 +1,6 @@
1
+ ################################################################################
2
+ # Time-stamp: <Wed 2017-08-23 14:43 svarrette>
3
+ #
1
4
  # File:: <tt>common/redhat.pp</tt>
2
5
  # Author:: <%= config[:author] %> (<%= config[:mail] %>)
3
6
  # Copyright:: Copyright (c) <%= Time.now.year %> <%= config[:author] %>