]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
Cleanup plugins directories and references
authorAndy McCrae <andy.mccrae@gmail.com>
Tue, 13 Mar 2018 11:30:09 +0000 (11:30 +0000)
committerSébastien Han <seb@redhat.com>
Wed, 14 Mar 2018 10:15:39 +0000 (11:15 +0100)
Having callback_plugins, and action plugins in random locations causes
a lot of disparity.

We should centralize this into one place in the plugins directory and
fix up the ansible.cfg to reflect this.

Additionally, since the ansible.cfg already reflects action_plugins, we
don't need a link to action_plugins in the base of the repository.

action_plugins [deleted symlink]
ansible.cfg
callback_plugins/installer_checkpoint.py [deleted file]
infrastructure-playbooks/ansible.cfg
plugins/callback/installer_checkpoint.py [new file with mode: 0644]
tox.ini

diff --git a/action_plugins b/action_plugins
deleted file mode 120000 (symlink)
index 3ffd654..0000000
+++ /dev/null
@@ -1 +0,0 @@
-plugins/actions
\ No newline at end of file
index 486f1bddc1ade3df781638f2e0d53d644ba5f0e2..102e487087501e5a34c8924df0f2673c49c2979a 100644 (file)
@@ -4,6 +4,7 @@
 [defaults]
 ansible_managed = Please do not change this file directly since it is managed by Ansible and will be overwritten
 action_plugins = plugins/actions
+callback_plugins = plugins/callback
 roles_path = ./roles
 # Be sure the user running Ansible has permissions on the logfile
 log_path = /var/log/ansible.log
diff --git a/callback_plugins/installer_checkpoint.py b/callback_plugins/installer_checkpoint.py
deleted file mode 100644 (file)
index 65e4967..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-"""Ansible callback plugin to print a summary completion status of installation
-phases.
-"""
-from datetime import datetime
-from ansible.plugins.callback import CallbackBase
-from ansible import constants as C
-
-
-class CallbackModule(CallbackBase):
-    """This callback summarizes installation phase status."""
-
-    CALLBACK_VERSION = 2.0
-    CALLBACK_TYPE = 'aggregate'
-    CALLBACK_NAME = 'installer_checkpoint'
-    CALLBACK_NEEDS_WHITELIST = False
-
-    def __init__(self):
-        super(CallbackModule, self).__init__()
-
-    def v2_playbook_on_stats(self, stats):
-
-        # Set the order of the installer phases
-        installer_phases = [
-            'installer_phase_ceph_mon',
-            'installer_phase_ceph_mgr',
-            'installer_phase_ceph_agent',
-            'installer_phase_ceph_osd',
-            'installer_phase_ceph_mds',
-            'installer_phase_ceph_rgw',
-            'installer_phase_ceph_nfs',
-            'installer_phase_ceph_restapi',
-            'installer_phase_ceph_rbdmirror',
-            'installer_phase_ceph_client',
-            'installer_phase_ceph_iscsi_gw',
-        ]
-
-        # Define the attributes of the installer phases
-        phase_attributes = {
-            'installer_phase_ceph_mon': {
-                'title': 'Install Ceph Monitor',
-                'playbook': 'roles/ceph-mon/tasks/main.yml'
-            },
-            'installer_phase_ceph_mgr': {
-                'title': 'Install Ceph Manager',
-                'playbook': 'roles/ceph-mgr/tasks/main.yml'
-            },
-            'installer_phase_ceph_agent': {
-                'title': 'Install Ceph Agent',
-                'playbook': 'roles/ceph-agent/tasks/main.yml'
-            },
-            'installer_phase_ceph_osd': {
-                'title': 'Install Ceph OSD',
-                'playbook': 'roles/ceph-osd/tasks/main.yml'
-            },
-            'installer_phase_ceph_mds': {
-                'title': 'Install Ceph MDS',
-                'playbook': 'roles/ceph-mds/tasks/main.yml'
-            },
-            'installer_phase_ceph_rgw': {
-                'title': 'Install Ceph RGW',
-                'playbook': 'roles/ceph-rgw/tasks/main.yml'
-            },
-            'installer_phase_ceph_nfs': {
-                'title': 'Install Ceph NFS',
-                'playbook': 'roles/ceph-nfs/tasks/main.yml'
-            },
-            'installer_phase_ceph_restapi': {
-                'title': 'Install Ceph REST API',
-                'playbook': 'roles/ceph-restapi/tasks/main.yml'
-            },
-            'installer_phase_ceph_rbdmirror': {
-                'title': 'Install Ceph RBD Mirror',
-                'playbook': 'roles/ceph-rbd-mirror/tasks/main.yml'
-            },
-            'installer_phase_ceph_client': {
-                'title': 'Install Ceph Client',
-                'playbook': 'roles/ceph-client/tasks/main.yml'
-            },
-            'installer_phase_ceph_iscsi_gw': {
-                'title': 'Install Ceph iSCSI Gateway',
-                'playbook': 'roles/ceph-iscsi-gw/tasks/main.yml'
-            },
-        }
-
-        # Find the longest phase title
-        max_column = 0
-        for phase in phase_attributes:
-            max_column = max(max_column, len(phase_attributes[phase]['title']))
-
-        if '_run' in stats.custom:
-            self._display.banner('INSTALLER STATUS')
-            for phase in installer_phases:
-                phase_title = phase_attributes[phase]['title']
-                padding = max_column - len(phase_title) + 2
-                if phase in stats.custom['_run']:
-                    phase_status = stats.custom['_run'][phase]['status']
-                    phase_time = phase_time_delta(stats.custom['_run'][phase])
-                    self._display.display(
-                        '{}{}: {} ({})'.format(phase_title, ' ' * padding, phase_status, phase_time),
-                        color=self.phase_color(phase_status))
-                    if phase_status == 'In Progress' and phase != 'installer_phase_initialize':
-                        self._display.display(
-                            '\tThis phase can be restarted by running: {}'.format(
-                                phase_attributes[phase]['playbook']))
-
-        self._display.display("", screen_only=True)
-
-    def phase_color(self, status):
-        """ Return color code for installer phase"""
-        valid_status = [
-            'In Progress',
-            'Complete',
-        ]
-
-        if status not in valid_status:
-            self._display.warning('Invalid phase status defined: {}'.format(status))
-
-        if status == 'Complete':
-            phase_color = C.COLOR_OK
-        elif status == 'In Progress':
-            phase_color = C.COLOR_ERROR
-        else:
-            phase_color = C.COLOR_WARN
-
-        return phase_color
-
-
-def phase_time_delta(phase):
-    """ Calculate the difference between phase start and end times """
-    time_format = '%Y%m%d%H%M%SZ'
-    phase_start = datetime.strptime(phase['start'], time_format)
-    if 'end' not in phase:
-        # The phase failed so set the end time to now
-        phase_end = datetime.now()
-    else:
-        phase_end = datetime.strptime(phase['end'], time_format)
-    delta = str(phase_end - phase_start).split(".")[0]  # Trim microseconds
-
-    return delta
index 72b0794b37bb05ece0c1550bca1b3105f0294e73..8d42b01c0edbf35e362e594a66f3e1e5bbc80df8 100644 (file)
@@ -1,4 +1,5 @@
 [defaults]
 ansible_managed = Please do not change this file directly since it is managed by Ansible and will be overwritten
 action_plugins = ../plugins/actions
