Browse Source

per_node is not parsing generated json

Hieradata for individual nodes leads to json decoding error.

Related: https://bugzilla.redhat.com/1924952
Change-Id: I1cea09bfd2595ce3ae6c2b39adbb40044a4e0b0b
(cherry picked from commit a68149f247)
(cherry picked from commit 057f2c849f)
changes/46/775346/1
David Vallee Delisle 4 months ago
parent
commit
f2602657ae
1 changed files with 10 additions and 2 deletions
  1. +10
    -2
      puppet/extraconfig/pre_deploy/per_node.yaml

+ 10
- 2
puppet/extraconfig/pre_deploy/per_node.yaml View File

@ -45,18 +45,26 @@ resources:
# the data of the NodeDataLookup parameter that matches the
# system UUID
echo $node_lookup | $(get_python) -c "
import ast
import json
import sys
input = sys.stdin.readline() or '{}'
cnt = json.loads(input)
try:
cnt = json.loads(input)
except json.decoder.JSONDecodeError:
cnt = ast.literal_eval(input)
print(json.dumps(cnt.get('${node_id}', {})))
" > /etc/puppet/hieradata/${node_id}.json
# handle upper case node id LP#1816652
echo $node_lookup | $(get_python) -c "
import ast
import json
import sys
input = sys.stdin.readline() or '{}'
cnt = json.loads(input)
try:
cnt = json.loads(input)
except json.decoder.JSONDecodeError:
cnt = ast.literal_eval(input)
print(json.dumps(cnt.get('${node_id_upper}', {})))
" > /etc/puppet/hieradata/${node_id_upper}.json


Loading…
Cancel
Save