don't install dbus snd pam-systemd on non-systemd hosts
[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     - lsof
46     - haveged
47     - ntp
48     - screen
49     - aptitude
50     - unp
51     - ca-certificates
52     - file
53     - zsh
54
55 - name: install systemd specific packages
56   apt: name={{ item }} state=present
57   with_items:
58     - dbus
59     - libpam-systemd
60   when: ansible_service_mgr == "systemd"
61
62 - name: install zshrc
63   copy: src={{ item.src }} dest={{ item.dest }} mode=0640
64   with_items:
65     - { "src": "zshrc", "dest": "/etc/zsh/zshrc" }
66     - { "src": "zshrc.skel", "dest": "/etc/skel/.zshrc" }
67
68 - name: set root default shell to zsh
69   user: name=root shell=/bin/zsh
70
71 - name: set default shell for adduser
72   lineinfile: dest=/etc/adduser.conf regexp={{ item.regexp }} line={{ item.line }}
73   with_items:
74     - { regexp: "^DSHELL", line: "DSHELL=/bin/zsh" }