Как настроить NTP на RedHat, SLES, Debian и Ubuntu? - PullRequest
0 голосов
/ 09 июля 2019

Я новичок в Ansible!

Я работаю над проектом установки / настройки NTP. У меня есть файл main.yaml, playbook ntp.yaml и 4 задания (debian-ntp.yaml, redhat-ntp.yaml, sles-ntp.yaml, ubuntu-ntp.yaml). Я не могу заставить это работать.

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)"

Что у меня есть:

Роли / база / задачи / 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"
    ...

Роли / база / задачи / ntp.yaml:

---
- hosts: all
  remote_user: root

  tasks:
  - name: Detect OS and run appropriate tasks
    include_tasks: "{{ ansible_distribution }}-ntp.yaml"

Роли / база / задачи / Debian-ntp.yaml:

---
- name: Ensure NTP packages are installed (debian).
  apt: "name={{ ntp_package }} state=installed"

роли / базовые / задачи / RedHat-ntp.yaml:

---
- name: Ensure NTP packages are installed (redhat).
  yum: "name={{ ntp_package }} state=installed"

роли / базовые / задачи / SLES-ntp.yaml:

---
- name: Ensure NTP packages are installed (sles).
  zypper: "name={{ ntp_package }} state=installed"

Роли / база / задачи / убунту-ntp.yaml:

---
- name: Ensure NTP packages are installed (ubuntu).
  apt: "name={{ ntp_package }} state=installed"

Следует установить и настроить ntp на всех (RedHat, SLES, Debian, Ubuntu).

Ошибка:

TASK [Определить ОС и запустить соответствующие задачи] ************************************** ************************************************** ************************************** фатально: [ablrh7ex6499]: СБОЙ! => {"причина": "Не удалось найти или получить доступ к '/home/jamekeit/ds9/roles/base/tasks/RedHat-ntp.yaml' на Ansible Controller."} фатально: [abls15ex8401]: СБОЙ! => {"причина": "Не удалось найти или получить доступ к '/home/jamekeit/ds9/roles/base/tasks/SLES-ntp.yaml' на Ansible Controller."} фатально: [abldeb8ex6658]: не удалось! => {"причина": "Не удалось найти или получить доступ к '/home/jamekeit/ds9/roles/base/tasks/Debian-ntp.yaml' на Ansible Controller."}

Я не понимаю, почему я получаю это, потому что у меня есть все файлы на Ansible Controller (debian-ntp.yaml, redhat-ntp.yaml, sles-ntp.yaml, ubuntu-ntp.yaml)

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...