Affects Version/s: None
Fix Version/s: PUP 5.2.0
Sprint:Org Scale Red Team 2017-08-22, Org Scale Red Team 2017-09-05
Release Notes:Not Needed
QA Risk Assessment:Needs Assessment
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
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")
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.
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"
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.