If you have created a custom RightScript in the RightScale interface that uses git to clone a repository and you are running that RightScript on boot following the RightScale git_repo recipe then you likely are having issues. The problem appears to stem from the fact that the environment variables are not completely cleaned up as expected including $GIT_SSH and possibly others. I have a work around noted below along with a line you can enter in your RightScript to clear the $GIT_SSH ENV variable as well.
I should start by saying that the results from this test included using RightScale with RackSpace Cloud Instances. The instances where using Ubuntu 12.04 as the operating system and the issues were located while using ServerTemplates based off of the 13.X tree of the Django App Node ServerTemplate and by pulling code from Github. The Django App ServerTemplate already syncs the app repository from Github in this case and the issues were noticed when attempting to sync a secondary Github repository during boot. If the script that syncs the secondary repo was run as an Operational RightScript then it works without issue because the repo_git recipe configuration variables are not used at all and therefore do not miss being cleaned up.
RightScale Stranded RackSpace Instance During Boot: Clone Git Repository
RightScale Stranded RackSpace Instance: Audit Entry Text
- *RS> RightScript: 'GIT CLONE: ServerMagic Install - Ubuntu' ****
- 13:10:46: Reading package lists...
- 13:10:47: Building dependency tree...
- 13:10:49: Reading state information...
- 13:10:49: git is already the newest version.
- git set to manually installed.
- 0 upgraded, 0 newly installed, 0 to remove and 11 not upgraded.
- 13:10:50: Cloning into '/usr/local/repos/servermagic'...
- 13:10:50: error:
- 13:10:50: cannot run /tmp/ssh.key.sh: No such file or directory
- 13:10:50: fatal: unable to fork
- 13:10:50: Script exit status: 128
- 13:10:50: Script duration: 5.159838
- *ERROR> Execution failed
- *ERROR> External command error: RightScript < GIT CLONE: ServerMagic Install - Ubuntu > exited with 128
- *ERROR> Subprocess exited with 1
- *RS> boot failed: logging::default, sys_firewall::default, sys_ntp::default,
- *RS> rightscale::default, rightscale::install_tools,
- *RS> block_device::setup_ephemeral, sys::setup_swap, db::default, repo::default,
- *RS> web_apache::default, app_django::setup_server_1_4, app::install_server,
- *RS> lb::default, db::request_appserver_allow, app::do_update_code,
- *RS> app::setup_db_connection, app::setup_vhost,
- *RS> app_django::run_custom_django_commands, app::do_loadbalancers_allow,
- *RS> web_apache::setup_monitoring, lb::do_attach_request,
- *RS> sys::do_reconverge_list_enable, GIT CLONE: ServerMagic Install - Ubuntu
- *ERROR> Failed to run boot sequence: Failed to run boot bundle
As you can see above the script is complaining about /tmp/ssh.key.sh which is part of the repo_git chef recipe for RightScale. This is caused by the GIT_SSH environment variable not being cleaned up after the repo_git recipe is run earlier in the boot process. I would assume this is a bug in the RightScale code since they do cleanup the actual /tmp/ssh.key.sh file but leave the ENV variable in place. Initially I took a stab at clearing out this environment variable and attempting to troubleshoot errors that came up after that but in the end I decided to use sudo to accomplish cloning my secondary git repo. First I will provide a single line of code to clear the GIT_SSH environment variable in case that is your only issue and you want to take that route in resolving the problem.
RightScript Bash Code To Get Around /tmp/ssh.key.sh Not Found Error:
- # clear GIT_SSH env variable
- export GIT_SSH=""
All that does is set GIT_SSH to nothing so when $GIT_SSH is called in a script it returns nothing. I was still having other issues after clearing out GIT_SSH so I decided to attempt to use sudo in an effort to reset the shell and that did end up solving my issue. If you are having issues cloning a git repository hosted on github via a RightScript then you can simply add “/usr/bin/sudo” before the git command as a workaround. Below is the line of shell code that was causing issues followed by the updated line of code that now works without issue.
RightScript Sync GIT Repository Hosted On Github: Causing ssh.key.sh Error
- /usr/bin/git clone email@example.com:ACCOUNT/REPO.git /path/to/repo
RightScript Sync GIT Repository Hosted On Github: Workaround
- /usr/bin/sudo /usr/bin/git clone firstname.lastname@example.org:ACCOUNT/REPO.git /path/to/repo
I assume if you run into any similar issues in a RightScript you could use the same method to clear out environment variables that hang around during the boot process. If anyone has other methods that resolve this or any other RightScale tips please note in the comments below!