kameleon-builder 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (157) hide show
  1. data/.editorconfig +0 -0
  2. data/.env +63 -15
  3. data/.gitignore +1 -0
  4. data/README.rst +4 -2
  5. data/Vagrantfile +13 -52
  6. data/bin/kameleon +5 -0
  7. data/completion/_kameleon.zsh +18 -0
  8. data/completion/kameleon.bash +13 -0
  9. data/completion/kameleon.fish +10 -0
  10. data/contrib/polipo_env.sh +2 -0
  11. data/contrib/steps/export/save_as_g5k.yaml +63 -0
  12. data/contrib/steps/setup/add_to_sudoers.yaml +5 -0
  13. data/docs/Makefile +10 -6
  14. data/docs/README.md +17 -0
  15. data/docs/source/_static/kameleon-logo.png +0 -0
  16. data/docs/source/_static/kameleon-logo.xcf +0 -0
  17. data/docs/source/_static/kameleon-long.png +0 -0
  18. data/docs/source/aliases.rst +4 -2
  19. data/docs/source/checkpoint.rst +2 -0
  20. data/docs/source/commands.rst +4 -3
  21. data/docs/source/conf.py +15 -7
  22. data/docs/source/context.rst +7 -4
  23. data/docs/source/faq.rst +39 -1
  24. data/docs/source/getting_started.rst +227 -1
  25. data/docs/source/grid5000_tutorial.rst +110 -0
  26. data/docs/source/index.rst +7 -2
  27. data/docs/source/installation.rst +12 -4
  28. data/docs/source/persistent_cache.rst +34 -0
  29. data/docs/source/recipe.rst +23 -16
  30. data/docs/source/use_cases.rst +93 -0
  31. data/docs/source/workspace.rst +2 -0
  32. data/kameleon-builder.gemspec +7 -1
  33. data/lib/kameleon.rb +3 -6
  34. data/lib/kameleon/cli.rb +104 -50
  35. data/lib/kameleon/compat.rb +39 -0
  36. data/lib/kameleon/context.rb +43 -13
  37. data/lib/kameleon/engine.rb +118 -77
  38. data/lib/kameleon/environment.rb +3 -5
  39. data/lib/kameleon/error.rb +15 -9
  40. data/lib/kameleon/logger.rb +7 -4
  41. data/lib/kameleon/persistent_cache.rb +139 -0
  42. data/lib/kameleon/recipe.rb +200 -81
  43. data/lib/kameleon/shell.rb +51 -16
  44. data/omnibus/.gitignore +11 -0
  45. data/omnibus/.kitchen.yml +25 -0
  46. data/omnibus/Berksfile +9 -0
  47. data/omnibus/Berksfile.lock +25 -0
  48. data/omnibus/Gemfile +12 -0
  49. data/omnibus/README.md +94 -0
  50. data/omnibus/config/projects/kameleon.rb +23 -0
  51. data/omnibus/config/software/kameleon.rb +24 -0
  52. data/omnibus/config/software/polipo.rb +30 -0
  53. data/omnibus/config/software/ruby.rb +158 -0
  54. data/omnibus/files/mac_dmg/Resources/background.png +0 -0
  55. data/omnibus/files/mac_dmg/Resources/icon.png +0 -0
  56. data/omnibus/files/mac_pkg/Resources/background.png +0 -0
  57. data/omnibus/files/mac_pkg/Resources/license.html +1 -0
  58. data/omnibus/files/mac_pkg/Resources/welcome.html +9 -0
  59. data/omnibus/omnibus.rb +27 -0
  60. data/omnibus/package-scripts/kameleon/makeselfinst +27 -0
  61. data/omnibus/package-scripts/kameleon/postrm +9 -0
  62. data/templates/archlinux-desktop.yaml +25 -0
  63. data/templates/archlinux.yaml +106 -0
  64. data/templates/debian-testing.yaml +25 -0
  65. data/templates/debian7-desktop.yaml +25 -0
  66. data/templates/{debian-wheezy-docker.yaml → debian7-docker.yaml} +30 -16
  67. data/templates/debian7-g5k.yaml +97 -0
  68. data/templates/debian7-oar-dev.yaml +51 -0
  69. data/templates/debian7.yaml +128 -0
  70. data/templates/extend.erb +23 -0
  71. data/templates/fedora-rawhide.yaml +30 -0
  72. data/templates/fedora20-desktop.yaml +21 -0
  73. data/templates/fedora20.yaml +105 -0
  74. data/templates/{debian-wheezy-chroot.yaml → old-debian7.yaml} +51 -38
  75. data/templates/{aliases → steps/aliases}/defaults.yaml +37 -12
  76. data/templates/steps/bootstrap/archlinux/arch_bootstrap.yaml +219 -0
  77. data/templates/steps/bootstrap/archlinux/install_bootloader.yaml +46 -0
  78. data/templates/steps/bootstrap/archlinux/populate_disk.yaml +39 -0
  79. data/templates/steps/bootstrap/debian/debootstrap.yaml +18 -10
  80. data/templates/steps/bootstrap/debian/debootstrap_arm.yaml +31 -0
  81. data/templates/steps/bootstrap/fedora/liveos_bootstrap.yaml +123 -0
  82. data/templates/steps/bootstrap/g5k_reserv.yaml +70 -0
  83. data/templates/steps/bootstrap/initialize_disk_chroot.yaml +84 -0
  84. data/templates/steps/bootstrap/initialize_disk_qemu.yaml +72 -0
  85. data/templates/steps/bootstrap/install_bootloader.yaml +42 -0
  86. data/templates/steps/bootstrap/prepare_chroot.yaml +126 -0
  87. data/templates/steps/bootstrap/prepare_docker.yaml +19 -8
  88. data/templates/steps/bootstrap/prepare_qemu.yaml +47 -0
  89. data/templates/steps/bootstrap/start_chroot.yaml +11 -2
  90. data/templates/steps/bootstrap/start_docker.yaml +2 -2
  91. data/templates/steps/bootstrap/start_qemu.yaml +75 -0
  92. data/templates/steps/bootstrap/ubuntu/debootstrap.yaml +27 -0
  93. data/templates/steps/breakpoint.yaml +2 -0
  94. data/templates/{checkpoints → steps/checkpoints}/docker.yaml +0 -0
  95. data/templates/steps/checkpoints/qcow2.yaml +38 -0
  96. data/templates/steps/checkpoints/qemu.yaml +39 -0
  97. data/templates/steps/export/clean_appliance.yaml +7 -1
  98. data/templates/steps/export/compact_qcow_img.yaml +12 -0
  99. data/templates/steps/export/save_appliance.yaml +58 -0
  100. data/templates/steps/export/save_appliance_from_g5k.yaml +47 -0
  101. data/templates/steps/export/save_vagrant_box.yaml +29 -0
  102. data/templates/steps/setup/archlinux/configure_keyboard.yaml +9 -0
  103. data/templates/steps/setup/archlinux/configure_network.yaml +9 -0
  104. data/templates/steps/setup/archlinux/configure_ruby.yaml +7 -0
  105. data/templates/steps/setup/archlinux/configure_system.yaml +20 -0
  106. data/templates/steps/setup/archlinux/install_dev_tools.yaml +18 -0
  107. data/templates/steps/setup/archlinux/install_gnome.yaml +27 -0
  108. data/templates/steps/setup/archlinux/install_software.yaml +9 -0
  109. data/templates/steps/setup/archlinux/install_yaourt.yaml +29 -0
  110. data/templates/steps/setup/autologin.yaml +16 -0
  111. data/templates/steps/setup/create_group.yaml +12 -0
  112. data/templates/steps/setup/create_user.yaml +9 -10
  113. data/templates/steps/setup/debian/configure_apt.yaml +65 -0
  114. data/templates/steps/setup/debian/configure_kernel.yaml +18 -0
  115. data/templates/steps/setup/debian/{keyboard_config.yaml → configure_keyboard.yaml} +1 -1
  116. data/templates/steps/setup/debian/{network_config.yaml → configure_network.yaml} +0 -0
  117. data/templates/steps/setup/debian/{system_config.yaml → configure_system.yaml} +0 -0
  118. data/templates/steps/setup/debian/install_gnome.yaml +13 -0
  119. data/templates/steps/setup/debian/install_kde.yaml +13 -0
  120. data/templates/steps/setup/debian/install_software.yaml +2 -0
  121. data/templates/steps/setup/debian/oar/oar_debian_config_frontend.yaml +8 -0
  122. data/templates/steps/setup/debian/oar/oar_debian_config_node.yaml +5 -0
  123. data/templates/steps/setup/debian/oar/oar_debian_config_server.yaml +5 -0
  124. data/templates/steps/setup/debian/oar/oar_prereq_install.yaml +16 -0
  125. data/templates/steps/setup/debian/setup_vagrant_box.yaml +52 -0
  126. data/templates/steps/setup/debian/upgrade_system.yaml +15 -0
  127. data/templates/steps/setup/fedora/configure_network.yaml +30 -0
  128. data/templates/steps/setup/fedora/configure_system.yaml +59 -0
  129. data/templates/steps/setup/fedora/install_software.yaml +3 -0
  130. data/templates/steps/setup/fedora/update_system.yaml +10 -0
  131. data/templates/steps/setup/oar/oar_config_devel.yaml +21 -0
  132. data/templates/steps/setup/oar/oar_config_frontend.yaml +38 -0
  133. data/templates/steps/setup/oar/oar_config_node.yaml +4 -0
  134. data/templates/steps/setup/oar/oar_config_server.yaml +25 -0
  135. data/templates/steps/setup/oar/oar_config_system.yaml +34 -0
  136. data/templates/steps/setup/oar/oar_devel_prereq_install.yaml +5 -0
  137. data/templates/steps/setup/oar/oar_git_install.yaml +21 -0
  138. data/templates/steps/setup/ubuntu/configure_apt.yaml +67 -0
  139. data/templates/ubuntu-12.04-desktop.yaml +25 -0
  140. data/templates/ubuntu-12.04.yaml +128 -0
  141. data/templates/ubuntu-14.04-desktop.yaml +27 -0
  142. data/templates/ubuntu-14.04.yaml +25 -0
  143. data/templates/vagrant-debian7.yaml +31 -0
  144. data/version.txt +1 -1
  145. metadata +155 -28
  146. checksums.yaml +0 -7
  147. data/templates/checkpoints/qcow2.yaml +0 -44
  148. data/templates/fedora-docker.yaml +0 -96
  149. data/templates/steps/bootstrap/fedora/docker_bootstrap.yaml +0 -25
  150. data/templates/steps/bootstrap/fedora/yum_bootstrap.yaml +0 -22
  151. data/templates/steps/bootstrap/prepare_appliance_with_nbd.yaml +0 -93
  152. data/templates/steps/export/build_appliance_from_docker.yaml +0 -105
  153. data/templates/steps/export/save_appliance_from_nbd.yaml +0 -54
  154. data/templates/steps/setup/debian/kernel_install.yaml +0 -20
  155. data/templates/steps/setup/debian/software_install.yaml +0 -15
  156. data/templates/steps/setup/fedora/kernel_install.yaml +0 -27
  157. data/templates/steps/setup/fedora/software_install.yaml +0 -10
