Fixup ipaclient.yaml for python3
This change does two things: 1. it uses print() which is the only supported way of calling print in python3 (and still works with python2). This way we avoid the following error: SyntaxError: Missing parentheses in call to 'print'. Did you mean print('...')? 2. It uses the PythonInterpreter variable to choose the python interpreter Tested and we correctly get the right wanted interpreter: ... fqdn=`echo $data | /usr/bin/python3 -c 'import json,sys;obj=json.load(sys.stdin);print(obj.get("join", {}).get("hostname", ""))'` ... Change-Id: I6e68664c650d0481a9f0cfd21985434d8c75e1a2 Co-Authored-By: Luca Miccini <lmiccini@redhat.com>
This commit is contained in:
parent
59fc8f10a3
commit
5b6984eb0f
@ -32,6 +32,10 @@ parameters:
|
|||||||
description: Mapping of service endpoint -> protocol. Typically set
|
description: Mapping of service endpoint -> protocol. Typically set
|
||||||
via parameter_defaults in the resource registry.
|
via parameter_defaults in the resource registry.
|
||||||
type: json
|
type: json
|
||||||
|
PythonInterpreter:
|
||||||
|
type: string
|
||||||
|
description: The python interpreter to use for python and ansible actions
|
||||||
|
default: /usr/bin/python
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
role_data:
|
role_data:
|
||||||
@ -43,6 +47,8 @@ outputs:
|
|||||||
host_prep_tasks:
|
host_prep_tasks:
|
||||||
- name: enroll client in ipa and get metadata
|
- name: enroll client in ipa and get metadata
|
||||||
become: yes
|
become: yes
|
||||||
|
vars:
|
||||||
|
python_interpreter: {get_param: PythonInterpreter}
|
||||||
block:
|
block:
|
||||||
- name: install needed packages
|
- name: install needed packages
|
||||||
package:
|
package:
|
||||||
@ -67,7 +73,7 @@ outputs:
|
|||||||
if [ -f /run/cloud-init/status.json ]; then
|
if [ -f /run/cloud-init/status.json ]; then
|
||||||
# Get metadata from config drive
|
# Get metadata from config drive
|
||||||
data=`cat /run/cloud-init/status.json`
|
data=`cat /run/cloud-init/status.json`
|
||||||
config_drive=`echo $data | python -c 'import json,re,sys;obj=json.load(sys.stdin);ds=obj.get("v1", {}).get("datasource"); print re.findall(r"source=(.*)]", ds)[0]'`
|
config_drive=`echo $data | {{ python_interpreter }} -c 'import json,re,sys;obj=json.load(sys.stdin);ds=obj.get("v1", {}).get("datasource"); print(re.findall(r"source=(.*)]", ds)[0])'`
|
||||||
if [[ -b $config_drive ]]; then
|
if [[ -b $config_drive ]]; then
|
||||||
temp_dir=`mktemp -d`
|
temp_dir=`mktemp -d`
|
||||||
mount $config_drive $temp_dir
|
mount $config_drive $temp_dir
|
||||||
@ -109,15 +115,15 @@ outputs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Get the instance hostname out of the metadata
|
# Get the instance hostname out of the metadata
|
||||||
fqdn=`echo $data | python -c 'import json,sys;obj=json.load(sys.stdin);print obj.get("join", {}).get("hostname", "")'`
|
fqdn=`echo $data | {{ python_interpreter }} -c 'import json,sys;obj=json.load(sys.stdin);print(obj.get("join", {}).get("hostname", ""))'`
|
||||||
|
|
||||||
if [ -z "$fqdn" ]; then
|
if [ -z "$fqdn" ]; then
|
||||||
echo "Unable to determine hostname"
|
echo "Unable to determine hostname"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
realm=`echo $data | python -c 'import json,sys;obj=json.load(sys.stdin);print obj.get("join", {}).get("krb_realm", "")'`
|
realm=`echo $data | {{ python_interpreter }} -c 'import json,sys;obj=json.load(sys.stdin);print(obj.get("join", {}).get("krb_realm", ""))'`
|
||||||
otp=`echo $data | python -c 'import json,sys;obj=json.load(sys.stdin);print obj.get("join", {}).get("ipaotp", "")'`
|
otp=`echo $data | {{ python_interpreter }} -c 'import json,sys;obj=json.load(sys.stdin);print(obj.get("join", {}).get("ipaotp", ""))'`
|
||||||
|
|
||||||
hostname=`/bin/hostname -f`
|
hostname=`/bin/hostname -f`
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user