Skip to content
This repository was archived by the owner on Jan 16, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
out/
*.rpm
*.deb
6 changes: 3 additions & 3 deletions PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ install=one-context.install
md5sums=('')

package() {
cp -rT ${srcdir}/addon-context-linux-${pkgver}/base_arch ${pkgdir}
cp -rT ${srcdir}/addon-context-linux-${pkgver}/base ${pkgdir}
cd ${srcdir}
TARGET=arch OUT=${pkgdir} ./generate.sh
cp -rT ${pkgdir}/usr/sbin ${pkgdir}/usr/bin
rm -rf ${pkgdir}/usr/sbin
}
}
171 changes: 104 additions & 67 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Linux VM Contextualization

## Description

These are the source of the contextualization packages used by VM to be configured with the information generated by OpenNebula.
These are the source of the contextualization packages used by VM to be
configured with the information generated by OpenNebula. This add-on is
compatible with OpenNebula >= 4.6.

## Get packages

Expand All @@ -11,99 +11,136 @@ Latest versions can be downloaded from the

## Development

To contribute bug patches or new features, you can use the github Pull Request model. It is assumed that code and documentation are contributed under the Apache License 2.0.
To contribute bug patches or new features, you can use the github Pull Request
model. It is assumed that code and documentation are contributed under
the Apache License 2.0.

