aboutsummaryrefslogtreecommitdiffstats
path: root/roles/common/tasks/main.yml
blob: b0537e5c0cb33b7016ff0a591e54672d60e77ee5 (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
- 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: Disable SSH password authentication
  lineinfile:
    dest: /etc/ssh/sshd_config
    regexp: "^PasswordAuthentication"
    line: "PasswordAuthentication no"
    state: present
  notify:
    - Restart ssh
  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: Add sudoers lecture path
  lineinfile:
    dest: /etc/sudoers
    regexp: '^Defaults +?lecture_file ?= ?".+?"$'
    line: 'Defaults    lecture_file = "/etc/sudo_lecture"'
    state: present
    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