Skip to content

Commit

Permalink
Homework 8.fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Vasiliy Motchenko committed Nov 16, 2023
1 parent 98eb605 commit 5108202
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions ansible/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,15 @@ def main():
output = subprocess.check_output(["terraform", "output", "-json"]).decode()
output_dict = json.loads(output)

data["app"]["hosts"].append(output_dict["external_ip_address_app"]["value"])
data["db"]["hosts"].append(output_dict["external_ip_address_db"]["value"])
if "external_ip_address_app" in output_dict:
data["app"]["hosts"].append(output_dict["external_ip_address_app"]["value"])
else:
data["app"]["hosts"].append("1.2.3.4")

if "external_ip_address_db" in output_dict:
data["db"]["hosts"].append(output_dict["external_ip_address_db"]["value"])
else:
data["db"]["hosts"].append("4.3.2.1")
else:
data["app"]["hosts"].append("1.2.3.4")
data["db"]["hosts"].append("4.3.2.1")
Expand Down

0 comments on commit 5108202

Please sign in to comment.