Remove Jinja from yaml files before parsing

This commit is contained in:
Jason Ertel
2022-07-08 17:07:24 -04:00
parent 69ce3613ff
commit a8e6b26406

View File

@@ -16,6 +16,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import os import os
import re
import subprocess import subprocess
import sys import sys
import time import time
@@ -71,7 +72,14 @@ def checkApplyOption(options):
def loadYaml(filename): def loadYaml(filename):
file = open(filename, "r") file = open(filename, "r")
return yaml.safe_load(file.read()) content = file.read()
# Remove Jinja templating
content = content.replace("{{ ssh_port }}", "22")
pattern = r'.*({%|{{|}}|%}).*'
content = re.sub(pattern, "", content)
return yaml.safe_load(content)
def writeYaml(filename, content): def writeYaml(filename, content):
file = open(filename, "w") file = open(filename, "w")