]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
setup env and execute playbook
authorVasu Kulkarni <vasu@redhat.com>
Wed, 7 Dec 2016 04:07:29 +0000 (20:07 -0800)
committerVasu Kulkarni <vasu@redhat.com>
Tue, 20 Dec 2016 22:42:58 +0000 (14:42 -0800)
Signed-off-by: Vasu Kulkarni <vasu@redhat.com>
teuthology/task/ceph_ansible.py

index dc8e3f04c8e59f0816c204de051867aab0dbed8a..eb413846fc0914a9b81cc9ac787f259b1cefda0f 100644 (file)
@@ -254,6 +254,85 @@ class CephAnsible(Task):
             log.error("Failed during ceph-ansible execution")
             raise CephAnsibleError("Failed during ceph-ansible execution")
 
+    def run_playbook(self):
+        # setup ansible on first mon node
+        ceph_installer = self.ceph_installer
+        args = self.args
+        if ceph_installer.os.package_type == 'rpm':
+            # install crypto packages for ansible
+            ceph_installer.run(args=[
+                'sudo',
+                'yum',
+                'install',
+                '-y',
+                'libffi-devel',
+                'python-devel',
+                'openssl-devel'
+            ])
+        else:
+            ceph_installer.run(args=[
+                'sudo',
+                'apt-get',
+                'install',
+                '-y',
+                'libssl-dev',
+                'libffi-dev',
+                'python-dev'
+            ])
+        ansible_repo = self.config['repo']
+        branch = 'master'
+        if self.config.get('branch'):
+            branch = self.config.get('branch')
+        ansible_ver = 'ansible==2.1'
+        if self.config.get('ansible-version'):
+            ansible_ver = 'ansible==' + self.config.get('ansible-version')
+        ceph_installer.run(
+            args=[
+                'rm',
+                '-rf',
+                run.Raw('~/ceph-ansible'),
+                ],
+            check_status=False
+        )
+        ceph_installer.run(args=[
+            'mkdir',
+            run.Raw('~/ceph-ansible'),
+            run.Raw(';'),
+            'git',
+            'clone',
+            run.Raw('-b %s' % branch),
+            run.Raw(ansible_repo),
+        ])
+        # copy the inventory file to installer node
+        ceph_installer.put_file(self.inventory, 'ceph-ansible/inven.yml')
+        # copy the site file
+        ceph_installer.put_file(self.playbook_file, 'ceph-ansible/site.yml')
+        # copy extra vars to groups/all
+        ceph_installer.put_file(self.extra_vars_file, 'ceph-ansible/group_vars/all')
+        # print for debug info
+        ceph_installer.run(args=('cat', 'ceph-ansible/inven.yml'))
+        ceph_installer.run(args=('cat', 'ceph-ansible/site.yml'))
+        ceph_installer.run(args=('cat', 'ceph-ansible/group_vars/all'))
+        str_args = ' '.join(args)
+        ceph_installer.run(args=[
+            run.Raw('cd ~/ceph-ansible'),
+            run.Raw(';'),
+            'virtualenv',
+            'venv',
+            run.Raw(';'),
+            run.Raw('source venv/bin/activate'),
+            run.Raw(';'),
+            'pip',
+            'install',
+            'setuptools>=11.3',
+            run.Raw(ansible_ver),
+            run.Raw(';'),
+            run.Raw(str_args)
+        ])
+        wait_for_health = self.config.get('wait-for-health', True)
+        if wait_for_health:
+            self.wait_for_ceph_health()
+
 
 
 class CephAnsibleError(Exception):