From 6a5cb3d43b79f72805de9b1e3469f2db9807f235 Mon Sep 17 00:00:00 2001 From: mitchellsalad Date: Fri, 24 Mar 2017 16:59:19 +0000 Subject: --- doc/forum/Manage_multiple_different_projects_with_propellor.mdwn | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 doc/forum/Manage_multiple_different_projects_with_propellor.mdwn diff --git a/doc/forum/Manage_multiple_different_projects_with_propellor.mdwn b/doc/forum/Manage_multiple_different_projects_with_propellor.mdwn new file mode 100644 index 00000000..bcba383c --- /dev/null +++ b/doc/forum/Manage_multiple_different_projects_with_propellor.mdwn @@ -0,0 +1,7 @@ +Hi there, + +I've been tasked with investigating propellor as an alternative to Ansible. I'm a little bit confused about how one might go about managing a *single* project's hosts with propellor, without infecting the global propellor config. It seems that everything is concerned with the ~/.propellor repository. However, I don't want project A's hosts to know about project B's and vice versa. I'm sure I'm overlooking something obvious! + +Thanks very much! + +Mitchell -- cgit v1.2.3 From c4fcd24f8758d6398254bd44a693c9706d16779b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 24 Mar 2017 14:09:40 -0400 Subject: releasing package propellor version 4.0.2 --- debian/changelog | 6 +++--- propellor.cabal | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/debian/changelog b/debian/changelog index 11c9922f..c3ae1903 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -propellor (4.0.2) UNRELEASED; urgency=medium +propellor (4.0.2) unstable; urgency=medium * Apt.mirror can be used to set the preferred apt mirror of a host, overriding the default CDN. This info is used by @@ -10,8 +10,8 @@ propellor (4.0.2) UNRELEASED; urgency=medium properties added to a chroot that way from being seen when propellor was running inside the chroot. This affected disk image creation, and possibly other things that use chroots. - - -- Joey Hess Sun, 19 Mar 2017 16:37:27 -0400 + + -- Joey Hess Fri, 24 Mar 2017 14:04:50 -0400 propellor (4.0.1) unstable; urgency=medium diff --git a/propellor.cabal b/propellor.cabal index 7319af23..e682cbd1 100644 --- a/propellor.cabal +++ b/propellor.cabal @@ -1,5 +1,5 @@ Name: propellor -Version: 4.0.1 +Version: 4.0.2 Cabal-Version: >= 1.8 License: BSD2 Maintainer: Joey Hess -- cgit v1.2.3 From f03ccd29779094190f3b6414e931ebc4ac798778 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 24 Mar 2017 14:09:50 -0400 Subject: add news item for propellor 4.0.2 --- doc/news/version_4.0.1.mdwn | 6 ------ doc/news/version_4.0.2.mdwn | 12 ++++++++++++ 2 files changed, 12 insertions(+), 6 deletions(-) delete mode 100644 doc/news/version_4.0.1.mdwn create mode 100644 doc/news/version_4.0.2.mdwn diff --git a/doc/news/version_4.0.1.mdwn b/doc/news/version_4.0.1.mdwn deleted file mode 100644 index e870a510..00000000 --- a/doc/news/version_4.0.1.mdwn +++ /dev/null @@ -1,6 +0,0 @@ -propellor 4.0.1 released with [[!toggle text="these changes"]] -[[!toggleable text=""" - * Fix build with pre-AMP ghc. - * Tor: Restart daemon after installing private key. - * Tor.named, Tor.torPrivKey: Include the new ed25519 public/private key - pair in addition to the old secret\_id\_key."""]] \ No newline at end of file diff --git a/doc/news/version_4.0.2.mdwn b/doc/news/version_4.0.2.mdwn new file mode 100644 index 00000000..b955c579 --- /dev/null +++ b/doc/news/version_4.0.2.mdwn @@ -0,0 +1,12 @@ +propellor 4.0.2 released with [[!toggle text="these changes"]] +[[!toggleable text=""" + * Apt.mirror can be used to set the preferred apt mirror of a host, + overriding the default CDN. This info is used by + Apt.stdSourcesList and Sbuild.builtFor. + Thanks, Sean Whitton. + * Property.Partition: Update kpartx output parser, as its output format + changed around version 0.6. Both output formats are supported now. + * Fix bug when using setContainerProps with a chroot that prevented + properties added to a chroot that way from being seen when propellor + was running inside the chroot. This affected disk image creation, and + possibly other things that use chroots."""]] \ No newline at end of file -- cgit v1.2.3 From 12fbce5422f015b3519a3ddaa3eceb3e291b2acd Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 24 Mar 2017 14:16:43 -0400 Subject: response --- .../comment_1_dbad48163b2efd6434ea7c37a72dfd30._comment | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 doc/forum/Manage_multiple_different_projects_with_propellor/comment_1_dbad48163b2efd6434ea7c37a72dfd30._comment diff --git a/doc/forum/Manage_multiple_different_projects_with_propellor/comment_1_dbad48163b2efd6434ea7c37a72dfd30._comment b/doc/forum/Manage_multiple_different_projects_with_propellor/comment_1_dbad48163b2efd6434ea7c37a72dfd30._comment new file mode 100644 index 00000000..7513cc09 --- /dev/null +++ b/doc/forum/Manage_multiple_different_projects_with_propellor/comment_1_dbad48163b2efd6434ea7c37a72dfd30._comment @@ -0,0 +1,14 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 1""" + date="2017-03-24T18:14:14Z" + content=""" +There did not used to be a good way to do that, but since propellor 3.2.3, +when you run eg "propellor --spin host", it first checks to see if there is +a `./config.hs` file, and if so, uses it instead of the user-global +`~/.propellor/config.hs`. + +So, just make different git repos for the different projects with propellor +`config.hs` files in them, and `cd` into the one you want to run before running +propellor. +"""]] -- cgit v1.2.3 From b711f16d671f709c21873ff7b3c13a93995e62f9 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 25 Mar 2017 17:09:24 -0400 Subject: todo --- doc/todo/property_to_install_propellor.mdwn | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 doc/todo/property_to_install_propellor.mdwn diff --git a/doc/todo/property_to_install_propellor.mdwn b/doc/todo/property_to_install_propellor.mdwn new file mode 100644 index 00000000..25db8193 --- /dev/null +++ b/doc/todo/property_to_install_propellor.mdwn @@ -0,0 +1,14 @@ +This seems redundant, since propellor must be running to ensure such a +Property, but a Property to install propellor is useful when eg, creating a +disk image that itself will need to run propellor. --[[Joey]] + +Should support: + +* Cloning the git repo propellor is running in. (Using eg `hostChroot`) +* Cloning some other git repo. +* Installing the precompiled propellor binary. +* Installing the propellor haskell library using cabal/stack/apt. + +Much of this is already implemented, in non-Property form, in +Propellor.Bootstrap, but will need adjustments for this new context. +--[[Joey]] -- cgit v1.2.3 From d6e6b48654a65c0c197a78e3ac91f4e5f74c71a5 Mon Sep 17 00:00:00 2001 From: bardur.arantsson Date: Tue, 28 Mar 2017 04:23:00 +0000 Subject: --- doc/forum/Using_propellor_for_continers_only.mdwn | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 doc/forum/Using_propellor_for_continers_only.mdwn diff --git a/doc/forum/Using_propellor_for_continers_only.mdwn b/doc/forum/Using_propellor_for_continers_only.mdwn new file mode 100644 index 00000000..c2b8673c --- /dev/null +++ b/doc/forum/Using_propellor_for_continers_only.mdwn @@ -0,0 +1,5 @@ +Hi, + +I was wondering: Is it possible to use propellor to generate images only without actually managing any hosts per-se? I couldn't find any documentation on that. + +Ideally, I'd also be able to use it directly from a sandbox so that I wouldn't have to even "pollute" the GHC/Cabal "global" (user home dir) database on the development machine. I see that there's support for having the config.hs stored in a different directory than ~/.propellor, but I haven't managed to get it working when I use a sandbox in e.g. ~/foo with the config.hs stored in the same directory. Perhaps that's just a bug? If it's supposed to work I can provide detailed error messages, etc. -- cgit v1.2.3 From fa84f575880cec54453fb2b89f6db78528c6a0ef Mon Sep 17 00:00:00 2001 From: bardur.arantsson Date: Tue, 28 Mar 2017 04:24:38 +0000 Subject: --- doc/forum/Using_propellor_for_continers_only.mdwn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/forum/Using_propellor_for_continers_only.mdwn b/doc/forum/Using_propellor_for_continers_only.mdwn index c2b8673c..faf07956 100644 --- a/doc/forum/Using_propellor_for_continers_only.mdwn +++ b/doc/forum/Using_propellor_for_continers_only.mdwn @@ -2,4 +2,4 @@ Hi, I was wondering: Is it possible to use propellor to generate images only without actually managing any hosts per-se? I couldn't find any documentation on that. -Ideally, I'd also be able to use it directly from a sandbox so that I wouldn't have to even "pollute" the GHC/Cabal "global" (user home dir) database on the development machine. I see that there's support for having the config.hs stored in a different directory than ~/.propellor, but I haven't managed to get it working when I use a sandbox in e.g. ~/foo with the config.hs stored in the same directory. Perhaps that's just a bug? If it's supposed to work I can provide detailed error messages, etc. +Ideally, I'd also be able to use it directly from a sandbox so that I wouldn't have to even "pollute" the GHC/Cabal "global" (user home dir) database on the development machine. I see that there's support for having the config.hs stored in a different directory than ~/.propellor, but I haven't managed to get it working when I use a sandbox in e.g. ~/foo with the config.hs stored in the same directory. Perhaps that's just a bug? If it's supposed to work I can provide detailed error messages, etc. **EDIT:** I'd also like to manage the git repository myself -- is that possible? -- cgit v1.2.3 From a8c6f64662578882e3470ba0fe013677108aa4f4 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 29 Mar 2017 15:13:26 -0400 Subject: response --- ...mment_1_95e8b7103f248d93570fecb6b8999996._comment | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 doc/forum/Using_propellor_for_continers_only/comment_1_95e8b7103f248d93570fecb6b8999996._comment diff --git a/doc/forum/Using_propellor_for_continers_only/comment_1_95e8b7103f248d93570fecb6b8999996._comment b/doc/forum/Using_propellor_for_continers_only/comment_1_95e8b7103f248d93570fecb6b8999996._comment new file mode 100644 index 00000000..dc6cc616 --- /dev/null +++ b/doc/forum/Using_propellor_for_continers_only/comment_1_95e8b7103f248d93570fecb6b8999996._comment @@ -0,0 +1,20 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 1""" + date="2017-03-29T19:09:37Z" + content=""" +Sounds like you may want to write a program that uses propellor as a +library. `Propellor.Engine.mainProperties` is a reasonable +entry point, just pass it a Host that has the properties you want +to run. + +For example: + + import Propellor + import Propellor.Engine + import Propellor.Property.DiskImage + + main :: IO () + main = mainProperties $ host "whatever" $ props + & imageBuilt "/some/disk.img" ... +"""]] -- cgit v1.2.3 From cd4a20edba2537deb99fbb43cabd6571751cd97a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 3 Apr 2017 14:56:55 -0400 Subject: clean up after merge --- config.hs | 2 +- privdata/relocate | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 privdata/relocate diff --git a/config.hs b/config.hs index 97d90636..ec313725 120000 --- a/config.hs +++ b/config.hs @@ -1 +1 @@ -joeyconfig.hs \ No newline at end of file +config-simple.hs \ No newline at end of file diff --git a/privdata/relocate b/privdata/relocate deleted file mode 100644 index 271692d8..00000000 --- a/privdata/relocate +++ /dev/null @@ -1 +0,0 @@ -.joeyconfig -- cgit v1.2.3 From 680f67970dcb25fac43e96bb732be1e53ffdffe5 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 4 Apr 2017 16:46:38 -0400 Subject: bug report --- doc/todo/initial_spin_compile_failure_recovery.mdwn | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 doc/todo/initial_spin_compile_failure_recovery.mdwn diff --git a/doc/todo/initial_spin_compile_failure_recovery.mdwn b/doc/todo/initial_spin_compile_failure_recovery.mdwn new file mode 100644 index 00000000..423b279c --- /dev/null +++ b/doc/todo/initial_spin_compile_failure_recovery.mdwn @@ -0,0 +1,5 @@ +When initial propellor --spin host fails to compile propellor +perhaps due to a ghc compatability bug, spinning again doesn't fix the +problem. IIRC /usr/local/propellor has a git repo set up, but no remote +set, and so the subsequent spin doesn't update it, since propellor is not +running there to receive a git push into the repo. --[[Joey]] -- cgit v1.2.3 From d1cbc66cb06482a5cb4168fc44b7e84fd4e8849e Mon Sep 17 00:00:00 2001 From: Daniel Brooks Date: Tue, 4 Apr 2017 13:56:03 -0700 Subject: property 'mount' a swap partition in Fstab.mounted --- src/Propellor/Property/Fstab.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Propellor/Property/Fstab.hs b/src/Propellor/Property/Fstab.hs index 60f11d8e..602276ea 100644 --- a/src/Propellor/Property/Fstab.hs +++ b/src/Propellor/Property/Fstab.hs @@ -35,7 +35,9 @@ mounted fs src mnt opts = tightenTargets $ -- This use of mountPoints, which is linux-only, is why this -- property currently only supports linux. mountnow = check (notElem mnt <$> mountPoints) $ - cmdProperty "mount" [mnt] + if fs == "swap" + then cmdProperty "swapon" [mnt] + else cmdProperty "mount" [mnt] newtype SwapPartition = SwapPartition FilePath -- cgit v1.2.3 From 2afeb3661f04beb0a84b740b327917c16ed27a3d Mon Sep 17 00:00:00 2001 From: db48x@80bd751a72d5a80737e2f875342cf845629c7202 Date: Tue, 4 Apr 2017 21:07:53 +0000 Subject: --- doc/forum/Git.cloned_deletes_harmless_empty_directory.mdwn | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 doc/forum/Git.cloned_deletes_harmless_empty_directory.mdwn diff --git a/doc/forum/Git.cloned_deletes_harmless_empty_directory.mdwn b/doc/forum/Git.cloned_deletes_harmless_empty_directory.mdwn new file mode 100644 index 00000000..ce3c192c --- /dev/null +++ b/doc/forum/Git.cloned_deletes_harmless_empty_directory.mdwn @@ -0,0 +1,3 @@ +In my case I have carefully set up the directory that I'm going to clone into with the correct group ownership and setgid permission, so that the cloned files will also have the correct ownership. This change just checks to see if the directory actually has anything in it before it deletes it. + +https://github.com/ArchiveTeam/glowing-computing-machine/tree/git-in-emtpy-directory -- cgit v1.2.3 From 1573c094362be744517d7d5e909a2148e6d79618 Mon Sep 17 00:00:00 2001 From: db48x@80bd751a72d5a80737e2f875342cf845629c7202 Date: Tue, 4 Apr 2017 21:10:01 +0000 Subject: --- doc/forum/Fstab.mounted_could_call_swapon_when_activating_swap.mdwn | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 doc/forum/Fstab.mounted_could_call_swapon_when_activating_swap.mdwn diff --git a/doc/forum/Fstab.mounted_could_call_swapon_when_activating_swap.mdwn b/doc/forum/Fstab.mounted_could_call_swapon_when_activating_swap.mdwn new file mode 100644 index 00000000..61cd10cc --- /dev/null +++ b/doc/forum/Fstab.mounted_could_call_swapon_when_activating_swap.mdwn @@ -0,0 +1,3 @@ +The mount command won't work when activating a swap partition/file, so we should call swapon instead. + +https://github.com/ArchiveTeam/glowing-computing-machine/tree/fstab-swap -- cgit v1.2.3 From 7a2a88c12805f277e1e89e63b006a0783ea8cc0b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 4 Apr 2017 22:31:00 -0400 Subject: comments --- ...mment_1_8ab6b313c80486f8f87a5e13e830bfa9._comment | 20 ++++++++++++++++++++ ...mment_1_7cd0521c6d071b25852f8355f4f61f94._comment | 20 ++++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 doc/forum/Fstab.mounted_could_call_swapon_when_activating_swap/comment_1_8ab6b313c80486f8f87a5e13e830bfa9._comment create mode 100644 doc/forum/Git.cloned_deletes_harmless_empty_directory/comment_1_7cd0521c6d071b25852f8355f4f61f94._comment diff --git a/doc/forum/Fstab.mounted_could_call_swapon_when_activating_swap/comment_1_8ab6b313c80486f8f87a5e13e830bfa9._comment b/doc/forum/Fstab.mounted_could_call_swapon_when_activating_swap/comment_1_8ab6b313c80486f8f87a5e13e830bfa9._comment new file mode 100644 index 00000000..4a144df5 --- /dev/null +++ b/doc/forum/Fstab.mounted_could_call_swapon_when_activating_swap/comment_1_8ab6b313c80486f8f87a5e13e830bfa9._comment @@ -0,0 +1,20 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 1""" + date="2017-04-05T02:17:00Z" + content=""" +This idea kind of makes sense, because swap partitions in /etc/fstab +get swaponed at boot. + +But, the implementation doesn't take the types into account. The `mounted` +property takes a FilePath for the mountpoint, but for swap that +needs to be "none", which is not really a file-path. Also, the `fstabbed` +property has a separate `SwapPartition` type, so making `mount` support +swap partitions without using that type feels wrong. + +It might be simpler all round to treat swap partitions being able to +be specified in /etc/fstab as a historical accident, which it kind of +is (increasingly so, since eg systemd has other ways to accomplish +that), and instead of shoehorning this into the `mounted` property, +add a new `swaponed` property. +"""]] diff --git a/doc/forum/Git.cloned_deletes_harmless_empty_directory/comment_1_7cd0521c6d071b25852f8355f4f61f94._comment b/doc/forum/Git.cloned_deletes_harmless_empty_directory/comment_1_7cd0521c6d071b25852f8355f4f61f94._comment new file mode 100644 index 00000000..91b403b0 --- /dev/null +++ b/doc/forum/Git.cloned_deletes_harmless_empty_directory/comment_1_7cd0521c6d071b25852f8355f4f61f94._comment @@ -0,0 +1,20 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 1""" + date="2017-04-05T02:22:54Z" + content=""" +I am not entirely happy with this patch, because it seems that if +Git.cloned took care to preserve permissions in this case, it could be +argued that it should also preserve permissions when the directory already +exists but has the wrong content. Or equally well argued that it should not +preserve permissions, which might be a leftover from some past unwanted +state. + +Is that really the best way to do it? You could instead say: + + Git.cloned user repo dir Nothing + `onChange` recursiveSetGID user dir + +And then you just have to write a recursiveSetGID which would be a +generally useful property. +"""]] -- cgit v1.2.3 From 9e6eff4e9fb0859c67d58b8beaf96fe0b472ac21 Mon Sep 17 00:00:00 2001 From: db48x@80bd751a72d5a80737e2f875342cf845629c7202 Date: Wed, 5 Apr 2017 02:37:45 +0000 Subject: Added a comment --- .../comment_2_289f157f129511242d93beae76fd03a3._comment | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 doc/forum/Git.cloned_deletes_harmless_empty_directory/comment_2_289f157f129511242d93beae76fd03a3._comment diff --git a/doc/forum/Git.cloned_deletes_harmless_empty_directory/comment_2_289f157f129511242d93beae76fd03a3._comment b/doc/forum/Git.cloned_deletes_harmless_empty_directory/comment_2_289f157f129511242d93beae76fd03a3._comment new file mode 100644 index 00000000..1a8c1447 --- /dev/null +++ b/doc/forum/Git.cloned_deletes_harmless_empty_directory/comment_2_289f157f129511242d93beae76fd03a3._comment @@ -0,0 +1,11 @@ +[[!comment format=mdwn + username="db48x@80bd751a72d5a80737e2f875342cf845629c7202" + nickname="db48x" + avatar="http://cdn.libravatar.org/avatar/ad2688127feb555a92154b16d8eeb5d3" + subject="comment 2" + date="2017-04-05T02:37:44Z" + content=""" +Yea, I guess that's a fair point about the other cases. + +It just seems inelegant to go back over all the files and fix up their permissions, when it could just have been set right to begin with. +"""]] -- cgit v1.2.3 From c14d4430bc70f69f41b2645f3ea25869d4f759bb Mon Sep 17 00:00:00 2001 From: db48x@80bd751a72d5a80737e2f875342cf845629c7202 Date: Wed, 5 Apr 2017 02:48:08 +0000 Subject: Added a comment --- .../comment_2_773fc1441dd06e9dd41508bd800298eb._comment | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 doc/forum/Fstab.mounted_could_call_swapon_when_activating_swap/comment_2_773fc1441dd06e9dd41508bd800298eb._comment diff --git a/doc/forum/Fstab.mounted_could_call_swapon_when_activating_swap/comment_2_773fc1441dd06e9dd41508bd800298eb._comment b/doc/forum/Fstab.mounted_could_call_swapon_when_activating_swap/comment_2_773fc1441dd06e9dd41508bd800298eb._comment new file mode 100644 index 00000000..62cabc0a --- /dev/null +++ b/doc/forum/Fstab.mounted_could_call_swapon_when_activating_swap/comment_2_773fc1441dd06e9dd41508bd800298eb._comment @@ -0,0 +1,13 @@ +[[!comment format=mdwn + username="db48x@80bd751a72d5a80737e2f875342cf845629c7202" + nickname="db48x" + avatar="http://cdn.libravatar.org/avatar/ad2688127feb555a92154b16d8eeb5d3" + subject="comment 2" + date="2017-04-05T02:48:08Z" + content=""" +Yes, perhaps if it took an Option FilePath (am I saying this correctly in Haskellese?) it would be nicer. + +I don't mind much how it's structured; this was just the smallest obvious change, since it was failing to mount it. Perhaps breaking it up into smaller, more primitive, pieces would help. Fstab.mounted could = Fstab.fstabbed `onChange` Fstab.mounted, for instance, and then I could write Fstab.fstabbed `onChange` Swap.swapEnabled (oh, but Fstab.fstabbed already exists; I'm not using it because it replaces the whole file, which seems like an odd thing to do. Maybe call it Fstab.listed instead?). + +Also, for maximum irony I was just perusing your most recent dozen commits or so, and saw you enable Apt.serviceInstalledRunning \"swapspace\" on one of your machines. That's amazing; I had no idea it existed! I am re-evaluating all of my life choices now. +"""]] -- cgit v1.2.3 From fcc5b96e595a20a8b93989fa59f2b73d1b6d3a1b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 4 Apr 2017 23:12:39 -0400 Subject: comment --- .../comment_3_f48a6191c56bed41eda55436f0aa3e9c._comment | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 doc/forum/Fstab.mounted_could_call_swapon_when_activating_swap/comment_3_f48a6191c56bed41eda55436f0aa3e9c._comment diff --git a/doc/forum/Fstab.mounted_could_call_swapon_when_activating_swap/comment_3_f48a6191c56bed41eda55436f0aa3e9c._comment b/doc/forum/Fstab.mounted_could_call_swapon_when_activating_swap/comment_3_f48a6191c56bed41eda55436f0aa3e9c._comment new file mode 100644 index 00000000..95c69551 --- /dev/null +++ b/doc/forum/Fstab.mounted_could_call_swapon_when_activating_swap/comment_3_f48a6191c56bed41eda55436f0aa3e9c._comment @@ -0,0 +1,15 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 3""" + date="2017-04-05T03:08:30Z" + content=""" +I like the idea of composing smaller properties to build the current +property, and add flexability. + +Renaming the existing `fstabbed` would probably be too much bother. +(Also, I think I picked that name because it kind of hints that the +existing fstab does not come out alive.) + +(The swapspace package is great if you can eat the now tiny overhead of a +swap file compared to a swap partition.) +"""]] -- cgit v1.2.3 From baf65fa9fff4b8451ba7f1ee129484723a8deb9b Mon Sep 17 00:00:00 2001 From: Daniel Brooks Date: Tue, 4 Apr 2017 23:32:57 -0700 Subject: break Fstab.mounted into smaller pieces which can be composed --- src/Propellor/Property/Fstab.hs | 52 ++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/src/Propellor/Property/Fstab.hs b/src/Propellor/Property/Fstab.hs index 602276ea..7bf18726 100644 --- a/src/Propellor/Property/Fstab.hs +++ b/src/Propellor/Property/Fstab.hs @@ -14,6 +14,17 @@ import Data.Char import Data.List import Utility.Table +-- | Ensures that contains a line mounting the specified +-- `Source` on the specified `MountPoint`. +listed :: FsType -> Source -> MountPoint -> MountOpts -> Property Linux +listed fs src mnt opts = tightenTargets $ + "/etc/fstab" `File.containsLine` l + `describe` (mnt ++ " mounted by fstab") + where + l = intercalate "\t" [src, mnt, fs, formatMountOpts opts, dump, passno] + dump = "0" + passno = "2" + -- | Ensures that contains a line mounting the specified -- `Source` on the specified `MountPoint`, and that it's currently mounted. -- @@ -24,20 +35,29 @@ import Utility.Table -- Note that if anything else is already mounted at the `MountPoint`, it -- will be left as-is by this property. mounted :: FsType -> Source -> MountPoint -> MountOpts -> Property Linux -mounted fs src mnt opts = tightenTargets $ - "/etc/fstab" `File.containsLine` l - `describe` (mnt ++ " mounted by fstab") - `onChange` mountnow - where - l = intercalate "\t" [src, mnt, fs, formatMountOpts opts, dump, passno] - dump = "0" - passno = "2" - -- This use of mountPoints, which is linux-only, is why this - -- property currently only supports linux. - mountnow = check (notElem mnt <$> mountPoints) $ - if fs == "swap" - then cmdProperty "swapon" [mnt] - else cmdProperty "mount" [mnt] +mounted fs src mnt opts = (listed fs src mnt opts) `onChange` (mountNow src) + +-- | Ensures that contains a line enabling the specified +-- `Source` to be used as swap space, and that it's enabled +swap :: Source -> Property Linux +swap src = (listed "swap" src "none" mempty) `onChange` (swapOn src) + +-- This use of mountPoints, which is linux-only, is why this +-- property currently only supports linux. +mountNow :: Source -> RevertableProperty Linux Linux +mountNow mnt = tightenTargets domount tightenTargets doumount + where domount = check (notElem mnt <$> mountPoints) $ + cmdProperty "mount" [mnt] + doumount = check (elem mnt <$> mountPoints) $ + cmdProperty "umount" [mnt] + +swapOn :: Source -> RevertableProperty Linux Linux +swapOn mnt = tightenTargets doswapon tightenTargets doswapoff + where swaps = lines <$> readProcess "swapon" ["--no-headings", "--show=NAME"] + doswapon = check (notElem mnt <$> swaps) $ + cmdProperty "swapon" [mnt] + doswapoff = check (elem mnt <$> swaps) $ + cmdProperty "swapoff" [mnt] newtype SwapPartition = SwapPartition FilePath @@ -79,8 +99,8 @@ genFstab mnts swaps mnttransform = do , pure "0" , pure (if mnt == "/" then "1" else "2") ] - getswapcfg (SwapPartition swap) = sequence - [ fromMaybe swap <$> getM (\a -> a swap) + getswapcfg (SwapPartition s) = sequence + [ fromMaybe s <$> getM (\a -> a s) [ uuidprefix getSourceUUID , sourceprefix getSourceLabel ] -- cgit v1.2.3 From 9298008c9d7d4c0dc6d4f59fd5cc48b1153bc009 Mon Sep 17 00:00:00 2001 From: db48x@80bd751a72d5a80737e2f875342cf845629c7202 Date: Wed, 5 Apr 2017 06:39:49 +0000 Subject: Added a comment --- .../comment_4_b1769231a633ad2b978ee4c9fa90591c._comment | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 doc/forum/Fstab.mounted_could_call_swapon_when_activating_swap/comment_4_b1769231a633ad2b978ee4c9fa90591c._comment diff --git a/doc/forum/Fstab.mounted_could_call_swapon_when_activating_swap/comment_4_b1769231a633ad2b978ee4c9fa90591c._comment b/doc/forum/Fstab.mounted_could_call_swapon_when_activating_swap/comment_4_b1769231a633ad2b978ee4c9fa90591c._comment new file mode 100644 index 00000000..ca04f945 --- /dev/null +++ b/doc/forum/Fstab.mounted_could_call_swapon_when_activating_swap/comment_4_b1769231a633ad2b978ee4c9fa90591c._comment @@ -0,0 +1,9 @@ +[[!comment format=mdwn + username="db48x@80bd751a72d5a80737e2f875342cf845629c7202" + nickname="db48x" + avatar="http://cdn.libravatar.org/avatar/ad2688127feb555a92154b16d8eeb5d3" + subject="comment 4" + date="2017-04-05T06:39:49Z" + content=""" +I took a stab at implementing this. It compiles, but I've not tested it yet as I need to get some sleep; consider it a work in progress. Looks right to me though. +"""]] -- cgit v1.2.3 From abc6a32c938c9b241428ca749b2dd2b39b9f7cc0 Mon Sep 17 00:00:00 2001 From: bardur.arantsson Date: Thu, 6 Apr 2017 02:14:58 +0000 Subject: Added a comment --- .../comment_2_42b45a126cfdf1dfc370b166c8042690._comment | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 doc/forum/Using_propellor_for_continers_only/comment_2_42b45a126cfdf1dfc370b166c8042690._comment diff --git a/doc/forum/Using_propellor_for_continers_only/comment_2_42b45a126cfdf1dfc370b166c8042690._comment b/doc/forum/Using_propellor_for_continers_only/comment_2_42b45a126cfdf1dfc370b166c8042690._comment new file mode 100644 index 00000000..45cd3e0c --- /dev/null +++ b/doc/forum/Using_propellor_for_continers_only/comment_2_42b45a126cfdf1dfc370b166c8042690._comment @@ -0,0 +1,8 @@ +[[!comment format=mdwn + username="bardur.arantsson" + avatar="http://cdn.libravatar.org/avatar/a0be0039b44d33262b7ae650a0803ad5" + subject="comment 2" + date="2017-04-06T02:14:58Z" + content=""" +I'll try that this weekend, thanks! +"""]] -- cgit v1.2.3 From 544ad71f3fce7d394945b447fcaf938d8067c5b3 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 6 Apr 2017 19:43:48 -0400 Subject: listed property should work on !Linux --- src/Propellor/Property/Fstab.hs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Propellor/Property/Fstab.hs b/src/Propellor/Property/Fstab.hs index 7bf18726..8196377f 100644 --- a/src/Propellor/Property/Fstab.hs +++ b/src/Propellor/Property/Fstab.hs @@ -16,10 +16,9 @@ import Utility.Table -- | Ensures that contains a line mounting the specified -- `Source` on the specified `MountPoint`. -listed :: FsType -> Source -> MountPoint -> MountOpts -> Property Linux -listed fs src mnt opts = tightenTargets $ - "/etc/fstab" `File.containsLine` l - `describe` (mnt ++ " mounted by fstab") +listed :: FsType -> Source -> MountPoint -> MountOpts -> Property UnixLike +listed fs src mnt opts = "/etc/fstab" `File.containsLine` l + `describe` (mnt ++ " mounted by fstab") where l = intercalate "\t" [src, mnt, fs, formatMountOpts opts, dump, passno] dump = "0" -- cgit v1.2.3 From 57525e0d0d1d300aa807f1c876945ee5e38a29df Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 6 Apr 2017 20:08:14 -0400 Subject: tweaks to db45x's patch Removed mountNow as a top-level property, as I don't think it makes sense for anything except for mounted to use it. db45x's patch turns out to have introduced a bug in mounted's use of "mountNow src". That made mountNow check if the device was a mount point, which it isn't. The fix would have been to use "mountNow mnt", but my inlining of mountnow just basically reverted the part of the patch that introduced the bug. swapOn does not involve the fstab so moved to the Mount module. (Also noticed that Mount.mounted is a kind of weird property, given that it fails the next time ran. It's only used internally by some chroot properties, so I left it as-is, but added a comment. It might make sense to make Mount.mounted check like mountNow does if the thing is already mounted.) --- debian/changelog | 7 +++ ...ent_5_6dc24952c8efa31a401191a8cf2d0b39._comment | 14 ++++++ src/Propellor/Property/Fstab.hs | 52 +++++++++------------- src/Propellor/Property/Mount.hs | 14 ++++++ 4 files changed, 57 insertions(+), 30 deletions(-) create mode 100644 doc/forum/Fstab.mounted_could_call_swapon_when_activating_swap/comment_5_6dc24952c8efa31a401191a8cf2d0b39._comment diff --git a/debian/changelog b/debian/changelog index c3ae1903..dcbe0a3e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +propellor (4.0.3) UNRELEASED; urgency=medium + + * Added Fstab.listed, Fstab.swap, and Mount.swapOn properties. + Thanks, Daniel Brooks. + + -- Joey Hess Thu, 06 Apr 2017 19:40:12 -0400 + propellor (4.0.2) unstable; urgency=medium * Apt.mirror can be used to set the preferred apt mirror of a host, diff --git a/doc/forum/Fstab.mounted_could_call_swapon_when_activating_swap/comment_5_6dc24952c8efa31a401191a8cf2d0b39._comment b/doc/forum/Fstab.mounted_could_call_swapon_when_activating_swap/comment_5_6dc24952c8efa31a401191a8cf2d0b39._comment new file mode 100644 index 00000000..f87500b2 --- /dev/null +++ b/doc/forum/Fstab.mounted_could_call_swapon_when_activating_swap/comment_5_6dc24952c8efa31a401191a8cf2d0b39._comment @@ -0,0 +1,14 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 5""" + date="2017-04-06T23:51:08Z" + content=""" +Merged. Have not tested it either. + +On my Debian system, the swapon command does not support the +`--no-headings` that you used. It's `--noheadings` here. Is that a typo in +your patch? + +I've simply removed that option for now, since it probably won't +hurt if it treats the heading like another device that's swapped on. +"""]] diff --git a/src/Propellor/Property/Fstab.hs b/src/Propellor/Property/Fstab.hs index 8196377f..29b85426 100644 --- a/src/Propellor/Property/Fstab.hs +++ b/src/Propellor/Property/Fstab.hs @@ -14,16 +14,6 @@ import Data.Char import Data.List import Utility.Table --- | Ensures that contains a line mounting the specified --- `Source` on the specified `MountPoint`. -listed :: FsType -> Source -> MountPoint -> MountOpts -> Property UnixLike -listed fs src mnt opts = "/etc/fstab" `File.containsLine` l - `describe` (mnt ++ " mounted by fstab") - where - l = intercalate "\t" [src, mnt, fs, formatMountOpts opts, dump, passno] - dump = "0" - passno = "2" - -- | Ensures that contains a line mounting the specified -- `Source` on the specified `MountPoint`, and that it's currently mounted. -- @@ -34,29 +24,31 @@ listed fs src mnt opts = "/etc/fstab" `File.containsLine` l -- Note that if anything else is already mounted at the `MountPoint`, it -- will be left as-is by this property. mounted :: FsType -> Source -> MountPoint -> MountOpts -> Property Linux -mounted fs src mnt opts = (listed fs src mnt opts) `onChange` (mountNow src) +mounted fs src mnt opts = tightenTargets $ + listed fs src mnt opts + `onChange` mountnow + where + -- This use of mountPoints, which is linux-only, is why this + -- property currently only supports linux. + mountnow = check (notElem mnt <$> mountPoints) $ + cmdProperty "mount" [mnt] + +-- | Ensures that contains a line mounting the specified +-- `Source` on the specified `MountPoint`. Does not ensure that it's +-- currently `mounted`. +listed :: FsType -> Source -> MountPoint -> MountOpts -> Property UnixLike +listed fs src mnt opts = "/etc/fstab" `File.containsLine` l + `describe` (mnt ++ " mounted by fstab") + where + l = intercalate "\t" [src, mnt, fs, formatMountOpts opts, dump, passno] + dump = "0" + passno = "2" -- | Ensures that contains a line enabling the specified --- `Source` to be used as swap space, and that it's enabled +-- `Source` to be used as swap space, and that it's enabled. swap :: Source -> Property Linux -swap src = (listed "swap" src "none" mempty) `onChange` (swapOn src) - --- This use of mountPoints, which is linux-only, is why this --- property currently only supports linux. -mountNow :: Source -> RevertableProperty Linux Linux -mountNow mnt = tightenTargets domount tightenTargets doumount - where domount = check (notElem mnt <$> mountPoints) $ - cmdProperty "mount" [mnt] - doumount = check (elem mnt <$> mountPoints) $ - cmdProperty "umount" [mnt] - -swapOn :: Source -> RevertableProperty Linux Linux -swapOn mnt = tightenTargets doswapon tightenTargets doswapoff - where swaps = lines <$> readProcess "swapon" ["--no-headings", "--show=NAME"] - doswapon = check (notElem mnt <$> swaps) $ - cmdProperty "swapon" [mnt] - doswapoff = check (elem mnt <$> swaps) $ - cmdProperty "swapoff" [mnt] +swap src = listed "swap" src "none" mempty + `onChange` swapOn src newtype SwapPartition = SwapPartition FilePath diff --git a/src/Propellor/Property/Mount.hs b/src/Propellor/Property/Mount.hs index 026509a9..5dcc5fe1 100644 --- a/src/Propellor/Property/Mount.hs +++ b/src/Propellor/Property/Mount.hs @@ -40,6 +40,9 @@ formatMountOpts (MountOpts []) = "defaults" formatMountOpts (MountOpts l) = intercalate "," l -- | Mounts a device, without listing it in . +-- +-- Note that this property will fail if the device is already mounted +-- at the MountPoint. mounted :: FsType -> Source -> MountPoint -> MountOpts -> Property UnixLike mounted fs src mnt opts = property (mnt ++ " mounted") $ toResult <$> liftIO (mount fs src mnt opts) @@ -52,6 +55,17 @@ bindMount src dest = tightenTargets $ `assume` MadeChange `describe` ("bind mounted " ++ src ++ " to " ++ dest) +-- | Enables swapping to a device, which must be formatted already as a swap +-- partition. +swapOn :: Source -> RevertableProperty Linux Linux +swapOn mnt = tightenTargets doswapon tightenTargets doswapoff + where + swaps = lines <$> readProcess "swapon" ["--show=NAME"] + doswapon = check (notElem mnt <$> swaps) $ + cmdProperty "swapon" [mnt] + doswapoff = check (elem mnt <$> swaps) $ + cmdProperty "swapoff" [mnt] + mount :: FsType -> Source -> MountPoint -> MountOpts -> IO Bool mount fs src mnt opts = boolSystem "mount" $ [ Param "-t", Param fs -- cgit v1.2.3