terraform-aws-gitlab-runner
terraform-aws-gitlab-runner copied to clipboard
Modify hosts file of machine (and agent)
I need to append to the hosts files of the machine so that traffic is routed locally instead of the public ip. Is there a configuration option that would allow this? Or possibly to execute a script that could echo into the hosts file.
Could you please give us more details on that use case please?
Sounds like userdata_pre_install
or userdata_post_install
if it is related to the Agent. If it is related to the Runners before_script
in the .gitlab-ci.yml
would be a good choice.
@veshant Does the above mentioned solution fit your needs?
Sorry didn't see this earlier. I'm trying to have traffic all routed through AWS instead of public internet (GL instance and runners in AWS), this specific issue is related to adding into the container registry. the before_script would work, however that would need to be added into every project and future projects too. Was hoping there was a way to have it globally set for the runners.
Sounds that #547 could fix your issue. There is a new parameter runners_extra_hosts
available.
@kayman-mk I actually committed that haha. Unfortunately it adds to the docker machine and not the docker container. I'm thinking I might try building an image with the hosts, but i'll need to look into that more.
Shouldn't we enhance #547 to pass the hosts to the docker container? We could inject it into the pre_build_script
or pre_clone_script
, right?
Example script:
xyz:
stage: verify
script:
- echo "127.0.0.1 ppp" >> /etc/hosts
- ping ppp
Yes that would make sense. I was waiting for the new GitLab Runner Autoscaling architecture to see if there were any other improvements that would allow this with a better approach. Is there any plan to support the new taskscaler + aws fleeting plugin since they are moving away from docker machine?
Refs: https://docs.gitlab.com/ee/architecture/blueprints/runner_scaling/index.html https://gitlab.com/gitlab-org/gitlab-runner/-/issues/29312 https://gitlab.com/gitlab-org/gitlab-runner/-/issues/29219#note_1169146211
We should definitely support that. I created a new issue #624 for that and close this issue as answered.