aboutsummaryrefslogtreecommitdiffstats
path: root/ansible/roles/common/tasks/main.yml
blob: 428161fc411248cbe759b6f557346510c79c1835 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
- name: Update hostname to match Ansible inventory
  hostname:
    name: "{{ inventory_hostname }}"
  tags:
    - role::common

- name: Update /etc/hosts to match Ansible inventory
  template:
    src: etc-hosts.j2
    dest: /etc/hosts
    mode: '0644'
    owner: root
    group: root
  tags:
    - role::common

- name: Configure SSH daemon options
  ansible.builtin.copy:
    content: |
      # Ansible managed

      # Logins
      PasswordAuthentication no
      PermitRootLogin no

      # Forwarding
      AllowAgentForwarding no
      X11Forwarding no

      # Connection keepalive
      ClientAliveInterval 300
      ClientAliveCountMax 3
    dest: /etc/ssh/sshd_config.d/hardening.conf
    owner: root
    group: root
    mode: "0444"
  notify:
    - Reload ssh
  tags:
    - role::common

- name: Configure default security limits
  ansible.builtin.copy:
    content: |
      # Ansible managed

      # <domain>  <type>  <item>  <value>
      *           soft    nproc   100
      *           hard    nproc   200
    dest: /etc/security/limits.d/pydis.conf
    owner: root
    group: root
    mode: "0444"
  tags:
    - role::common

- name: Set timezone to UTC
  file:
    src: /usr/share/zoneinfo/Etc/UTC
    dest: /etc/localtime
    mode: '0644'
    owner: root
    group: root
  notify:
    - Restart systemd-timesyncd
  tags:
    - role::common

- name: Create sudoers lecture
  template:
    src: sudo_lecture.j2
    dest: /etc/sudo_lecture
    mode: '0644'
    owner: root
    group: root
  tags:
    - role::common

- name: Configure sudo
  template:
    src: sudoers.j2
    dest: /etc/sudoers.d/pydis
    owner: root
    group: root
    mode: '0440'
    validate: /usr/sbin/visudo -cf %s
  tags:
    - role::common

- name: Configure MOTD
  template:
    src: motd.j2
    dest: /etc/motd
    mode: '0644'
    owner: root
    group: root
  tags:
    - role::common

- name: Enable default .bashrc for root
  copy:
    src: /etc/skel/.bashrc
    dest: /root/.bashrc
    remote_src: true
    mode: '0644'
    owner: root
    group: root
  tags:
    - role::common