semaphore-playbooks/debian12-basic.yml

145 lines
3.6 KiB
YAML
Raw Normal View History

2023-07-21 02:23:22 +02:00
---
- name: Update web servers
hosts: all
remote_user: root
2023-07-21 06:09:23 +02:00
vars:
2023-07-21 06:12:06 +02:00
swapfile_size: 1024
2023-07-21 06:09:23 +02:00
swapfile_path: /swapfile
2023-07-21 02:23:22 +02:00
tasks:
- name: Update all packages to their latest version
ansible.builtin.apt:
name: "*"
state: latest
update_cache: yes
- name: Install a list of packages
ansible.builtin.apt:
pkg:
2023-07-21 05:00:58 +02:00
- htop
2023-07-21 06:09:23 +02:00
- unp
2023-07-21 06:18:56 +02:00
- ufw
2023-07-21 19:16:27 +02:00
- net-tools
2023-08-06 22:11:57 +02:00
- unzip
- btop
2024-04-28 22:44:50 +02:00
- git
2024-04-29 11:16:04 +02:00
- make
2024-04-29 11:53:04 +02:00
- fzf
2023-07-21 06:09:23 +02:00
2024-04-29 10:33:56 +02:00
- name: Remove "neovim" package
ansible.builtin.apt:
name: neovim
state: absent
2023-07-21 06:09:23 +02:00
- name: Create swap file
2023-07-21 06:10:55 +02:00
command: dd if=/dev/zero of={{ swapfile_path }} bs=1M count={{ swapfile_size }}
2023-07-21 06:09:23 +02:00
args:
creates: "{{ swapfile_path }}"
register: swapfile_register_create
- name: Set swap file permissions
file:
path: "{{ swapfile_path }}"
state: "file"
owner: "root"
group: "root"
mode: "0600"
- name: Initialize swap file
command: mkswap {{ swapfile_path }}
when: swapfile_register_create is changed
- name: Enable swap file
command: swapon {{ swapfile_path }}
when: swapfile_register_create is changed
- name: Manage swap file in /etc/fstab
mount:
src: "{{ swapfile_path }}"
name: "none"
fstype: "swap"
opts: "sw,nofail"
dump: "0"
passno: "0"
2023-07-21 06:18:56 +02:00
state: "present"
2023-07-21 06:19:47 +02:00
- name: Allow all access to tcp port 22
community.general.ufw:
rule: allow
port: '22'
proto: tcp
2023-07-21 13:03:45 +02:00
#Monitoring Server
- name: Install monitoring service from deb
ansible.builtin.apt:
deb: https://kekscloud-releases.s3.eu-central-003.backblazeb2.com/http-server-status/stable.deb
2023-07-21 06:19:47 +02:00
2023-07-21 19:17:43 +02:00
- name: Allow all access to tcp port 3003
2023-07-21 19:16:27 +02:00
community.general.ufw:
rule: allow
port: '3003'
proto: tcp
2023-07-21 19:27:56 +02:00
- name: Enable service httpd and ensure it is not masked
ansible.builtin.systemd:
name: http-server-status
enabled: true
masked: no
2023-07-21 19:16:27 +02:00
2023-07-21 19:27:56 +02:00
- name: Make sure a service http-server-status.service is running
ansible.builtin.systemd:
2023-07-21 20:34:39 +02:00
state: restarted
2023-07-21 19:31:09 +02:00
name: http-server-status.service
2023-07-21 19:16:27 +02:00
2023-07-21 06:19:47 +02:00
- name: Allow everything and enable UFW
community.general.ufw:
state: enabled
2023-08-07 00:30:57 +02:00
policy: deny
- name: Download b2 client
ansible.builtin.get_url:
url: https://github.com/Backblaze/B2_Command_Line_Tool/releases/download/v3.9.0/b2-linux
dest: /usr/local/bin/b2
2023-08-07 00:37:22 +02:00
mode: '0770'
2023-08-07 00:38:38 +02:00
- name: Setup b2 client for backups
2024-04-28 22:44:50 +02:00
ansible.builtin.command: "b2 authorize_account {{ b2keyID }} {{ b2applicationKey }}"
2024-04-29 10:33:56 +02:00
# Install neovim from source if not exists, needed because the apt version ist 7.x but we need 8.x
- name: Check if nviom config folder exists
stat:
path: "/opt/nvim-linux64/bin"
register: nvim
2024-04-29 10:41:30 +02:00
- name: Download nvim for linux
2024-04-29 10:33:56 +02:00
ansible.builtin.get_url:
url: "https://github.com/neovim/neovim/releases/download/v0.9.5/nvim-linux64.tar.gz"
dest: "/tmp/nvim-linux64.tar.gz"
mode: '0440'
when: not nvim.stat.exists
2024-04-29 10:41:30 +02:00
- name: Extract nvim to /opt
2024-04-29 10:33:56 +02:00
ansible.builtin.unarchive:
2024-04-29 10:46:22 +02:00
src: "/tmp/nvim-linux64.tar.gz"
remote_src: true
2024-04-29 10:33:56 +02:00
dest: /opt
when: not nvim.stat.exists
2024-04-29 10:41:30 +02:00
- name: add nvim to path in bash
2024-04-29 10:33:56 +02:00
ansible.builtin.lineinfile:
2024-04-29 11:04:27 +02:00
path: ~/.bashrc
2024-04-29 10:33:56 +02:00
regexp: '^export PATH'
line: 'export PATH="$PATH:/opt/nvim-linux64/bin"'
2024-04-28 22:44:50 +02:00
# Setup neovim
- name: Check if nviom config folder exists
stat:
path: "~/.config/nvim"
register: nvimConfig
- name: Git checkout
ansible.builtin.git:
repo: 'https://github.com/LazyVim/starter'
dest: '~/.config/nvim/'
2024-04-28 22:47:08 +02:00
when: not nvimConfig.stat.exists