Anderson, Craig (ca846m) 9f71952feb osconfig cleanup
This patchset allows users to select the context in which certain
osconfig tasks run, rather than a hard-coded assumption.

It also adds scripts directories which are run in these contexts.

Change-Id: I695c3078b4d883a506c243bc715a509f6844c126
2021-02-24 00:04:33 -08:00

26 lines
1.1 KiB
YAML

# Execute scripts defined in the playbook
- name: "user-scripts | running user-defined scripts"
shell: "{{ item.file_content }}"
loop: "{{ user_scripts }}"
when: run_context in item.run_contexts
- name: "user-scripts | check for common scripts dir"
stat:
path: "{{ user_scripts_dir_default }}"
register: common_stat_result
- name: "user-scripts | check for qcow scripts dir"
stat:
path: "{{ user_scripts_dir_qcow }}"
register: qcow_stat_result
# Bulk-execute scripts in the scripts directory
- name: "user-scripts | running additional user-defined scripts"
shell: for s in $(find "{{ user_scripts_dir_default }}" -maxdepth 1 -type f | grep -v README.md | sort); do chmod 755 $s; eval $s; done
when: run_context == default_run_context and common_stat_result.stat.exists
# Bulk-execute scripts in the scripts directory
- name: "user-scripts | running additional user-defined scripts"
shell: for s in $(find "{{ user_scripts_dir_qcow }}" -maxdepth 1 -type f | grep -v README.md | sort); do chmod 755 $s; eval $s; done
when: run_context == qcow_run_context and qcow_stat_result.stat.exists