+callback_plugins = ../plugins/callback
 roles_path = ../roles
diff --git a/plugins/callback/installer_checkpoint.py b/plugins/callback/installer_checkpoint.py
new file mode 100644 (file)
index 0000000..65e4967
--- /dev/null
@@ -0,0 +1,139 @@
+"""Ansible callback plugin to print a summary completion status of installation
+phases.
+"""
+from datetime import datetime
+from ansible.plugins.callback import CallbackBase
+from ansible import constants as C
+
+
+class CallbackModule(CallbackBase):
+    """This callback summarizes installation phase status."""
+
+    CALLBACK_VERSION = 2.0
+    CALLBACK_TYPE = 'aggregate'
+    CALLBACK_NAME = 'installer_checkpoint'
+    CALLBACK_NEEDS_WHITELIST = False
+
+    def __init__(self):
+        super(CallbackModule, self).__init__()
+
+    def v2_playbook_on_stats(self, stats):
+
+        # Set the order of the installer phases
+        installer_phases = [
+            'installer_phase_ceph_mon',
+            'installer_phase_ceph_mgr',
+            'installer_phase_ceph_agent',
+            'installer_phase_ceph_osd',
+            'installer_phase_ceph_mds',
+            'installer_phase_ceph_rgw',
+            'installer_phase_ceph_nfs',
+            'installer_phase_ceph_restapi',
+            'installer_phase_ceph_rbdmirror',
+            'installer_phase_ceph_client',
+            'installer_phase_ceph_iscsi_gw',
+        ]
+
+        # Define the attributes of the installer phases
+        phase_attributes = {
+            'installer_phase_ceph_mon': {
+                'title': 'Install Ceph Monitor',
+                'playbook': 'roles/ceph-mon/tasks/main.yml'
+            },
+            'installer_phase_ceph_mgr': {
+                'title': 'Install Ceph Manager',
+                'playbook': 'roles/ceph-mgr/tasks/main.yml'
+            },
+            'installer_phase_ceph_agent': {
+                'title': 'Install Ceph Agent',
+                'playbook': 'roles/ceph-agent/tasks/main.yml'
+            },
+            'installer_phase_ceph_osd': {
+                'title': 'Install Ceph OSD',
+                'playbook': 'roles/ceph-osd/tasks/main.yml'
+            },
+            'installer_phase_ceph_mds': {
+                'title': 'Install Ceph MDS',
+                'playbook': 'roles/ceph-mds/tasks/main.yml'
+            },
+            'installer_phase_ceph_rgw': {
+                'title': 'Install Ceph RGW',
+                'playbook': 'roles/ceph-rgw/tasks/main.yml'
+            },
+            'installer_phase_ceph_nfs': {
+                'title': 'Install Ceph NFS',
+                'playbook': 'roles/ceph-nfs/tasks/main.yml'
+            },
+            'installer_phase_ceph_restapi': {
+                'title': 'Install Ceph REST API',
+                'playbook': 'roles/ceph-restapi/tasks/main.yml'
+            },
+            'installer_phase_ceph_rbdmirror': {
+                'title': 'Install Ceph RBD Mirror',
+                'playbook': 'roles/ceph-rbd-mirror/tasks/main.yml'
+            },
+            'installer_phase_ceph_client': {
+                'title': 'Install Ceph Client',
+                'playbook': 'roles/ceph-client/tasks/main.yml'
+            },
+            'installer_phase_ceph_iscsi_gw': {
+                'title': 'Install Ceph iSCSI Gateway',
+                'playbook': 'roles/ceph-iscsi-gw/tasks/main.yml'
+            },
+        }
+
+        # Find the longest phase title
+        max_column = 0
+        for phase in phase_attributes:
+            max_column = max(max_column, len(phase_attributes[phase]['title']))
+
+        if '_run' in stats.custom:
+            self._display.banner('INSTALLER STATUS')
+            for phase in installer_phases:
+                phase_title = phase_attributes[phase]['title']
+                padding = max_column - len(phase_title) + 2
+                if phase in stats.custom['_run']:
+                    phase_status = stats.custom['_run'][phase]['status']
+                    phase_time = phase_time_delta(stats.custom['_run'][phase])
+                    self._display.display(
+                        '{}{}: {} ({})'.format(phase_title, ' ' * padding, phase_status, phase_time),
+                        color=self.phase_color(phase_status))
+                    if phase_status == 'In Progress' and phase != 'installer_phase_initialize':
+                        self._display.display(
+                            '\tThis phase can be restarted by running: {}'.format(
+                                phase_attributes[phase]['playbook']))
+
+        self._display.display("", screen_only=True)
+
+    def phase_color(self, status):
+        """ Return color code for installer phase"""
+        valid_status = [
+            'In Progress',
+            'Complete',
+        ]
+
+        if status not in valid_status:
+            self._display.warning('Invalid phase status defined: {}'.format(status))
+
+        if status == 'Complete':
+            phase_color = C.COLOR_OK
+        elif status == 'In Progress':
+            phase_color = C.COLOR_ERROR
+        else:
+            phase_color = C.COLOR_WARN
+
+        return phase_color
+
+
+def phase_time_delta(phase):
+    """ Calculate the difference between phase start and end times """
+    time_format = '%Y%m%d%H%M%SZ'
+    phase_start = datetime.strptime(phase['start'], time_format)
+    if 'end' not in phase:
+        # The phase failed so set the end time to now
+        phase_end = datetime.now()
+    else:
+        phase_end = datetime.strptime(phase['end'], time_format)
+    delta = str(phase_end - phase_start).split(".")[0]  # Trim microseconds
+
+    return delta
diff --git a/tox.ini b/tox.ini
index 019adcce1d393e24bbea81773424fe23f17bcfd8..df6a66f31235113d04bf6fdf302caeb2703060ce 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -124,6 +124,7 @@ setenv=
   ANSIBLE_SSH_ARGS = -F {changedir}/vagrant_ssh_config
   ANSIBLE_CONFIG = -F {toxinidir}/ansible.cfg
   ANSIBLE_ACTION_PLUGINS = {toxinidir}/plugins/actions
+  ANSIBLE_CALLBACK_PLUGINS = {toxinidir}/plugins/callback
   ANSIBLE_CALLBACK_WHITELIST = profile_tasks
   # only available for ansible >= 2.2
   ANSIBLE_STDOUT_CALLBACK = debug