Browse Source

Merge pull request #1672 from jstuever/os_clocks

Add openshift_clock role
Jason DeTiberus 8 years ago
parent
commit
dc0d59545e

+ 2 - 0
inventory/byo/hosts.aep.example

@@ -409,6 +409,8 @@ openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true',
 # masterConfig.volumeConfig.dynamicProvisioningEnabled, configurable as of 1.2/3.2, enabled by default
 #openshift_master_dynamic_provisioning_enabled=False
 
+# Configure usage of openshift_clock role.
+#openshift_clock_enabled=true
 
 # host group for masters
 [masters]

+ 3 - 0
inventory/byo/hosts.origin.example

@@ -414,6 +414,9 @@ openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true',
 # masterConfig.volumeConfig.dynamicProvisioningEnabled, configurable as of 1.2/3.2, enabled by default
 #openshift_master_dynamic_provisioning_enabled=False
 
+# Configure usage of openshift_clock role.
+#openshift_clock_enabled=true
+
 # host group for masters
 [masters]
 ose3-master[1:3]-ansible.test.example.com

+ 3 - 0
inventory/byo/hosts.ose.example

@@ -410,6 +410,9 @@ openshift_master_identity_providers=[{'name': 'htpasswd_auth', 'login': 'true',
 # masterConfig.volumeConfig.dynamicProvisioningEnabled, configurable as of 1.2/3.2, enabled by default
 #openshift_master_dynamic_provisioning_enabled=False
 
+# Configure usage of openshift_clock role.
+#openshift_clock_enabled=true
+
 # host group for masters
 [masters]
 ose3-master[1:3]-ansible.test.example.com

+ 15 - 0
roles/openshift_clock/meta/main.yml

@@ -0,0 +1,15 @@
+---
+galaxy_info:
+  author: Jeremiah Stuever
+  description: OpenShift Clock
+  company: Red Hat, Inc.
+  license: Apache License, Version 2.0
+  min_ansible_version: 1.9
+  platforms:
+  - name: EL
+    versions:
+    - 7
+  categories:
+  - cloud
+dependencies:
+- { role: openshift_facts }

+ 14 - 0
roles/openshift_clock/tasks/main.yaml

@@ -0,0 +1,14 @@
+---
+- name: Set clock facts
+  openshift_facts:
+    role: clock
+    local_facts:
+      enabled: "{{ openshift_clock_enabled | default(None) }}"
+
+- name: Install ntp package
+  action: "{{ ansible_pkg_mgr }} name=ntp state=present"
+  when: openshift.clock.enabled | bool and not openshift.clock.chrony_installed | bool
+
+- name: Start and enable ntpd/chronyd
+  shell: timedatectl set-ntp true
+  when: openshift.clock.enabled | bool

+ 1 - 0
roles/openshift_etcd/meta/main.yml

@@ -13,6 +13,7 @@ galaxy_info:
   - cloud
 dependencies:
 - role: openshift_etcd_facts
+- role: openshift_clock
 - role: openshift_docker
   when: openshift.common.is_containerized | bool
 - role: etcd

+ 11 - 0
roles/openshift_facts/library/openshift_facts.py

@@ -1549,6 +1549,7 @@ class OpenShiftFacts(object):
             OpenShiftFactsUnsupportedRoleError:
     """
     known_roles = ['builddefaults',
+                   'clock',
                    'cloudprovider',
                    'common',
                    'docker',
@@ -1719,6 +1720,16 @@ class OpenShiftFacts(object):
                 docker['version'] = version_info['version']
             defaults['docker'] = docker
 
+        if 'clock' in roles:
+            exit_code, _, _ = module.run_command(['rpm', '-q', 'chrony'])
+            if exit_code == 0:
+                chrony_installed = True
+            else:
+                chrony_installed = False
+            defaults['clock'] = dict(
+                enabled=True,
+                chrony_installed=chrony_installed)
+
         if 'cloudprovider' in roles:
             defaults['cloudprovider'] = dict(kind=None)
 

+ 1 - 0
roles/openshift_master/meta/main.yml

@@ -12,6 +12,7 @@ galaxy_info:
   categories:
   - cloud
 dependencies:
+- role: openshift_clock
 - role: openshift_docker
 - role: openshift_cli
 - role: openshift_master_certificates

+ 1 - 0
roles/openshift_node/meta/main.yml

@@ -12,6 +12,7 @@ galaxy_info:
   categories:
   - cloud
 dependencies:
+- role: openshift_clock
 - role: openshift_docker
 - role: openshift_node_certificates
 - role: openshift_cloud_provider