@@ -1,3 +1,5 @@
1
+ .. _`checkpoint`:
2
+
1
3
  ----------
2
4
  Checkpoint
3
5
  ----------
@@ -1,3 +1,5 @@
1
+ .. _`commands`:
2
+
1
3
  --------
2
4
  Commands
3
5
  --------
@@ -12,8 +14,7 @@ The exec command is a simple command execute, in the given context, the user
12
14
  command in argument. The context is specified by the name suffix local, out or
13
15
  in like this ``exec_[in/out/local]``.
14
16
 
15
- It is currently used most to execute bash script, but you can use any tools
16
- callable with bash.
17
+ It is mostly used to execute bash script or other comand line application.
17
18
 
18
19
  For example this command save the message "Hello world:" in the hello.txt file
19
20
  within the workdir of the *in* context:
@@ -40,7 +41,7 @@ to the new_file within the in context workdir:
40
41
  - exec_out: cat my_file
41
42
  - exec_in: cat > new_file
42
43
 
43
- This command are usually not used directly but with Aliases_.
44
+ This command are usually not used directly but with :ref:`Aliases`.
44
45
 
45
46
  Hooks
46
47
  ~~~~~
data/docs/source/conf.py CHANGED
@@ -27,8 +27,8 @@ import datetime
27
27
  # Add any Sphinx extension module names here, as strings. They can be
