kameleon-builder 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,8 @@
1
1
  module Kameleon
2
2
  module Utils
3
3
 
4
- def self.resolve_vars(raw, yaml_path, initial_variables)
4
+ def self.resolve_vars(raw, yaml_path, initial_variables, kwargs = {})
5
+ strict = kwargs.fetch('strict', true)
5
6
  raw.to_s.gsub(/\$\$\{[a-zA-Z0-9\-_]+\}|\$\$[a-zA-Z0-9\-_]+/) do |var|
6
7
  # remove the dollars
7
8
  if var.include? "{"
@@ -13,7 +14,9 @@ module Kameleon
13
14
  if initial_variables.has_key? strip_var
14
15
  value = initial_variables[strip_var]
15
16
  else
16
- fail RecipeError, "#{yaml_path}: variable #{var} not found in local or global"
17
+ if strict
18
+ fail RecipeError, "#{yaml_path}: variable #{var} not found in local or global" \
19
+ end
17
20
  end
18
21
  return $` + resolve_vars(value.to_s + $', yaml_path, initial_variables)
19
22
  end
@@ -29,8 +29,8 @@ global:
29
29
  - $$distrib
30
30
 
31
31
  # Frontend options
32
- g5k_user: $$my_gk5_username # CHANGE ME
33
- g5k_site: $$my_gk5_site # CHANGE ME
32
+ g5k_user: $$my_g5k_username # CHANGE ME
33
+ g5k_site: $$my_g5k_site # CHANGE ME
34
34
 
35
35
  # Kenv
36
36
  kenv: "wheezy-x64-base"
@@ -0,0 +1,43 @@
1
+ #==============================================================================
2
+ # vim: softtabstop=2 shiftwidth=2 expandtab fenc=utf-8 cc=81 tw=80
3
+ #==============================================================================
4
+ #
5
+ # DESCRIPTION: Debian 7 appliance with kameleon.
6
+ #
7
+ #==============================================================================
8
+
9
+ ---
10
+ extend: debian7-desktop
11
+
12
+ global:
13
+ # You can see the base template `debian7-desktop.yaml` to know the
14
+ # variables that you can override
15
+ arch: amd64
16
+
17
+ bootstrap:
18
+ - @base
19
+
20
+ setup:
21
+ - @base
22
+ - autologin
23
+ - install_software:
24
+ - packages: parted qemu-system debootstrap qemu-utils
25
+ - install_kameleon:
26
+ - deb_install:
27
+ - exec_in: wget http://kameleon.imag.fr/pkg/kameleon_2.1.0+20140612204940-1_amd64.deb -O kameleon_2.1.0_amd64.deb
28
+ - exec_in: dpkg -i kameleon_2.1.0_amd64.deb
29
+ - exec_in: rm -f kameleon_2.1.0_amd64.deb
30
+ - prepare_export:
31
+ - nullify_freespace:
32
+ - exec_in: rm -rf /tmp/* || true
33
+ - exec_in: rm -rf /var/tmp/* || true
34
+ - exec_in: |
35
+ echo "Nullify freespace..."
36
+ dd if=/dev/zero of=/bigemptyfile bs=1M 2>&1 >/dev/null || true
37
+ rm -f /bigemptyfile
38
+
39
+ export:
40
+ - save_appliance:
41
+ - save_as_qcow2:
42
+ - exec_out: qemu-img convert -c -O qcow2 $$image_disk $KAMELEON_WORKDIR/$$kameleon_recipe_name.qcow2
43
+ - exec_out: echo "Saved qcow2 appliance to $KAMELEON_WORKDIR/$$kameleon_recipe_name.qcow2"
@@ -96,7 +96,7 @@ setup:
96
96
  - dist_upgrade: true
97
97
  - install_software:
98
98
  - packages: >
99
- debian-keyring ntp zip unzip rsync sudo less vim bash-completion
99
+ debian-keyring ntp rsync sudo less vim bash-completion
100
100
  - configure_kernel:
101
101
  - arch: $$arch
102
102
  # Configuration
@@ -0,0 +1,107 @@
1
+ #==============================================================================
2
+ # vim: softtabstop=2 shiftwidth=2 expandtab fenc=utf-8 cc=81 tw=80
3
+ #==============================================================================
4
+ #
5
+ # DESCRIPTION: Build a debian image for docker with docker
6
+ #
7
+ #==============================================================================
8
+
9
+ ---
10
+ # Loads some helpful aliases
11
+ aliases: defaults.yaml
12
+ # Enables qcow2 checkpoint
13
+ # checkpoint: docker.yaml
14
+ #== Global variables use by Kameleon engine and the steps
15
+ global:
16
+ ## User varibales : used by the recipe
17
+ user_name: kameleon
18
+ user_password: $$user_name
19
+
20
+ # Distribution
21
+ distrib: debian
22
+ release: wheezy
23
+ arch: amd64
24
+
25
+ ## Docker options
26
+ docker_dns: 208.67.222.222
27
+ docker_image: $$kameleon_recipe_name
28
+ docker_hostname: $$kameleon_recipe_name
29
+
30
+ # rootfs options
31
+ rootfs_download_path: /var/cache/kameleon/$$distrib/$$release/$$arch/rootfs
32
+
33
+ ## System variables. Required by kameleon engine
34
+ # Include specific steps
35
+ include_steps:
36
+ - $$distrib/$$release
37
+ - $$distrib
38
+
39
+ # Apt options
40
+ apt_repository: http://ftp.debian.org/debian/
41
+ apt_enable_contrib: true
42
+ apt_enable_nonfree: true
43
+ apt_install_recommends: false
44
+
45
+ # Shell session from where we launch exec_out commands. There is often a
46
+ # local bash session, but it can be a remote shell on other machines or on
47
+ # any shell. (eg. bash, chroot, fakechroot, ssh, tmux, lxc...)
48
+ out_context:
49
+ cmd: bash
50
+ workdir: $$kameleon_cwd
51
+
52
+ # Shell session that allows us to connect to the building machine in order to
53
+ # configure it and setup additional programs
54
+ ssh_config_file: $$kameleon_cwd/ssh_config
55
+ in_context:
56
+ cmd: LC_ALL=POSIX ssh -F $$ssh_config_file $$kameleon_recipe_name -t /bin/bash
57
+ workdir: /root/kameleon_workdir
58
+
59
+ #== Bootstrap the new system and create the 'in_context'
60
+ bootstrap:
61
+ - debootstrap:
62
+ - include_pkg: >
63
+ ifupdown locales libui-dialog-perl dialog isc-dhcp-client netbase
64
+ net-tools iproute acpid openssh-server pciutils extlinux
65
+ linux-image-$$arch
66
+ - release: $$release
67
+ - arch: $$arch
68
+ - repository: $$apt_repository
69
+ - enable_cache: true
70
+ - prepare_docker
71
+ - start_docker
72
+
73
+
74
+ #== Install and configuration steps
75
+ # WARNING: this part should be independante from the out context (whenever
76
+ # possible...)
77
+ setup:
78
+ # Install
79
+ - configure_apt:
80
+ - repository: $$apt_repository
81
+ - enable_contrib_repo: $$apt_enable_contrib
82
+ - enable_nonfree_repo: $$apt_enable_nonfree
83
+ - install_recommends: $$apt_install_recommends
84
+ - upgrade_system:
85
+ - dist_upgrade: true
86
+ - install_software:
87
+ - packages: >
88
+ debian-keyring ntp rsync sudo less vim bash-completion
89
+ # Configuration
90
+ - configure_system:
91
+ - locales: POSIX C en_US fr_FR de_DE
92
+ - lang: en_US.UTF-8
93
+ - timezone: UTC
94
+ - configure_keyboard:
95
+ - layout: "us,fr,de"
96
+ - create_group:
97
+ - name: admin
98
+ - create_user:
99
+ - name: $$user_name
100
+ - groups: sudo admin
101
+ - password: $$user_password
102
+
103
+ #== Export the generated appliance in the format of your choice
104
+ export:
105
+ - save_docker_appliance:
106
+ - commit:
107
+ - exec_out: docker commit $(cat MAIN_CONTAINER_ID) -t $$kameleon_recipe_name:latest
@@ -8,7 +8,7 @@
8
8
  - exec_out: mkdir -p $$kameleon_cwd/checkpoints
9
9
  - exec_out: |
10
10
  if [ ! -e "$$image_disk" ] ; then
11
- qemu-img create -f qcow2 -o preallocation=metadata $$kameleon_cwd/checkpoints/base.qcow2 $$image_size
11
+ qemu-img create -f qcow2 $$kameleon_cwd/checkpoints/base.qcow2 $$image_size
12
12
  # keep a link to the last checkpoint disk
13
13
  ln -sf $$kameleon_cwd/checkpoints/base.qcow2 $$image_disk
14
14
  fi
@@ -7,7 +7,7 @@
7
7
  - check_cmd_out: qemu-img
8
8
  - exec_out: |
9
9
  rm -f $$image_disk
10
- qemu-img create -f qcow2 -o preallocation=metadata $$image_disk $$image_size
10
+ qemu-img create -f qcow2 $$image_disk $$image_size
11
11
 
12
12
  - load_nbd_module:
13
13
  - on_checkpoint: redo
@@ -1,13 +1,4 @@
1
-
2
- - check_docker:
3
- - on_bootstrap_init:
4
- - exec_out: DOCKER=${DOCKER:-docker}
5
- - rescue:
6
- - exec_out: command -V $DOCKER
7
- - breakpoint: >
8
- error: Docker executable no found. Make sure Docker
9
- is installed and/or use the DOCKER variable to set Docker
10
- executable.
1
+ - insecure_ssh_key: $$kameleon_cwd/insecure_ssh_key
11
2
 
12
3
  - clean_containers:
13
4
  - on_checkpoint: redo
@@ -19,31 +10,42 @@
19
10
  - exec_out: cat CONTAINERS_TO_CLEAN | xargs -I {} docker rm {}
20
11
  - exec_out: rm -f CONTAINERS_TO_CLEAN
21
12
 
22
- - import_rootfs:
23
- - exec_out: |
24
- docker images | grep -q $$image \
25
- || (echo "Importing $$image to docker..." && cat "$$rootfs_archive"\
26
- | docker import - $$image \
27
- | xargs -I {} docker tag {} $$image:base)
28
- - exec_out: docker tag $$image:base $$image:latest
29
13
 
30
- - configure_sshd:
31
- - on_checkpoint: redo
32
- - exec_out: echo -e 'y\n' | ssh-keygen -q -t rsa -f $$insecure_ssh_key -N ''
14
+ - configure_ssh_access:
15
+ - exec_out: echo -e 'y\n' | ssh-keygen -q -t dsa -f $$insecure_ssh_key -N ''
33
16
  - exec_out: cat $$insecure_ssh_key
17
+ - exec_out: chroot $$rootfs_download_path mkdir -p /root/.ssh
34
18
  - exec_out: |
35
- CID="kameleon_container_$[($RANDOM % ($[50000 - 50] + 1)) + 50]"
36
- cat $${insecure_ssh_key}.pub | \
37
- docker run -i -a stdin --dns $$dns --name $CID $$image:latest \
38
- /bin/bash -c "mkdir -p /root/.ssh ; \
39
- tee -a /root/.ssh/authorized_keys"
40
- - on_export_init:
41
- - exec_in: rm -rf /root/.ssh
42
- - exec_out: echo "$CID" >> CONTAINERS_TO_CLEAN
43
- - exec_out: |
44
- docker images | grep $$image \
45
- | grep sshd \
46
- | awk '{print $3}' \
47
- | xargs -I {} docker rmi {}
48
- - exec_out: docker commit $CID $$image:sshd > /dev/null
49
- - exec_out: docker tag $$image:sshd $$image:latest
19
+ cat $${insecure_ssh_key}.pub > $$rootfs_download_path/root/.ssh/authorized_keys
20
+ cat $${insecure_ssh_key}.pub > $$rootfs_download_path/root/.ssh/kameleon_insecure_public_key
21
+ chmod 600 $$rootfs_download_path/root/.ssh/authorized_keys
22
+ chmod 755 $$rootfs_download_path/root/.ssh
23
+ - on_clean:
24
+ - exec_out: rm -rf $$rootfs_download_path/root/.ssh
25
+
26
+ - import_to_docker:
27
+ - check_cmd_out: docker
28
+ - exec_out: echo "Importing $$docker_image to docker..."
29
+ - exec_out: tar -C $$rootfs_download_path -c . | $DOCKER import - $$docker_image:base
30
+
31
+ - create_ssh_config:
32
+ - write_out:
33
+ - $$ssh_config_file
34
+ - |
35
+ Host $$kameleon_recipe_name
36
+ HostName 127.0.0.1
37
+ User root
38
+ IdentityFile $$insecure_ssh_key
39
+ UserKnownHostsFile /dev/null
40
+ StrictHostKeyChecking no
41
+ PasswordAuthentication no
42
+ IdentitiesOnly yes
43
+ LogLevel FATAL
44
+ ForwardAgent yes
45
+ ControlPath /tmp/$${kameleon_short_uuid}%r@%h:%p
46
+ ControlMaster auto
47
+ ControlPersist yes
48
+ Compression yes
49
+ Protocol 2
50
+ - on_export_clean:
51
+ - exec_out: rm -f /tmp/$${kameleon_short_uuid}*
@@ -40,7 +40,7 @@
40
40
  IdentitiesOnly yes
41
41
  LogLevel FATAL
42
42
  ForwardAgent yes
43
- ControlPath $(pwd)/master-%l-%r@%h:%p
43
+ ControlPath /tmp/$${kameleon_short_uuid}%r@%h:%p
44
44
  ControlMaster auto
45
45
  ControlPersist yes
46
46
  Compression yes
@@ -1,12 +1,16 @@
1
1
  - start_sshd:
2
2
  - on_checkpoint: redo
3
3
  - exec_out: |
4
- CID=$(docker run -d -p 127.0.0.1::22 -i --dns $$dns -h $$hostname --privileged "$$image:latest" \
5
- /bin/bash -c "service ssh restart ; tail -f /dev/null")
4
+ CID=$(docker run -d -p 127.0.0.1::22 -i \
5
+ --dns $$docker_dns \
6
+ -h $$docker_hostname \
7
+ --privileged "$$docker_image:base" \
8
+ /bin/bash -c "service ssh restart ; tail -f /dev/null")
6
9
  - exec_out: echo "$CID" >> CONTAINERS_TO_CLEAN
7
10
  - exec_out: echo $CID > MAIN_CONTAINER_ID
8
11
  - on_export_clean:
9
12
  - exec_out: rm -f MAIN_CONTAINER_ID
10
13
  - exec_out: echo $(docker port $CID 22) | cut -d':' -f2 > MAIN_CONTAINER_PORT
14
+ - exec_out: echo "Port $(cat MAIN_CONTAINER_PORT)" >> $$ssh_config_file
11
15
  - on_export_clean:
12
16
  - exec_out: rm -f MAIN_CONTAINER_PORT
@@ -47,7 +47,7 @@
47
47
  - exec_in: |
48
48
  sleep 2 && shutdown -h now &
49
49
  - exec_out: |
50
- while nc -w 0 -z localhost $$qemu_monitor_port
50
+ while nc -w 1 -z localhost $$qemu_monitor_port
51
51
  do
52
52
  sleep 1
53
53
  echo -n "."
@@ -58,7 +58,7 @@
58
58
  - on_checkpoint: redo
59
59
  - on_export_clean:
60
60
  - exec_out: |
61
- if nc -w 0 -z localhost $$qemu_monitor_port 2>/dev/null
61
+ if nc -w 1 -z localhost $$qemu_monitor_port 2>/dev/null
62
62
  then
63
63
  echo "Shutting down qemu virtual machine..."
64
64
  echo "system_reset" | nc localhost $$qemu_monitor_port 1>/dev/null 2>&1
@@ -1,6 +1,6 @@
1
1
  create: |
2
2
  if [ -f "$$kameleon_cwd/checkpoint_enabled" ] ; then
3
- if nc -w 0 -z localhost $$qemu_monitor_port 2>/dev/null
3
+ if nc -w 1 -z localhost $$qemu_monitor_port 2>/dev/null
4
4
  then
5
5
  echo "savevm @microstep_id" | nc localhost $$qemu_monitor_port
6
6
  fi
@@ -5,7 +5,7 @@
5
5
  - exec_in: tgz-g5k $$filename.tar.gz
6
6
  - exec_out: |
7
7
  rsync -avz -e "ssh -F $$out_cwd/ssh_config" \
8
- $$kameleon_recipe_name:/root/$$filename.tar.gz \
8
+ $$kameleon_recipe_name:$$in_cwd/$$filename.tar.gz \
9
9
  $$out_cwd/$$filename.tar.gz
10
10
  - exec_out: echo "Saved tar.gz appliance to $$out_cwd/$$filename.tar.gz"
11
11
  - exec_in: rm -f $$in_cwd/$$filename.tar.gz
data/version.txt CHANGED
@@ -1 +1 @@
1
- 2.1.0
1
+ 2.1.1
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kameleon-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2014-06-12 00:00:00.000000000 Z
15
+ date: 2014-06-16 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: childprocess
@@ -85,7 +85,7 @@ dependencies:
85
85
  requirements:
86
86
  - - ~>
87
87
  - !ruby/object:Gem::Version
88
- version: 3.0.4
88
+ version: '3.0'
89
89
  type: :runtime
90
90
  prerelease: false
91
91
  version_requirements: !ruby/object:Gem::Requirement
@@ -93,7 +93,7 @@ dependencies:
93
93
  requirements:
94
94
  - - ~>
95
95
  - !ruby/object:Gem::Version
96
- version: 3.0.4
96
+ version: '3.0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: pry
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -182,13 +182,15 @@ email:
182
182
  - bruno.bzeznik@imag.fr
183
183
  executables:
184
184
  - kameleon
185
- extensions: []
185
+ extensions:
186
+ - ext/mkrf_conf.rb
186
187
  extra_rdoc_files: []
187
188
  files:
188
189
  - .editorconfig
189
190
  - .env
190
191
  - .gitignore
191
192
  - AUTHORS
193
+ - CHANGELOG.rst
192
194
  - COPYING
193
195
  - Gemfile
194
196
  - README.rst
@@ -233,6 +235,9 @@ files:
233
235
  - docs/source/commands.rst
234
236
  - docs/source/conf.py
235
237
  - docs/source/context.rst
238
+ - docs/source/debian7.yaml
239
+ - docs/source/debian_customized.yaml
240
+ - docs/source/debian_customized_g5k.yaml
236
241
  - docs/source/faq.rst
237
242
  - docs/source/getting_started.rst
238
243
  - docs/source/grid5000_tutorial.rst
@@ -240,8 +245,10 @@ files:
240
245
  - docs/source/installation.rst
241
246
  - docs/source/persistent_cache.rst
242
247
  - docs/source/recipe.rst
248
+ - docs/source/tau_install_g5k.yaml
243
249
  - docs/source/use_cases.rst
244
250
  - docs/source/workspace.rst
251
+ - ext/mkrf_conf.rb
245
252
  - kameleon-builder.gemspec
246
253
  - lib/kameleon.rb
247
254
  - lib/kameleon/cli.rb
@@ -280,10 +287,11 @@ files:
280
287
  - templates/archlinux.yaml
281
288
  - templates/debian-testing.yaml
282
289
  - templates/debian7-desktop.yaml
283
- - templates/debian7-docker.yaml
284
290
  - templates/debian7-g5k.yaml
291
+ - templates/debian7-kameleon.yaml
285
292
  - templates/debian7-oar-dev.yaml
286
293
  - templates/debian7.yaml
294
+ - templates/docker-debian7.yaml
287
295
  - templates/extend.erb
288
296
  - templates/fedora-rawhide.yaml
289
297
  - templates/fedora20-desktop.yaml
@@ -380,7 +388,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
380
388
  requirements:
381
389
  - - ! '>='
382
390
  - !ruby/object:Gem::Version
383
- version: 1.9.3
391
+ version: '0'
384
392
  required_rubygems_version: !ruby/object:Gem::Requirement
385
393
  none: false
386
394
  requirements: