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.
@@ -21,11 +21,23 @@
21
21
  ],
22
22
  "operatingsystem_support": [
23
23
  {
24
- "operatingsystem": "Debian",
24
+ "operatingsystem": "RedHat",
25
+ "operatingsystemrelease": [
26
+ "7"
27
+ ]
28
+ },
29
+ {
30
+ "operatingsystem": "CentOS",
25
31
  "operatingsystemrelease": [
26
- "6",
27
32
  "7"
28
33
  ]
34
+ },
35
+ {
36
+ "operatingsystem": "Debian",
37
+ "operatingsystemrelease": [
38
+ "7",
39
+ "8"
40
+ ]
29
41
  }
30
42
  ],
31
43
  "tags": <%= config[:tags] %>
@@ -1,12 +1,14 @@
1
1
  site_name: <%= config[:name] %> Puppet Module
2
2
  pages:
3
- - ['index.md', 'Home']
4
- - ['overview.md', 'Overview']
5
- - ['vagrant.md', 'Tests with Vagrant']
6
- - ['contributing/index.md', 'Contributing', 'Overview']
7
- - ['contributing/layout.md', 'Contributing', 'Directory Layout']
8
- - ['contributing/setup.md', 'Contributing', 'Repository Setup and Developments']
9
- - ['contributing/versioning.md', 'Contributing', 'Module Versioning']
10
- - ['rtfd.md', 'Documentation', 'RTFD']
11
- - ['contacts.md', 'Contacts']
3
+ - Home: 'index.md'
4
+ - Overview: 'overview.md'
5
+ - Tests with Vagrant: 'vagrant.md'
6
+ - Contributing:
7
+ - Overview: 'contributing/index.md'
8
+ - Directory Layout: 'contributing/layout.md'
9
+ - Repository Setup and Developments: 'contributing/setup.md'
10
+ - Module Versioning: 'contributing/versioning.md'
11
+ - Documentation:
12
+ - RTFD: 'rtfd.md'
13
+ - Contacts: 'contacts.md'
12
14
  theme: readthedocs
@@ -16,5 +16,5 @@
16
16
  # sudo puppet apply -t /vagrant/tests/init.pp
17
17
  #
18
18
  node default {
19
- include <%= config[:shortname] %>
19
+ include ::<%= config[:shortname] %>
20
20
  }
