During test, that couldn't be picked up because of a
implementation detail / design decision, it seems:
A more generic template file in the `/var/snap` dir is _preferred over_
a more specific template file in the `/snap` dir.
See the order of the 2 for-loops here:
@ src/maasserver/preseed.py
789 def get_preseed_template(filenames):
790 """Get the path and content for the first template found.
791
792 :param filenames: An iterable of relative filenames.
793 """
...
796 for location in settings.PRESEED_TEMPLATE_LOCATIONS:
797 for filename in filenames:
798 filepath = os.path.join(location, filename)
799 try:
800 with open(filepath, encoding="utf-8") as stream:
801 content = stream.read()
802 except OSError:
803 pass # Ignore.
804 else:
805 return filepath, content
...
In my test server, there was a more generic file in /var/snap:
- /var/snap/maas/current/preseeds/curtin_userdata
which prevented the centos specific file in /snap/ to be picked:
- /snap/maas/current/etc/maas/preseeds/curtin_userdata_centos
Once I removed /var/snap/.../curtin_userdata, the changes
in /snap/.../curtin_userdata_centos were effective.
...
Well, that seems to be _the right thing to do_...
Specifically because it allows users to have their own,
_more generic_ template file that works on all releases,
and ignores the release-based templates shipped in SNAP.
...
I just think we should update the documentation about it,
right now it has 2 issues:
1) It only mentions the `/var/snap/maas/current/preseeds/`
path, which might puzzle users seeing behavior specified
in the (unknown) `/snap/maas/etc/maas/preseeds/` location.
2) The paths for DEB/SNAP are incorrectly changing due to
the UI/CLI view-change, not on DEB/SNAP change.
I take that back. :)
Alexsander mentioned something I missed earlier.
We apparently just need to update docs,
and I have to read code more carefully. :)
...
The SNAP build _HAS_ `/etc/maas/ preseeds/ ` as well;
it's in the read-only side (`/snap`),
not in the read-write side (`/var/snap`).
If I look closer than I did in comment #10:
The SNAP build also runs `setup.cfg` per the `python` plugin [1], preseeds` with same filenames.
and as such, populates `/etc/maas/
@ snap/snapcraft.yaml
72 parts:
73 maas:
74 plugin: python
[1] https:/ /snapcraft. io/docs/ python- plugin
And the preseed template locations for the snap configuration
file actually include _BOTH_ of them (which I read but didn't
investigate properly):
@ src/maasserver/ djangosettings/ snap.py
19 PRESEED_ TEMPLATE_ LOCATIONS = ( join(os. environ[ "SNAP_DATA" ], "preseeds"), join(os. environ[ "SNAP"] , "etc", "maas", "preseeds"),
20 os.path.
21 os.path.
22 )
During test, that couldn't be picked up because of a
implementation detail / design decision, it seems:
A more generic template file in the `/var/snap` dir is _preferred over_
a more specific template file in the `/snap` dir.
See the order of the 2 for-loops here:
@ src/maasserver/ preseed. py
789 def get_preseed_ template( filenames) : PRESEED_ TEMPLATE_ LOCATIONS: join(location, filename)
790 """Get the path and content for the first template found.
791
792 :param filenames: An iterable of relative filenames.
793 """
...
796 for location in settings.
797 for filename in filenames:
798 filepath = os.path.
799 try:
800 with open(filepath, encoding="utf-8") as stream:
801 content = stream.read()
802 except OSError:
803 pass # Ignore.
804 else:
805 return filepath, content
...
In my test server, there was a more generic file in /var/snap: maas/current/ preseeds/ curtin_ userdata
- /var/snap/
which prevented the centos specific file in /snap/ to be picked: current/ etc/maas/ preseeds/ curtin_ userdata_ centos
- /snap/maas/
Once I removed /var/snap/ .../curtin_ userdata, the changes ../curtin_ userdata_ centos were effective.
in /snap/.
...
Well, that seems to be _the right thing to do_...
Specifically because it allows users to have their own,
_more generic_ template file that works on all releases,
and ignores the release-based templates shipped in SNAP.
...
I just think we should update the documentation about it,
right now it has 2 issues:
1) It only mentions the `/var/snap/ maas/current/ preseeds/ ` maas/etc/ maas/preseeds/ ` location.
path, which might puzzle users seeing behavior specified
in the (unknown) `/snap/
2) The paths for DEB/SNAP are incorrectly changing due to
the UI/CLI view-change, not on DEB/SNAP change.
https:/ /maas.io/ docs/about- customising- machines# heading- -templates
We should fix it here: (note the 2 `[tab]` tags)
@ src/maas- offline- docs/src/ src/about- customising- machines- 5976.md
132 [tabs] maas/current/ preseeds/ ` directory ... preseeds/ ` directory ...
133 [tab version="v3.2 Snap,v3.2 Packages,v3.1 Snap,v3.1 Packages,v3.0 Snap,v3.0 Packages,v2.9 Snap,v2.9 Packages" view="UI"]
134 ... template files are found in the `/var/snap/
135 [/tab]
136 [tab version="v3.2 Snap,v3.2 Packages,v3.1 Snap,v3.1 Packages,v3.0 Snap,v3.0 Packages,v2.9 Snap,v2.9 Packages" view="CLI"]
137 ... template files are found in the `/etc/maas/
138 [/tab]
139 [/tabs]