Проблемы с клонированием частного репозитория Chef с помощью Test Kitchen

У меня возникли проблемы с попыткой клонировать частный репозиторий git из gitolite. Я устанавливаю git 2.8.1 и использую Chef 12.9. Я пытаюсь создать оболочку SSH, которую ресурс шеф-повара git может использовать для аутентификации в моем репозитории.

....
file "/tmp/ssh_wrapper.sh" do
  content "#!/bin/sh\nexec /usr/bin/ssh -i #{/tmp/key.pem} \"$@\""
  user "root"
  group "root"
  mode "0700"
  action :create
end
git "/home/some_repo" do
  repository "[email protected]:some_repo.git"
  revision "1.0.0"
  user "root"
  group "root"
  ssh_wrapper "/tmp/ssh_wrapper.sh"
  action :sync
end
....

Я получаю следующую ошибку при попытке синхронизации с репозиторием git с помощью тестовой кухни.

================================================================================
           Error executing action `sync` on resource 'git[/home/some_repo]'
           ===========================================================================    =====

           Mixlib::ShellOut::ShellCommandFailed
           ------------------------------------
           Expected process to exit with [0], but received '128'
           ---- Begin output of git ls-remote "[email protected]:some_repo.git" "1.0.0*" ----
           STDOUT:
           STDERR: Host key verification failed.
           fatal: Could not read from remote repository.

           Please make sure you have the correct access rights
           and the repository exists.
           ---- End output of git ls-remote "[email protected]:some_repo.git" "1.0.0*" ----
           Ran git ls-remote "[email protected]:some_repo.git" "1.0.0*" returned 128

           Resource Declaration:
           ---------------------
           # In /tmp/kitchen/cookbooks/version_control/definitions/some_git_repo.rb

            33:   git "/home/some_repo" do
            34:     repository "[email protected]:some_repo.git"
            35:     revision "1.0.0"
            36:     user "root"
            37:     group "root"
            38:     ssh_wrapper "/tmp/ssh_wrapper.sh"
            39:     action :sync
            40:   end
            41:   # Remote the SSH private key

           Compiled Resource:
           ------------------
           # Declared in /tmp/kitchen/cookbooks/version_control/definitions/some_git_repo.rb:33:in `block in from_file'

           git("/home/some_repo") do
             params {:owner=>"root", :group=>"root", :mode=>"700", :revision=>"1.0.2", :path=>"/home/", :name=>"some_repo"}
             action [:sync]
             retries 0
             retry_delay 2
             default_guard_interpreter :default
             destination "/home/some_repo"
             enable_checkout true
             revision "1.0.0"
             remote "origin"
             ssh_wrapper "/tmp/ssh_wrapper.sh"
             checkout_branch "deploy"
             declared_type :git
             cookbook_name :version_control
             recipe_name "test"
             repository "[email protected]:some_repo.git"
             user "root"
             group "root"
           end

           Platform:
           ---------
           x86_64-linux


       Running handlers:
       [2016-05-02T21:27:02+00:00] ERROR: Running exception handlers
       Running handlers complete
       [2016-05-02T21:27:02+00:00] ERROR: Exception handlers complete
       Chef Client failed. 22 resources updated in 02 minutes 10 seconds
       [2016-05-02T21:27:02+00:00] FATAL: Stacktrace dumped to /tmp/kitchen/cache/chef-stacktrace.out
       [2016-05-02T21:27:02+00:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
       [2016-05-02T21:27:02+00:00] ERROR: git[/home/some_repo] (version_control::test line 33) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '128'
       ---- Begin output of git ls-remote "[email protected]:some_repo.git" "1.0.0*" ----
       STDOUT:
       STDERR: Host key verification failed.
       fatal: Could not read from remote repository.

       Please make sure you have the correct access rights
       and the repository exists.
       ---- End output of git ls-remote "[email protected]:some_company.git" "1.0.0*" ----
       Ran git ls-remote "[email protected]:some_repo.git" "1.0.0*" returned 128
       [2016-05-02T21:27:02+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
>>>>>> Converge failed on instance <test-add-some-repo-ubuntu-1404>.
>>>>>> Please see .kitchen/logs/test-add-some-repo-ubuntu-1404.log for more details
>>>>>> ------Exception-------
>>>>>> Class: Kitchen::ActionFailed
>>>>>> Message: SSH exited (1) for command: [sh -c '

sudo -E /opt/chef/bin/chef-solo --config /tmp/kitchen/solo.rb --log_level auto --force-formatter --no-color --json-attributes /tmp/kitchen/dna.json
']
>>>>>> ----------------------

В документации к ресурсу git сказано, что свойство ssh_wrapper устанавливает переменную среды GIT_SSH. Когда я вхожу в настройку бродячей виртуальной машины с помощью тестовой кухни и запускаю следующую команду...

GIT_SSH=/tmp/ssh_wrapper.sh git ls-remote "[email protected]:some_repo.git" "1.0.0*"

... Я могу получить доступ к репозиторию.

Я безуспешно пробовал решения в нескольких сообщениях о переполнении стека. поваренная книга git: как исправить разрешение запрещено при клонировании частного репо?, Как чтобы получить частный репозиторий git с помощью шеф-повара из gitolite, Частный репозиторий Chef deploy_resource, ключи развертывания ssh и ssh_wrapper, git ошибка при развертывании через шеф-повара

Я тоже пробовал бегать...

GIT_SSH=/tmp/ssh_wrapper.sh git ls-remote "[email protected]:some_repo.git" "1.0.0*"

... используя ресурс bash и execute.

Я не понимаю, почему я не могу клонировать этот репозиторий. Кажется, мне не хватает чего-то основного здесь, но я действительно не знаю, что. Любая помощь приветствуется.


person PaulM    schedule 02.05.2016    source источник


Ответы (1)


Ваша оболочка SSH должна отключить проверку ключа хоста или вам необходимо предварительно заполнить файл known_hosts. Ознакомьтесь с кулинарной книгой application_git, которая позаботится обо всем этом за вас.

person coderanger    schedule 02.05.2016
comment
Спасибо за помощь. Для тех, кто заинтересован, я обновил свой файл ssh_wrapper, чтобы он содержал следующее. файл /tmp/ssh_wrapper.sh do content #!/bin/sh\nexec /usr/bin/ssh -i #{/tmp/key.pem} -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \$@ \ пользовательская корневая группа корневой режим 0700 действие :создать конец - person PaulM; 03.05.2016