|
|
|
@ -3,8 +3,9 @@
|
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
|
from ipalib import api
|
|
|
|
|
import json
|
|
|
|
|
from ipalib import api, errors
|
|
|
|
|
from six import u
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def initialize():
|
|
|
|
@ -72,25 +73,29 @@ def parse_args():
|
|
|
|
|
return parser.parse_args()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def print_host(host):
|
|
|
|
|
'''
|
|
|
|
|
This function is really a stub, it could return variables to be used in
|
|
|
|
|
a playbook. However, at this point there are no variables stored in
|
|
|
|
|
FreeIPA/IPA.
|
|
|
|
|
|
|
|
|
|
def get_host_attributes(api, host):
|
|
|
|
|
"""
|
|
|
|
|
This function expects one string, this hostname to lookup variables for.
|
|
|
|
|
'''
|
|
|
|
|
Args:
|
|
|
|
|
api: FreeIPA API Object
|
|
|
|
|
host: Name of Hostname
|
|
|
|
|
|
|
|
|
|
print(json.dumps({}))
|
|
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
Returns: Dict of Host vars if found else None
|
|
|
|
|
"""
|
|
|
|
|
try:
|
|
|
|
|
result = api.Command.host_show(u(host))['result']
|
|
|
|
|
if 'usercertificate' in result:
|
|
|
|
|
del result['usercertificate']
|
|
|
|
|
return json.dumps(result, indent=1)
|
|
|
|
|
except errors.NotFound as e:
|
|
|
|
|
return {}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
|
args = parse_args()
|
|
|
|
|
api = initialize()
|
|
|
|
|
|
|
|
|
|
if args.host:
|
|
|
|
|
print_host(args.host)
|
|
|
|
|
print(get_host_attributes(api, args.host))
|
|
|
|
|
elif args.list:
|
|
|
|
|
api = initialize()
|
|
|
|
|
list_groups(api)
|
|
|
|
|