From 58553acacc151aa73ceb812722372c4ce602416d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 26 Jan 2017 02:47:58 -0400 Subject: response --- .../comment_1_082e5d5b8e25335bc90577abcfef1d21._comment | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 doc/forum/Inherited_Variables.../comment_1_082e5d5b8e25335bc90577abcfef1d21._comment (limited to 'doc/forum/Inherited_Variables...') diff --git a/doc/forum/Inherited_Variables.../comment_1_082e5d5b8e25335bc90577abcfef1d21._comment b/doc/forum/Inherited_Variables.../comment_1_082e5d5b8e25335bc90577abcfef1d21._comment new file mode 100644 index 00000000..e4b32398 --- /dev/null +++ b/doc/forum/Inherited_Variables.../comment_1_082e5d5b8e25335bc90577abcfef1d21._comment @@ -0,0 +1,15 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 1""" + date="2017-01-26T06:39:35Z" + content=""" +This is where propellor's `Info` system comes in. `Propellor.Info.getOS` +can be run to get the OS info. + +It's also possible to add new properties that add new values with custom +types to `Info`. + +The hostname is not currently stored in `Info`, but it probably should be; +that would be a good simplification. Currently there's a +separate way to get the hostname: `asks hostName` (run in the Propellor monad) +"""]] -- cgit v1.3-2-g0d8e From 81a51f728bc021ac6f0cbf227a39682439196b32 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 26 Jan 2017 02:54:00 -0400 Subject: example --- .../comment_2_988319ed6de46eff2eac0d5ef36382f9._comment | 15 +++++++++++++++ src/Propellor/Property/.Sbuild.hs.swp | Bin 0 -> 16384 bytes 2 files changed, 15 insertions(+) create mode 100644 doc/forum/Inherited_Variables.../comment_2_988319ed6de46eff2eac0d5ef36382f9._comment create mode 100644 src/Propellor/Property/.Sbuild.hs.swp (limited to 'doc/forum/Inherited_Variables...') diff --git a/doc/forum/Inherited_Variables.../comment_2_988319ed6de46eff2eac0d5ef36382f9._comment b/doc/forum/Inherited_Variables.../comment_2_988319ed6de46eff2eac0d5ef36382f9._comment new file mode 100644 index 00000000..676f41ac --- /dev/null +++ b/doc/forum/Inherited_Variables.../comment_2_988319ed6de46eff2eac0d5ef36382f9._comment @@ -0,0 +1,15 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 2""" + date="2017-01-26T06:50:39Z" + content=""" +A worked example: + + server :: Property Debian + server = property' "some description" $ \w -> do + os <- getOS + hostname <- asks hostName + ensureProperty w $ + File.hasContent "/etc/apt/sources.list.d/matrix.list" + (genSourcesList os hostname) +"""]] diff --git a/src/Propellor/Property/.Sbuild.hs.swp b/src/Propellor/Property/.Sbuild.hs.swp new file mode 100644 index 00000000..a361c431 Binary files /dev/null and b/src/Propellor/Property/.Sbuild.hs.swp differ -- cgit v1.3-2-g0d8e From 394ca458814a63a24f53e78e536d223b768db5e2 Mon Sep 17 00:00:00 2001 From: craige Date: Fri, 27 Jan 2017 21:54:45 +0000 Subject: Added a comment: Thanks! --- .../comment_3_acf78fa9f732f070bf73c2ab601464ee._comment | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 doc/forum/Inherited_Variables.../comment_3_acf78fa9f732f070bf73c2ab601464ee._comment (limited to 'doc/forum/Inherited_Variables...') diff --git a/doc/forum/Inherited_Variables.../comment_3_acf78fa9f732f070bf73c2ab601464ee._comment b/doc/forum/Inherited_Variables.../comment_3_acf78fa9f732f070bf73c2ab601464ee._comment new file mode 100644 index 00000000..fcdf923b --- /dev/null +++ b/doc/forum/Inherited_Variables.../comment_3_acf78fa9f732f070bf73c2ab601464ee._comment @@ -0,0 +1,8 @@ +[[!comment format=mdwn + username="craige" + avatar="http://cdn.libravatar.org/avatar/64ac5816ea3a51347d1f699022d1fdc1" + subject="Thanks!" + date="2017-01-27T21:54:45Z" + content=""" +Thanks Joey. I think that's exactly what I need. Very helpful :-) +"""]] -- cgit v1.3-2-g0d8e From 6b085cf6ecd379ca446e850b9967f21433bd7102 Mon Sep 17 00:00:00 2001 From: "craige@a46118dff5bc0fad85259759970d8b4b9fc377d7" Date: Fri, 3 Feb 2017 00:04:05 +0000 Subject: Added a comment --- ...ment_4_5bf7b1f69b48b4d9c516d424e4438208._comment | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 doc/forum/Inherited_Variables.../comment_4_5bf7b1f69b48b4d9c516d424e4438208._comment (limited to 'doc/forum/Inherited_Variables...') diff --git a/doc/forum/Inherited_Variables.../comment_4_5bf7b1f69b48b4d9c516d424e4438208._comment b/doc/forum/Inherited_Variables.../comment_4_5bf7b1f69b48b4d9c516d424e4438208._comment new file mode 100644 index 00000000..3b691b2a --- /dev/null +++ b/doc/forum/Inherited_Variables.../comment_4_5bf7b1f69b48b4d9c516d424e4438208._comment @@ -0,0 +1,21 @@ +[[!comment format=mdwn + username="craige@a46118dff5bc0fad85259759970d8b4b9fc377d7" + nickname="craige" + avatar="http://cdn.libravatar.org/avatar/6d2207226de755da46aa2fdff9af70b2" + subject="comment 4" + date="2017-02-03T00:04:05Z" + content=""" +Ugh, sorry to ask again but I'm specifically stuck trying to extract the Debian suite only from this. Is this stored as a specific value I can draw on? I've been wading through the source and added in a swag of trial and error with no luck. + +I can see the suite listed in the output + + Just (System (Debian Linux (Stable \"jessie\")) + +but I was wondering if there was a method to pull out just the suite code name (ie: \"jessie\") that did not involve a regex looking for it amongst that output. + +The goal is to query Info so that a suite name can be added to a sources list. + +If I have to regex, that's OK, I just didn't want to go down that path if there was a smarted way. + +Thanks Joey :-) +"""]] -- cgit v1.3-2-g0d8e From b52c37df64ab2a3e261c7f9daba9e7b812e55706 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 3 Feb 2017 15:42:21 -0400 Subject: response --- ...mment_5_6fbd29f568ec8b97be47874e2aac57a3._comment | 20 ++++++++++++++++++++ src/Propellor/Property.hs | 4 ++-- 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 doc/forum/Inherited_Variables.../comment_5_6fbd29f568ec8b97be47874e2aac57a3._comment (limited to 'doc/forum/Inherited_Variables...') diff --git a/doc/forum/Inherited_Variables.../comment_5_6fbd29f568ec8b97be47874e2aac57a3._comment b/doc/forum/Inherited_Variables.../comment_5_6fbd29f568ec8b97be47874e2aac57a3._comment new file mode 100644 index 00000000..16819bd6 --- /dev/null +++ b/doc/forum/Inherited_Variables.../comment_5_6fbd29f568ec8b97be47874e2aac57a3._comment @@ -0,0 +1,20 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 5""" + date="2017-02-03T19:32:58Z" + content=""" +What you're looking for is not a regexp, but Haskell's [pattern +matching](https://www.haskell.org/tutorial/patterns.html). + +For example: + + myproperty :: Property Debian + myproperty = withOS "some desc here" $ \w o -> case o of + -- Pattern match on the OS, to get the Debian stable release + (Just (System (Debian _kernel (Stable release)) _arch)) -> + ensureProperty w $ Apt.setSourcesListD (sourcesLines release) "mysources" + _ -> unsupportedOS + + sourcesLines :: Release -> [Line] + sourcesLines release = undefined +"""]] diff --git a/src/Propellor/Property.hs b/src/Propellor/Property.hs index 06145333..7860a3df 100644 --- a/src/Propellor/Property.hs +++ b/src/Propellor/Property.hs @@ -308,8 +308,8 @@ pickOS a b = c `addChildren` [toChildProperty a, toChildProperty b] -- -- > myproperty :: Property Debian -- > myproperty = withOS "foo installed" $ \w o -> case o of --- > (Just (System (Debian (Stable release)) arch)) -> ensureProperty w ... --- > (Just (System (Debian suite) arch)) -> ensureProperty w ... +-- > (Just (System (Debian kernel (Stable release)) arch)) -> ensureProperty w ... +-- > (Just (System (Debian kernel suite) arch)) -> ensureProperty w ... -- > _ -> unsupportedOS' -- -- Note that the operating system specifics may not be declared for all hosts, -- cgit v1.3-2-g0d8e