Rebase against upstream rev 532

This commit is contained in:
Garrett Holmstrom 2012-03-05 13:32:08 -08:00
parent 0c4c3bafb5
commit 2f7ad55032
13 changed files with 40 additions and 462 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
/cloud-init-0.6.2-bzr450.tar.gz
/cloud-init-0.6.2-bzr457.tar.gz
/cloud-init-0.6.3-bzr532.tar.gz

View File

@ -1,41 +0,0 @@
Index: cloud-init-fedora/cloudinit/CloudConfig/cc_keys_to_console.py
===================================================================
--- cloud-init-fedora.orig/cloudinit/CloudConfig/cc_keys_to_console.py
+++ cloud-init-fedora/cloudinit/CloudConfig/cc_keys_to_console.py
@@ -21,7 +21,7 @@ import subprocess
frequency = per_instance
def handle(name,cfg,cloud,log,args):
- write_ssh_prog='/usr/lib/cloud-init/write-ssh-key-fingerprints'
+ write_ssh_prog='/usr/libexec/cloud-init/write-ssh-key-fingerprints'
try:
confp = open('/dev/console',"wb")
subprocess.call(write_ssh_prog,stdout=confp)
Index: cloud-init-fedora/cloudinit/CloudConfig/cc_ssh.py
===================================================================
--- cloud-init-fedora.orig/cloudinit/CloudConfig/cc_ssh.py
+++ cloud-init-fedora/cloudinit/CloudConfig/cc_ssh.py
@@ -85,7 +85,7 @@ def handle(name,cfg,cloud,log,args):
send_ssh_keys_to_console()
def send_ssh_keys_to_console():
- subprocess.call(('/usr/lib/cloud-init/write-ssh-key-fingerprints',))
+ subprocess.call(('/usr/libexec/cloud-init/write-ssh-key-fingerprints',))
def apply_credentials(keys, user, disable_root, disable_root_opts=DISABLE_ROOT_OPTS, log=global_log):
keys = set(keys)
Index: cloud-init-fedora/setup.py
===================================================================
--- cloud-init-fedora.orig/setup.py
+++ cloud-init-fedora/setup.py
@@ -40,9 +40,8 @@ setup(name='cloud-init',
data_files=[('/etc/cloud', glob('config/*.cfg')),
('/etc/cloud/cloud.cfg.d', glob('config/cloud.cfg.d/*')),
('/etc/cloud/templates', glob('templates/*')),
- ('/etc/init', glob('upstart/*.conf')),
('/usr/share/cloud-init', []),
- ('/usr/lib/cloud-init',
+ ('/usr/libexec/cloud-init',
['tools/uncloud-init', 'tools/write-ssh-key-fingerprints']),
('/usr/share/doc/cloud-init', filter(is_f,glob('doc/*'))),
('/usr/share/doc/cloud-init/examples', filter(is_f,glob('doc/examples/*'))),

View File

@ -1,82 +0,0 @@
Index: cloud-init-fedora/cloudinit/CloudConfig/cc_puppet.py
===================================================================
--- cloud-init-fedora.orig/cloudinit/CloudConfig/cc_puppet.py
+++ cloud-init-fedora/cloudinit/CloudConfig/cc_puppet.py
@@ -22,6 +22,7 @@ import subprocess
import StringIO
import ConfigParser
import cloudinit.CloudConfig as cc
+import cloudinit.util as util
def handle(name,cfg,cloud,log,args):
# If there isn't a puppet key in the configuration don't do anything
@@ -58,6 +59,7 @@ def handle(name,cfg,cloud,log,args):
ca_fh.close()
os.chown('/var/lib/puppet/ssl/certs/ca.pem',
pwd.getpwnam('puppet').pw_uid, 0)
+ util.restorecon_if_possible('/var/lib/puppet', recursive=True)
else:
#puppet_conf_fh.write("\n[%s]\n" % (cfg_name))
# If puppet.conf already has this section we don't want to write it again
@@ -81,6 +83,7 @@ def handle(name,cfg,cloud,log,args):
os.rename('/etc/puppet/puppet.conf','/etc/puppet/puppet.conf.old')
with open('/etc/puppet/puppet.conf', 'wb') as configfile:
puppet_config.write(configfile)
+ util.restorecon_if_possible('/etc/puppet/puppet.conf')
# Set puppet default file to automatically start
subprocess.check_call(['sed', '-i',
'-e', 's/^START=.*/START=yes/',
Index: cloud-init-fedora/cloudinit/CloudConfig/cc_ssh.py
===================================================================
--- cloud-init-fedora.orig/cloudinit/CloudConfig/cc_ssh.py
+++ cloud-init-fedora/cloudinit/CloudConfig/cc_ssh.py
@@ -66,6 +66,8 @@ def handle(name,cfg,cloud,log,args):
genkeys+='ssh-keygen -f /etc/ssh/ssh_host_ecdsa_key -t ecdsa -N ""; '
subprocess.call(('sh', '-c', "{ %s } </dev/null" % (genkeys)))
+ util.restorecon_if_possible('/etc/ssh', recursive=True)
+
try:
user = util.get_cfg_option_str(cfg,'user')
disable_root = util.get_cfg_option_bool(cfg, "disable_root", True)
Index: cloud-init-fedora/cloudinit/SshUtil.py
===================================================================
--- cloud-init-fedora.orig/cloudinit/SshUtil.py
+++ cloud-init-fedora/cloudinit/SshUtil.py
@@ -147,6 +147,7 @@ def setup_user_keys(keys, user, key_pref
util.write_file(authorized_keys, content, 0600)
os.chown(authorized_keys, pwent.pw_uid, pwent.pw_gid)
+ util.restorecon_if_possible(ssh_dir, recursive=True)
os.umask(saved_umask)
Index: cloud-init-fedora/cloudinit/util.py
===================================================================
--- cloud-init-fedora.orig/cloudinit/util.py
+++ cloud-init-fedora/cloudinit/util.py
@@ -28,6 +28,12 @@ import time
import traceback
import re
+try:
+ import selinux
+ HAVE_LIBSELINUX = True
+except ImportError:
+ HAVE_LIBSELINUX = False
+
def read_conf(fname):
try:
stream = open(fname,"r")
@@ -113,6 +119,11 @@ def write_file(file,content,mode=0644,om
os.chmod(file,mode)
f.write(content)
f.close()
+ restorecon_if_possible(file)
+
+def restorecon_if_possible(path, recursive=False):
+ if HAVE_LIBSELINUX and selinux.is_selinux_enabled():
+ selinux.restorecon(path, recursive=recursive)
# get keyid from keyserver
def getkeybyid(keyid,keyserver):

View File

@ -1,44 +0,0 @@
Index: cloud-init-fedora/cloudinit/CloudConfig/cc_locale.py
===================================================================
--- cloud-init-fedora.orig/cloudinit/CloudConfig/cc_locale.py
+++ cloud-init-fedora/cloudinit/CloudConfig/cc_locale.py
@@ -16,15 +16,17 @@
# 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 cloudinit.util as util
+import os.path
import subprocess
import traceback
-def apply_locale(locale):
- subprocess.Popen(['locale-gen', locale]).communicate()
- subprocess.Popen(['update-locale', locale]).communicate()
+def apply_locale(locale, cfgfile):
+ if os.path.exists('/usr/sbin/locale-gen'):
+ subprocess.Popen(['locale-gen', locale]).communicate()
+ if os.path.exists('/usr/sbin/update-locale'):
+ subprocess.Popen(['update-locale', locale]).communicate()
- util.render_to_file('default-locale', '/etc/default/locale', \
- { 'locale' : locale })
+ util.render_to_file('default-locale', cfgfile, { 'locale' : locale })
def handle(name,cfg,cloud,log,args):
if len(args) != 0:
@@ -32,12 +34,15 @@ def handle(name,cfg,cloud,log,args):
else:
locale = util.get_cfg_option_str(cfg,"locale",cloud.get_locale())
+ locale_cfgfile = util.get_cfg_option_str(cfg, "locale_configfile",
+ "/etc/default/locale")
+
if not locale: return
log.debug("setting locale to %s" % locale)
try:
- apply_locale(locale)
+ apply_locale(locale, locale_cfgfile)
except Exception as e:
log.debug(traceback.format_exc(e))
raise Exception("failed to apply locale %s" % locale)

View File

@ -1,32 +0,0 @@
Index: cloud-init-fedora/cloudinit/CloudConfig/cc_puppet.py
===================================================================
--- cloud-init-fedora.orig/cloudinit/CloudConfig/cc_puppet.py
+++ cloud-init-fedora/cloudinit/CloudConfig/cc_puppet.py
@@ -16,6 +16,7 @@
# 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
+import os.path
import pwd
import socket
import subprocess
@@ -84,10 +85,15 @@ def handle(name,cfg,cloud,log,args):
with open('/etc/puppet/puppet.conf', 'wb') as configfile:
puppet_config.write(configfile)
util.restorecon_if_possible('/etc/puppet/puppet.conf')
- # Set puppet default file to automatically start
- subprocess.check_call(['sed', '-i',
- '-e', 's/^START=.*/START=yes/',
- '/etc/default/puppet'])
+ # Set puppet to automatically start
+ if os.path.exists('/etc/default/puppet'):
+ subprocess.check_call(['sed', '-i',
+ '-e', 's/^START=.*/START=yes/',
+ '/etc/default/puppet'])
+ elif os.path.exists('/bin/systemctl'):
+ subprocess.check_call(['/bin/systemctl', 'enable', 'puppet.service'])
+ elif os.path.exists('/sbin/chkconfig'):
+ subprocess.check_call(['/sbin/chkconfig', 'puppet', 'on'])
# Start puppetd
subprocess.check_call(['service', 'puppet', 'start'])

View File

@ -1,14 +0,0 @@
Index: cloud-init-fedora/cloudinit/util.py
===================================================================
--- cloud-init-fedora.orig/cloudinit/util.py
+++ cloud-init-fedora/cloudinit/util.py
@@ -145,7 +145,8 @@ def getkeybyid(keyid,keyserver):
def runparts(dirp, skip_no_exist=True):
if skip_no_exist and not os.path.isdir(dirp): return
-
+ if os.path.isdir(dirp) and os.listdir(dirp) == []: return
+
cmd = [ 'run-parts', '--regex', '.*', dirp ]
sp = subprocess.Popen(cmd)
sp.communicate()

View File

@ -1,66 +0,0 @@
Index: cloud-init-fedora/cloudinit/CloudConfig/cc_ssh.py
===================================================================
--- cloud-init-fedora.orig/cloudinit/CloudConfig/cc_ssh.py
+++ cloud-init-fedora/cloudinit/CloudConfig/cc_ssh.py
@@ -31,7 +31,7 @@ def handle(name,cfg,cloud,log,args):
global_log = log
# remove the static keys from the pristine image
- for f in glob.glob("/etc/ssh/ssh_host_*_key*"):
+ for f in glob.glob("/etc/ssh/ssh_host_*key*"):
try: os.unlink(f)
except: pass
@@ -61,10 +61,10 @@ def handle(name,cfg,cloud,log,args):
log.debug("generated %s from %s" % pair)
else:
# if not, generate them
- genkeys ='ssh-keygen -f /etc/ssh/ssh_host_rsa_key -t rsa -N ""; '
- genkeys+='ssh-keygen -f /etc/ssh/ssh_host_dsa_key -t dsa -N ""; '
- genkeys+='ssh-keygen -f /etc/ssh/ssh_host_ecdsa_key -t ecdsa -N ""; '
- subprocess.call(('sh', '-c', "{ %s } </dev/null" % (genkeys)))
+ for keytype in util.get_cfg_option_list_or_str(cfg, 'ssh_genkeytypes',
+ ['rsa', 'dsa', 'ecdsa']):
+ subprocess.call(['ssh-keygen', '-t', keytype, '-N', '',
+ '-f', '/etc/ssh/ssh_host_%s_key' % keytype])
util.restorecon_if_possible('/etc/ssh', recursive=True)
@@ -84,11 +84,6 @@ def handle(name,cfg,cloud,log,args):
util.logexc(log)
log.warn("applying credentials failed!\n")
- send_ssh_keys_to_console()
-
-def send_ssh_keys_to_console():
- subprocess.call(('/usr/libexec/cloud-init/write-ssh-key-fingerprints',))
-
def apply_credentials(keys, user, disable_root, disable_root_opts=DISABLE_ROOT_OPTS, log=global_log):
keys = set(keys)
if user:
Index: cloud-init-fedora/cloudinit/util.py
===================================================================
--- cloud-init-fedora.orig/cloudinit/util.py
+++ cloud-init-fedora/cloudinit/util.py
@@ -84,6 +84,7 @@ def get_cfg_option_str(yobj, key, defaul
def get_cfg_option_list_or_str(yobj, key, default=None):
if not yobj.has_key(key): return default
+ if yobj[key] is None: return []
if isinstance(yobj[key],list): return yobj[key]
return([yobj[key]])
Index: cloud-init-fedora/tools/write-ssh-key-fingerprints
===================================================================
--- cloud-init-fedora.orig/tools/write-ssh-key-fingerprints
+++ cloud-init-fedora/tools/write-ssh-key-fingerprints
@@ -3,8 +3,7 @@
echo
echo "#############################################################"
echo "-----BEGIN SSH HOST KEY FINGERPRINTS-----"
-ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key.pub
-ssh-keygen -l -f /etc/ssh/ssh_host_dsa_key.pub
+echo /etc/ssh/ssh_host_*key.pub | xargs -n 1 ssh-keygen -l -f
echo "-----END SSH HOST KEY FINGERPRINTS-----"
echo "#############################################################"
} | logger -p user.info -s -t "ec2"

View File

@ -1,44 +0,0 @@
Index: cloud-init-fedora/cloudinit/CloudConfig/cc_set_passwords.py
===================================================================
--- cloud-init-fedora.orig/cloudinit/CloudConfig/cc_set_passwords.py
+++ cloud-init-fedora/cloudinit/CloudConfig/cc_set_passwords.py
@@ -104,7 +104,7 @@ def handle(name,cfg,cloud,log,args):
errors.append(e)
try:
- p = util.subp(['service', 'ssh', 'restart'])
+ p = util.subp(['service', cfg.get('ssh_svcname', 'ssh'), 'restart'])
log.debug("restarted sshd")
except:
log.warn("restart of ssh failed")
Index: cloud-init-fedora/cloudinit/CloudConfig/cc_ssh.py
===================================================================
--- cloud-init-fedora.orig/cloudinit/CloudConfig/cc_ssh.py
+++ cloud-init-fedora/cloudinit/CloudConfig/cc_ssh.py
@@ -31,9 +31,10 @@ def handle(name,cfg,cloud,log,args):
global_log = log
# remove the static keys from the pristine image
- for f in glob.glob("/etc/ssh/ssh_host_*key*"):
- try: os.unlink(f)
- except: pass
+ if cfg.get("ssh_deletekeys", True):
+ for f in glob.glob("/etc/ssh/ssh_host_*key*"):
+ try: os.unlink(f)
+ except: pass
if cfg.has_key("ssh_keys"):
# if there are keys in cloud-config, use them
@@ -63,8 +64,10 @@ def handle(name,cfg,cloud,log,args):
# if not, generate them
for keytype in util.get_cfg_option_list_or_str(cfg, 'ssh_genkeytypes',
['rsa', 'dsa', 'ecdsa']):
- subprocess.call(['ssh-keygen', '-t', keytype, '-N', '',
- '-f', '/etc/ssh/ssh_host_%s_key' % keytype])
+ keyfile = '/etc/ssh/ssh_host_%s_key' % keytype
+ if not os.path.exists(keyfile):
+ subprocess.call(['ssh-keygen', '-t', keytype, '-N', '',
+ '-f', keyfile])
util.restorecon_if_possible('/etc/ssh', recursive=True)

View File

@ -1,86 +0,0 @@
Index: cloud-init-fedora/systemd/cloud-config.service
===================================================================
--- /dev/null
+++ cloud-init-fedora/systemd/cloud-config.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Apply the settings specified in cloud-config
+After=network.target syslog.target cloud-config.target
+Requires=cloud-config.target
+Wants=network.target
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/cloud-init-cfg all config
+RemainAfterExit=yes
+
+[Install]
+WantedBy=multi-user.target
Index: cloud-init-fedora/systemd/cloud-config.target
===================================================================
--- /dev/null
+++ cloud-init-fedora/systemd/cloud-config.target
@@ -0,0 +1,10 @@
+# cloud-init normally emits a "cloud-config" upstart event to inform third
+# parties that cloud-config is available, which does us no good when we're
+# using systemd. cloud-config.target serves as this synchronization point
+# instead. Services that would "start on cloud-config" with upstart can
+# instead use "After=cloud-config.target" and "Wants=cloud-config.target"
+# as appropriate.
+
+[Unit]
+Description=Cloud-config availability
+Requires=cloud-init-local.service cloud-init.service
Index: cloud-init-fedora/systemd/cloud-final.service
===================================================================
--- /dev/null
+++ cloud-init-fedora/systemd/cloud-final.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Execute cloud user/final scripts
+After=network.target syslog.target cloud-config.service rc-local.service
+Requires=cloud-config.target
+Wants=network.target
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/cloud-init-cfg all final
+RemainAfterExit=yes
+
+[Install]
+WantedBy=multi-user.target
Index: cloud-init-fedora/systemd/cloud-init-local.service
===================================================================
--- /dev/null
+++ cloud-init-fedora/systemd/cloud-init-local.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Initial cloud-init job (pre-networking)
+Wants=local-fs.target
+After=local-fs.target
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/cloud-init start-local
+RemainAfterExit=yes
+
+[Install]
+WantedBy=multi-user.target
Index: cloud-init-fedora/systemd/cloud-init.service
===================================================================
--- /dev/null
+++ cloud-init-fedora/systemd/cloud-init.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=Initial cloud-init job (metadata service crawler)
+After=local-fs.target network.target cloud-init-local.service
+Requires=network.target
+Wants=local-fs.target cloud-init-local.service
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/cloud-init start
+RemainAfterExit=yes
+
+[Install]
+WantedBy=multi-user.target

View File

@ -1,18 +0,0 @@
Index: cloud-init-fedora/cloudinit/CloudConfig/cc_timezone.py
===================================================================
--- cloud-init-fedora.orig/cloudinit/CloudConfig/cc_timezone.py
+++ cloud-init-fedora/cloudinit/CloudConfig/cc_timezone.py
@@ -45,6 +45,13 @@ def handle(name,cfg,cloud,log,args):
except:
log.debug("failed to write to /etc/timezone")
raise
+ if os.path.exists("/etc/sysconfig/clock"):
+ try:
+ with open("/etc/sysconfig/clock", "w") as fp:
+ fp.write('ZONE="%s"\n' % timezone)
+ except:
+ log.debug("failed to write to /etc/sysconfig/clock")
+ raise
try:
shutil.copy(tz_file, "/etc/localtime")

View File

@ -0,0 +1,28 @@
=== modified file 'cloudinit/CloudConfig/cc_keys_to_console.py'
--- cloudinit/CloudConfig/cc_keys_to_console.py 2012-01-18 14:07:33 +0000
+++ cloudinit/CloudConfig/cc_keys_to_console.py 2012-03-05 21:53:13 +0000
@@ -26,7 +26,7 @@
def handle(_name, cfg, _cloud, log, _args):
- cmd = ['/usr/lib/cloud-init/write-ssh-key-fingerprints']
+ cmd = ['/usr/libexec/cloud-init/write-ssh-key-fingerprints']
fp_blacklist = util.get_cfg_option_list_or_str(cfg,
"ssh_fp_console_blacklist", [])
key_blacklist = util.get_cfg_option_list_or_str(cfg,
=== modified file 'setup.py'
--- setup.py 2011-12-20 16:39:46 +0000
+++ setup.py 2012-03-05 22:00:19 +0000
@@ -40,9 +40,8 @@
data_files=[('/etc/cloud', glob('config/*.cfg')),
('/etc/cloud/cloud.cfg.d', glob('config/cloud.cfg.d/*')),
('/etc/cloud/templates', glob('templates/*')),
- ('/etc/init', glob('upstart/*.conf')),
('/usr/share/cloud-init', []),
- ('/usr/lib/cloud-init',
+ ('/usr/libexec/cloud-init',
['tools/uncloud-init', 'tools/write-ssh-key-fingerprints']),
('/usr/share/doc/cloud-init', filter(is_f,glob('doc/*'))),
('/usr/share/doc/cloud-init/examples', filter(is_f,glob('doc/examples/*'))),

View File

@ -1,38 +1,18 @@
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
Name: cloud-init
Version: 0.6.2
Release: 0.8.bzr457%{?dist}
Version: 0.6.3
Release: 0.1.bzr532%{?dist}
Summary: Cloud instance init scripts
Group: System Environment/Base
License: GPLv3
URL: http://launchpad.net/cloud-init
# bzr export -r 457 cloud-init-0.6.2-bzr457.tar.gz lp:cloud-init
Source0: %{name}-%{version}-bzr457.tar.gz
# bzr export -r 532 cloud-init-0.6.3-bzr532.tar.gz lp:cloud-init
Source0: %{name}-%{version}-bzr532.tar.gz
Source1: cloud-init-fedora.cfg
Source2: cloud-init-README.fedora
Patch0: cloud-init-0.6.2-fedora.patch
# The current patch set is in flux as we stabilize cloud-init on Fedora.
# It will be submitted upstream as soon as it becomes reasonable to do so.
# Add systemd support (not yet upstream)
Patch2: cloud-init-0.6.2-systemd.patch
# Restore created files' selinux contexts (not yet upstream)
Patch3: cloud-init-0.6.2-filecontext.patch
# Make locale file location configurable (not yet upstream)
Patch4: cloud-init-0.6.2-localefile.patch
# Write timezone data to /etc/sysconfig/clock (not yet upstream)
Patch5: cloud-init-0.6.2-tzsysconfig.patch
# Make enabling the puppet service work on Fedora (not yet upstream)
Patch7: cloud-init-0.6.2-puppetenable.patch
# Make the types of SSH keys to generate configurable (not yet upstream)
Patch8: cloud-init-0.6.2-sshkeytypes.patch
# https://bugs.launchpad.net/cloud-init/+bug/857926
Patch10: cloud-init-0.6.2-runparts-emptydir.patch
# Deal with differences between out sshd service and Ubuntu's (not yet upstream)
Patch11: cloud-init-0.6.2-sshsvc.patch
Patch0: cloud-init-0.6.3-fedora.patch
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@ -64,16 +44,8 @@ ssh keys and to let the user run various scripts.
%prep
%setup -q -n %{name}-%{version}-bzr457
%patch0 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch7 -p1
%patch8 -p1
%patch10 -p1
%patch11 -p1
%setup -q -n %{name}-%{version}-bzr532
%patch0 -p0
cp -p %{SOURCE2} README.fedora
@ -155,6 +127,9 @@ fi
%changelog
* Mon Mar 5 2012 Garrett Holmstrom <gholms@fedoraproject.org> - 0.6.3-0.1.bzr532
- Rebased against upstream rev 532
* Thu Jan 12 2012 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.6.2-0.8.bzr457
- Rebuilt for https://fedoraproject.org/wiki/Fedora_17_Mass_Rebuild

View File

@ -1 +1,2 @@
b8c9145213f6642e23270543fba24fb9 cloud-init-0.6.2-bzr457.tar.gz
c5f118f17683c7aacd8e127e756eb070 cloud-init-0.6.3-bzr532.tar.gz