Last active
August 14, 2019 11:49
-
-
Save KeyboardInterrupt/4d6e2be651a0d5d646df8070ddbb20dd to your computer and use it in GitHub Desktop.
Revisions
-
Christian S revised this gist
Aug 14, 2019 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,8 +22,8 @@ xml_config = subprocess.check_output( xml_status = subprocess.check_output( ["crm_mon", "--as-xml"] ) dict_config = xmltodict.parse(xml_config ,attr_prefix="") dict_status = xmltodict.parse(xml_status ,attr_prefix="") dict_combined = dict_config.copy() dict_combined.update(dict_status) -
Christian S created this gist
Aug 14, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,32 @@ #!/usr/bin/python # # Description: # This script is a custom fact for ansible that turns `crm configure show` and `crm_mon` # output into a fact that can be used in Ansible. i.E. to iterate over all # nodes in a cluster, check for the location of a resource and so on. # # Dependencies: # - xmltodict - https://pypi.org/project/xmltodict/ # # Author: # KeyboardInterrupt - www.keyboardinterrupt.com # import xmltodict import json import subprocess xml_config = subprocess.check_output( ["crm", "configure", "show", "xml"] ) xml_status = subprocess.check_output( ["crm_mon", "--as-xml"] ) dict_config = xmltodict.parse(xml_config) dict_status = xmltodict.parse(xml_status) dict_combined = dict_config.copy() dict_combined.update(dict_status) json_combined = json.dumps(dict_combined) print(json_combined)