From d2d12dda2ddd576504adc32f71944eab72d6481a Mon Sep 17 00:00:00 2001 From: Harm Weites Date: Sat, 9 Aug 2014 10:27:28 +0000 Subject: new: Buildscript for installing on FreeBSD. This should do until a proper port is created. --- tools/build-on-freebsd | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100755 tools/build-on-freebsd (limited to 'tools') diff --git a/tools/build-on-freebsd b/tools/build-on-freebsd new file mode 100755 index 00000000..03cba7fc --- /dev/null +++ b/tools/build-on-freebsd @@ -0,0 +1,40 @@ +#!/bin/sh +# Since there is no official FreeBSD port yet, we need some way of building and +# installing cloud-init. This script takes care of building and installing. It +# will optionally make a first run at the end. + +# Check dependencies: +[ ! -f /tmp/c-i.dependencieschecked ] && pkg install py27-cheetah py27-Jinja2 py27-prettytable py27-oauth py27-serial py27-configobj py27-yaml py27-argparse py27-requests py27-six +touch /tmp/c-i.dependencieschecked + +# Required but unavailable port/pkg: py27-jsonpatch +# Luckily, the install step will take care of this by installing it from pypi... + +# Build the code and install in /usr/local/: +python setup.py build +python setup.py install -O1 --skip-build --prefix /usr/local/ --init-system sysvinit_freebsd + +# Move the configdir to /usr/local/ and use freebsd.cfg: +[ -d /usr/local/etc/cloud ] && rm -rf /usr/local/etc/cloud +mv /etc/cloud /usr/local/etc/ +mv /usr/local/etc/cloud/cloud.freebsd.cfg /usr/local/etc/cloud/cloud.cfg + +# Enable cloud-init in /etc/rc.conf: +sed -i.bak -e "/cloudinit_enable=.*/d" /etc/rc.conf +echo 'cloudinit_enable="YES"' >> /etc/rc.conf + +echo "Installation completed." + +if [ "$1" = "run" ] +then + echo "Ok, now let's see if it works." + + # Remove old metadata + rm -rf /var/lib/cloud + + # Just log everything, quick&dirty + rm /usr/local/etc/cloud/cloud.cfg.d/05_logging.cfg + + # Start: + /usr/local/etc/rc.d/cloudinit start +fi -- cgit v1.2.3 From aff5c13ac9e3723e99d7414ac82f30c853f453fd Mon Sep 17 00:00:00 2001 From: Harm Weites Date: Sat, 9 Aug 2014 10:56:13 +0000 Subject: fix: More dependencies. --- tools/build-on-freebsd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/build-on-freebsd b/tools/build-on-freebsd index 03cba7fc..52bceb21 100755 --- a/tools/build-on-freebsd +++ b/tools/build-on-freebsd @@ -4,7 +4,7 @@ # will optionally make a first run at the end. # Check dependencies: -[ ! -f /tmp/c-i.dependencieschecked ] && pkg install py27-cheetah py27-Jinja2 py27-prettytable py27-oauth py27-serial py27-configobj py27-yaml py27-argparse py27-requests py27-six +[ ! -f /tmp/c-i.dependencieschecked ] && pkg install py27-cheetah py27-Jinja2 py27-prettytable py27-oauth py27-serial py27-configobj py27-yaml py27-argparse py27-requests py27-six py27-boto gpart sudo touch /tmp/c-i.dependencieschecked # Required but unavailable port/pkg: py27-jsonpatch -- cgit v1.2.3 From 5d96928ee2a2573aaf49727adafc91120daa1d36 Mon Sep 17 00:00:00 2001 From: Harm Weites Date: Sat, 9 Aug 2014 10:57:28 +0000 Subject: new: Some datasources (like Smartos) use dmidecode to gather some specific information, so install it. --- tools/build-on-freebsd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/build-on-freebsd b/tools/build-on-freebsd index 52bceb21..ff59bd25 100755 --- a/tools/build-on-freebsd +++ b/tools/build-on-freebsd @@ -4,7 +4,7 @@ # will optionally make a first run at the end. # Check dependencies: -[ ! -f /tmp/c-i.dependencieschecked ] && pkg install py27-cheetah py27-Jinja2 py27-prettytable py27-oauth py27-serial py27-configobj py27-yaml py27-argparse py27-requests py27-six py27-boto gpart sudo +[ ! -f /tmp/c-i.dependencieschecked ] && pkg install py27-cheetah py27-Jinja2 py27-prettytable py27-oauth py27-serial py27-configobj py27-yaml py27-argparse py27-requests py27-six py27-boto gpart sudo dmidecode touch /tmp/c-i.dependencieschecked # Required but unavailable port/pkg: py27-jsonpatch -- cgit v1.2.3 From f1202c1b0aeae7378589215887c74f325e6c77cd Mon Sep 17 00:00:00 2001 From: Harm Weites Date: Sat, 9 Aug 2014 21:24:19 +0000 Subject: change: Create a symlink to python2.7, to make sure running plain python works. --- tools/build-on-freebsd | 3 +++ 1 file changed, 3 insertions(+) (limited to 'tools') diff --git a/tools/build-on-freebsd b/tools/build-on-freebsd index ff59bd25..0a545207 100755 --- a/tools/build-on-freebsd +++ b/tools/build-on-freebsd @@ -3,6 +3,9 @@ # installing cloud-init. This script takes care of building and installing. It # will optionally make a first run at the end. +# Since there is no python by default, create a symlink for convenience sake: +ln -sf /usr/local/bin/python2.7 /usr/local/bin/python + # Check dependencies: [ ! -f /tmp/c-i.dependencieschecked ] && pkg install py27-cheetah py27-Jinja2 py27-prettytable py27-oauth py27-serial py27-configobj py27-yaml py27-argparse py27-requests py27-six py27-boto gpart sudo dmidecode touch /tmp/c-i.dependencieschecked -- cgit v1.2.3 From 7e0407491345989a2640149a9a365b6f7167c7af Mon Sep 17 00:00:00 2001 From: Harm Weites Date: Sat, 9 Aug 2014 21:25:54 +0000 Subject: change: Make note of another python lib pypi takes care of. --- tools/build-on-freebsd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/build-on-freebsd b/tools/build-on-freebsd index 0a545207..da33e4b0 100755 --- a/tools/build-on-freebsd +++ b/tools/build-on-freebsd @@ -10,7 +10,7 @@ ln -sf /usr/local/bin/python2.7 /usr/local/bin/python [ ! -f /tmp/c-i.dependencieschecked ] && pkg install py27-cheetah py27-Jinja2 py27-prettytable py27-oauth py27-serial py27-configobj py27-yaml py27-argparse py27-requests py27-six py27-boto gpart sudo dmidecode touch /tmp/c-i.dependencieschecked -# Required but unavailable port/pkg: py27-jsonpatch +# Required but unavailable port/pkg: py27-jsonpatch py27-jsonpointer # Luckily, the install step will take care of this by installing it from pypi... # Build the code and install in /usr/local/: -- cgit v1.2.3 From 891496973520c91fd02ccfc55aa606234418accb Mon Sep 17 00:00:00 2001 From: Harm Weites Date: Sun, 10 Aug 2014 09:41:42 +0000 Subject: change: Save and restore the SSH keys between builds. --- tools/build-on-freebsd | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tools') diff --git a/tools/build-on-freebsd b/tools/build-on-freebsd index da33e4b0..7d19f44c 100755 --- a/tools/build-on-freebsd +++ b/tools/build-on-freebsd @@ -32,6 +32,9 @@ if [ "$1" = "run" ] then echo "Ok, now let's see if it works." + # Backup SSH keys + mv /etc/ssh/ssh_host_* /tmp/ + # Remove old metadata rm -rf /var/lib/cloud @@ -40,4 +43,7 @@ then # Start: /usr/local/etc/rc.d/cloudinit start + + # Restore SSH keys + mv /tmp/ssh_host_* /etc/ssh/ fi -- cgit v1.2.3 From 833ebcba6ca333183284d1f9a0fe5f53df802712 Mon Sep 17 00:00:00 2001 From: Harm Weites Date: Sun, 10 Aug 2014 11:50:19 +0000 Subject: change: Install everything in the right location on both Linux (which ofcourse already was good) and FreeBSD (which realy likes /usr/local for this). --- setup.py | 51 ++++++++++++++++++++++++++++++++++++-------------- tools/build-on-freebsd | 4 +--- 2 files changed, 38 insertions(+), 17 deletions(-) (limited to 'tools') diff --git a/setup.py b/setup.py index 7b061824..b09c0456 100755 --- a/setup.py +++ b/setup.py @@ -90,6 +90,42 @@ def read_requires(): return str(deps).splitlines() +# Install everything in the right location and take care of Linux (default) and +# FreeBSD systems. +def read_datafiles(): + sysname = os.uname()[0] + if sysname == 'FreeBSD': + return [ + ('/usr/local/etc/cloud', glob('config/*.cfg')), + ('/usr/local/etc/cloud/cloud.cfg.d', glob('config/cloud.cfg.d/*')), + ('/usr/local/etc/cloud/templates', glob('templates/*')), + ('/usr/local/share/cloud-init', []), + ('/usr/local/lib/cloud-init', + ['tools/uncloud-init', 'tools/write-ssh-key-fingerprints']), + ('/usr/local/share/doc/cloud-init', + [f for f in glob('doc/*') if is_f(f)]), + ('/usr/local/share/doc/cloud-init/examples', + [f for f in glob('doc/examples/*') if is_f(f)]), + ('/usr/local/share/doc/cloud-init/examples/seed', + [f for f in glob('doc/examples/seed/*') if is_f(f)]), + ] + else: + return [ + ('/etc/cloud', glob('config/*.cfg')), + ('/etc/cloud/cloud.cfg.d', glob('config/cloud.cfg.d/*')), + ('/etc/cloud/templates', glob('templates/*')), + ('/usr/share/cloud-init', []), + ('/usr/lib/cloud-init', + ['tools/uncloud-init', 'tools/write-ssh-key-fingerprints']), + ('/usr/share/doc/cloud-init', + [f for f in glob('doc/*') if is_f(f)]), + ('/usr/share/doc/cloud-init/examples', + [f for f in glob('doc/examples/*') if is_f(f)]), + ('/usr/share/doc/cloud-init/examples/seed', + [f for f in glob('doc/examples/seed/*') if is_f(f)]), + ] + + # TODO: Is there a better way to do this?? class InitsysInstallData(install): init_system = None @@ -138,20 +174,7 @@ setuptools.setup(name='cloud-init', 'tools/cloud-init-per', ], license='GPLv3', - data_files=[('/etc/cloud', glob('config/*.cfg')), - ('/etc/cloud/cloud.cfg.d', glob('config/cloud.cfg.d/*')), - ('/etc/cloud/templates', glob('templates/*')), - ('/usr/share/cloud-init', []), - ('/usr/lib/cloud-init', - ['tools/uncloud-init', - 'tools/write-ssh-key-fingerprints']), - ('/usr/share/doc/cloud-init', - [f for f in glob('doc/*') if is_f(f)]), - ('/usr/share/doc/cloud-init/examples', - [f for f in glob('doc/examples/*') if is_f(f)]), - ('/usr/share/doc/cloud-init/examples/seed', - [f for f in glob('doc/examples/seed/*') if is_f(f)]), - ], + data_files=read_datafiles(), install_requires=read_requires(), cmdclass={ # Use a subclass for install that handles diff --git a/tools/build-on-freebsd b/tools/build-on-freebsd index 7d19f44c..6e6ce8b6 100755 --- a/tools/build-on-freebsd +++ b/tools/build-on-freebsd @@ -17,9 +17,7 @@ touch /tmp/c-i.dependencieschecked python setup.py build python setup.py install -O1 --skip-build --prefix /usr/local/ --init-system sysvinit_freebsd -# Move the configdir to /usr/local/ and use freebsd.cfg: -[ -d /usr/local/etc/cloud ] && rm -rf /usr/local/etc/cloud -mv /etc/cloud /usr/local/etc/ +# Use the correct config file: mv /usr/local/etc/cloud/cloud.freebsd.cfg /usr/local/etc/cloud/cloud.cfg # Enable cloud-init in /etc/rc.conf: -- cgit v1.2.3 From 57b5f63467dcc74b0b39a14b5baeb1974cdc3373 Mon Sep 17 00:00:00 2001 From: Harm Weites Date: Thu, 14 Aug 2014 16:18:15 +0000 Subject: fix: Install the python package that will install the required link to the python2.7 binary. This defaults to 2.7, which is fine. --- tools/build-on-freebsd | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'tools') diff --git a/tools/build-on-freebsd b/tools/build-on-freebsd index 6e6ce8b6..6a3f38ec 100755 --- a/tools/build-on-freebsd +++ b/tools/build-on-freebsd @@ -3,11 +3,8 @@ # installing cloud-init. This script takes care of building and installing. It # will optionally make a first run at the end. -# Since there is no python by default, create a symlink for convenience sake: -ln -sf /usr/local/bin/python2.7 /usr/local/bin/python - # Check dependencies: -[ ! -f /tmp/c-i.dependencieschecked ] && pkg install py27-cheetah py27-Jinja2 py27-prettytable py27-oauth py27-serial py27-configobj py27-yaml py27-argparse py27-requests py27-six py27-boto gpart sudo dmidecode +[ ! -f /tmp/c-i.dependencieschecked ] && pkg install python py27-cheetah py27-Jinja2 py27-prettytable py27-oauth py27-serial py27-configobj py27-yaml py27-argparse py27-requests py27-six py27-boto gpart sudo dmidecode touch /tmp/c-i.dependencieschecked # Required but unavailable port/pkg: py27-jsonpatch py27-jsonpointer -- cgit v1.2.3 From 9d8628772131bbe127bfefd6337cda34025723c8 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Fri, 22 Aug 2014 16:50:47 -0400 Subject: build-on-freebsd: minor cleanups/bikeshedding --- tools/build-on-freebsd | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) (limited to 'tools') diff --git a/tools/build-on-freebsd b/tools/build-on-freebsd index 6a3f38ec..66b95d68 100755 --- a/tools/build-on-freebsd +++ b/tools/build-on-freebsd @@ -3,8 +3,22 @@ # installing cloud-init. This script takes care of building and installing. It # will optionally make a first run at the end. +fail() { echo "FAILED:" "$@" 1>&2; exit 1; } + # Check dependencies: -[ ! -f /tmp/c-i.dependencieschecked ] && pkg install python py27-cheetah py27-Jinja2 py27-prettytable py27-oauth py27-serial py27-configobj py27-yaml py27-argparse py27-requests py27-six py27-boto gpart sudo dmidecode +depscheck=/tmp/c-i.dependencieschecked +pkgs=" + dmidecode + py27-argparse + py27-boto gpart sudo + py27-configobj py27-yaml + py27-Jinja2 + py27-oauth py27-serial + py27-prettytable + py27-requests py27-six + python py27-cheetah +" +[ -f "$depschecked" ] || pkg install ${pkgs} || fail "install packages" touch /tmp/c-i.dependencieschecked # Required but unavailable port/pkg: py27-jsonpatch py27-jsonpointer @@ -23,8 +37,7 @@ echo 'cloudinit_enable="YES"' >> /etc/rc.conf echo "Installation completed." -if [ "$1" = "run" ] -then +if [ "$1" = "run" ]; then echo "Ok, now let's see if it works." # Backup SSH keys -- cgit v1.2.3 From c728de2115aacbe0f48d65661c076caace5e16e7 Mon Sep 17 00:00:00 2001 From: Harm Weites Date: Sat, 23 Aug 2014 12:06:51 +0000 Subject: fix: Use the correct variable. --- tools/build-on-freebsd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/build-on-freebsd b/tools/build-on-freebsd index 66b95d68..b0203cb8 100755 --- a/tools/build-on-freebsd +++ b/tools/build-on-freebsd @@ -6,7 +6,7 @@ fail() { echo "FAILED:" "$@" 1>&2; exit 1; } # Check dependencies: -depscheck=/tmp/c-i.dependencieschecked +depschecked=/tmp/c-i.dependencieschecked pkgs=" dmidecode py27-argparse @@ -19,7 +19,7 @@ pkgs=" python py27-cheetah " [ -f "$depschecked" ] || pkg install ${pkgs} || fail "install packages" -touch /tmp/c-i.dependencieschecked +touch $depschecked # Required but unavailable port/pkg: py27-jsonpatch py27-jsonpointer # Luckily, the install step will take care of this by installing it from pypi... -- cgit v1.2.3 From 9fcb3f2c7c129576f9a2175614bcb384d492f63e Mon Sep 17 00:00:00 2001 From: Harm Weites Date: Sat, 23 Aug 2014 12:16:03 +0000 Subject: change: Rename the config file to cloud.cfg-freebsd so it doesn't get copied per default. Packaging will take care of installing this configfile on the BSD platform. --- config/cloud.cfg-freebsd | 88 ++++++++++++++++++++++++++++++++++++++++++++++++ config/cloud.freebsd.cfg | 88 ------------------------------------------------ tools/build-on-freebsd | 4 +-- 3 files changed, 90 insertions(+), 90 deletions(-) create mode 100644 config/cloud.cfg-freebsd delete mode 100644 config/cloud.freebsd.cfg (limited to 'tools') diff --git a/config/cloud.cfg-freebsd b/config/cloud.cfg-freebsd new file mode 100644 index 00000000..bb3a4a51 --- /dev/null +++ b/config/cloud.cfg-freebsd @@ -0,0 +1,88 @@ +# The top level settings are used as module +# and system configuration. + +syslog_fix_perms: root:wheel + +# This should not be required, but leave it in place until the real cause of +# not beeing able to find -any- datasources is resolved. +datasource_list: ['OpenStack'] + +# A set of users which may be applied and/or used by various modules +# when a 'default' entry is found it will reference the 'default_user' +# from the distro configuration specified below +users: + - default + +# If this is set, 'root' will not be able to ssh in and they +# will get a message to login instead as the above $user (ubuntu) +disable_root: false + +# This will cause the set+update hostname module to not operate (if true) +preserve_hostname: false + +# Example datasource config +# datasource: +# Ec2: +# metadata_urls: [ 'blah.com' ] +# timeout: 5 # (defaults to 50 seconds) +# max_wait: 10 # (defaults to 120 seconds) + +# The modules that run in the 'init' stage +cloud_init_modules: +# - migrator + - seed_random + - bootcmd +# - write-files + - growpart + - resizefs + - set_hostname + - update_hostname +# - update_etc_hosts +# - ca-certs +# - rsyslog + - users-groups + - ssh + +# The modules that run in the 'config' stage +cloud_config_modules: +# - disk_setup +# - mounts + - ssh-import-id + - locale +# - set-passwords +# - package-update-upgrade-install +# - landscape +# - timezone +# - puppet +# - chef +# - salt-minion +# - mcollective + - disable-ec2-metadata + - runcmd +# - byobu + +# The modules that run in the 'final' stage +cloud_final_modules: + - rightscale_userdata + - scripts-vendor + - scripts-per-once + - scripts-per-boot + - scripts-per-instance + - scripts-user + - ssh-authkey-fingerprints + - keys-to-console + - phone-home + - final-message + - power-state-change + +# System and/or distro specific settings +# (not accessible to handlers/transforms) +system_info: + distro: freebsd + default_user: + name: beastie + lock_passwd: True + gecos: FreeBSD + groups: [wheel] + sudo: ["ALL=(ALL) NOPASSWD:ALL"] + shell: /bin/sh diff --git a/config/cloud.freebsd.cfg b/config/cloud.freebsd.cfg deleted file mode 100644 index bb3a4a51..00000000 --- a/config/cloud.freebsd.cfg +++ /dev/null @@ -1,88 +0,0 @@ -# The top level settings are used as module -# and system configuration. - -syslog_fix_perms: root:wheel - -# This should not be required, but leave it in place until the real cause of -# not beeing able to find -any- datasources is resolved. -datasource_list: ['OpenStack'] - -# A set of users which may be applied and/or used by various modules -# when a 'default' entry is found it will reference the 'default_user' -# from the distro configuration specified below -users: - - default - -# If this is set, 'root' will not be able to ssh in and they -# will get a message to login instead as the above $user (ubuntu) -disable_root: false - -# This will cause the set+update hostname module to not operate (if true) -preserve_hostname: false - -# Example datasource config -# datasource: -# Ec2: -# metadata_urls: [ 'blah.com' ] -# timeout: 5 # (defaults to 50 seconds) -# max_wait: 10 # (defaults to 120 seconds) - -# The modules that run in the 'init' stage -cloud_init_modules: -# - migrator - - seed_random - - bootcmd -# - write-files - - growpart - - resizefs - - set_hostname - - update_hostname -# - update_etc_hosts -# - ca-certs -# - rsyslog - - users-groups - - ssh - -# The modules that run in the 'config' stage -cloud_config_modules: -# - disk_setup -# - mounts - - ssh-import-id - - locale -# - set-passwords -# - package-update-upgrade-install -# - landscape -# - timezone -# - puppet -# - chef -# - salt-minion -# - mcollective - - disable-ec2-metadata - - runcmd -# - byobu - -# The modules that run in the 'final' stage -cloud_final_modules: - - rightscale_userdata - - scripts-vendor - - scripts-per-once - - scripts-per-boot - - scripts-per-instance - - scripts-user - - ssh-authkey-fingerprints - - keys-to-console - - phone-home - - final-message - - power-state-change - -# System and/or distro specific settings -# (not accessible to handlers/transforms) -system_info: - distro: freebsd - default_user: - name: beastie - lock_passwd: True - gecos: FreeBSD - groups: [wheel] - sudo: ["ALL=(ALL) NOPASSWD:ALL"] - shell: /bin/sh diff --git a/tools/build-on-freebsd b/tools/build-on-freebsd index b0203cb8..23bdf487 100755 --- a/tools/build-on-freebsd +++ b/tools/build-on-freebsd @@ -28,8 +28,8 @@ touch $depschecked python setup.py build python setup.py install -O1 --skip-build --prefix /usr/local/ --init-system sysvinit_freebsd -# Use the correct config file: -mv /usr/local/etc/cloud/cloud.freebsd.cfg /usr/local/etc/cloud/cloud.cfg +# Install the correct config file: +cp config/cloud.cfg-freebsd /usr/local/etc/cloud/cloud.cfg # Enable cloud-init in /etc/rc.conf: sed -i.bak -e "/cloudinit_enable=.*/d" /etc/rc.conf -- cgit v1.2.3