Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

cloudera director bootstrap python

Solved Go to solution
Highlighted

cloudera director bootstrap python

Master Collaborator

Hi, is it possible to define a template for cloudera director to call a python script in the bootstrap process?

The documentation states that the bootstrapScriptsPaths defines a list of script file (shell commands) - so I assume only shell commands are supported.

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: cloudera director bootstrap python

Expert Contributor

Hi Tomas79,

 

I think a Python script will work if you start it with a shebang (e.g., #/usr/bin/env python). Director uses essentially the following shell command to run a script, so I can see a Python script working with it.

 

 

sudo chmod 700 'scriptName' && sudo 'scriptName'

 

Even so, running a Python script directly is a little hacky because we haven't thought about Director running anything other than shell scripts with this capability, so I can't guarantee that this command won't change in the future to not work with a Python script. However, something like the following shell script will be fine.

 

#!/usr/bin/env bash
python <<EOF
print 'Hello world!'
EOF

 

 

Or:

 

#!/usr/bin/env bash
curl -O http://host/path/to/downloadable/script.py
python script.py

 

 

Or rather than downloading the script, bake it into your AMI / image. So, there are a few options.

1 REPLY 1

Re: cloudera director bootstrap python

Expert Contributor

Hi Tomas79,

 

I think a Python script will work if you start it with a shebang (e.g., #/usr/bin/env python). Director uses essentially the following shell command to run a script, so I can see a Python script working with it.

 

 

sudo chmod 700 'scriptName' && sudo 'scriptName'

 

Even so, running a Python script directly is a little hacky because we haven't thought about Director running anything other than shell scripts with this capability, so I can't guarantee that this command won't change in the future to not work with a Python script. However, something like the following shell script will be fine.

 

#!/usr/bin/env bash
python <<EOF
print 'Hello world!'
EOF

 

 

Or:

 

#!/usr/bin/env bash
curl -O http://host/path/to/downloadable/script.py
python script.py

 

 

Or rather than downloading the script, bake it into your AMI / image. So, there are a few options.

Don't have an account?
Coming from Hortonworks? Activate your account here