M
M
Mika Slepinin2016-11-17 18:35:53
Ansible
Mika Slepinin, 2016-11-17 18:35:53

Ansible - how best to organize work with ssh keys?

What is the best way to organize work with ssh keys in Ansible?
Let's say I have 10 machines where I want to run playbooks from mine, local, and two laptops.
The start of the playbook looks like this:

- hosts: server
  remote_user: test
  become: yes
  become_method: sudo

Right now, when I'm working from one local machine, it has a "test" user. All machines also have this user added to the "wheel" group
and forwarded keys. I added all the keys manually via ssh-copy-id, on each of the 10 machines.
Is it possible to automate this somehow? If there are 1000 machines, will you have to manually add ssh keys to each one?
Tried also using one set of keys for all, like this:
- name: Добавляю ssh-ключ
  authorized_key: user=test key="{{ lookup('file', '/home/test/.ssh/id_rsa.pub') }}"

but it doesn't work.
Is it somehow possible to go from many users to one key?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Danil Biryukov-Romanov, 2016-11-17
@urtow

Raise the CI server and run playbooks from it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question