Answer the question
In order to leave comments, you need to log in
How to properly configure ssh authorization for pipeline in gitlab ci to run ansible-playbook?
Task: installing\updating the application on a group of linux servers.
gitlab-runner is only installed on one server for ansible from which the playbook is running.
gitlab-ci.yml is something like this:
stages:
- install_zabbix_agent
install_zabbix_agent:
stage: install_zabbix_agent
script:
- 'ansible-playbook playbooks/zabbix-agent-linux.yml -i environments/inventory'
tags:
- zabbix
Answer the question
In order to leave comments, you need to log in
Gitlab has secrets where, among other things, you can put SSH keys.
But in general, since you already have runners running on your hosts, it means that you already have access and it is enough to add the gitlab-runner
necessary rights to the user, for example, via sudo
.
3. Give access to the user from which the ansible script is executed on other machines. Just scatter the public key on the rest of the servers.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question