When executing the playbook with -t level1-memberserver, the file prelim.yml is skipped because the include task in main.yml it isn't tagged - always, but rather tagged prelim_tasks.
- name: Include the preliminary tasks
ansible.builtin.include_tasks: prelim.yml
tags:
- prelim_tasks
Skipping the tasks in this file, causes the variable windows_installation_type to not be defined and the playbook fails on 2.2.33 | PATCH | Ensure Increase scheduling priority is set to Administrators Window ManagerWindow Manager Group during a lookup of that variable.
The workaround for this is to run the playbook with -t level1-memberserver,prelim_tasks,untagged. It's necessary to add untagged because the tasks in the prelim.yml file are not tagged, so while -t level1-memberserver,prelim_tasks will include the file, it won't run any tasks within the file.
Expected Behavior
Using a tag in the playbook execution shouldn't exclude tasks in prelim.yml
Actual Behavior**
TASK [/home/user1/ansible/Windows-2019-CIS : 2.2.33 | PATCH | Ensure Increase scheduling priority is set to Administrators Window ManagerWindow Manager Group] *************************
fatal: [192.168.93.131]: FAILED! => {"msg": "The task includes an option with an undefined variable. The error was: {{ [\"Administrators\"] if (windows_installation_type==\"Server Core\") else ([\"Administrators\",\"Window Manager\\Window Manager Group\"]) }}: 'windows_installation_type' is undefined. 'windows_installation_type' is undefined. {{ [\"Administrators\"] if (windows_installation_type==\"Server Core\") else ([\"Administrators\",\"Window Manager\\Window Manager Group\"]) }}: 'windows_installation_type' is undefined. 'windows_installation_type' is undefined\n\nThe error appears to be in '/home/user1/ansible/Windows-2019-CIS/tasks/section02.yml': line 490, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: \"2.2.33 | PATCH | Ensure Increase scheduling priority is set to Administrators Window ManagerWindow Manager Group\"\n ^ here\n"}
Environment (please complete the following information)
Ansible Version: 2.14.4
Host Python Version: 3.9.16
Ansible Server Python Version: 3.9.16
Target server details: Windows Server 2019
Additional Details:
Additional Notes
Anything additional goes here
Possible Solution
Not sure if there are use cases where you wouldn't want the prelim tasks tasks to run, but if there aren't any, tasks in prelim.yml should be tagged - always
Describe the Issue
When executing the playbook with
-t level1-memberserver
, the file prelim.yml is skipped because the include task in main.yml it isn't tagged- always
, but rather tagged prelim_tasks.Skipping the tasks in this file, causes the variable windows_installation_type to not be defined and the playbook fails on
2.2.33 | PATCH | Ensure Increase scheduling priority is set to Administrators Window ManagerWindow Manager Group
during a lookup of that variable.The workaround for this is to run the playbook with
-t level1-memberserver,prelim_tasks,untagged
. It's necessary to add untagged because the tasks in the prelim.yml file are not tagged, so while-t level1-memberserver,prelim_tasks
will include the file, it won't run any tasks within the file.Expected Behavior
Using a tag in the playbook execution shouldn't exclude tasks in prelim.yml
Actual Behavior**
Environment (please complete the following information)
Additional Notes
Anything additional goes here
Possible Solution
Not sure if there are use cases where you wouldn't want the prelim tasks tasks to run, but if there aren't any, tasks in prelim.yml should be tagged
- always