Merge pull request 'feat: node_lookup compatability for Debian' (#158) from neoloc/node_lookup_debian into develop
Reviewed-on: unkinben/puppet-prod#158
This commit is contained in:
commit
085416fea9
@ -3,6 +3,7 @@ import requests
|
||||
import sys
|
||||
import argparse
|
||||
import json
|
||||
import os
|
||||
|
||||
def build_query(node=None, fact_name=None, match=None, show_role=False):
|
||||
query_filters = []
|
||||
@ -23,8 +24,16 @@ def build_query(node=None, fact_name=None, match=None, show_role=False):
|
||||
return json.dumps(["and"] + query_filters)
|
||||
|
||||
def query_puppetdb(query):
|
||||
# Determine the correct SSL certificate path based on the OS
|
||||
if os.path.exists('/etc/ssl/certs/ca-certificates.crt'): # Debian/Ubuntu
|
||||
cert_path = '/etc/ssl/certs/ca-certificates.crt'
|
||||
elif os.path.exists('/etc/pki/tls/cert.pem'): # RHEL/CentOS
|
||||
cert_path = '/etc/pki/tls/cert.pem'
|
||||
else:
|
||||
raise FileNotFoundError("SSL certificate file not found.")
|
||||
|
||||
url = 'https://puppetdbapi.main.unkin.net/pdb/query/v4/facts'
|
||||
response = requests.get(url, params={'query': query}, verify='/etc/pki/tls/cert.pem')
|
||||
response = requests.get(url, params={'query': query}, verify=cert_path)
|
||||
process_response(response)
|
||||
|
||||
def process_response(response):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user