28
28
  # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
29
29
  # ones.
30
- extensions = []
31
-
30
+ extensions = ['sphinx.ext.todo']
31
+ AUTHORS = "Michael Mercier, Salem Harrache"
32
32
  # Add any paths that contain templates here, relative to this directory.
33
33
  templates_path = ['_templates']
34
34
 
@@ -124,7 +124,7 @@ if not on_rtd: # only import and set the theme if we're building docs locally
124
124
 
125
125
  # The name of an image file (relative to this directory) to place at the top
126
126
  # of the sidebar.
127
- #html_logo = None
127
+ # html_logo = '_static/kameleon-long.png'
128
128
 
129
129
  # The name of an image file (within the static path) to use as favicon of the
130
130
  # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
@@ -188,14 +188,22 @@ htmlhelp_basename = 'Kameleondoc'
188
188
 
189
189
  # -- Options for LaTeX output ---------------------------------------------
190
190
 
191
- latex_elements = {}
191
+ latex_logo = '_static/kameleon-long.png'
192
+
193
+ latex_elements = {
194
+ 'tableofcontents': "\\tableofcontents",
195
+ 'preamble': '''%
196
+ \pagestyle{plain}
197
+ \pagenumbering{arabic}
198
+ ''',
199
+ }
192
200
 
