using capistrano on a shared host, how to set the temporary directory for repo access - capistrano

cap is trying to create this location on my server to access my git repo (on bitbucket). Unfortunately this is a shared host, and the ssh keys are in my user directory, not in /tmp…. so this fails:
GIT_ASKPASS=/bin/echo GIT_SSH=/tmp/doman.com/git-ssh.sh /usr/bin/env git ls-remote
Can I configure this tmp dir to be in my home dir?

According to the Capistrano Github page you should set the :tmp_dir variable to a directory on your homepath like /home/user/tmp/capistrano
For example:
set :tmp_dir, '/home/user/tmp/capistrano'

Related

Extract Git URL from file using Powershell

1/ I need to extract in a folder a specific part of url. The url is in the subfolder named ".git" and I use the command:
git remote get-url --all origin
url look like this:
- git#servername:do-amont/production/ei2/nova/migration-devfactory.git
- ssh://servername.domain.com:30272/do-amont/production/ei2/nova/migration-devfactory.git
- https: //gitlab-review-dev-jxuor3.openshift-intra-dev.domain. com/do-amont/production/ei2/nova/migration-devfactory.git
the part I need is
do-amont/production/ei2/nova/migration-devfactory.git
After that I need to put the extracting url on this command
git remote set-url --add origin ssh://git#l203ei3007.domain.com:30272/do-amont/production/ei2/nova/migration-devfactory.git
I need to automatise these step on powershell
You can get the URL from the git config for a specified remote via the git config git command-line command, as long as you run it from within the directory with the .git folder.
So you could do something like this (assumes the part of the URL you want to keep is always after a colon):
$GitURL = (git config remote.origin.url).split(':')[1]
git remote set-url --add origin "ssh://git#l203ei3007.domain.com:30272/$GitURL"

Polymer 2.0 upload to GitHub-Pages

I have problem with uploading my Polymer component into gh pages.
I'm try this from tutorial:
# git clone the Polymer tools repository somewhere outside of your
# element project
git clone git://github.com/Polymer/tools.git
# Create a temporary directory for publishing your element and cd into it
mkdir temp && cd temp
# Run the gp.sh script. This will allow you to push a demo-friendly
# version of your page and its dependencies to a GitHub pages branch
# of your repository (gh-pages). Below, we pass in a GitHub username
# and the repo name for our element
../tools/bin/gp.sh <username> <test-element>
# Finally, clean-up your temporary directory as you no longer require it
cd ..
rm -rf temp
But it's not working.
In terminal I have this errors:
There is something I'm, missing?
Here is your problem:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
For the script to run as intended, you need to add your public ssh key to your github project. Settings -> Deploy keys -> Add deploy Key.
Alternatively, you can manually execute the steps in gp.sh that involve pulling from and pushing to github.
If you don't feel like splitting up the script, try running the commands manually, that should work. The only multi-line command in the script is this one:
echo "{
\"directory\": \"components\"
}
" > .bowerrc
Good luck.

Pushing entire Rundeck configuration to github

I want to push entire Rundeck configuration to Github. Is there any way for doing this ?
Considering the Rundeck configuration layout, all you would need to do is:
cd $RDECK_BASE
git init .
git remote add origin /url/new/empty/GitHub/repo
echo '*'>.gitignore
echo '!/etc/'>.gitignore
echo '!/server/'>.gitignore
echo '/server/*'>.gitignore
echo '!/server/config/'>.gitignore
git add .
git commit -m "Rundeck config"
git push -u master
Basically, you need to ignore what is not configuration before adding everything else (ie, the config files), and pushing to your own GitHub repo.
Make sure those files don't have sensitive credential information in them though (or at least push them to a private GitHub repo if you have one)

Capistrano - How to put files in the shared folder?

I am new to Capistranoand I saw there is shared folder and also option :linked_files. I think shared folder is used to keep files between releases. But my question is, how do files end up being in the shared folder?
Also, if I want to symlink another directory to the current directory e.g. static folder at some path, how do I put it at the linked_dirs ?
Lastly how to set chmod 755 to linked_files and linked_dirs.
Thank you.
Folders inside your app are symlinks to folders in the shared directory. If your app writes to log/production.log, it will actually write to ../shared/log/production.log. That's how the files end up being in the shared folder.
You can see how this works by looking at the feature specs or tests in Capistrano.
If you want to chmod these shared files, you can just do it once directly over ssh since they won't ever be modified by Capistrano after they've been created.
To add a linked directory, in your deploy.rb:
set :linked_dirs, %w{bin log tmp/backup tmp/pids tmp/cache tmp/sockets vendor/bundle}
or
set :linked_dirs, fetch(:linked_dirs) + %w{public/system}
Capistrano 3.5+
Capistrano 3.5 introduced append for array fields. From the official docs, you should use these:
For Shared Files:
append :linked_files, %w{config/database.yml}
For Shared Directories:
append :linked_dirs, %w{bin log public/uploads vendor/bundle}
I've written a task for Capistrano 3 to upload your config files to the shared folder of each of your servers, it'll check these directories in order:
config/deploy/config/:stage/*.yml
config/deploy/config/*.yml
And upload all config files found. It'll only upload the files if they've changed. Note also that if you have the same file on both directories then the second one will be ignored.
Here's the code: https://gist.github.com/Jesus/448d618c83fb0445ebbf
One last thing, this task is just uploading the config. files to your remote shared folder, you still need to set linked_files in config/deploy.rb, eg:
set :linked_files, %w{config/database.yml config/aws.yml}
UPDATE:
If you're using Git, you'll probably want to ignore these files:
echo "config/deploy/config/*" >> .gitignore
There are 3 simple steps you can follow to put a file that you don't want to change in consecutive releases; add your file to linked_files list.
set :linked_files, fetch(:linked_files, []).push('config.php')
Select all the files that you want to share. Put this file from your local to remote server through scp
scp config.php deployer#amazon:~/capistrano/shared/config.php
Now, deploy through the command given below:
bundle exec cap staging deploy
of course, staging can be changed as per requirements may be production,sandbox etc.
One more thing, because you don't want your team members to commit such files. So, put this file to your .gitignore file. And push it to git remote repo.
For Capistrano 3.5+, as specified in official doc :
append :linked_dirs, ".bundle", "tmp"
For me non of the above worked so I ended up adding two functions to the end of the deployment process:
namespace :your_company do
desc "remove index.php"
task :rm_files do
on roles(:all) do
execute "rm -rf #{release_path}/index.php"
end
end
end
namespace :your_company do
desc "add symlink to index.php"
task :add_files do
on roles(:all) do
execute "ln -sf #{shared_path }/index.php #{release_path}/index.php"
end
end
end
after "deploy:finished", "your_company:rm_files"
after "deploy:finished", "your_company:add_files"

How do I change the temporary directory that Capistrano uses?

How would I change the temporary dir that Capistrano uses?
Example: Instead of /tmp, I want to use /home/user/tmp
My current VPS has /tmp mounted as noexec, which gives me permission denied errors while trying to run cap production deploy.
In Capistrano 3,
set :tmp_dir, '/home/user/tmp'
Are you talking about the remote tmp directory? If yes, here an example::
set :copy_remote_dir, deploy_to
This will change the default tmp directory where the archive was copied on the remote server to the deployment directory instead.
For the ones who are still using Capistrano 2, tmp_dir does not exist. However you can use copy_dir instead:
set :copy_dir, '/home/user/tmp'
Link to the source code: https://github.com/capistrano/capistrano/blob/legacy-v2/lib/capistrano/recipes/deploy/strategy/copy.rb#L275