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)"What I have:
roles/base/tasks/main.yaml:
---
## PLAYBOOK TO INSTALL AND CONFIGURE NTP ON REDHAT/ DEBIAN SYSTEMS
- name: Include OS-specific variables
include_vars: "{{ ansible_distribution }}.yaml"
- include: redhat-ntp.yaml
when: ansible_distribution|lower == 'redhat'
- include: debian-ntp.yaml
when: ansible_distribution|lower == 'debian'
- include: sles-ntp.yaml
when: ansible_distribution|lower == 'sles'
- include: ubuntu-ntp.yaml
when: ansible_distribution|lower == 'ubuntu'
- name: Set the correct timezone
file: src={{ ntp_timezone }} dest=/etc/localtime state=link force=yes
- name: Configure NTP
template: src={{ item }} dest={{ ntp_config }}
with_first_found:
- "../templates/{{ ansible_distribution }}-{{ ansible_distribution_version }}.ntp.conf.j2"
- "../templates/{{ ansible_distribution }}.ntp.conf.j2"
- "../templates/{{ ansible_os_family }}.ntp.conf.j2"
- "../templates/ntp.conf.j2"
#- name: Restart NTP
## service: name={{ ntp_service }} state=restarted
#
- name: Force NTP update
shell: "service {{ ntp_service }} stop && ntpdate -s {{ ntpdate_server }} && service {{ ntp_service }} start"
...
roles/base/tasks/ntp.yaml:
---
- hosts: all
remote_user: root
tasks:
- name: Detect OS and run appropriate tasks
include_tasks: "{{ ansible_distribution }}-ntp.yaml"
roles/base/tasks/debian-ntp.yaml:
---
- name: Ensure NTP packages are installed (debian).
apt: "name={{ ntp_package }} state=installed"
roles/base/tasks/redhat-ntp.yaml:
---
- name: Ensure NTP packages are installed (redhat).
yum: "name={{ ntp_package }} state=installed"
roles/base/tasks/sles-ntp.yaml:
---
- name: Ensure NTP packages are installed (sles).
zypper: "name={{ ntp_package }} state=installed"
roles/base/tasks/ubuntu-ntp.yaml:
---
- name: Ensure NTP packages are installed (ubuntu).
apt: "name={{ ntp_package }} state=installed"
Should install and configure ntp on all (RedHat, SLES, Debian, Ubuntu).
Error:
TASK [Detect OS and run appropriate tasks] ****************************************************************************************************************************** fatal: [ablrh7ex6499]: FAILED! => {"reason": "Could not find or access '/home/jamekeit/ds9/roles/base/tasks/RedHat-ntp.yaml' on the Ansible Controller."} fatal: [abls15ex8401]: FAILED! => {"reason": "Could not find or access '/home/jamekeit/ds9/roles/base/tasks/SLES-ntp.yaml' on the Ansible Controller."} fatal: [abldeb8ex6658]: FAILED! => {"reason": "Could not find or access '/home/jamekeit/ds9/roles/base/tasks/Debian-ntp.yaml' on the Ansible Controller."}
I don't understand why I'm getting this because I have all the files on the Ansible Controller (debian-ntp.yaml, redhat-ntp.yaml, sles-ntp.yaml, ubuntu-ntp.yaml)
--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/977898a1-60cf-482c-beec-bd36834d4101%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
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.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?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"
To unsubscribe from this group and stop receiving emails from it, send an email to ansible...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/977898a1-60cf-482c-beec-bd36834d4101%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
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"
To unsubscribe from this group and stop receiving emails from it, send an email to ansible...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/977898a1-60cf-482c-beec-bd36834d4101%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
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"
To unsubscribe from this group and stop receiving emails from it, send an email to ansible...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/977898a1-60cf-482c-beec-bd36834d4101%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.