Skip to content

Instantly share code, notes, and snippets.

@jonsbun
Created December 3, 2019 21:36
Show Gist options
  • Save jonsbun/ca77975e3df80a879e8d4e284c89b7a6 to your computer and use it in GitHub Desktop.
Save jonsbun/ca77975e3df80a879e8d4e284c89b7a6 to your computer and use it in GitHub Desktop.
Prepare Server(s) for Ansible (ansible-init): https://github.com/jonsbun/ansible-init
---
- name: Prepare localhost for Ansible usage
hosts: localhost
connection: local
gather_facts: yes
tasks:
- name: Generate SSH key
user:
name: "{{ ansible_user_id }}"
generate_ssh_key: yes
- name: Prepare host(s) for Ansible usage
hosts: all
gather_facts: no
tasks:
- name: Set authorized key on remote
authorized_key:
user: "{{ ansible_user }}"
state: present
key: "{{ lookup('file', lookup('env','HOME') + '/.ssh/id_rsa.pub') }}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment