Jira (PUP-6485) make it easier to require based on tag

5 views
Skip to first unread message

R.I.Pienaar (JIRA)

unread,
Jul 9, 2016, 3:08:03 AM7/9/16
to puppe...@googlegroups.com
R.I.Pienaar created an issue
 
Puppet / Bug PUP-6485
make it easier to require based on tag
Issue Type: Bug Bug
Assignee: Unassigned
Created: 2016/07/09 12:07 AM
Priority: Normal Normal
Reporter: R.I.Pienaar

At present you can do like:

package{"foo": tag => bar}
file{"/foo": }
 
Package<| tag == "bar" |> -> File["/foo"]

I am not aware though of a way to express this relationship inside the file resource, I tried a few things but this seems like it would be nice:

file{"/foo":
  require => Package <| tag == "bar" |>
}

This strikes me as a more natural looking fit than above and involves less typing etc, of course you should ideally stick these packages in a class and require the class, but this is not really feasable when you are using defined types.

This fails though with

Error: Could not parse for environment production: Invalid use of expression. A Virtual Query does not produce a value

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v6.4.13#64028-sha1:b7939e9)
Atlassian logo

R.I.Pienaar (JIRA)

unread,
Jul 9, 2016, 3:17:05 AM7/9/16
to puppe...@googlegroups.com
R.I.Pienaar updated an issue
Change By: R.I.Pienaar
At present you can do like:

{code}
$packages.each |$ package | { "foo"
  package{$package
: tag => bar , ensure => present }
}

file{"/foo": }

Package<| tag == "bar" |> -> File["/foo"]
{code}


I am not aware though of a way to express this relationship inside the file resource, I tried a few things but this seems like it would be nice:

{code}

file{"/foo":
  require => Package <| tag == "bar" |>
}
{code}


This strikes me as a more natural looking fit than above and involves less typing etc, of course you should ideally stick these packages in a class and require the class, but this is not really feasable when you are using defined types.

This fails though with

{code}

Error: Could not parse for environment production: Invalid use of expression. A Virtual Query does not produce a value
{code}

Henrik Lindberg (JIRA)

unread,
Jul 10, 2016, 5:13:05 PM7/10/16
to puppe...@googlegroups.com
Henrik Lindberg commented on Bug PUP-6485
 
Re: make it easier to require based on tag

While not exactly the same - you could do:

{puppet:code}

$packages.each |$package| {
package{$package:
tag => bar, # not really needed
ensure => present,
before => File['/foo'],
}
}

file

{"/foo": }

 

Henrik Lindberg (JIRA)

unread,
Jul 10, 2016, 5:17:02 PM7/10/16
to puppe...@googlegroups.com

Queries cannot produce a value - they run very late in the compilation process. We need to change what queries are in that case.

You can also map, all of the produced resouces - like this:

$tmp = $packages.map |$package| {
  package{$package: 
    ensure => present,
  }
}
file{"/foo": }
$tmp -> File['/foo']

Henrik Lindberg (JIRA)

unread,
Jul 10, 2016, 5:19:09 PM7/10/16
to puppe...@googlegroups.com

I probably mixed up require/before...

R.I.Pienaar (JIRA)

unread,
Jul 11, 2016, 2:57:03 AM7/11/16
to puppe...@googlegroups.com
R.I.Pienaar commented on Bug PUP-6485

thanks Henrik Lindberg, as is often the case my manifests are much more complex than what I showed, so many loops of packages etc all in conditionals - but I think with your suggestion I can figure it out. Did anticipate your answer would be about the late processing of queries, but maybe this can be kept open for some other language addition if not done exactly with queries (though they would be nice)

Henrik Lindberg (JIRA)

unread,
Jul 11, 2016, 5:40:06 PM7/11/16
to puppe...@googlegroups.com

We would like a query that is just that and that produces references to resources that you then operate on (like in this case, add dependencies on them).

The difficult issues are how to deal with late binding logic - now there is a precedence among them - it is far from perfect.

Henrik Lindberg (JIRA)

unread,
Jul 12, 2016, 5:03:06 AM7/12/16
to puppe...@googlegroups.com
Henrik Lindberg updated an issue
 
Change By: Henrik Lindberg
Scrum Team: Language

Henrik Lindberg (JIRA)

unread,
Sep 7, 2016, 6:12:32 PM9/7/16
to puppe...@googlegroups.com
Henrik Lindberg updated an issue
Change By: Henrik Lindberg
Team: Puppet Developer Support
This message was sent by Atlassian JIRA (v6.4.14#64029-sha1:ae256fe)
Atlassian logo

Moses Mendoza (JIRA)

unread,
May 16, 2017, 7:24:02 PM5/16/17
to puppe...@googlegroups.com
Moses Mendoza updated an issue
Change By: Moses Mendoza
Labels: triaged

Josh Cooper (JIRA)

unread,
Mar 16, 2018, 4:41:03 PM3/16/18
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Team: Puppet Developer Experience Platform Core
This message was sent by Atlassian JIRA (v7.7.1#77002-sha1:e75ca93)
Atlassian logo

Josh Cooper (JIRA)

unread,
Mar 16, 2018, 4:41:03 PM3/16/18
to puppe...@googlegroups.com
Josh Cooper updated an issue
Change By: Josh Cooper
Sub-team: Language

David McTavish (Jira)

unread,
Dec 6, 2021, 11:35:01 AM12/6/21
to puppe...@googlegroups.com
David McTavish updated an issue
 
Puppet / Improvement PUP-6485
Change By: David McTavish
Issue Type: Bug Improvement
This message was sent by Atlassian Jira (v8.13.2#813002-sha1:c495a97)
Atlassian logo

David McTavish (Jira)

unread,
Dec 6, 2021, 11:35:03 AM12/6/21
to puppe...@googlegroups.com
David McTavish updated an issue
Change By: David McTavish
Labels: final_triage

David McTavish (Jira)

unread,
Dec 6, 2021, 1:33:02 PM12/6/21
to puppe...@googlegroups.com
David McTavish updated an issue
Change By: David McTavish
Priority: Normal Low

Yan Fitterer (Jira)

unread,
Jun 23, 2022, 9:09:02 AM6/23/22
to puppe...@googlegroups.com
Yan Fitterer commented on Improvement PUP-6485
 
Re: make it easier to require based on tag

david.mctavish I'd like to upvote this feature (I landed on this issue after trying it out thinking it may work, and getting the same error). Is this comment sufficient, or are feature requests tracked elsewhere ?

This message was sent by Atlassian Jira (v8.20.2#820002-sha1:829506d)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages