mounting an NFS share via curtin_userdata

Scott Moser scott.moser at canonical.com
Fri Oct 28 19:02:03 UTC 2016


On Fri, 28 Oct 2016, G_Gold wrote:

> Andres,
>
> I believe I've tried that, too. Here's the actual snip from the
> file:
> Lines with < > are not default.
>
> I hope I'm not missing on a silly typo..
>
> =begin=
>
> late_commands:
>   maas: [wget, '--no-proxy', '{{node_disable_pxe_url|escape.shell}}', '--post-data', '{{node_disable_pxe_data|escape.shell}}', '-O', '/dev/null'] >>
> <<  mk_share: ["curtin", "in-target", "--", "sh", "-c", "mkdir /data"] >>
> <<  ins_nfs: ["curtin", "in-target", "--", "apt-get", "update"] >>
> <<  ins_nfs: ["curtin", "in-target", "--", "apt-get", "-y", "install", "nfs-common"] >>
> {{if third_party_drivers and driver}}
>   [ .. ]
>   driver_07_update_initramfs: ["curtin", "in-target", "--", "update-initramfs", "-u"]
> {{endif}}
> <<mount_share: curtin in-target -- sh -c "/bin/echo '192.168.1.1:/data /data nfs rw 0 0' > /etc/fstab" >>

You most certainly want to use [ ] form of invoking commands.
using 'mount_share': with a string rather than an array will pass the
string to shell, and that get interpreted.
So basically you're getting an additional "sh -c" wrapped around it.

its best to just avoid shell interpretation entirely.
So easy thing to do is:

mount_share: [
   'curtin', 'in-target', '--', 'sh', '-c',
   'file="$1"; shift; for line in "$@"; do echo "$line"; done >> "$file"',
   'file-appender', '/etc/fstab',
   '# these are added by Guy',
   '192.168.1.1:/data /data nfs rw 0 0']

that executes 'sh' in the target with the provided '-c' (the process will
be named "file-appender").  It writes to the file in its first arg ($1
which we pass in as /etc/fstab)
a line for each of the other args.


> >     However, the node still boots with the share not mounted,
> >     while mounting manually works with no issues.

You didn't say if the entries were getting written to fstab or not.
If they're getting written for you, then we're trying to debug the wrong
thing here, and we need to debug why systemd isn't doing the mounts.


>
> power_state:
>   mode: reboot
> =end=
>
>
> On Fri,Oct 28 01:30:PM, Andres Rodriguez wrote:
> > Hi Guy,
> >
> > Try this instead:
> >
> > mount_share: curtin in-target -- sh -c "/bin/echo '192.168.1.1:/data /data nfs
> > <options>' >> /etc/fstab"
> >
> > On Fri, Oct 28, 2016 at 1:02 PM, G_Gold <gy_gold12 at yahoo.com> wrote:
> >
> >     Greetings, list.
> >
> >     I'm trying to accomplish a seemingly simple task, with little
> >     success.
> >     The goal is to have a node boot after deployment with an NFS
> >     share mounted. (The NFS server is a system within the node's
> >     LAN).
> >
> >     I've tried multiple directives within /etc/maas/presseed/curtin_userdata ,
> >     the last  one being:
> >
> >       mount_share:["curtin", "in-target", "--", "sh", "-c", "/bin/echo
> >     '192.168.1.1:/data /data nfs _netdev,rw 0 0'  >> /etc/fstab"]
> >
> >     However, the node still boots with the share not mounted,
> >     while mounting manually works with no issues.
> >
> >     Thank you.
> >
> >     --
> >     G.Gold
> >
> >     --
> >     Maas-devel mailing list
> >     Maas-devel at lists.ubuntu.com
> >     Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/
> >     listinfo/maas-devel
> >
> >
> >
> >
> > --
> > Andres Rodriguez
> > Engineering Manager, MAAS
> > Canonical USA, Inc.
>
> --
> Guy Gold
>
> --
> Maas-devel mailing list
> Maas-devel at lists.ubuntu.com
> Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/maas-devel
>


More information about the Maas-devel mailing list