source: main/waeup-ansible/bootstrap.yml @ 13845

Last change on this file since 13845 was 13845, checked in by uli, 9 years ago

Add tasks for securing sshd config.

File size: 1.9 KB
Line 
1---
2# This ansible-playbook prepares fresh-from-hetzner
3# servers for work with ansible.
4#
5# What it does:
6#   secures sshd (according to bettercrypto.org)
7#   adds accounts uli/henrik/deploy
8#   disables root access
9#
10# This playbook should be executed as first thing
11# after getting your hands over new hardware
12#
13# It will normally be run with ``ask-pass``
14#
15- hosts: yet-untouched
16  vars:
17    deploy_user: 'deploy'
18    deploy_public_key: "{{ lookup('file', 'files/id-deploy.pub') }}"
19  tasks:
20
21    - name: "bootstrap | create 'deploy' user"
22      user:
23        name="{{ deploy_user }}"
24        append=yes
25        uid=2222
26
27    - name: "bootstrap | update authorized key of 'deploy'"
28      authorized_key:
29        user="{{ deploy_user }}"
30        key="{{ deploy_public_key }}"
31
32    - name: "bootstrap | grant sudoers perms to 'deploy'"
33      lineinfile:
34        "dest=/etc/sudoers
35        insertafter=EOF
36        line='{{ deploy_user }} ALL=(ALL) NOPASSWD: ALL'
37        regexp='{{ deploy_user }} ALL=(ALL) NOPASSWD: ALL'
38        state=present"
39
40    - name: "bootstrap | disable dsa keys in sshd_config"
41      lineinfile:
42        dest=/etc/ssh/sshd_config
43        backrefs=yes
44        line='# HostKey /etc/ssh/ssh_host_dsa_key'
45        regexp='^HostKey /etc/ssh/ssh_host_dsa_key'
46        state=present
47
48    - name: "bootstrap | disable ecdsa keys in sshd_config"
49      lineinfile:
50        dest=/etc/ssh/sshd_config
51        backrefs=yes
52        line='# HostKey /etc/ssh/ssh_host_ecdsa_key'
53        regexp='^HostKey /etc/ssh/ssh_host_ecdsa_key'
54        state=present
55
56    - name: "bootstrap | set key bits in sshd_config to 4096"
57      lineinfile:
58        dest=/etc/ssh/sshd_config
59        backrefs=yes
60        line='ServerKeyBits 4096'
61        regexp='^ServerKeyBits 1024'
62        state=present
63
64    - name: "bootstrap | restart sshd"
65      service:
66        name="ssh"
67        enabled=yes
68        state=restarted
Note: See TracBrowser for help on using the repository browser.