From ac1ccf5183fa7412247d3161e99da93c32f56ff2 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Sat, 9 Jun 2012 12:38:32 -0700 Subject: Start adding a system section. --- config/cloud.cfg | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'config') diff --git a/config/cloud.cfg b/config/cloud.cfg index 3688f88d..33feec48 100644 --- a/config/cloud.cfg +++ b/config/cloud.cfg @@ -1,7 +1,6 @@ user: ubuntu disable_root: 1 preserve_hostname: False -# datasource_list: ["NoCloud", "ConfigDrive", "OVF", "MAAS", "Ec2", "CloudStack"] cloud_init_modules: - bootcmd @@ -40,3 +39,10 @@ cloud_final_modules: - keys-to-console - phone-home - final-message + +system_info: + paths: + cloud_dir: /var/lib/cloud/ + templates_dir: /etc/cloud/templates/ + upstart_dir: /etc/init/ + distro: ubuntu -- cgit v1.2.3 From d732453a809811e2ea37cd60025ffcfc132329de Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Fri, 15 Jun 2012 17:44:53 -0700 Subject: Continued adding more comments about what each section/option does. Continued adding more system info sections as needed for various components. Enabled the welcome transform. --- config/cloud.cfg | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) (limited to 'config') diff --git a/config/cloud.cfg b/config/cloud.cfg index 33feec48..f1c43f2f 100644 --- a/config/cloud.cfg +++ b/config/cloud.cfg @@ -1,8 +1,26 @@ +# The top level settings are used as transforms +# and system configuration. + +# This user will have its passwd adjusted user: ubuntu -disable_root: 1 -preserve_hostname: False +# 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 +disable_root: true + +# 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 transform modules that run in the 'init' stage cloud_init_modules: + - welcome - bootcmd - resizefs - set_hostname @@ -12,6 +30,7 @@ cloud_init_modules: - rsyslog - ssh + # The transform modules that run in the 'config' stage cloud_config_modules: - mounts - ssh-import-id @@ -30,6 +49,7 @@ cloud_config_modules: - runcmd - byobu +# The transform modules that run in the 'final' stage cloud_final_modules: - rightscale_userdata - scripts-per-once @@ -40,9 +60,15 @@ cloud_final_modules: - phone-home - final-message +# System and/or distro specific settings system_info: - paths: - cloud_dir: /var/lib/cloud/ - templates_dir: /etc/cloud/templates/ - upstart_dir: /etc/init/ + # This will affect which distro class gets used distro: ubuntu + # Other config here will be given to the distro class and/or path classes + paths: + cloud_dir: "/var/lib/cloud/" + templates_dir: "/etc/cloud/templates/" + upstart_dir: "/etc/init/" + package_mirror: "http://archive.ubuntu.com/ubuntu" + availability_zone_template: "http://%(zone)s.ec2.archive.ubuntu.com/ubuntu/" + ssh_svcname: ssh -- cgit v1.2.3 From af2bf6577dc17ff85c38f76fddf6f6c7fbad992b Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Sat, 16 Jun 2012 20:03:38 -0700 Subject: Match the transform named final_msg by adding a _msg to the transform name. --- cloudinit/transforms/welcome.py | 64 ------------------------------------- cloudinit/transforms/welcome_msg.py | 64 +++++++++++++++++++++++++++++++++++++ config/cloud.cfg | 2 +- 3 files changed, 65 insertions(+), 65 deletions(-) delete mode 100644 cloudinit/transforms/welcome.py create mode 100644 cloudinit/transforms/welcome_msg.py (limited to 'config') diff --git a/cloudinit/transforms/welcome.py b/cloudinit/transforms/welcome.py deleted file mode 100644 index 04691d21..00000000 --- a/cloudinit/transforms/welcome.py +++ /dev/null @@ -1,64 +0,0 @@ -# vi: ts=4 expandtab -# -# Copyright (C) 2012 Canonical Ltd. -# Copyright (C) 2012 Hewlett-Packard Development Company, L.P. -# Copyright (C) 2012 Yahoo! Inc. -# -# Author: Scott Moser -# Author: Juerg Haefliger -# Author: Joshua Harlow -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 3, as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -from cloudinit.settings import PER_ALWAYS - -from cloudinit import templater -from cloudinit import util -from cloudinit import version - -import sys - -welcome_message_def = ("Cloud-init v. {{version}} starting stage {{stage}} at " - "{{timestamp}}. Up {{uptime}} seconds.") - - -frequency = PER_ALWAYS - - -def handle(_name, cfg, cloud, log, args): - - welcome_msg = util.get_cfg_option_str(cfg, "welcome_msg") - if not welcome_msg: - tpl_fn = cloud.get_template_filename("welcome_msg") - if tpl_fn: - welcome_msg = util.load_file(tpl_fn) - - if not welcome_msg: - welcome_msg = welcome_message_def - - stage = "??" - if args: - stage = args[0] - - tpl_params = { - 'stage': stage, - 'version': version.version_string(), - 'uptime': util.uptime(), - 'timestamp': util.time_rfc2822(), - } - try: - contents = templater.render_string(welcome_msg, tpl_params) - # TODO use log or sys.stderr?? - sys.stderr.write("%s\n" % (contents)) - except: - util.logexc(log, "Failed to render welcome message template") diff --git a/cloudinit/transforms/welcome_msg.py b/cloudinit/transforms/welcome_msg.py new file mode 100644 index 00000000..04691d21 --- /dev/null +++ b/cloudinit/transforms/welcome_msg.py @@ -0,0 +1,64 @@ +# vi: ts=4 expandtab +# +# Copyright (C) 2012 Canonical Ltd. +# Copyright (C) 2012 Hewlett-Packard Development Company, L.P. +# Copyright (C) 2012 Yahoo! Inc. +# +# Author: Scott Moser +# Author: Juerg Haefliger +# Author: Joshua Harlow +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 3, as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +from cloudinit.settings import PER_ALWAYS + +from cloudinit import templater +from cloudinit import util +from cloudinit import version + +import sys + +welcome_message_def = ("Cloud-init v. {{version}} starting stage {{stage}} at " + "{{timestamp}}. Up {{uptime}} seconds.") + + +frequency = PER_ALWAYS + + +def handle(_name, cfg, cloud, log, args): + + welcome_msg = util.get_cfg_option_str(cfg, "welcome_msg") + if not welcome_msg: + tpl_fn = cloud.get_template_filename("welcome_msg") + if tpl_fn: + welcome_msg = util.load_file(tpl_fn) + + if not welcome_msg: + welcome_msg = welcome_message_def + + stage = "??" + if args: + stage = args[0] + + tpl_params = { + 'stage': stage, + 'version': version.version_string(), + 'uptime': util.uptime(), + 'timestamp': util.time_rfc2822(), + } + try: + contents = templater.render_string(welcome_msg, tpl_params) + # TODO use log or sys.stderr?? + sys.stderr.write("%s\n" % (contents)) + except: + util.logexc(log, "Failed to render welcome message template") diff --git a/config/cloud.cfg b/config/cloud.cfg index f1c43f2f..147e0500 100644 --- a/config/cloud.cfg +++ b/config/cloud.cfg @@ -20,7 +20,7 @@ preserve_hostname: false # The transform modules that run in the 'init' stage cloud_init_modules: - - welcome + - welcome_msg - bootcmd - resizefs - set_hostname -- cgit v1.2.3 From a2e75f6d01688026b7ccfe5d71a11fff6205a287 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Sat, 16 Jun 2012 20:44:58 -0700 Subject: 1. Fix the welcome_msg name to welcome_message (oops) 2. Adjust that name in the cloud.cfg 3. Add in the ability to specify a dictionary that is the transform instead of a list which makes the config look nicer when users have custom transforms with arguments and such. --- cloudinit/stages.py | 12 +++++++ cloudinit/transforms/welcome_message.py | 64 +++++++++++++++++++++++++++++++++ cloudinit/transforms/welcome_msg.py | 64 --------------------------------- config/cloud.cfg | 12 ++++--- 4 files changed, 84 insertions(+), 68 deletions(-) create mode 100644 cloudinit/transforms/welcome_message.py delete mode 100644 cloudinit/transforms/welcome_msg.py (limited to 'config') diff --git a/cloudinit/stages.py b/cloudinit/stages.py index 70f2bcc9..ba6cb915 100644 --- a/cloudinit/stages.py +++ b/cloudinit/stages.py @@ -431,6 +431,18 @@ class Transforms(object): contents['args'] = item[2:] if contents: module_list.append(contents) + elif isinstance(item, (dict)): + contents = {} + valid = False + if 'name' in item: + contents['mod'] = item['name'].strip() + valid = True + if 'frequency' in item: + contents['freq'] = item['frequency'].strip() + if 'args' in item: + contents['args'] = item['args'] or [] + if contents and valid: + module_list.append(contents) else: raise TypeError(("Failed to read '%s' item in config," " unknown type %s") % diff --git a/cloudinit/transforms/welcome_message.py b/cloudinit/transforms/welcome_message.py new file mode 100644 index 00000000..04691d21 --- /dev/null +++ b/cloudinit/transforms/welcome_message.py @@ -0,0 +1,64 @@ +# vi: ts=4 expandtab +# +# Copyright (C) 2012 Canonical Ltd. +# Copyright (C) 2012 Hewlett-Packard Development Company, L.P. +# Copyright (C) 2012 Yahoo! Inc. +# +# Author: Scott Moser +# Author: Juerg Haefliger +# Author: Joshua Harlow +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License version 3, as +# published by the Free Software Foundation. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +from cloudinit.settings import PER_ALWAYS + +from cloudinit import templater +from cloudinit import util +from cloudinit import version + +import sys + +welcome_message_def = ("Cloud-init v. {{version}} starting stage {{stage}} at " + "{{timestamp}}. Up {{uptime}} seconds.") + + +frequency = PER_ALWAYS + + +def handle(_name, cfg, cloud, log, args): + + welcome_msg = util.get_cfg_option_str(cfg, "welcome_msg") + if not welcome_msg: + tpl_fn = cloud.get_template_filename("welcome_msg") + if tpl_fn: + welcome_msg = util.load_file(tpl_fn) + + if not welcome_msg: + welcome_msg = welcome_message_def + + stage = "??" + if args: + stage = args[0] + + tpl_params = { + 'stage': stage, + 'version': version.version_string(), + 'uptime': util.uptime(), + 'timestamp': util.time_rfc2822(), + } + try: + contents = templater.render_string(welcome_msg, tpl_params) + # TODO use log or sys.stderr?? + sys.stderr.write("%s\n" % (contents)) + except: + util.logexc(log, "Failed to render welcome message template") diff --git a/cloudinit/transforms/welcome_msg.py b/cloudinit/transforms/welcome_msg.py deleted file mode 100644 index 04691d21..00000000 --- a/cloudinit/transforms/welcome_msg.py +++ /dev/null @@ -1,64 +0,0 @@ -# vi: ts=4 expandtab -# -# Copyright (C) 2012 Canonical Ltd. -# Copyright (C) 2012 Hewlett-Packard Development Company, L.P. -# Copyright (C) 2012 Yahoo! Inc. -# -# Author: Scott Moser -# Author: Juerg Haefliger -# Author: Joshua Harlow -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License version 3, as -# published by the Free Software Foundation. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -from cloudinit.settings import PER_ALWAYS - -from cloudinit import templater -from cloudinit import util -from cloudinit import version - -import sys - -welcome_message_def = ("Cloud-init v. {{version}} starting stage {{stage}} at " - "{{timestamp}}. Up {{uptime}} seconds.") - - -frequency = PER_ALWAYS - - -def handle(_name, cfg, cloud, log, args): - - welcome_msg = util.get_cfg_option_str(cfg, "welcome_msg") - if not welcome_msg: - tpl_fn = cloud.get_template_filename("welcome_msg") - if tpl_fn: - welcome_msg = util.load_file(tpl_fn) - - if not welcome_msg: - welcome_msg = welcome_message_def - - stage = "??" - if args: - stage = args[0] - - tpl_params = { - 'stage': stage, - 'version': version.version_string(), - 'uptime': util.uptime(), - 'timestamp': util.time_rfc2822(), - } - try: - contents = templater.render_string(welcome_msg, tpl_params) - # TODO use log or sys.stderr?? - sys.stderr.write("%s\n" % (contents)) - except: - util.logexc(log, "Failed to render welcome message template") diff --git a/config/cloud.cfg b/config/cloud.cfg index 147e0500..0e431962 100644 --- a/config/cloud.cfg +++ b/config/cloud.cfg @@ -18,9 +18,13 @@ preserve_hostname: false # timeout: 5 # (defaults to 50 seconds) # max_wait: 10 # (defaults to 120 seconds) -# The transform modules that run in the 'init' stage +# The transform that run in the 'init' stage cloud_init_modules: - - welcome_msg +# This is the hash way of specifying a transform + - name: welcome_message +# This argument list will get passed to the transform when activated + args: + - init - bootcmd - resizefs - set_hostname @@ -30,7 +34,7 @@ cloud_init_modules: - rsyslog - ssh - # The transform modules that run in the 'config' stage + # The transforms that run in the 'config' stage cloud_config_modules: - mounts - ssh-import-id @@ -49,7 +53,7 @@ cloud_config_modules: - runcmd - byobu -# The transform modules that run in the 'final' stage +# The transforms that run in the 'final' stage cloud_final_modules: - rightscale_userdata - scripts-per-once -- cgit v1.2.3 From 860155034677c0d2b51c903b6affd6f7174afee6 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Sat, 16 Jun 2012 20:48:30 -0700 Subject: Consistently use dashes instead of underscores for the transform names --- config/cloud.cfg | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'config') diff --git a/config/cloud.cfg b/config/cloud.cfg index 0e431962..7a6bf243 100644 --- a/config/cloud.cfg +++ b/config/cloud.cfg @@ -21,15 +21,15 @@ preserve_hostname: false # The transform that run in the 'init' stage cloud_init_modules: # This is the hash way of specifying a transform - - name: welcome_message + - name: welcome-message # This argument list will get passed to the transform when activated args: - init - bootcmd - resizefs - - set_hostname - - update_hostname - - update_etc_hosts + - set-hostname + - update-hostname + - update-etc-hosts - ca-certs - rsyslog - ssh @@ -55,7 +55,7 @@ cloud_config_modules: # The transforms that run in the 'final' stage cloud_final_modules: - - rightscale_userdata + - rightscale-userdata - scripts-per-once - scripts-per-boot - scripts-per-instance -- cgit v1.2.3 From 103e5fe784007a2ee3855031fd55d2470fa0d19c Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Mon, 18 Jun 2012 17:30:21 -0700 Subject: Add comments as to what the special reference sections mean in log_cfgs --- config/cloud.cfg.d/05_logging.cfg | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'config') diff --git a/config/cloud.cfg.d/05_logging.cfg b/config/cloud.cfg.d/05_logging.cfg index 2e7ac2ed..410a0650 100644 --- a/config/cloud.cfg.d/05_logging.cfg +++ b/config/cloud.cfg.d/05_logging.cfg @@ -1,4 +1,4 @@ -## this yaml formated config file handles setting +## This yaml formated config file handles setting ## logger information. The values that are necessary to be set ## are seen at the bottom. The top '_log' are only used to remove ## redundency in a syslog and fallback-to-file case. @@ -53,5 +53,9 @@ _log: args=("/dev/log", handlers.SysLogHandler.LOG_USER) log_cfgs: +# These will be joined into a string that defines the configuration - [ *log_base, *log_syslog ] +# These will be joined into a string that defines the configuration - [ *log_base, *log_file ] +# A file path can also be used +# - /etc/log.conf -- cgit v1.2.3 From 5917096c8c686b10cf24a0b4c63eb075726f87df Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Mon, 18 Jun 2012 21:05:57 -0700 Subject: 1. Removed the welcome message for now :-) --- config/cloud.cfg | 6 ++---- templates/welcome_msg.tmpl | 15 --------------- 2 files changed, 2 insertions(+), 19 deletions(-) delete mode 100644 templates/welcome_msg.tmpl (limited to 'config') diff --git a/config/cloud.cfg b/config/cloud.cfg index 7a6bf243..b11b5aa5 100644 --- a/config/cloud.cfg +++ b/config/cloud.cfg @@ -21,10 +21,8 @@ preserve_hostname: false # The transform that run in the 'init' stage cloud_init_modules: # This is the hash way of specifying a transform - - name: welcome-message -# This argument list will get passed to the transform when activated - args: - - init + - name: bootcmd +# This is the string way of specifying a transform - bootcmd - resizefs - set-hostname diff --git a/templates/welcome_msg.tmpl b/templates/welcome_msg.tmpl deleted file mode 100644 index 999202cc..00000000 --- a/templates/welcome_msg.tmpl +++ /dev/null @@ -1,15 +0,0 @@ - _ - _( )_ - ( ) - (_______) - _ \ \ \ \ - _( )_ _ - ( ) _( )_ -(_______) ( ) - \ \ \ \ (_______) - \ \ \ \ - -Cloud-init v. {{version}} -Starting stage: {{stage}} on {{timestamp}} -System uptime: {{uptime}} seconds --- -- cgit v1.2.3 From d464a95b93a3956ba09edba91d651c9493bd66ca Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Wed, 20 Jun 2012 16:33:21 -0700 Subject: Move back to the old dashs mixed with underscores for now until checking/migrating and then using canonicalized name is done. --- config/cloud.cfg | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'config') diff --git a/config/cloud.cfg b/config/cloud.cfg index b11b5aa5..a87b613d 100644 --- a/config/cloud.cfg +++ b/config/cloud.cfg @@ -1,11 +1,11 @@ # The top level settings are used as transforms # and system configuration. -# This user will have its passwd adjusted +# This user will have its password adjusted user: ubuntu # 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 +# will get a message to login instead as the above $user (ubuntu) disable_root: true # This will cause the set+update hostname module to not operate (if true) @@ -18,21 +18,18 @@ preserve_hostname: false # timeout: 5 # (defaults to 50 seconds) # max_wait: 10 # (defaults to 120 seconds) -# The transform that run in the 'init' stage +# The modules that run in the 'init' stage cloud_init_modules: -# This is the hash way of specifying a transform - - name: bootcmd -# This is the string way of specifying a transform - bootcmd - resizefs - - set-hostname - - update-hostname - - update-etc-hosts + - set_hostname + - update_hostname + - update_etc_hosts - ca-certs - rsyslog - ssh - # The transforms that run in the 'config' stage +# The modules that run in the 'config' stage cloud_config_modules: - mounts - ssh-import-id @@ -51,9 +48,9 @@ cloud_config_modules: - runcmd - byobu -# The transforms that run in the 'final' stage +# The modules that run in the 'final' stage cloud_final_modules: - - rightscale-userdata + - rightscale_userdata - scripts-per-once - scripts-per-boot - scripts-per-instance -- cgit v1.2.3 From 1a0da144ef9afbc36a04cda9f17308b7eb4bcaf7 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Thu, 21 Jun 2012 19:48:06 -0700 Subject: Comment cleanups and remove unneeded quotes. --- config/cloud.cfg | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'config') diff --git a/config/cloud.cfg b/config/cloud.cfg index a87b613d..5dae4047 100644 --- a/config/cloud.cfg +++ b/config/cloud.cfg @@ -1,4 +1,4 @@ -# The top level settings are used as transforms +# The top level settings are used as module # and system configuration. # This user will have its password adjusted @@ -60,14 +60,15 @@ cloud_final_modules: - final-message # System and/or distro specific settings +# (not accessible to handlers/transforms) system_info: # This will affect which distro class gets used distro: ubuntu # Other config here will be given to the distro class and/or path classes paths: - cloud_dir: "/var/lib/cloud/" - templates_dir: "/etc/cloud/templates/" - upstart_dir: "/etc/init/" - package_mirror: "http://archive.ubuntu.com/ubuntu" - availability_zone_template: "http://%(zone)s.ec2.archive.ubuntu.com/ubuntu/" + cloud_dir: /var/lib/cloud/ + templates_dir: /etc/cloud/templates/ + upstart_dir: /etc/init/ + package_mirror: http://archive.ubuntu.com/ubuntu + availability_zone_template: http://%(zone)s.ec2.archive.ubuntu.com/ubuntu/ ssh_svcname: ssh -- cgit v1.2.3