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

Last change on this file since 13847 was 13847, checked in by uli, 8 years ago

Fix task for modifying sudoers file.

As colon followed by space (': ') is interpreted by PyYAML erranous (a
well-known problem, as it looks), we have to do tricks. "Quoting" the
colon with the "{{ ':' }}" expression helps.

File size: 1.8 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="^root"
36        line="{{ deploy_user }}  ALL=(ALL) NOPASSWD{{ ':' }} ALL"
37        state=present
38
39    - name: "bootstrap | disable dsa keys in sshd_config"
40      lineinfile:
41        dest=/etc/ssh/sshd_config
42        backrefs=yes
43        line='# HostKey /etc/ssh/ssh_host_dsa_key'
44        regexp='^HostKey /etc/ssh/ssh_host_dsa_key'
45        state=present
46
47    - name: "bootstrap | disable ecdsa keys in sshd_config"
48      lineinfile:
49        dest=/etc/ssh/sshd_config
50        backrefs=yes
51        line='# HostKey /etc/ssh/ssh_host_ecdsa_key'
52        regexp='^HostKey /etc/ssh/ssh_host_ecdsa_key'
53        state=present
54
55    - name: "bootstrap | set key bits in sshd_config to 4096"
56      lineinfile:
57        dest=/etc/ssh/sshd_config
58        backrefs=yes
59        line='ServerKeyBits 4096'
60        regexp='^ServerKeyBits 1024'
61        state=present
62
63    - name: "bootstrap | restart sshd"
64      service:
65        name="ssh"
66        enabled=yes
67        state=restarted
Note: See TracBrowser for help on using the repository browser.