summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPedro Alvarez <pedro.alvarez@codethink.co.uk>2013-10-09 14:34:34 +0000
committerPedro Alvarez <pedro.alvarez@codethink.co.uk>2013-10-10 09:59:04 +0000
commitdd5ac6445d51f7fd09d6ca11c627c5f7de179968 (patch)
treed5b2e399c4b6bf7c2152638cfc73c7df02c78f20
parentc5fb47090baabc2f6b6cb5bf2fab7b61155a7018 (diff)
downloadcloud-init-baserock/morph-rebase-7-3v2.tar.gz
Modify cloud-init configuration.baserock/morph-rebase-7-3v2
Modify cloud.cfg to remove ubuntu specific modules. Also add a baserock configuration and a distribution file.
-rw-r--r--cloudinit/distros/baserock.py127
-rw-r--r--config/cloud.cfg65
-rw-r--r--config/cloud.cfg.d/baserock.cfg19
3 files changed, 153 insertions, 58 deletions
diff --git a/cloudinit/distros/baserock.py b/cloudinit/distros/baserock.py
new file mode 100644
index 00000000..fb9ed92b
--- /dev/null
+++ b/cloudinit/distros/baserock.py
@@ -0,0 +1,127 @@
+# 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 <scott.moser@canonical.com>
+# Author: Juerg Haefliger <juerg.haefliger@hp.com>
+# Author: Joshua Harlow <harlowja@yahoo-inc.com>
+#
+# 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 <http://www.gnu.org/licenses/>.
+
+import os
+
+from cloudinit import distros
+from cloudinit import helpers
+from cloudinit import log as logging
+from cloudinit import util
+
+from cloudinit.distros.parsers.hostname import HostnameConf
+
+from cloudinit.settings import PER_INSTANCE
+
+LOG = logging.getLogger(__name__)
+
+APT_GET_COMMAND = ('apt-get', '--option=Dpkg::Options::=--force-confold',
+ '--option=Dpkg::options::=--force-unsafe-io',
+ '--assume-yes', '--quiet')
+
+
+class Distro(distros.Distro):
+ hostname_conf_fn = "/etc/hostname"
+ network_conf_fn = "/etc/network/interfaces"
+
+ def __init__(self, name, cfg, paths):
+ distros.Distro.__init__(self, name, cfg, paths)
+ # This will be used to restrict certain
+ # calls from repeatly happening (when they
+ # should only happen say once per instance...)
+ self._runner = helpers.Runners(paths)
+ self.osfamily = 'debian'
+
+ def apply_locale(self, locale, out_fn=None):
+ pass
+
+ def install_packages(self, pkglist):
+ pass
+
+ def _write_network(self, settings):
+ util.write_file(self.network_conf_fn, settings)
+ return ['all']
+
+ def _bring_up_interfaces(self, device_names):
+ use_all = False
+ for d in device_names:
+ if d == 'all':
+ use_all = True
+ if use_all:
+ return distros.Distro._bring_up_interface(self, '--all')
+ else:
+ return distros.Distro._bring_up_interfaces(self, device_names)
+
+ def _select_hostname(self, hostname, fqdn):
+ # Prefer the short hostname over the long
+ # fully qualified domain name
+ if not hostname:
+ return fqdn
+ return hostname
+
+ def _write_hostname(self, your_hostname, out_fn):
+ conf = None
+ try:
+ # Try to update the previous one
+ # so lets see if we can read it first.
+ conf = self._read_hostname_conf(out_fn)
+ except IOError:
+ pass
+ if not conf:
+ conf = HostnameConf('')
+ conf.set_hostname(your_hostname)
+ util.write_file(out_fn, str(conf), 0644)
+
+ def _read_system_hostname(self):
+ sys_hostname = self._read_hostname(self.hostname_conf_fn)
+ return (self.hostname_conf_fn, sys_hostname)
+
+ def _read_hostname_conf(self, filename):
+ conf = HostnameConf(util.load_file(filename))
+ conf.parse()
+ return conf
+
+ def _read_hostname(self, filename, default=None):
+ hostname = None
+ try:
+ conf = self._read_hostname_conf(filename)
+ hostname = conf.hostname
+ except IOError:
+ pass
+ if not hostname:
+ return default
+ return hostname
+
+ def _get_localhost_ip(self):
+ # Note: http://www.leonardoborda.com/blog/127-0-1-1-ubuntu-debian/
+ return "127.0.1.1"
+
+ def set_timezone(self, tz):
+ pass
+
+ def package_command(self, command, args=None, pkgs=None):
+ pass
+
+ def update_package_sources(self):
+ pass
+
+ def get_primary_arch(self):
+ pass
diff --git a/config/cloud.cfg b/config/cloud.cfg
index a07cd3b0..f62e22d6 100644
--- a/config/cloud.cfg
+++ b/config/cloud.cfg
@@ -1,26 +1,3 @@
-# The top level settings are used as module
-# and system configuration.
-
-# 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: 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 modules that run in the 'init' stage
cloud_init_modules:
- migrator
@@ -34,32 +11,22 @@ cloud_init_modules:
- update_etc_hosts
- ca-certs
- rsyslog
- - users-groups
- - ssh
+# - users-groups
# The modules that run in the 'config' stage
cloud_config_modules:
# Emit the cloud config ready event
# this can be used by upstart jobs for 'start on cloud-config'.
- - emit_upstart
+ - ssh
- disk_setup
- mounts
- ssh-import-id
- - locale
- set-passwords
- - grub-dpkg
- - apt-pipelining
- - apt-configure
- - 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:
@@ -74,36 +41,18 @@ cloud_final_modules:
- final-message
- power-state-change
-# System and/or distro specific settings
-# (not accessible to handlers/transforms)
system_info:
# This will affect which distro class gets used
- distro: ubuntu
+ distro: baserock
# Default user name + that default users groups (if added/used)
default_user:
- name: ubuntu
- lock_passwd: True
- gecos: Ubuntu
- groups: [adm, audio, cdrom, dialout, dip, floppy, netdev, plugdev, sudo, video]
- sudo: ["ALL=(ALL) NOPASSWD:ALL"]
+ name: root
+ lock_passwd: false
+ gecos: Root
+ groups: [root, pulse-access]
shell: /bin/bash
# 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_mirrors:
- - arches: [i386, amd64]
- failsafe:
- primary: http://archive.ubuntu.com/ubuntu
- security: http://security.ubuntu.com/ubuntu
- search:
- primary:
- - http://%(ec2_region)s.ec2.archive.ubuntu.com/ubuntu/
- - http://%(availability_zone)s.clouds.archive.ubuntu.com/ubuntu/
- security: []
- - arches: [armhf, armel, default]
- failsafe:
- primary: http://ports.ubuntu.com/ubuntu-ports
- security: http://ports.ubuntu.com/ubuntu-ports
ssh_svcname: ssh
diff --git a/config/cloud.cfg.d/baserock.cfg b/config/cloud.cfg.d/baserock.cfg
new file mode 100644
index 00000000..d0c4b9c4
--- /dev/null
+++ b/config/cloud.cfg.d/baserock.cfg
@@ -0,0 +1,19 @@
+datasource_list: [ NoCloud, ConfigDrive, AltCloud, OVF, MAAS, Ec2, None ]
+
+output:
+ init: [ ">> /var/log/init.err", "> /var/log/init.log" ]
+ config: [ ">> /var/log/config.err", "> /var/log/config.log" ]
+ final: [ ">> /var/log/final.err", "> /var/log/final.log" ]
+
+#logging user and file
+def_log_file: /var/log/cloud-init-logging.log
+syslog_fix_perms: root:root
+
+
+# The top level settings are used as module
+# and system configuration.
+
+# 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
+