added base role
[noc.git] / roles / base / tasks / main.yaml
1 ---
2 - name: only allow pubkey auth for root
3   lineinfile:
4      dest: /etc/ssh/sshd_config
5      regexp: "^PermitRootLogin"
6      line: "PermitRootLogin without-password"
7   notify: restart ssh
8
9 - name: limit allowed users (1/2)
10   lineinfile:
11      dest: /etc/ssh/sshd_config
12      regexp: "^AllowUsers"
13      line: "AllowUsers {{ ' '.join([ 'root' ] | union(sshd_allowusers_group | default([])) | union(sshd_allowusers_host | default([]))) }}"
14   when: "{{ sshd_allowusers_set | default(true) }}"
15   notify: restart ssh
16
17 - name: limit allowed users (2/2)
18   lineinfile:
19      dest: /etc/ssh/sshd_config
20      regexp: "^AllowUsers"
21      state: absent
22   when: "not {{ sshd_allowusers_set | default(true) }}"
23   notify: restart ssh
24
25 - name: Set authorized keys for root user
26   authorized_key:
27     user: root
28     key: "{{ lookup('pipe','cat ssh/noc/*.pub') }}"
29     exclusive: yes
30
31 - name: disable apt suggests and recommends
32   copy: src=02no-recommends dest=/etc/apt/apt.conf.d/ mode=0640
33
34 - name: install basic packages
35   apt: name={{ item }} state=present
36   with_items:
37     - less
38     - psmisc
39     - sudo
40     - htop
41     - dstat
42     - mtr-tiny
43     - tcpdump
44     - debian-goodies
45     - dbus
46     - libpam-systemd
47     - lsof
48     - haveged
49     - ntp
50     - screen
51     - aptitude
52     - unp
53     - ca-certificates
54     - file
55     - zsh
56
57 - name: install zshrc
58   copy: src={{ item.src }} dest={{ item.dest }} mode=0640
59   with_items:
60     - { "src": "zshrc", "dest": "/etc/zsh/zshrc" }
61     - { "src": "zshrc.skel", "dest": "/etc/skel/.zshrc" }
62
63 - name: set root default shell to zsh
64   user: name=root shell=/bin/zsh
65
66 - name: set default shell for adduser
67   lineinfile: dest=/etc/adduser.conf regexp={{ item.regexp }} line={{ item.line }}
68   with_items:
69     - { regexp: "^DSHELL", line: "DSHELL=/bin/zsh" }