puppet-prod/site/profiles/templates/base/scripts/puppetwrapper.py.erb
Ben Vincent a054a94d98 feat: puppet wrapper replace dot
- set puppet wrapper to replace '.' with '_' in the branch name
2024-02-10 15:31:45 +11:00

23 lines
746 B
Plaintext

#!/usr/bin/env python3
import sys
import subprocess
def main():
# If "-E" is in the arguments, modify the following argument
args = sys.argv[1:]
if "-E" in args:
index = args.index("-E")
if index + 1 < len(args): # Check if there's another argument after "-E"
environment_value = args[index + 1]
# Replace \ and - with _
modified_environment_value = environment_value.replace("\\", "_").replace("-", "_").replace("/","_").replace(".","_")
args[index + 1] = modified_environment_value
# Construct the full puppet command with the modified args
command = ["/opt/puppetlabs/bin/puppet"] + args
subprocess.run(command)
if __name__ == "__main__":
main()