193
201
  # Grouping the document tree into LaTeX files. List of tuples
194
202
  # (source start file, target name, title,
195
203
  # author, documentclass [howto, manual, or own class]).
196
204
  latex_documents = [
197
205
  ('index', 'Kameleon.tex', u'Kameleon Documentation',
198
- u'Salem Harrache, Michael Mercier', 'manual'),
206
+ AUTHORS, 'howto'),
199
207
  ]
200
208
 
201
209
  # The name of an image file (relative to this directory) to place at the top of
@@ -225,7 +233,7 @@ latex_documents = [
225
233
  # (source start file, name, description, authors, manual section).
226
234
  man_pages = [
227
235
  ('index', 'kameleon', u'Kameleon Documentation',
228
- [u'Salem Harrache', u'Michael Mercier'], 1)
236
+ AUTHORS.split(', '), 1)
229
237
  ]
230
238
 
231
239
  # If true, show URL addresses after external links.
@@ -239,7 +247,7 @@ man_pages = [
239
247
  # dir menu entry, description, category)
240
248
  texinfo_documents = [
241
249
  ('index', 'Kameleon', u'Kameleon Documentation',
242
- u'Salem Harrache, Michael Mercier', 'Kameleon',
250
+ AUTHORS, 'Kameleon',
243
251
  'One line description of project.', 'Miscellaneous'),
244
252
  ]
245
253
 
@@ -1,11 +1,14 @@
1
+ .. _`context`:
2
+
1
3
  -------
2
4
  Context
3
5
  -------
4
6
 
5
- To understand how Kameleon work you have to get the *context* notion. A context
6
- is an execution environnement with his variables (like $PATH, $TERM,...), his
7
- tools (debootstrap, yum, ...) and all his specifics (filesystem, local/remote,
8
- ...). When you build an appliance you deal with 3 contexts:
7
+ To understand how Kameleon works you have to get the *context* notion. A context
8
+ is an execution environnement with its variables (like $PATH, $TERM,...), its
9
+ tools (debootstrap, yum, ...) and all its specifics (filesystem, local/remote,
10
+ ...). It also manage the connections to your context and make it easy and reliable.
11
+ When you build an appliance you deal with 3 contexts:
9
12
 
10
13
  - The *local* context which is the Kameleon execution environnement
11
14
  - The *out* context where you will bootstrap the appliance
data/docs/source/faq.rst CHANGED
@@ -2,4 +2,42 @@
2
2
  FAQ
3
3
  ---
4
4
 
5
- Work in progress...
5
+ .. note::
6
+ Work in progress...
7
+
8
+ Why my step file is not valid?
9
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10
+ When you try to build your recipe, you gat this message::
11
+
12
+ [global]: The macrostep /path/to/my/step/step.yaml is not valid
13
+
14
+ It means your step is not a valid YAML file. Be sure that you did not use some tabulations
15
+ instead of spaces or mix dictionnary and list in the same level. It is recommended to (re)read
16
+ the :doc:`recipe` documentation.
17
+
18
+ I have some troubles with qemu-nbd, what should I do?
19
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20
+ qemu-nbd is heavily used is some recipes and when the recipe crash it can be left in a
21
+ bad state. So, when you build you got this::
22
+
23
+ qemu-nbd: Failed to bdrv_open ...
24
+ nbd device /dev/nbd2 is unavailable
25
+
26
+ It means the that the ``/dev/ndb2`` device is not available anymore so go to the recipe and
27
+ change the value of ``nbd_device`` to something else like ``/dev/nbd3``.
28
+
29
+ .. note::
30
+ This is a cleaning problem and this is just a workaround. If you find an way to be clean
31
+ the nbd device correctly lest us know!
32
+
33
+ If the problem persist you can try to reboot your computer or remove the entire build directory.
34
+
35
+ What is a *mapping value*?
36
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
37
+
38
+ When you write a command and you got this error::
39
+
40
+ Error: ... mapping values are not allowed in this context at line 6 column 27
41
+
42
+ In YAML the mapping value is a ``:`` character. If you put this in a command the YAML parser
43
+ will not understand and raise an error. Just put some quotes around your command and that's it!
@@ -2,5 +2,231 @@
2
2
  Getting Started
3
3
  ---------------
4
4
 
5
+ .. note::
6
+ This page is a work in progress...
5
7
 
6
- Work in progress...
8
+ Installation
9
+ ~~~~~~~~~~~~
10
+
11
+ To install Kameleon have a look at the :doc:`installation` section.
12
+
13
+ Create a new recipe from template
14
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15
+
16
+ First thing to know is that Kameleon is an automation tool for bash. It brings
17
+ the ease of error handling, retry, checkpointing, easy debugging and cleaning
18
+ to your scripts to help you build your software appliance.
19
+
20
+ The template system built-in allows you quickly build a system and to understand the
21
+ Kameleon basics. Let see the template list::
22
+
23
+ kameleon templates
24
+
25
+ It shows the templates names and descriptions directly from the templates files shipped
26
+ with Kameleon::
27
+
28
+ The following templates are available in /var/lib/gems/1.9.1/gems/kameleon-builder-2.0.0/templates:
29
+ NAME | DESCRIPTION
30
+ ---------------------|-----------------------------------------------------------
31
+ fedora-docker | Fedora base image [Work in progress].
32
+ debian-wheezy-chroot | Build a debian wheezy appliance using chroot and qemu-nbd.
33
+ debian-wheezy-docker | Build a debian wheezy appliance using Docker.
34
+
35
+ Let's pick one of these. The ``debian-wheezy-chroot`` is a good example. Now you
36
+ will create a new recipe from this template. Let's name it ``debian_test``::
37
+
38
+ kameleon new debian_test -t debian-wheezy-chroot
39
+
40
+ Kameleon make a direct copy of the YAML template recipe file and all
41
+ the other required files like steps or aliases ones. You can see that in the
42
+ ``new`` command output::
43
+
44
+ [cli]: Cloning template 'debian-wheezy-chroot'
45
+ [recipe]: Loading /var/lib/gems/1.9.1/gems/kameleon-builder-2.0.0/templates/debian-wheezy-chroot.yaml
46
+ [recipe]: Loading aliases /var/lib/gems/1.9.1/gems/kameleon-builder-2.0.0/templates/aliases/defaults.yaml
47
+ [recipe]: Loading checkpoint configuration /var/lib/gems/1.9.1/gems/kameleon-builder-2.0.0/templates/checkpoints/qcow2.yaml
48
+ [recipe]: Loading macrostep /var/lib/gems/1.9.1/gems/kameleon-builder-2.0.0/templates/steps/bootstrap/debian/debootstrap.yaml
49
+ [recipe]: Loading macrostep /var/lib/gems/1.9.1/gems/kameleon-builder-2.0.0/templates/steps/bootstrap/prepare_appliance_with_nbd.yaml
50
+ [recipe]: Loading macrostep /var/lib/gems/1.9.1/gems/kameleon-builder-2.0.0/templates/steps/bootstrap/start_chroot.yaml
51
+ [recipe]: Loading macrostep /var/lib/gems/1.9.1/gems/kameleon-builder-2.0.0/templates/steps/setup/debian/software_install.yaml
52
+ [recipe]: Loading macrostep /var/lib/gems/1.9.1/gems/kameleon-builder-2.0.0/templates/steps/setup/debian/kernel_install.yaml
53
+ [recipe]: Loading macrostep /var/lib/gems/1.9.1/gems/kameleon-builder-2.0.0/templates/steps/setup/debian/system_config.yaml
54
+ [recipe]: Loading macrostep /var/lib/gems/1.9.1/gems/kameleon-builder-2.0.0/templates/steps/setup/debian/keyboard_config.yaml
55
+ [recipe]: Loading macrostep /var/lib/gems/1.9.1/gems/kameleon-builder-2.0.0/templates/steps/setup/debian/network_config.yaml
56
+ [recipe]: Loading macrostep /var/lib/gems/1.9.1/gems/kameleon-builder-2.0.0/templates/steps/setup/create_user.yaml
57
+ [recipe]: Loading macrostep /var/lib/gems/1.9.1/gems/kameleon-builder-2.0.0/templates/steps/export/save_appliance_from_nbd.yaml
58
+ [recipe]: Loading recipe metadata
59
+ [cli]: New recipe "debian_test" as been created in /home/mercierm/kameleon_ws/recipes/debian_test.yaml
60
+
61
+ You can check that you got all the files in your workspace for example with the
62
+ UNIX ``tree`` command::
63
+
64
+ tree
65
+ .
66
+ `-- recipes
67
+ |-- aliases
68
+ | `-- defaults.yaml
69
+ |-- checkpoints
70
+ | `-- qcow2.yaml
71
+ |-- debian_test.yaml
72
+ `-- steps
73
+ |-- bootstrap
74
+ | |-- debian
75
+ | | `-- debootstrap.yaml
76
+ | |-- prepare_appliance_with_nbd.yaml
77
+ | `-- start_chroot.yaml
78
+ |-- export
79
+ | `-- save_appliance_from_nbd.yaml
80
+ `-- setup
81
+ |-- create_user.yaml
82
+ `-- debian
83
+ |-- kernel_install.yaml
84
+ |-- keyboard_config.yaml
85
+ |-- network_config.yaml
86
+ |-- software_install.yaml
87
+ `-- system_config.yaml
88
+
89
+ 9 directories, 13 files
90
+
91
+ To understand this hierarchy please refer to the :doc:`recipe` documentation.
92
+
93
+ Build my new recipe
94
+ ~~~~~~~~~~~~~~~~~~~
95
+
96
+ .. note::
97
+ Be sure to be `root` to run the following steps. It is needed for loading
98
+ modules, chrooting,...
99
+
100
+ There is no magic in Kameleon, everything is written in YAML:
101
+ from your system bootstrap to its export. It empowers you to customize anything
102
+ you want at anytime during the appliance build. But before changing anything
103
+ just build the template to see how it works::
104
+
105
+ kameleon build debian_test
106
+
107
+ Oups! Maybe you get an error like this::
108
+
109
+ ...
110
+ [engine]: qemu-img is missing
111
+ [engine]: Press [c] to continue with execution
112
+ [engine]: Press [a] to abort execution
113
+ [engine]: Press [l] to switch to local_context shell
114
+ [engine]: Press [o] to switch to out_context shell
115
+ [engine]: answer ? [c/a/l/o]:
116
+
117
+ This is the interactive prompt of Kameleon.
118
+ It is a powerful tool that offers you the possibility to fix a problem
119
+ if something goes wrong during the build process.
120
+ For this example, the problem is due to the missing ``qemu-img`` binary.
121
+ So you have to install it on your ``out`` context (to read more about context see the
122
+ :doc:`context` page). Just type the ``o`` key and ``Enter``. Now you are logged
123
+ in your out context. If you are on a Debian based system install the missing
124
+ package::
125
+
126
+ apt-get install qemu-utils
127
+
128
+ Press ``Ctrl-d`` or type ``exit`` to go back to the Kameleon prompt then press
129
+ ``c`` and ``Enter`` to continue the build.
130
+
131
+ The first time it will take a while to finish the building process. But, Thanks
132
+ to the :doc:`checkpoint` mechanism you can abort with ``Ctrl-c`` anytime during
133
+ the build without problem. Every step is backed up and if you start the
134
+ build again, it will skip all the steps already done
135
+ to restart at the point you have just stopped. Moreover, if you change anything in the recipe
136
+ Kameleon will know it (using recipe and steps hashes), so your next build will
137
+ automatically restart at the right steps. Here is a good example: The first
138
+ time you built your recipe you should have something like this::
139
+
140
+ ...
141
+ [cli]: Build recipe 'debian_test' is completed !
142
+ [cli]: Build total duration : 424 secs
143
+ ...
144
+
145
+ Now you can run your appliance using qemu::
146
+
147
+ qemu-system-x86_64 -enable-kvm builds/debian_test/debian_test.qcow2
148
+
149
+ .. note::
150
+ If you do not have access to a graphical server use the ``-curses`` option
151
+
152
+ How to use the checkpoint
153
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
154
+
155
+ You just have to run the build again and you will notice that it is much faster::
156
+
157
+ kameleon build debian_test
158
+ ...
159
+ [engine]: Step 1 : bootstrap/_init_bootstrap/_init_0_debootstrap
160
+ [engine]: ---> fac7c7045b6f
161
+ [engine]: ---> Using cache
162
+ ...
163
+ [cli]: Build recipe 'debian_test' is completed !
164
+ [cli]: Build total duration : 4 secs
165
+ ...
166
+
167
+ As you can see Kameleon has used the checkpoint cache for each step and in
168
+ doing so it takes just 4 seconds to build the recipe again. Well the recipe did
169
+ not change so there is no real challenge to build it so fast. Let's change
170
+ the user name for example. Open the ``debian_test.yaml`` recipe file and in the
171
+ global section change the user name like this::
172
+
173
+ user_name: my_user
174
+
175
+ Save the file and re-build the recipe again. This is a part of the outputs you
176
+ should see::
177
+
178
+ kameleon build debian_test
179
+ ...
180
+ [engine]: Step 29 : setup/create_user/create_group
181
+ [engine]: ---> ad19db198510
182
+ [engine]: ---> Using cache
183
+ [engine]: Step 30 : setup/create_user/add_user
184
+ [engine]: ---> 6bde599e7ed1
185
+ [engine]: ---> Running step
186
+ [engine]: ---> Creating checkpoint : 6bde599e7ed1
187
+ [engine]: Step 31 : setup/create_user/add_group_to_sudoers
188
+ [engine]: ---> 28b7a1fae5e2
189
+ [engine]: ---> Running step
190
+ [engine]: ---> Creating checkpoint : 28b7a1fae5e2
191
+ ...
192
+ [cli]: Build recipe 'debian_test' is completed !
193
+ [cli]: Build total duration : 29 secs
194
+ ...
195
+
196
+ This need a little explanation: You have change the ``user_name`` value in the
197
+ recipe. This variable is firstly used in the ``add_user`` :ref:`microstep`, in the
198
+ create_user :ref:`step` within the setup section. That is why all microsteps
199
+ before this one (the 30 in our case) are using the cache but all the microsteps after
200
+ are build again, to prevent side effects of this change, even if they are not
201
+ using the ``add_user`` value.
202
+
203
+ Add a new step
204
+ ~~~~~~~~~~~~~~
205
+
206
+ Let's assume that you want to add a step to put a timestamp in your image to
207
+ know when it was built. First, you have to create a step file in the
208
+ ``steps/setup`` folder because you want your timestamp to be added inside the
209
+ newly created appliance before exporting it. Let's call it ``add_timestamp.yaml``:
210
+
211
+ .. literalinclude:: ../../contrib/steps/setup/add_timestamp.yaml
212
+ :language: yaml
213
+
214
+ Then you should have this step to the recipe at the end of the setup section::
215
+
216
+ ...
217
+ setup:
218
+ ...
219
+ - add_timestamp
220
+
221
+ Then build again your recipe and run it like before to see that your timestamp
222
+ has been truly added.
223
+ To get more information about steps definition and usage like default
224
+ variable and microstep selection see :ref:`step`.
225
+
226
+ Advanced Features
227
+ ~~~~~~~~~~~~~~~~~
228
+
229
+ Kameleon gives you a lot of extension and customization possibilities. You can
230
+ define you own :doc:`aliases` and even your own :doc:`checkpoint` mechanism. You
231
+ are invited to go through the rest of the documentation to fully understand
232
+ Kameleon and it's great possibilities.
@@ -0,0 +1,110 @@
1
+ ==================
2
+ Grid'5000 Tutorial
3
+ ==================
4
+
5
+ This tutorial will introduce Kameleon a tool to build software appliances that can be
6
+ deployed on different infrastructures such as: virtualization, cloud computing, baremetal, etc.
7
+
8
+ ---------------
9
+ Kameleon basics
10
+ ---------------
11
+
12
+ First of all, let's see all the syntax flavors that Kameleon have to offer.
13
+ From this point, we assume that kameleon have been installed and it's already working
14
+ in your system, otherwise will refer to[1].
15
+ Kameleon can be seen as a shell sequencier which will boost your shell scripts.
16
+ It is based on the execution of shell scripts but it provides some syntax sugar that makes
17
+ the work with shell scripts less painfull.
18
+
19
+ We will start with the basics
20
+
21
+ Kameleon Hello world
22
+ ~~~~~~~~~~~~~~~~~~~~
23
+
24
+ Everything we want to build have to be specified by a recipe. Kameleon will read this recipe
25
+ and it will execute the appropiate actions. Let's create a hello world recipe for kameleon.
26
+ Open a text editor and write the following::
27
+
28
+ setup:
29
+ - first_step:
30
+ - hello_microstep:
31
+ - exec_local: echo "Hello world"
32
+ # The end
33
+
34
+ save the privious file as a YAML file. For instance hello_world.yaml.
35
+
36
+ .. note::
37
+ Be sure of respecting the YAML syntax `yaml`_.
38
+
39
+ .. _yaml: http://www.yaml.org/
40
+
41
+
42
+ Then, you run it like this::
43
+
44
+ kameleon build hello_world.yaml
45
+
46
+ You will have some output that looks like this::
47
+
48
+ [kameleon]: Starting recipe consistency check
49
+ [kameleon]: Resolving variables
50
+ [kameleon]: Calculating microstep identifiers
51
+ [kameleon]: Creating kameleon working directory : /home/cristian/Repositories/exptools/setup_complex_exp/tests/new_version/build/hello_world
52
+ [kameleon]: Building local context [local]
53
+ [kameleon]: Building external context [out]
54
+ [kameleon]: Building internal context [in]
55
+ [kameleon]: Starting build recipe 'hello_world.yaml'
56
+ [kameleon]: Step 1 : setup/first_step/hello_microstep
57
+ [kameleon]: ---> Running step
58
+ [kameleon]: Starting process: "bash"
59
+ [local_ctx]: The local_context has been initialized
60
+ [local_ctx]: Hello world
61
+ [kameleon]:
62
+ [kameleon]: Build recipe 'hello_world.yaml' is completed !
63
+ [kameleon]: Build total duration : 0 secs
64
+ [kameleon]: Build directory : /home/cristian/Repositories/exptools/setup_complex_exp/tests/new_version/build/hello_world
65
+ [kameleon]: Build recipe file : /home/cristian/Repositories/exptools/setup_complex_exp/tests/new_version/build/hello_world/kameleon_build_recipe.yaml
66
+ [kameleon]: Log file : /home/cristian/Repositories/exptools/setup_complex_exp/tests/new_version/kameleon.log
67
+
68
+ With this simple example, we have already introduced most of the Kameleon concepts and syntax.
69
+ First, how recipes are structured. Which could be done using: sections, steps, microsteps.
70
+
71
+ * Sections: The sections correspond to the minimal actions that have to be performed in order to have a software
72
+ stack that can be run almost anywhere. This brings to Kameleon a high degree of customizability, reuse of
73
+ code and users have total control in when and where the
74
+ sections have to take place. This minimal actions are: bootstrap, setup and export.
75
+
76
+ * Steps: It refers to a specific action to be done inside a section.
77
+ Steps can be declared in independent files that improves the degree of reusability.
78
+
79
+ * Microsteps: procedures composed of shell commands. The goal of dividing steps into microsteps is the
80
+ possibility of activating certain actions within a step.
81
+
82
+ The Kameleon hierarchy encourages the reuse (shareability) of code and modularity of procedures.
83
+
84
+ The minimal building block are the commands exec_ which wraps shell commands adding
85
+ a simple error handling and interactivenes in case of a problem.
86
+ These commands are executed in a given context. Which could be: local, in, out.
87
+ That are going to be defined later. They can be used as follows::
88
+
89
+ setup:
90
+ - first_step:
91
+ - hello_microstep:
92
+ - exec_local: echo "Hello world"
93
+ - exec_in: echo "Hello world"
94
+ - exec_out: echo "Hello world"
95
+ # The end
96
+
97
+
98
+ * Local context: It represents the Kameleon execution environment. Normally is the user’s machine.
99
+
100
+ * OUT context: It is where the appliance will be bootstraped. Some procedures have to be carried out in
101
+ order create the place where the software appliance is built (In context).
102
+ This can be: the same user’s machine using chroot.
103
+ Thus, in this context is where the setup of the chroot takes place.
104
+ Establishing the proper environmental variables in order to have a clean environment.
105
+ Other examples are: setting up a virtual machine, access to an infrastructure in order to get an instance and be able to deploy, setting
106
+ a Docker container, etc.
107
+
108
+ * IN context: It makes reference to inside the newly
109
+ created appliance. It can be mapped to a chroot,
110
+ virtual machine, physical machine, Linux container, etc.