blob: dc29f0a0d10b2cd231a4ccf2d49990f4e1672bb0 [file] [log] [blame]
---
- hosts: '{{ hosts }}'
become: yes
# gather_facts: no
vars:
pubkey: '~/.ssh/id_rsa.pub'
tasks:
# - name: Wait for port 22
# wait_for:
# port: 22
# timeout: 300
# delay: '{{ delay_before_check }}'
- name: Build EC2 facts cache
ec2_facts:
- name: Build setup facts cache
setup:
- name: Copy local public keys to server for user {{ user }}
authorized_key:
user: '{{ user }}'
state: present
key: "{{ lookup('file', '{{ pubkey }}') }}"
- name: Permit root login over SSH
lineinfile:
state: present
dest: /etc/ssh/sshd_config
regexp: '(^#)(PermitRootLogin yes)'
line: '\2'
backrefs: yes
notify:
- Restart SSH service
handlers:
- name: Restart SSH service
service:
name: sshd
state: restarted