How we can fetch code from Gitlab when create image using packer?

早过忘川 提交于 2019-12-13 08:55:48

问题


I am creating image using packer. I have used 2 provisioners i.e Shell and ansible-local and both are working fine and installed all the required packages.

But now i need to deploy my application code too into my image which is over Gitlab. I am out of idea how we can do this. Can you please help me how we can fetch the code from Gitlab to create image using packer?

Any assistance will be appreciated.

Thanks.


回答1:


You should use ssh agent forwarding.

  1. On the host running Packer load a ssh key that have access to git repository ssh-add <path to private key>.

  2. Ensure that you have "ssh_disable_agent_forwarding": false (default) in your packer template. See Docs: Communicator.

Now in your packer provisioning script you should be able to clone the repository over SSH with git clone git@<GitLab server>:<repo.git>.



来源:https://stackoverflow.com/questions/53826216/how-we-can-fetch-code-from-gitlab-when-create-image-using-packer

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!