Sample Header Ad - 728x90

pass parameters to bash script using chef attributes

2 votes
3 answers
9749 views
I have a bash script ( let's say main.sh ) which I need to integrate with chef. Currently we are using "expect" to pass the parameters to main.sh. Now I need to make script in such a way that the parameters for main.sh will be passed using attribute file in chef. I know that we can put our code in a bash resource but i am struggling to pass the parameters like passwords, user names, ports using chef attributes ?? Below is how the script looks like: #!/usr/bin/expect set filename [lindex $argv 0] set f [open $filename] set inputs [split [read $f] "\n"] # Below parameters i need to pass using chef attributes instead of expect inputs lassign $inputs ADMIN_PASSWORD CREATE_USER USER_EMAIL FIRST_NAME LAST_NAME INST_PATH #read -e -p "Enter the installation folder path(//): " FILEPATH3 #FILEPATH3=$(echo $FILEPATH3 | sed 's/ /\\ /') spawn "$INST_PATH/main.sh" expect "Enter system admin password:" send "$ADMIN_PASSWORD\r" expect "Create a new user y/n (y):" send "$CREATE_USER\r" ............. .............
Asked by Krishna Sharma (181 rep)
Sep 22, 2015, 04:50 AM
Last activity: Apr 22, 2019, 11:57 PM