Skip to content

Dynamic vars_files inclusion in chapter 5 'Playbook Variables' example broken #245

@geerlingguy

Description

@geerlingguy

The way that vars_files are included probably changed somewhere in the Ansible 2.x lifecycle, rendering the example in the book a bit broken.

The playbook is:

---
- hosts: example
  vars_files:
    - "apache_default.yml"
    - "apache_{{ ansible_os_family }}.yml"
  tasks:
    - service: name={{ apache }} state=running

But that doesn't work.

Instead, we used include_vars in today's livestream, with with_first_found, which worked a bit better. I need to update that example in the book so it works correctly and doesn't mislead readers.

Also ansible_os_family is not CentOS, it's RedHat, on Cent OS (ansible_distribution is CentOS, however).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions