diff --git a/rundeck-puppetdb-nodes-plugin/contents/rundeck_puppetdb_nodes.py b/rundeck-puppetdb-nodes-plugin/contents/rundeck_puppetdb_nodes.py index 9f2f85d..5fc2c51 100644 --- a/rundeck-puppetdb-nodes-plugin/contents/rundeck_puppetdb_nodes.py +++ b/rundeck-puppetdb-nodes-plugin/contents/rundeck_puppetdb_nodes.py @@ -31,7 +31,10 @@ def destroy_krb_ticket(self): def get_facts_puppetdb(self, apiurl, facts, hostgroup): url ='%s/facts' % apiurl - query_base = '["and",["or",%s],["in", "certname", ["extract", "certname", ["select-facts", ["and", ["=", "name", "hostgroup"], ["~", "value", "%s"]]]]]]' + if 'v3' in apiurl: + query_base = '["and",["or",%s],["in", "certname", ["extract", "certname", ["select-facts", ["and", ["=", "name", "hostgroup"], ["~", "value", "%s"]]]]]]' + else: + query_base = '["and",["or",%s],["in", "certname", ["extract", "certname", ["select_facts", ["and", ["=", "name", "hostgroup"], ["~", "value", "%s"]]]]]]' query_facts = ','.join(['["=","name","%s"]' % fact for fact in facts]) query = query_base % (query_facts, hostgroup)