2024-09-18 10:08:38 +00:00
|
|
|
- name: Configure system
|
2024-09-18 12:10:57 +00:00
|
|
|
hosts: "{{ target_host }}"
|
2024-09-18 10:08:38 +00:00
|
|
|
become: yes
|
|
|
|
|
|
|
|
tasks:
|
|
|
|
- name: Set unique hostname
|
|
|
|
hostname:
|
|
|
|
name: "{{ inventory_hostname }}"
|
|
|
|
when: ansible_hostname != inventory_hostname
|
|
|
|
|
|
|
|
- name: Install additional packages
|
|
|
|
apt:
|
|
|
|
name:
|
|
|
|
- doas
|
|
|
|
- zsh
|
|
|
|
- tmux
|
|
|
|
- git
|
|
|
|
- jq
|
|
|
|
- acl
|
|
|
|
- curl
|
|
|
|
- wget
|
|
|
|
- netcat-traditional
|
|
|
|
- fping
|
|
|
|
- rsync
|
|
|
|
- htop
|
|
|
|
- iotop
|
|
|
|
- iftop
|
|
|
|
- tar
|
|
|
|
- less
|
|
|
|
- firewalld
|
|
|
|
- sshguard
|
|
|
|
- wireguard
|
|
|
|
- iproute2
|
|
|
|
- iperf3
|
|
|
|
- zfsutils-linux
|
|
|
|
- net-tools
|
|
|
|
- ca-certificates
|
|
|
|
- gnupg
|
|
|
|
- sshpass
|
|
|
|
state: latest
|
|
|
|
update_cache: true
|
|
|
|
|
|
|
|
- name: Verify status of firewalld and enable sshguard
|
|
|
|
systemd:
|
|
|
|
name: "{{ item }}"
|
|
|
|
enabled: yes
|
|
|
|
state: started
|
|
|
|
loop:
|
|
|
|
- firewalld
|
|
|
|
- sshguard
|
|
|
|
|
|
|
|
- name: Disable and remove snapd
|
|
|
|
block:
|
|
|
|
- name: Disable snapd services
|
|
|
|
systemd:
|
|
|
|
name: "{{ item }}"
|
|
|
|
enabled: no
|
|
|
|
state: stopped
|
|
|
|
loop:
|
|
|
|
- snapd.service
|
|
|
|
- snapd.socket
|
|
|
|
- snapd.seeded
|
|
|
|
- snapd.snap-repair.timer
|
|
|
|
|
|
|
|
- name: Purge snapd
|
|
|
|
apt:
|
|
|
|
name: snapd
|
|
|
|
state: absent
|
|
|
|
|
|
|
|
- name: Remove snap directories
|
|
|
|
file:
|
|
|
|
path: "{{ item }}"
|
|
|
|
state: absent
|
|
|
|
loop:
|
|
|
|
- "{{ ansible_env.HOME }}/snap"
|
|
|
|
- /snap
|
|
|
|
- /var/snap
|
|
|
|
- /var/lib/snapd
|
|
|
|
become: yes
|
|
|
|
|
2024-09-23 13:29:16 +00:00
|
|
|
# TODO: Make username and password configurable
|
2024-09-20 04:34:16 +00:00
|
|
|
- name: Create a user `dev`
|
2024-09-18 10:08:38 +00:00
|
|
|
user:
|
2024-09-20 04:34:16 +00:00
|
|
|
name: dev
|
2024-09-18 10:08:38 +00:00
|
|
|
password: "{{ 'so-service-provider' | password_hash('sha512') }}"
|
2024-09-18 12:10:57 +00:00
|
|
|
shell: /bin/zsh
|
2024-09-18 10:08:38 +00:00
|
|
|
state: present
|
|
|
|
|
2024-09-23 13:29:16 +00:00
|
|
|
- name: Add dev user to sudoers group
|
2024-09-18 10:08:38 +00:00
|
|
|
user:
|
2024-09-20 04:34:16 +00:00
|
|
|
name: dev
|
2024-09-18 10:08:38 +00:00
|
|
|
groups: sudo
|
|
|
|
append: yes
|
|
|
|
|
2024-09-20 04:34:16 +00:00
|
|
|
- name: Ensure .ssh directory exists for 'dev' user
|
2024-09-18 10:08:38 +00:00
|
|
|
file:
|
2024-09-20 04:34:16 +00:00
|
|
|
path: /home/dev/.ssh
|
2024-09-18 10:08:38 +00:00
|
|
|
state: directory
|
2024-09-20 04:34:16 +00:00
|
|
|
owner: dev
|
|
|
|
group: dev
|
2024-09-18 10:08:38 +00:00
|
|
|
mode: '0700'
|
2024-09-23 13:29:16 +00:00
|
|
|
|
|
|
|
# TODO: Add tasks to setup passwordless sudo for the user
|