| |
@@ -21,6 +21,21 @@
|
| |
|
| |
import yaml
|
| |
|
| |
+
|
| |
+ def print_bad_inventory(exctype, value, tb):
|
| |
+ """Print empty inventory on any uncatched exception. This will prevent
|
| |
+ running playbook on localhost.
|
| |
+ """
|
| |
+ hosts = ["fake_hostname_failed_inventory"]
|
| |
+ bad_inv = {"localhost": {"hosts": hosts, "vars": {}},
|
| |
+ "subjects": {"hosts": hosts, "vars": {}},
|
| |
+ "_meta": {"hostvars": {}}}
|
| |
+ sys.stdout.write(json.dumps(bad_inv, indent=4, separators=(',', ': ')))
|
| |
+
|
| |
+
|
| |
+ sys.excepthook = print_bad_inventory
|
| |
+
|
| |
+
|
| |
IDENTITY = """
|
| |
-----BEGIN RSA PRIVATE KEY-----
|
| |
MIIEpQIBAAKCAQEA1DrTSXQRF8isQQfPfK3U+eFC4zBrjur+Iy15kbHUYUeSHf5S
|
| |
Inventory provisioners may fail. If provision script fail playbook may
run on localhost system. This change will prevent running playbook on
localhost when one of inventory script fail.
Signed-off-by: Andrei Stepanov astepano@redhat.com