Skip to content

Instantly share code, notes, and snippets.

@samdoran
Created July 12, 2017 14:59
Show Gist options
  • Save samdoran/a6e75762b64e7ddaaa8c84f99796a9cc to your computer and use it in GitHub Desktop.
Save samdoran/a6e75762b64e7ddaaa8c84f99796a9cc to your computer and use it in GitHub Desktop.
Get a list of task files and run them
- hosts: somehosts
become: yes
tasks:
- name: Get list of task files
find:
paths: /opt/ansible/tasks
patterns: '*.yml'
register: _task_files
- name: Include tasks
include: "{{ task_file.path }}.yml"
loop_control:
loop_var: task_file
with_items: "{{ _task_files.files }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment