summaryrefslogtreecommitdiff
path: root/cloudinit/config/cc_mounts.py
diff options
context:
space:
mode:
authorScott Moser <smoser@brickies.net>2016-11-04 13:46:09 -0400
committerScott Moser <smoser@brickies.net>2016-11-04 13:46:09 -0400
commitb380e16183446f2e39f47a3c0804d2081714acb2 (patch)
treea5e05b4a22553769d6eaa7e5fa93e3401a758b2b /cloudinit/config/cc_mounts.py
parent882b22e024733e17757fdbe36ba2a3672c6ebe06 (diff)
parenta1cdebdea65ccd827060c823146992bba9debe19 (diff)
downloadvyos-cloud-init-b380e16183446f2e39f47a3c0804d2081714acb2.tar.gz
vyos-cloud-init-b380e16183446f2e39f47a3c0804d2081714acb2.zip
merge from master at 0.7.8-34-ga1cdebd
Diffstat (limited to 'cloudinit/config/cc_mounts.py')
-rw-r--r--cloudinit/config/cc_mounts.py52
1 files changed, 50 insertions, 2 deletions
diff --git a/cloudinit/config/cc_mounts.py b/cloudinit/config/cc_mounts.py
index 2b981935..dfc4b598 100644
--- a/cloudinit/config/cc_mounts.py
+++ b/cloudinit/config/cc_mounts.py
@@ -18,6 +18,54 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
+"""
+Mounts
+------
+**Summary:** configure mount points and swap files
+
+This module can add or remove mountpoints from ``/etc/fstab`` as well as
+configure swap. The ``mounts`` config key takes a list of fstab entries to add.
+Each entry is specified as a list of ``[ fs_spec, fs_file, fs_vfstype,
+fs_mntops, fs-freq, fs_passno ]``. For more information on these options,
+consult the manual for ``/etc/fstab``. When specifying the ``fs_spec``, if the
+device name starts with one of ``xvd``, ``sd``, ``hd``, or ``vd``, the leading
+``/dev`` may be omitted.
+
+In order to remove a previously listed mount, an entry can be added to the
+mounts list containing ``fs_spec`` for the device to be removed but no
+mountpoint (i.e. ``[ sda1 ]`` or ``[ sda1, null ]``).
+
+The ``mount_default_fields`` config key allows default options to be specified
+for the values in a ``mounts`` entry that are not specified, aside from the
+``fs_spec`` and the ``fs_file``. If specified, this must be a list containing 7
+values. It defaults to::
+
+ mount_default_fields: [none, none, "auto", "defaults,nobootwait", "0", "2"]
+
+Swap files can be configured by setting the path to the swap file to create
+with ``filename``, the size of the swap file with ``size`` maximum size of
+the swap file if using an ``size: auto`` with ``maxsize``. By default no
+swap file is created.
+
+**Internal name:** ``cc_mounts``
+
+**Module frequency:** per instance
+
+**Supported distros:** all
+
+**Config keys**::
+
+ mounts:
+ - [ /dev/ephemeral0, /mnt, auto, "defaults,noexec" ]
+ - [ sdc, /opt/data ]
+ - [ xvdh, /opt/data, "auto", "defaults,nobootwait", "0", "0" ]
+ mount_default_fields: [None, None, "auto", "nefaults,nobootwait", "0", "2"]
+ swap:
+ filename: <file>
+ size: <"auto"/size in bytes>
+ maxsize: <size in bytes>
+"""
+
from string import whitespace
import logging
@@ -265,7 +313,7 @@ def handle(_name, cfg, cloud, log, _args):
# fs_spec, fs_file, fs_vfstype, fs_mntops, fs-freq, fs_passno
def_mnt_opts = "defaults,nobootwait"
if cloud.distro.uses_systemd():
- def_mnt_opts = "defaults,nofail"
+ def_mnt_opts = "defaults,nofail,x-systemd.requires=cloud-init.service"
defvals = [None, None, "auto", def_mnt_opts, "0", "2"]
defvals = cfg.get("mount_default_fields", defvals)
@@ -401,5 +449,5 @@ def handle(_name, cfg, cloud, log, _args):
try:
util.subp(("mount", "-a"))
- except Exception:
+ except util.ProcessExecutionError:
util.logexc(log, "Activating mounts via 'mount -a' failed")