[PUP-7815] Modules can find and list all their tasks Created: 2017/08/02  Updated: 2017/09/14  Resolved: 2017/08/23

Status: Closed
Project: Puppet
Component/s: None
Affects Version/s: None
Fix Version/s: PUP 5.2.0

Type: Story Priority: Normal
Reporter: Dan Lidral-Porter Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Blocks
is blocked by PA-1401 Gettext fails to install from homebre... Closed
Cloners
Relates
Template:
Epic Link: Puppet Server API for Tasks
Team: Organizational Scale
Story Points: 3
Sprint: Org Scale Red Team 2017-08-22, Org Scale Red Team 2017-09-05
Release Notes: Not Needed
QA Risk Assessment: Needs Assessment

 Description   

This ticket covers giving modules the ability to list all the tasks that they contain. This involves:

  • finding all files in the tasks folders that do not end in '.conf' or '.md';
  • checking if every executable file not ending in '.json' (the 'executable file') has a matching metadata file with the same basename that does end in '.json' (the 'metadata file'):
    • if so, then each of those matching file pairs constitutes one task;
    • if not, each metadata file needs to be parsed to find the matching executable file, and any executable files left over that are not named by any metadata files are tasks that have no metadata;
  • returning an array of hashes with the files for each task: the executable file and (if it exists) the metadata file.
    Similar to https://github.com/puppetlabs/puppet/blob/ebd96213cab43bb2a8071b7ac0206c3ed0be8e58/lib/puppet/info_service.rb

Can be used to call from Clojure (Puppet server) so that the Puppet team can change the underlying implementation if we wish.

The new API:

  • Is defined in Puppet::InfoService that has class level methods that defines services

tasks_per_environment
A class level method `tasks_per_environment` that returns the names and modules of available tasks in the environment. Arguments: "environment_name" as a string (or a list of "environment_name")
Output:

 [{:module => {:name => "apache"}, :name => "apache::install"}, …]

If there are no tasks in the named environment, returns the empty array.
If the named environment does not exist, raises EnvironmentNotFound.

Note that no information about the task itself is returned (e.g. metadata or file information), so no files are read or statted; the only filesystem IO performed is directory scans of each modules' tasks directory.

task_data
A class level method that returns files associated with a given task. Returns absolute file path of task metadata if found (else nil) and returns list of absolute paths to any non-metadata files with the provided name (empty list if none). Files list excludes any files with .json, .md, .conf extensions.

Arguments: "environment_name", "module", "task_name"
Output:

{:metadata_file => "path/to/file/<task_name>.json",
 :files => ["path/to/file/<task_name>.exe", "path/to/file/<task_name>", ...]}

If the named module does not exist, raises Puppet::Module::MissingModule.

If the named environment does not exist, raises Puppet::Environments::EnvironmentNotFound.

If the named task does not exist, raises Puppet::Module::Task::TaskNotFound.

The path to the metadata file of a task should be retreivable from outside the task class; if no metadata file was provided when the task was created, it should be nil.



 Comments   
Comment by Henrik Lindberg [ 2017/08/03 ]

I think tasks should be represented by puppet data types. We then have all the loading, reflection, serialization, etc. already implemented. It also makes it possible to directly and without ambiguity refer to a task via its name.

Comment by Moses Mendoza [ 2017/08/15 ]

merged to puppet/master at https://github.com/puppetlabs/puppet/commit/0c94a921b8cb9bb65c5c42381ee013afa6976d10

Comment by Kenn Hussey [ 2017/08/21 ]

Moses Mendoza if a PR has been merged, should this issue be moved to 'Ready for CI', or is additional information/work required here?

Comment by Moses Mendoza [ 2017/08/21 ]

Kenn Hussey I'm not sure what the tasks team workflow is - this issue appears to have been in ready for ci and was moved to needs information later?

Comment by Dan Lidral-Porter [ 2017/08/22 ]

This is in 'Needs Information' to reflect it being blocked on puppet agent CI problems – the last passing puppet-agent build is from August 11th, before this was merged.

Comment by Kenn Hussey [ 2017/08/28 ]

Justin Holguin please add release notes for this issue, if needed.

Comment by Garrett Guillotte [ 2017/09/07 ]

> Justin Holguin please add release notes for this issue, if needed.

Please and thank you! I'm compiling release notes now.

Generated at Sat Dec 07 15:47:24 PST 2019 using JIRA 7.7.1#77002-sha1:e75ca93d5574d9409c0630b81c894d9065296414.