From 353d4bb0cfe3d15e38ad668f424de69d6e6fe925 Mon Sep 17 00:00:00 2001 From: nazunalika Date: Sun, 13 Dec 2020 23:57:25 -0700 Subject: [PATCH] fixing issue #582 --- .../group_vars/chronyclients/main.yml | 3 -- ansible/inventories/production/hosts.ini | 6 ++-- ansible/playbooks/init-rocky-chrony.yml | 28 +++++++++++++++++++ ansible/playbooks/tasks/chrony.yml | 6 ++++ ansible/playbooks/vars/RedHat.yml | 2 -- ansible/playbooks/vars/chrony.yml | 5 ++-- ansible/playbooks/vars/chronyserver.yml | 9 ++++++ 7 files changed, 47 insertions(+), 12 deletions(-) delete mode 100644 ansible/inventories/production/group_vars/chronyclients/main.yml create mode 100644 ansible/playbooks/vars/chronyserver.yml diff --git a/ansible/inventories/production/group_vars/chronyclients/main.yml b/ansible/inventories/production/group_vars/chronyclients/main.yml deleted file mode 100644 index fbae2d9..0000000 --- a/ansible/inventories/production/group_vars/chronyclients/main.yml +++ /dev/null @@ -1,3 +0,0 @@ ---- - -chrony_timeservers = ["chrony001.rockylinux.com", "chrony002.rockylinux.com"] diff --git a/ansible/inventories/production/hosts.ini b/ansible/inventories/production/hosts.ini index a2c65e2..dfe102d 100644 --- a/ansible/inventories/production/hosts.ini +++ b/ansible/inventories/production/hosts.ini @@ -23,8 +23,6 @@ build-a-box ansible_host=10.100.1.112 idp001 ansible_host=10.100.x.x [chronyservers] -chronyd001 ansiblehost=10.100.3.110 -chronyd002 ansiblehost=10.200.3.111 +chrony001 ansiblehost=10.100.3.110 +chrony002 ansiblehost=10.200.3.111 -[chronyclients] -build-abox asnsiblehost=10.100.x.x diff --git a/ansible/playbooks/init-rocky-chrony.yml b/ansible/playbooks/init-rocky-chrony.yml index c2870c8..6482d08 100644 --- a/ansible/playbooks/init-rocky-chrony.yml +++ b/ansible/playbooks/init-rocky-chrony.yml @@ -2,10 +2,38 @@ # Sets Up Chrony Server/Client # Created: @derekmpage # Kudos: @danielkubat @Darkbat91 +# Fixes: @nazunalika - name: Rocky Chrony Runbook hosts: all become: true + vars_files: + - vars/chrony.yml + + # This is to try to avoid the handler issue in pre/post tasks + handlers: + - import_tasks: handlers/main.yml + + pre_tasks: + - name: Check if ansible cannot be run here + stat: + path: /etc/no-ansible + register: no_ansible + + - name: Verify if we can run ansible + assert: + that: + - "not no_ansible.stat.exists" + msg: "/etc/no-ansible exists - skipping run on this node" tasks: - name: Configure Chrony import_tasks: tasks/chrony.yml + + post_tasks: + - name: Touching run file that ansible has ran here + file: + path: /var/log/ansible.run + state: touch + mode: '0644' + owner: root + group: root diff --git a/ansible/playbooks/tasks/chrony.yml b/ansible/playbooks/tasks/chrony.yml index 0fa28fd..db72733 100644 --- a/ansible/playbooks/tasks/chrony.yml +++ b/ansible/playbooks/tasks/chrony.yml @@ -1,4 +1,10 @@ --- +- name: Create overrides if we're an IPA Replica + include_vars: "{{ item }}" + with_first_found: + - "chronyserver.yml" + when: "'chronyservers' in group_names" + - name: Install chrony packages yum: name: "{{ chrony_packages }}" diff --git a/ansible/playbooks/vars/RedHat.yml b/ansible/playbooks/vars/RedHat.yml index 9f6b27c..723005b 100644 --- a/ansible/playbooks/vars/RedHat.yml +++ b/ansible/playbooks/vars/RedHat.yml @@ -160,5 +160,3 @@ enable_svc: syslog_packages: - rsyslog -ntp_packages: - - chrony diff --git a/ansible/playbooks/vars/chrony.yml b/ansible/playbooks/vars/chrony.yml index 781b1f3..c390488 100644 --- a/ansible/playbooks/vars/chrony.yml +++ b/ansible/playbooks/vars/chrony.yml @@ -26,9 +26,8 @@ chrony_service_enabled: yes # default internet timeservers to use chrony_timeservers: - - 0.pool.ntp.org - - 1.pool.ntp.org - - 2.pool.ntp.org + - chrony001.rockylinux.com + - chrony002.rockylinux.com # is chrony ntp server - allows client connections chrony_server: false diff --git a/ansible/playbooks/vars/chronyserver.yml b/ansible/playbooks/vars/chronyserver.yml new file mode 100644 index 0000000..b2c7b63 --- /dev/null +++ b/ansible/playbooks/vars/chronyserver.yml @@ -0,0 +1,9 @@ +--- + +# default internet timeservers to use +chrony_timeservers: + - chrony001.rockylinux.com + - chrony002.rockylinux.com + +# is chrony ntp server - allows client connections +chrony_server: true