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

Last change on this file since 17902 was 16987, checked in by uli, 2 years ago

Update SSH config to current infosec state.

File size: 1.9 KB
Line 
1---
2# This ansible-playbook prepares fresh-from-hetzner
3# servers for work with ansible.
4#
5# It should be played as first thing after getting your hands over new
6# hardware
7#
8# The documentation for this playbook is in `README.rst`.  Please read
9# it! Do not run this playbook without having read the README.
10#
11- hosts: yet_untouched
12  become: yes
13  vars:
14    # Enable root access via SSH? Set to false not before user
15    # accounts are active.
16    permit_ssh_root: false
17    # Allow admin users below to become root w/o entering password?
18    permit_become_root_no_password: true
19    create_admin_user: false
20    # create hashed passwords like this:
21    #      $ diceware -d '-' -n 6 --no-caps | tee mypw | mkpasswd -s --method=sha-512 >> mypw
22    admin_users: {}
23
24        #    uli:
25        #         hashed_pw: "$6$iuoXy2wO3elWM6d2$NR/ayKF58q0Bm0BdsR.g.Nt5xYzD0s0t17ZjrYaRpY7nkRekjgHTnqw849pK9FdynmNZAioW6oQBQx3BB5kcd0"
26
27  roles:
28  - openssh
29
30  handlers:
31  - name: "Restart sshd"
32    service:
33      name="ssh"
34      enabled=yes
35      state=restarted
36
37  tasks:
38  - name: Create admin users
39    when: create_admin_users
40    user:
41      name: "{{ item.key }}"
42      shell: /bin/bash
43      groups: sudo
44      password: "{{ item.value.hashed_pw }}"
45      update_password: on_create
46      state: present
47    with_dict: "{{ admin_users }}"
48
49  - name: Disable SSH root access
50    # make sure this is not run before you can log in otherwise!
51    lineinfile:
52      dest=/etc/ssh/sshd_config
53      backrefs=yes
54      line='PermitRootLogin no'
55      regexp='^PermitRootLogin yes'
56      state=present
57    notify: "restart sshd"
58    when: not permit_ssh_root
59
60  - name: Disable SSH root access
61    # make sure this is not run before you can log in otherwise!
62    lineinfile:
63      dest=/etc/ssh/sshd_config
64      line="AuthenticationMethods publickey"
65      state=present
66    notify: "restart sshd"
67    when: not permit_ssh_root
Note: See TracBrowser for help on using the repository browser.