summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
authorBen Howard <ben.howard@canonical.com>2014-02-13 16:42:02 -0700
committerBen Howard <ben.howard@canonical.com>2014-02-13 16:42:02 -0700
commit507aeed12312af7fc8a9fcfca6b845183a5a3c51 (patch)
treedbbfe55a50f1406e5e073c40972867020b92c905 /cloudinit
parent5d2a31bd66fc5fc10901e30a2b9c79c7f4d1a172 (diff)
downloadvyos-cloud-init-507aeed12312af7fc8a9fcfca6b845183a5a3c51.tar.gz
vyos-cloud-init-507aeed12312af7fc8a9fcfca6b845183a5a3c51.zip
Define default vendordata for SmartOS. In absence of a vendordata, use a
default #cloud-config that writes per-boot script that fetches subsequent sdc:operator-scripts and executes it.
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/sources/DataSourceSmartOS.py33
1 files changed, 33 insertions, 0 deletions
diff --git a/cloudinit/sources/DataSourceSmartOS.py b/cloudinit/sources/DataSourceSmartOS.py
index 140c7814..8db652ef 100644
--- a/cloudinit/sources/DataSourceSmartOS.py
+++ b/cloudinit/sources/DataSourceSmartOS.py
@@ -95,6 +95,34 @@ BUILTIN_CLOUD_CONFIG = {
'device': 'ephemeral0'}],
}
+BUILTIN_VENDOR_DATA = """
+#cloud-config:
+write_files:
+ - encoding: b64
+ owner: root:root
+ path: %(script_d)s/01_sdc-operator-script.sh
+ permissions: '0755'
+ content: |
+ """ + base64.b64encode("""#!/bin/sh
+# This file is written as part of the default vendor data for
+# SmartOS. This script looks for the SmartDC operator script
+# and then executes it. It will be run each boot.
+#
+# This requires the Joyent Metadata client to be installed.
+# On Ubuntu, it is provided via the joyent-mdata-client package
+# Or you can get it via https://github.com/joyent/mdata-client
+
+my_path=$(dirname $0)
+[ -x /usr/sbin/mdata-get ] || exit 1
+
+/usr/sbin/mdata-get sdc:operator-script > \
+ $my_path/operator-script || exit 0
+
+[ -e $my_path/operator-script ] || exit 0
+chmod 0700 $my_path/operator-script
+exec /run/sdc/operator-script
+""")
+
# @datadictionary: this is legacy path for placing files from metadata
# per the SmartOS location. It is not preferable, but is done for
# legacy reasons
@@ -186,6 +214,11 @@ class DataSourceSmartOS(sources.DataSource):
if md['user-data']:
ud = md['user-data']
+ if not md['vendordata']:
+ md['vendordata'] = BUILTIN_VENDOR_DATA % {
+ 'script_d': self.user_script_d
+ }
+
self.metadata = util.mergemanydict([md, self.metadata])
self.userdata_raw = ud
self.vendordata_raw = md['vendordata']