Ansible NTP Install/Config

I am new to Ansible!

I’m working on an NTP Install/Configure Project. I have a main.yaml file, a ntp.yaml playbook and 4 tasks (debian-ntp.yaml, redhat-ntp.yaml, sles-ntp.yaml, ubuntu-ntp.yaml). I can’t seem to get this to work.

ansible --version
ansible 2.8.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/kjames/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/site-packages/ansible
  executable location = /usr/bin/ansible
  python version = 2.7.5 (default, Apr  9 2019, 14:30:50) [GCC 4.8.5 20150623 (Red Hat 4.8.5-36)]

cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"

Your files are lower cased, ansible_distribution is not.

To match your other logic, you probably want to do this:

include_tasks: “{{ ansible_distribution|lower }}-ntp.yaml”

This is what I know:

RedHat, Debian, SLES… returned by ansible_distribution all have capitals somewhere in the naming, as you can see in the error message. My files are all lowercase. I have checked and there are no capitals in my naming.

In my playbook include_tasks: "{{ ansible_distribution }}-ntp.yaml" is the reason for the error. Either I can fix my file names to match mixed case returned by the variable or turn everything to lower case with the lower filter as it is done elsewhere in my tasks files. I don’t know how to do either of these! I’ve tried with the lower filter but I still get the same error. I don’t know how to use the match mixed case. Can someone please help?

I have used include_tasks: “{{ ansible_distribution|lower }}-ntp.yaml” but I get the same error

That worked!

Now I’m getting:

fatal: [xxxxxxxxx]: FAILED! => {“msg”: "The task includes an option with an undefined variable. The error was: ‘ntp_package’ is undefined