]> git-server-git.apps.pok.os.sepia.ceph.com Git - teuthology.git/commitdiff
ansible: Add ability to skip tags during ansible task 1164/head
authorDavid Galloway <dgallowa@redhat.com>
Thu, 5 Apr 2018 14:42:02 +0000 (10:42 -0400)
committerDavid Galloway <dgallowa@redhat.com>
Thu, 5 Apr 2018 17:19:41 +0000 (13:19 -0400)
Signed-off-by: David Galloway <dgallowa@redhat.com>
teuthology/task/ansible.py
teuthology/test/task/test_ansible.py

index baf5d5a8067e001c1a96ec74ec86c7ab662b3757..f0ad662f7dc180f1204bcd884fb2c6a1df33d9c8 100644 (file)
@@ -62,6 +62,8 @@ class Ansible(Task):
                     not, we generate a temporary file to use.
         tags:       A string including any (comma-separated) tags to be passed
                     directly to ansible-playbook.
+        skip_tags:  A string of comma-separated tags that will be skipped by 
+                    passing them to ansible-playbook using --skip-tags.
         vars:       A dict of vars to be passed to ansible-playbook via the
                     --extra-vars flag
         group_vars: A dict with keys matching relevant group names in the
@@ -96,6 +98,7 @@ class Ansible(Task):
         inventory: /path/to/inventory
         playbook: /path/to/playbook.yml
         tags: my_tags
+        skip_tags: my_skipped_tags
         vars:
             var1: string_value
             var2:
@@ -353,6 +356,9 @@ class Ansible(Task):
         tags = self.config.get('tags')
         if tags:
             args.extend(['--tags', tags])
+        skip_tags = self.config.get('skip_tags')
+        if skip_tags:
+            args.extend(['--skip-tags', skip_tags])
         return args
 
     def teardown(self):
index 790bf2a13f6edc2764fc3fca1a9447ab167126e0..a255e5e9d7efe86b57ff109f02e0bf0e76466209 100644 (file)
@@ -392,6 +392,17 @@ class TestAnsibleTask(TestTask):
         assert args.count('--tags') == 1
         assert args[args.index('--tags') + 1] == 'user,pubkeys'
 
+    def test_build_args_skip_tags(self):
+        self.task_config.update(dict(
+            playbook=[],
+            skip_tags="user,pubkeys"
+        ))
+        task = self.klass(self.ctx, self.task_config)
+        task.setup()
+        args = task._build_args()
+        assert args.count('--skip-tags') == 1
+        assert args[args.index('--skip-tags') + 1] == 'user,pubkeys'
+
     def test_build_args_no_vars(self):
         self.task_config.update(dict(
             playbook=[],