Affects Version/s: None
Fix Version/s: None
- Puppet resource commands should detect existing tasks with logon triggers
- Should be able to CRUD tasks with logon triggers
- Should have spec tests for the trigger type
- Should have an acceptance test to create and delete the trigger
Sprint:Windows 2018-08-15, Windows 2018-08-22
QA Risk Assessment:Needs Assessment
Similar to adding support for the boot trigger (as implemented in
MODULES-6267 / PR https://github.com/puppetlabs/puppetlabs-scheduled_task/pull/42), support should be added for the logon trigger.
After refactoring is complete from
MODULES-7463, the number of files in the project is reduced to:
- the scheduled_task type, which should have a minor doc / example added where the other schedule types are inline documented - see https://github.com/puppetlabs/puppetlabs-scheduled_task/blob/991bf4a49804e5932772615214312fd29aff2461/lib/puppet/type/scheduled_task.rb#L119-L190
- the two providers, which should not require modification
- task api integration / support files
- error.rb - no mods required
- task.rb - no mods required
- trigger.rb - modifications should only be necessary here
In addition to adding the new schedule type logon, support must be added for the UserId property of the COM ILogonTrigger interface. The new trigger hash value should be called either user or user_id. Note that we will not be adding support for the Delay value at this time (as it's pertinent to more trigger types and that's ticketed / slated for a later release as part of MODULES-7215)
A mapping of manifest -> ITrigger is in table form at https://gist.github.com/Iristyle/58ff446bd3f60e68d52df3868c917a0e
To support the additional type requires modifying the trigger classes Manifest and Type such that:
- The Manifest class understands a schedule of logon as it understands other schedule types like once. This is stored in the ValidScheduleKeys array.
- The Manifest hash understands a key of user as it understands other values. This is stored in the ValidKeys array.
- The Manifest method canonicalize_and_validate performs correct validation over the new schedule type of logon and requires user as a mandatory field.
- The Type class includes Type::TASK_TRIGGER_LOGON in the EVENT_BASED_TRIGGER_MAP
- The Type method to_manifest_hash must properly set the schedule type and copy the UserId value from the ITrigger instance
- The Type method append_trigger must properly set the UserId value on the new ITrigger instance based on what was set in the manifest
While demoing the code base, a quick incomplete spike that doesn't include docs or tests was put together at https://github.com/Iristyle/puppetlabs-scheduled_task/commit/45da6e4f980a34d4c62cde825cb66af9e250c3d8
In addition task_spec.rb should be modified so that it no longer ignores logon and some modifications should be made to the tests in trigger_spec.rb validation.
Once implemented, a manifest like the following should behave be able to create / modify a logon task, should behave idempotently, etc.
A task that sets compatibility => 1 like the following should fail I believe (but worth testing to observe behavior)