@@ -0,0 +1,229 @@
1
+ #!/usr/bin/env bash
2
+ # Time-stamp: <Sun 2017-08-20 19:08 svarrette>
3
+ ###########################################################################################
4
+ # __ __ _ ____ _ _
5
+ # \ \ / /_ _ __ _ _ __ __ _ _ __ | |_ | __ ) ___ ___ | |_ ___| |_ _ __ __ _ _ __
6
+ # \ \ / / _` |/ _` | '__/ _` | '_ \| __| | _ \ / _ \ / _ \| __/ __| __| '__/ _` | '_ \
7
+ # \ V / (_| | (_| | | | (_| | | | | |_ | |_) | (_) | (_) | |_\__ \ |_| | | (_| | |_) |
8
+ # \_/ \__,_|\__, |_| \__,_|_| |_|\__| |____/ \___/ \___/ \__|___/\__|_| \__,_| .__/
9
+ # |___/ |_|
10
+ # Copyright (c) 2017 UL HPC Team <hpc-sysadmins@uni.lu>
11
+ ###########################################################################################
12
+ # ULHPC (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
+ MOTD="/etc/motd"
27
+ DOTFILES_DIR='/etc/dotfiles.d'
28
+ DOTFILES_URL='https://github.com/ULHPC/dotfiles.git'
29
+ SUPPORT_MAIL='hpc-sysadmins@uni.lu'
30
+ EXTRA_PACKAGES=
31
+
32
+ # List of default packages to install
33
+ COMMON_DEFAULT_PACKAGES="ruby wget figlet git screen bash-completion rsync vim"
34
+
35
+ GEMS="librarian-puppet falkorlib"
36
+
37
+ ######
38
+ # Print information in the following form: '[$2] $1' ($2=INFO if not submitted)
39
+ # usage: info text [title]
40
+ ##
41
+ info () {
42
+ echo
43
+ echo "${SETCOLOR_BOLD}###${SETCOLOR_NORMAL} ${SETCOLOR_TITLE}${1}${SETCOLOR_NORMAL} ${SETCOLOR_BOLD}###${SETCOLOR_NORMAL}"
44
+ }
45
+ error() {
46
+ echo
47
+ echo "${SETCOLOR_RED}*** ERROR *** $*${SETCOLOR_NORMAL}"
48
+ exit 1
49
+ }
50
+
51
+ print_usage() {
52
+ cat <<EOF
53
+ $0 [--name "vagrant box name"] \
54
+ [--title "Title"] \
55
+ [--subtitle "Subtitle"] \
56
+ [--desc "description"] \
57
+ [--support "support@mail.com"]
58
+ [-x "pkg1 pkg2 ..."]
59
+
60
+ Bootstrap a Vagrant box
61
+ This will generate the appropriate ${MOTD} file
62
+ EOF
63
+ }
64
+
65
+ ####################### Per OS Bootstrapping function ##########################
66
+ setup_redhat() {
67
+ info "Running yum update"
68
+ yum update -y >/dev/null
69
+
70
+ info "Installing default packages"
71
+ yum install -y epel-release
72
+ yum install -y ${COMMON_DEFAULT_PACKAGES} ruby-devel bind-utils ${EXTRA_PACKAGES} >/dev/null
73
+
74
+ info "Uninstalling (eventually) existing Puppet installation"
75
+ yum erase -y puppet puppetlabs-release >/dev/null
76
+
77
+ info "Adding repo for Puppet 4"
78
+ rpm -ivh https://yum.puppetlabs.com/puppetlabs-release-pc1-el-$1.noarch.rpm
79
+
80
+ sleep 1
81
+ info "Installing Puppet and its dependencies"
82
+ yum install -y puppet-agent >/dev/null
83
+ }
84
+
85
+ setup_apt() {
86
+ case $1 in
87
+ 3*) codename=cumulus ;;
88
+ 6) codename=squeeze ;;
89
+ 7) codename=wheezy ;;
90
+ 8) codename=jessie ;;
91
+ 9) codename=stretch ;;
92
+ 12.04) codename=precise ;;
93
+ 14.04) codename=trusty ;;
94
+ 16.04) codename=xenial ;;
95
+ *) echo "Release not supported" ;;
96
+ esac
97
+
98
+ info "Adding repo for Puppet 4"
99
+ wget -q "http://apt.puppetlabs.com/puppetlabs-release-pc1-${codename}.deb" >/dev/null
100
+ dpkg -i "puppetlabs-release-pc1-${codename}.deb" >/dev/null
101
+
102
+ info "Running apt-get update"
103
+ apt-get update >/dev/null 2>&1
104
+
105
+ info "Installing default packages"
106
+ apt-get install -y ${COMMON_DEFAULT_PACKAGES} git-core rubygems ${EXTRA_PACKAGES} >/dev/null
107
+
108
+ info "Installing Puppet and its dependencies"
109
+ apt-get install puppet-agent -y >/dev/null
110
+ apt-get install apt-transport-https -y >/dev/null
111
+ }
112
+
113
+ setup_linux() {
114
+ ARCH=$(uname -m | sed 's/x86_//;s/i[3-6]86/32/')
115
+ if [ -f /etc/redhat-release ]; then
116
+ OS=$(cat /etc/redhat-release | cut -d ' ' -f 1)
117
+ majver=$(cat /etc/redhat-release | sed 's/[A-Za-z]*//g' | sed 's/ //g' | cut -d '.' -f 1)
118
+ elif [ -f /etc/SuSE-release ]; then
119
+ OS=sles
120
+ majver=$(cat /etc/SuSE-release | grep VERSION | cut -d '=' -f 2 | tr -d '[:space:]')
121
+ elif [ -f /etc/os-release ]; then
122
+ . /etc/os-release
123
+ OS=$ID
124
+ majver=$VERSION_ID
125
+ elif [ -f /etc/debian_version ]; then
126
+ OS=Debian
127
+ majver=$(cat /etc/debian_version | cut -d '.' -f 1)
128
+ elif [ -f /etc/lsb-release ]; then
129
+ . /etc/lsb-release
130
+ OS=$DISTRIB_ID
131
+ majver=$DISTRIB_RELEASE
132
+ elif [ -f /etc/os-release ]; then
133
+ . /etc/os-release
134
+ OS=$ID
135
+ majver=$VERSION_ID
136
+ else
137
+ OS=$(uname -s)
138
+ majver=$(uname -r)
139
+ fi
140
+ distro=$(echo $OS | tr '[:upper:]' '[:lower:]')
141
+ info "Detected Linux distro: ${distro} version ${majver} on arch ${ARCH}"
142
+ case "$distro" in
143
+ debian|ubuntu) setup_apt $majver ;;
144
+ redhat|fedora|centos|scientific|amazon) setup_redhat $majver ;;
145
+ *) echo "Not supported distro: $distro"; exit 1;;
146
+ esac
147
+
148
+ }
149
+
150
+ setup_dotfiles () {
151
+ if [ ! -d "${DOTFILES_DIR}" ]; then
152
+ info "cloning ULHPC/dotfiles repository in '/etc/dotfiles.d"
153
+ git clone ${DOTFILES_URL} ${DOTFILES_DIR}
154
+ fi
155
+ # Correct __git_ps1
156
+ local src_git_prompt="/usr/share/git-core/contrib/completion/git-prompt.sh"
157
+ local dst_git_prompt="/etc/profile.d/git-prompt.sh"
158
+ if [ -f "${src_git_prompt}" ]; then
159
+ info "installing git-prompt to define __git_ps1"
160
+ [ ! -e "${dst_git_prompt}" ] && ln -s ${src_git_prompt} ${dst_git_prompt}
161
+ fi
162
+ local dotfile_install_cmd="${DOTFILES_DIR}/install.sh --offline --force -d ${DOTFILES_DIR} --bash --screen"
163
+ if [ -d "${DOTFILES_DIR}" ]; then
164
+ info "installing dotfiles for 'root' user"
165
+ ${dotfile_install_cmd}
166
+ info "installing dotfiles for 'vagrant' user"
167
+ sudo -u vagrant ${dotfile_install_cmd}
168
+ fi
169
+ }
170
+
171
+ setup_motd() {
172
+ local motd=/etc/motd
173
+ local has_figlet=$(which figlet 2>/dev/null)
174
+ info "setup ${motd}"
175
+ cat <<EOF > ${motd}
176
+ ================================================================================
177
+ Welcome to the Vagrant box $(hostname)
178
+ ================================================================================
179
+ EOF
180
+ if [ -n "${has_figlet}" ]; then
181
+ cat <<EOF >> ${motd}
182
+ $(${has_figlet} -w 80 -c "$(hostname -s)")
183
+ EOF
184
+ fi
185
+ cat <<EOF >> ${motd}
186
+ ================================================================================
187
+ Hostname.... $(hostname -f)
188
+ OS.......... $(facter os.name) $(facter os.release.full)
189
+ Support..... ${SUPPORT_MAIL}
190
+ Docs........ Vagrant: http://docs.vagrantup.com/v2/
191
+ ================================================================================
192
+ EOF
193
+ }
194
+
195
+ setup_gems() {
196
+ sudo gem install --no-ri --no-rdoc ${GEMS}
197
+ }
198
+
199
+ ######################################################################################
200
+ [ $UID -gt 0 ] && error "You must be root to execute this script (current uid: $UID)"
201
+
202
+
203
+ # Parse the command-line options
204
+ while [ $# -ge 1 ]; do
205
+ case $1 in
206
+ -h | --help) print_usage; exit 0;;
207
+ -V | --version) print_version; exit 0;;
208
+ -n | --name) shift; NAME=$1;;
209
+ -t | --title) shift; TITLE=$1;;
210
+ -st| --subtitle) shift; SUBTITLE=$1;;
211
+ -d | --desc) shift; DESC=$1;;
212
+ -s | --support) shift; SUPPORT_MAIL=$1;;
213
+ -x | --extras) shift; EXTRA_PACKAGES=$1;;
214
+ esac
215
+ shift
216
+ done
217
+
218
+ # Let's go
219
+ case "$OSTYPE" in
220
+ linux*) setup_linux ;;
221
+ *) echo "unknown: $OSTYPE"; exit 1;;
222
+ esac
223
+
224
+ [ -f /usr/bin/puppet ] || ln -s /opt/puppetlabs/puppet/bin/puppet /usr/bin/puppet
225
+ [ -f /usr/bin/facter ] || ln -s /opt/puppetlabs/puppet/bin/facter /usr/bin/facter
226
+
227
+ setup_dotfiles
228
+ setup_motd
229
+ setup_gems
@@ -0,0 +1,51 @@
1
+ # -*- mode: yaml; -*-
2
+ # Time-stamp: <Mon 2017-08-21 23:15 svarrette>
3
+ ################################################################################
4
+ # Complementary configuration for Vagrant
5
+ # You can overwrite here the default settings defined in ../../Vagrantfile and
6
+ # define additional VMs (agents) to deploy upon vagrant up (in addition to the
7
+ # puppet master 'master')
8
+
9
+ #___________________________________________
10
+ # Complete / re-define the default boxes below
11
+ # Format:
12
+ # :<os><version>: <username>/<box> # see https://vagrantcloud.com
13
+ # :boxes:
14
+ # :windows2012: 'opentable/win-2012r2-standard-amd64-nocm'
15
+ # :freebsd12: 'freebsd/FreeBSD-12.0-RELEASE'
16
+ # :centos7: 'centos/7',
17
+ # :debian8: 'debian/contrib-jessie64',
18
+ # :ubuntu14: 'ubuntu/trusty64'
19
+
20
+ #_________________
21
+ # Default settings
22
+ # :defaults:
23
+ # :os: :centos7 # Default OS from the above box definition
24
+ # :ram: 512 # Default RAM
25
+ # :vcpus: 1 # Default number of virtual CPUs
26
+ # :vbguest_auto_update: 1 # check/update box guest additions
27
+
28
+ #____________________
29
+ # Network settings
30
+ # :network:
31
+ # :domain: 'vagrant.dev' # network domain to use
32
+ # :range: '10.10.1.0/24' # IP range to use
33
+ # :ip_offset: 10
34
+ # # client / VMs defined below will start on xx.xx.xx.<ip_offset>
35
+
36
+ #___________________________________________________________
37
+ # VMs / Vagrant boxes to define apart from the puppet master
38
+ # Format:
39
+ # <name>:
40
+ # :hostname: <hostname>
41
+ # :desc: <VM-description>
42
+ # :os: <os>
43
+ # :ram: <ram>
44
+ # :vcpus: <vcpus>
45
+ # :role: <role>
46
+ # :roles:
47
+ # - <role1>
48
+ # - <role2>
49
+ # :vms:
50
+ # 'default':
51
+ # :os: :debian8
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env ruby
2
+ ##########################################################################
3
+ # puppet_module_setup.rb
4
+ # @author Sebastien Varrette <Sebastien.Varrette@uni.lu>
5
+ # Time-stamp: <Mon 2017-08-21 13:01 svarrette>
6
+ #
7
+ # @description Prepare the Vagrant box to test this Puppet module
8
+ #
9
+ # Copyright (c) 2014-2017 Sebastien Varrette <Sebastien.Varrette@uni.lu>
10
+ # . http://varrette.gforge.uni.lu
11
+ ##############################################################################
12
+
13
+ require 'json'
14
+ require 'yaml'
15
+ require 'falkorlib'
16
+
17
+ include FalkorLib::Common
18
+
19
+ # Load metadata
20
+ basedir = File.directory?('/vagrant') ? '/vagrant' : Dir.pwd
21
+ jsonfile = File.join( basedir, 'metadata.json')
22
+ puppetdir = '/etc/puppetlabs'
23
+
24
+ error "Unable to find the metadata.json" unless File.exists?(jsonfile)
25
+
26
+ metadata = JSON.parse( IO.read( jsonfile ) )
27
+ name = metadata["name"].gsub(/^[^\/-]+[\/-]/,'')
28
+ modulepath=`puppet config print modulepath`.chomp
29
+ moduledir=modulepath.split(':').first
30
+
31
+
32
+ run %{ cd #{moduledir}/.. && librarian-puppet clean && rm Puppetfile* }
33
+ run %{ ln -s /vagrant/metadata.json #{moduledir}/../ }
34
+ run %{ cd #{moduledir}/.. && librarian-puppet install --verbose }
35
+
36
+
37
+ # metadata["dependencies"].each do |dep|
38
+ # lib = dep["name"]
39
+ # shortname = lib.gsub(/^.*[\/-]/,'')
40
+ # action = File.directory?("#{moduledir}/#{shortname}") ? 'upgrade --force' : 'install'
41
+ # run %{ puppet module #{action} #{lib} }
42
+ # end
43
+
44
+ puts "Module path: #{modulepath}"
45
+ puts "Moduledir: #{moduledir}"
46
+
47
+ info "set symlink to the '#{basedir}' module for local developments"
48
+ run %{ ln -s #{basedir} #{moduledir}/#{name} } unless File.exists?("#{moduledir}/#{name}")
49
+
50
+ # Use of 'hiera.yaml' version 3 is deprecated. It should be converted to version 5
51
+ hiera = '/etc/puppetlabs/puppet/hiera.yaml'
52
+
53
+
54
+
55
+
56
+ # Prepare hiera
57
+ # unless File.exists?('/etc/puppet/hiera.yaml')
58
+ # run %{ ln -s /etc/hiera.yaml /etc/puppet/hiera.yaml } if File.exists?("/etc/hiera.yaml")
59
+ # end
60
+ # # # hieracfg = YAML::load_file('/etc/hiera.yaml')
61
+ # # # [ '/vagrant/tests/hiera' ].each do |d|
62
+ # # # hieracfg[:datadir] = [] if hieracfg[:datadir].nil?
63
+ # # # hieracfg[:datadir] << d #if File.directory?('#{d}')
64
+ # # # end
65
+ # # # hieracfg[:hierarchy] = [] if hieracfg[:hierarchy].nil?
66
+ # # # hieracfg[:hierarchy] << 'common' unless hieracfg[:hierarchy].include?('common')
67
+ # hieracfg = {
68
+ # :backends => [ 'yaml' ],
69
+ # :hierarchy => [ 'defaults', 'common' ],
70
+ # :yaml => {
71
+ # :datadir => '/vagrant/tests/hiera',
72
+ # }
73
+ # }
74
+ # FalkorLib::Common.store_config('/etc/hiera.yaml', hieracfg, {:no_interaction => true})
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.8
4
+ version: 0.7.9
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-17 00:00:00.000000000 Z
11
+ date: 2017-08-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -522,7 +522,6 @@ files:
522
522
  - templates/motd/motd.erb
523
523
  - templates/puppet/modules/.gitignore
524
524
  - templates/puppet/modules/.pmtignore
525
- - templates/puppet/modules/.vagrant_init.rb
526
525
  - templates/puppet/modules/Gemfile
527
526
  - templates/puppet/modules/README.md.erb
528
527
  - templates/puppet/modules/Rakefile
@@ -548,6 +547,9 @@ files:
548
547
  - templates/puppet/modules/templates/templatename-variables.erb
549
548
  - templates/puppet/modules/tests/init.pp.erb
550
549
  - templates/puppet/modules/tests/params.pp.erb
550
+ - templates/puppet/modules/tests/vagrant/bootstrap.sh
551
+ - templates/puppet/modules/tests/vagrant/config.yaml
552
+ - templates/puppet/modules/tests/vagrant/puppet_modules_setup.rb
551
553
  homepage: https://github.com/Falkor/falkorlib
552
554
  licenses:
553
555
  - MIT
@@ -1,67 +0,0 @@
1
- #!/usr/bin/env ruby
2
- ##########################################################################
3
- # vagrant_init.rb
4
- # @author Sebastien Varrette <Sebastien.Varrette@uni.lu>
5
- # Time-stamp: <Tue 2015-06-02 22:43 svarrette>
6
- #
7
- # @description
8
- #
9
- # Copyright (c) 2014 Sebastien Varrette <Sebastien.Varrette@uni.lu>
10
- # . http://varrette.gforge.uni.lu
11
- ##############################################################################
12
-
13
- require 'json'
14
- require 'yaml'
15
- require 'falkorlib'
16
-
17
- include FalkorLib::Common
18
-
19
- # Load metadata
20
- basedir = File.directory?('/vagrant') ? '/vagrant' : Dir.pwd
21
- jsonfile = File.join( basedir, 'metadata.json')
22
-
23
- error "Unable to find the metadata.json" unless File.exists?(jsonfile)
24
-
25
- metadata = JSON.parse( IO.read( jsonfile ) )
26
- name = metadata["name"].gsub(/^[^\/-]+[\/-]/,'')
27
- modulepath=`puppet config print modulepath`.chomp
28
- moduledir=modulepath.split(':').first
29
-
30
-
31
- run %{ cd /etc/puppet && librarian-puppet clean && rm Puppetfile* }
32
- run %{ ln -s /vagrant/metadata.json /etc/puppet/ }
33
- run %{ cd /etc/puppet && librarian-puppet install --verbose }
34
-
35
-
36
- # metadata["dependencies"].each do |dep|
37
- # lib = dep["name"]
38
- # shortname = lib.gsub(/^.*[\/-]/,'')
39
- # action = File.directory?("#{moduledir}/#{shortname}") ? 'upgrade --force' : 'install'
40
- # run %{ puppet module #{action} #{lib} }
41
- # end
42
-
43
- puts "Module path: #{modulepath}"
44
- puts "Moduledir: #{moduledir}"
45
-
46
- info "set symlink to the '#{basedir}' module for local developments"
47
- run %{ ln -s #{basedir} #{moduledir}/#{name} } unless File.exists?("#{moduledir}/#{name}")
48
-
49
- # Prepare hiera
50
- unless File.exists?('/etc/puppet/hiera.yaml')
51
- run %{ ln -s /etc/hiera.yaml /etc/puppet/hiera.yaml } if File.exists?("/etc/hiera.yaml")
52
- end
53
- # # hieracfg = YAML::load_file('/etc/hiera.yaml')
54
- # # [ '/vagrant/tests/hiera' ].each do |d|
55
- # # hieracfg[:datadir] = [] if hieracfg[:datadir].nil?
56
- # # hieracfg[:datadir] << d #if File.directory?('#{d}')
57
- # # end
58
- # # hieracfg[:hierarchy] = [] if hieracfg[:hierarchy].nil?
59
- # # hieracfg[:hierarchy] << 'common' unless hieracfg[:hierarchy].include?('common')
60
- hieracfg = {
61
- :backends => [ 'yaml' ],
62
- :hierarchy => [ 'defaults', 'common' ],
63
- :yaml => {
64
- :datadir => '/vagrant/tests/hiera',
65
- }
66
- }
67
- FalkorLib::Common.store_config('/etc/hiera.yaml', hieracfg, {:no_interaction => true})