Created
May 9, 2018 18:04
-
-
Save lrvick/fa44015cf56586de1214f99e04d26103 to your computer and use it in GitHub Desktop.
Ansible pattern for multi-os configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- hosts: all | |
become: yes | |
become_user: "{{ lookup('env','SUDO_USER') }}" | |
tasks: | |
- name: Display OS Details | |
block: | |
- debug: | |
var: ansible_distribution | |
verbosity: 1 | |
- debug: | |
var: ansible_distribution_major_version | |
verbosity: 1 | |
- name: Display all variables/facts known for a host | |
debug: | |
var: hostvars[inventory_hostname] | |
verbosity: 4 | |
- name: Include OS specific tasks | |
include_tasks: "{{ os_item }}" | |
with_first_found: | |
- "tasks/{{ ansible_distribution | lower }}-{{ ansible_distribution_major_version}}.yml" | |
- "tasks/{{ ansible_distribution | lower }}.yml" | |
tags: vars | |
loop_control: | |
loop_var: os_item |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment