aboutsummaryrefslogtreecommitdiffstats
path: root/tasks/general.yml
blob: 0ec92197f147156d0a3fdeb59ed4a1be03cd53b1 (plain)
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
- name: Install packages
  package:
    name: "{{ item }}"
    state: present
  loop:
    - rsync
    - dma
    - jq
    - curl
    - bash
    - python
    - py311-pip
    - fastfetch

- name: Install amd64-specific packages
  package:
    name: "{{ item }}"
    state: present
  loop:
    - vm-bhyve
    - drm-kmod
  when: not is_test_vm

- name: Set up periodic.conf
  template:
    src: etc_periodic.conf.j2
    dest: /etc/periodic.conf
    owner: root
    group: wheel
    mode: "0644"

- name: Set up /etc/rc.conf
  template:
    src: etc_rc.conf.j2
    dest: /etc/rc.conf
    owner: root
    group: wheel
    mode: "0644"
  register: rc_conf

- name: Set up fstab
  template:
    src: etc_fstab.j2
    dest: /etc/fstab
    owner: root
    group: wheel
    mode: "0644"
  register: fstab
  when: not is_test_vm

- name: Run mount -a
  shell: mount -a
  when: not is_test_vm and fstab.changed

- name: Start auditd
  service:
    name: auditd
    state: started

- name: Check if pylogsentinel is installed
  shell: pip show pylogsentinel
  register: pylogsentinel_check
  failed_when: false
  changed_when: false

- name: Install pylogsentinel
  shell: pip install pylogsentinel==0.3.0 --force --no-input
  when: pylogsentinel_check.rc != 0

- name: Install pylogsentinel.conf
  template:
    src: usr_local_etc_pylogsentinel.conf.j2
    dest: /usr/local/etc/pylogsentinel.conf
    owner: root
    group: wheel
    mode: "0644"

- name: Install pylogsentinel-batch-email.sh
  template:
    src: usr_local_bin_pylogsentinel-batch-email.sh.j2
    dest: /usr/local/bin/pylogsentinel-batch-email.sh
    owner: root
    group: wheel
    mode: "0755"

- name: Set up crontab
  template:
    src: etc_crontab.j2
    dest: /etc/crontab
    owner: root
    group: wheel
    mode: "0644"
  register: etc_crontab

- name: Restart cron
  service:
    name: cron
    state: restarted
  when: etc_crontab.changed

- name: Install logto
  template:
    src: usr_local_bin_logto.sh.j2
    dest: /usr/local/bin/logto
    owner: root
    group: wheel
    mode: "0755"

- name: Copy backup SSH private key
  copy:
    src: "{{ backup_ssh_privkey_file }}"
    dest: /root/.ssh/backup
    owner: root
    group: wheel
    mode: "0600"
  when: not is_test_vm

- name: Copy backup SSH public key
  copy:
    src: "{{ backup_ssh_pubkey_file }}"
    dest: /root/.ssh/backup.pub
    owner: root
    group: wheel
    mode: "0644"
  when: not is_test_vm

- name: Copy SSH config
  template:
    src: root_ssh_config.j2
    dest: /root/.ssh/config
    owner: root
    group: wheel
    mode: "0644"
  when: not is_test_vm

- name: Copy backup script
  template:
    src: usr_local_bin_backup.sh.j2
    dest: /usr/local/bin/backup
    owner: root
    group: wheel
    mode: "0755"
  when: not is_test_vm

- name: Check if zroot/vm exists
  shell: zfs list zroot/vm
  register: zroot_vm_check
  failed_when: false
  changed_when: false
  when: not is_test_vm

- name: Add vm dataset for bhyve and init
  when: not is_test_vm and zroot_vm_check.rc != 0
  block:
    - name: Create vm dataset
      shell: zfs create zroot/vm

    - name: Run vm init
      shell: vm init

- name: Install .bashrc
  copy:
    src: templates/root_bashrc
    dest: /root/.bashrc
    owner: root
    group: wheel
    mode: "0644"