Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

within doesn't work with this #13

Closed
Jalle19 opened this issue Apr 24, 2019 · 8 comments
Closed

within doesn't work with this #13

Jalle19 opened this issue Apr 24, 2019 · 8 comments
Assignees

Comments

@Jalle19
Copy link

Jalle19 commented Apr 24, 2019

It seems all within blocks are simply skipped, i.e. the code inside them doesn't run.

@komazarari komazarari self-assigned this Apr 28, 2019
@Jalle19
Copy link
Author

Jalle19 commented Jun 4, 2019

@komazarari any idea on how to fix this?

@Jalle19
Copy link
Author

Jalle19 commented Jun 4, 2019

e.g. I have a task like this:

namespace :ops do
    desc "Clone ops repository"
    task :clone do
      on roles(:all) do
        within "/home/ubuntu" do
          if test("[ ! -d ops ]")
            execute :"ssh-keyscan", "bitbucket.org > ~/.ssh/known_hosts"
            execute :git, "clone ", fetch(:ops_repo_url)
          end
        end
      end
    end
end

Which is run using this:

before :starting, "ops:clone"

But the whole task is simply skipped. It can't be the roles(:all) because I use that in other tasks and they execute just fine.

@komazarari
Copy link
Owner

Hi, sorry for late reply and thank you for describing the details.
But I couldn't reproduce this problem, I think this is related to before hook with namespace.

Could you try simply single task by cap <stage> ops:clone --trace and check it works or not?
If your problem is caused by within block, the single task will not work correctly. Otherwise, it's better to check the before hook, for example, try changing before :starting ... to before "deploy:starting", etc.

@Jalle19
Copy link
Author

Jalle19 commented Jun 5, 2019

I'll try and report back, thanks for the tips!

@Jalle19
Copy link
Author

Jalle19 commented Jun 10, 2019

@komazarari this is what I get when running the task explicitly:

$ cap localhost ops:clone --trace
** Invoke localhost (first_time)
** Execute localhost
** Invoke load:defaults (first_time)
** Execute load:defaults
** Invoke ops:clone (first_time)
** Execute ops:clone

@Jalle19
Copy link
Author

Jalle19 commented Jun 10, 2019

It seems to only fail when using within "/hardcoded/path". If I use e.g. within release_path it works fine.

@Jalle19
Copy link
Author

Jalle19 commented Jun 10, 2019

"Fixed" it by changing the whole task to:

desc "Clone ops repository"
task :clone do
  on roles(:all) do
	  if !File.directory?(fetch(:ops_path))
		execute :"ssh-keyscan", "bitbucket.org > ~/.ssh/known_hosts"
		execute :git, "clone ", fetch(:ops_repo_url), fetch(:ops_path)
	  end
  end
end

Now since it doesn't use within it "just works"

@Jalle19 Jalle19 closed this as completed Jun 10, 2019
@Jalle19
Copy link
Author

Jalle19 commented Aug 22, 2019

Just noticed that within works perfectly in another repository that uses the exact same code. Losing my mind with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants