Skip to content

Commit

Permalink
func writePlayBook is improved in ansible.py
Browse files Browse the repository at this point in the history
  • Loading branch information
mperov authored Mar 27, 2024
1 parent c76571c commit 7ba14b4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ansible.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-

#
# Copyright (c) 2022 Maksim Perov <[email protected]>
# Copyright (c) 2024 Maksim Perov <[email protected]>
#

import sys
Expand Down Expand Up @@ -95,12 +95,12 @@ def getGroupsPlayBook(groups = []):
yaml.explicit_start = True # --- at the beginning of yaml
return yaml.dump(content)

def writePlayBook(playbook = getPingPlayBook()):
def writePlayBook(filename = FILE_PLAYBOOK, playbook = getPingPlayBook()):
try:
with open(FILE_PLAYBOOK , "w") as f:
with open(filename, "w") as f:
f.write(playbook)
except Exception as e:
print("ERROR: " + FILE_PLAYBOOK + " isn't writable!")
print("ERROR: " + filename + " isn't writable!")
print(str(e))
sys.exit(-1)
print('YAML is successfully generating to ' + FILE_PLAYBOOK)
Expand Down

0 comments on commit 7ba14b4

Please sign in to comment.