More info:
* [How to Contribute](http://opennebula.org/addons/contribute/)
* Support: [OpenNebula user forum](https://forum.opennebula.org/c/support)
* Development: [OpenNebula developers forum](https://forum.opennebula.org/c/development)
* Issues Tracking: Github issues (https://github.com/OpenNebula/addon-context-linux/issues)

## Authors
### Repository structure

* Leader: Javier Fontan (jfontan@opennebula.org)
All code is located under `src/` and structure follows the installation
directory structure. Files for different environments/targets are picked
by the tag, tags are part of the filename separated from the installation
name by 2 hashes (`##`). Tags are dot-separated.

## Compatibility
Examples:

This add-on is compatible with OpenNebula >= 4.6.
* `script` - non-tagged file for all targets
* `script##systemd` - file tagged with **systemd**
* `script##systemd.rpm` - file tagged with **systemd** and **rpm**

## Requirements
### Contextualization scripts

* Ruby >= 1.8.7
* gem fpm
* dpkg utils for deb package creation
* rpm utils for rpm package creation
Contextualization scripts, which are executed on every boot and during
the reconfiguration, are located in `src/etc/one-context.d/`. Scripts are
divided into following 2 parts:

* local - pre-networking, prefixed with `loc-`
* post-networking, prefixed with `net-`

All other scripts, which are not prefixed with `loc-` or `net-`, are
executed as a first during the post-networking contextualization stage.

On Ubuntu/Debian you can install the package `rpm` and you will be able to generate both rpm and deb packages.
## Build own package

## Use
Package contains following parts:

### Package Description
* main control scripts (`/usr/sbin/one-context*`)
* contextualization scripts (`/etc/one-context.d/*`)
* init scripts to start the contextualization
* OneGate scripts (`/usr/bin/one-gate*`)
* udev rules to trigger reconfiguration on NIC hotplug

Here are located the files needed to generate OpenNebula contextualization packages. The packages generated contain these files:
Other actions include:

* `/etc/udev/rules.d/*` These files disable the udev network an cdrom
generation
* `/etc/init.d/vmcontext` This is the startup script that will try to mount
context cdrom, load contextualizaton variables,
call scripts in the contextualization scripts
directory and call init.sh if it exists in the
context cd.
* `/etc/one-context.d/*` This directory holds the scripts that will be
called by vmcontext script. They should be named
starting with a number so they are called in order.
* delete persistent cd and net rules from /etc/udev/rules.d
* delete network configuration files

By default only the network configuration context script is included in the
packages. These scripts are different for rpm and deb based distributions and
are located in `base_<deb|rpm>` directories.
### Requirements

The packages also have a post-install script that does these steps:
* Ruby >= 1.8.7
* gem fpm
* dpkg utils for deb package creation
* rpm utils for rpm package creation

* Delete persistent cd and net rules from /etc/udev/rules.d
* Links vmcontext script to /etc/rc<runlevel>.d
* Deletes network configuration files
On Ubuntu/Debian you can install the package `rpm` and you will be able
to generate both rpm and deb packages.

### Package Generation
### Steps

The script `generator.sh` generates both deb and rpm packages and can be configured to include more files in the package or change some of its parameters.
The script `generate.sh` is able to create both **deb** and **rpm** packages
and can be configured to include more files in the package or change some of
its parameters. Package type and content are configured by the env. variable
`TARGET`, the corresponding target must be defined in `target.sh`. Target
describes the package format, name, dependencies, and files. Files are
selected by the tags. Set of required tags is defined for the target
(in `targets.sh`), each file has a list of corresponding tags right in its
filename (divided by the regular name by 2 hashes `##`, dot-separated).

On start it creates a temporary directory and copies there:

* `base` directory
* `base_<deb|rpm>` directory
* All files tagged with no, some (but only from TARGET set) or all tags.
* Any file or directory from the arguments.

Then these files are included in the package.

The default parameters to create a package are as follows:

VERSION=1.0.1
MAINTAINER=OpenNebula Systems <support@opennebula.systems>
LICENSE=Apache
PACKAGE_NAME=one-context
VENDOR=OpenNebula Systems
DESCRIPTION="
This package prepares a VM image for OpenNebula:
* Disables udev net and cd persistent rules
* Deletes udev net and cd persistent rules
* Unconfigures the network
* Adds OpenNebula contextualization scripts to startup

To get support use the OpenNebula mailing list:
http://opennebula.org/community:mailinglists
"
PACKAGE_TYPE=deb
URL=http://opennebula.org

You can change any parameter setting an environment variable with the same name. For example, to generate an rpm package with a different package name:

$ PACKAGE_TYPE=rpm PACKAGE_NAME=my-context ./generate.sh

You can also include new files. This is handy to, for example, include new scripts executed to contextualize an image. For example, we can have an script that install a user ssh key. We will create the file hierarchy that will go inside the package in a directory:

$ mkdir -p ssh/etc/one-context.d
$ cp <our-ssh-script> ssh/etc/one-context.d/01-ssh-key
$ ./generate.sh ssh/etc
```
VERSION=1.0.1
RELEASE=1
MAINTAINER="OpenNebula Systems <support@opennebula.systems>"
LICENSE="Apache 2.0"
VENDOR="OpenNebula Systems"
DESCRIPTION="
This package prepares a VM image for OpenNebula:
* Disables udev net and cd persistent rules
* Deletes udev net and cd persistent rules
* Unconfigures the network
* Adds OpenNebula contextualization scripts to startup

To get support use the OpenNebula mailing list:
http://OpenNebula.org
"
URL=http://opennebula.org
```

A target contains following parameters, e.g. **el7** target:

```
NAME=one-context
RELSUFFIX=.el7
TYPE=rpm
TAGS="rpm systemd one"
DEPENDS="util-linux bind-utils cloud-utils-growpart ruby rubygem-json"
REPLACES="cloud-init"
POSTIN=postinstall.one
PREUN=preuninstall.one
```

You can change any parameter setting an environment variable with the same name.
For example, to generate an **el7 rpm** package with a different package name:

```
$ TARGET=el7 NAME=my-one-context ./generate.sh
```

You can also include new files. This is handy to include new scripts executed
to contextualize an image. For example, we can have a script that installs
a user ssh key. We will create the file hierarchy that will go inside
the package in a directory:

```
$ mkdir -p ssh/etc/one-context.d
$ cp <our-ssh-script> ssh/etc/one-context.d/loc-01-ssh-key
$ TARGET=el7 ./generate.sh ssh/etc
```

NOTE: The generator must be executed from the same directory it resides.

## Authors

* Leader: Javier Fontan (jfontan@opennebula.org)
120 changes: 0 additions & 120 deletions base/usr/sbin/one-contextd

This file was deleted.

Loading