Ansible : Automatisches Registrieren der SSH Keys
Wir haben hier einige Adminstratoren die auf die erstellten Umgebungen Zugriff benötigen. Der Zugriff geschieht immer über einen SSH Key. Diese werden in unseren Ansible Script auf diese Weise registriert.
- name: register default ssh admin keys authorized_key: user: admin state: present key: "{{ lookup('file', '{{ item }}') }}" with_fileglob: - "/ansible-deploy/global/ssh-keys/*.pub" - name: register admin-ssh-key for user app authorized_key: user: app state: present key: '{{ item }}' with_file: - "{{ admin_ssh_pub_file }}" - name: register default ssh app keys authorized_key: user: app state: present key: "{{ lookup('file', '{{ item }}') }}" with_fileglob: - '/ansible-deploy/global/ssh-keys/*.pub' # allow developers to access servers - name: register projekt-ssh keys for user app authorized_key: user: app state: present key: "{{ lookup('file', '{{ item }}') }}" with_fileglob: - '/ansible-deploy/customers/{{ customer }}/project_ssh_keys/*.pub' # register key for user app to allow access between servers # to generate a private key for this platform you can change into the project_ssh_keys directory and use # ssh-keygen -t rsa -b 4096 -f ./id_rsa -P '' -C 'app-key' - name: copy the app private key copy: owner: app group: app mode: 0600 src: "/ansible-deploy/customers/{{ customer }}/project_ssh_keys/id_rsa" dest: "/home/app/.ssh/id_rsa"