Skip to content

Instantly share code, notes, and snippets.

@wdennis
Created March 17, 2021 03:50
Show Gist options
  • Save wdennis/ea2a97a994b0c78d6372fb8875acce8a to your computer and use it in GitHub Desktop.
Save wdennis/ea2a97a994b0c78d6372fb8875acce8a to your computer and use it in GitHub Desktop.
---
- name: Fail if OS is not Ubuntu
fail:
msg: "This role only supports Ubuntu Linux currently."
when: (ansible_distribution != "Ubuntu")
- name: Run Ubuntu 16.04 tasks
include_tasks: Ubuntu-16.04.yml
when: (ansible_distribution == "Ubuntu" and ansible_distribution_version == "16.04")
register: run_1604
- name: Run Ubuntu 18.04 tasks
include_tasks: Ubuntu-18.04.yml
when: (ansible_distribution == "Ubuntu" and ansible_distribution_version == "18.04")
register: run_1804
- debug:
msg: "{{ [run_1604, run_1804] | reject('skipped') | list }}"
- name: Fail if distro version does not match supported versions
fail:
msg: "This role does not yet support this version of Ubuntu."
when: not ([run_1604, run_1804] | reject('skipped') | list)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment