fix: add and remove blank lines

Add blank lines where it helps with readability (e.g., between each
task) but also remove needless one.
This commit is contained in:
Christoph Schug 2024-03-03 16:34:29 +01:00
parent 6e52db9cf6
commit 70a8bea0ed
19 changed files with 37 additions and 1 deletions

View File

@ -2,16 +2,19 @@
- name: install fail2ban and configure sshd - name: install fail2ban and configure sshd
hosts: "{{ my_hosts | d([]) }}" hosts: "{{ my_hosts | d([]) }}"
become: true become: true
tasks: tasks:
- name: install fail2ban - name: install fail2ban
ansible.builtin.apt: ansible.builtin.apt:
name: name:
- fail2ban - fail2ban
update_cache: true update_cache: true
- name: copy fail2ban configfiles - name: copy fail2ban configfiles
ansible.builtin.copy: ansible.builtin.copy:
src: configfiles/debian-sshd-default.conf src: configfiles/debian-sshd-default.conf
dest: /etc/fail2ban/jail.d/debian-sshd-default.conf dest: /etc/fail2ban/jail.d/debian-sshd-default.conf
- name: restart fail2ban - name: restart fail2ban
ansible.builtin.systemd_service: ansible.builtin.systemd_service:
state: restarted state: restarted

View File

@ -2,12 +2,14 @@
- name: add ssh key - name: add ssh key
hosts: "{{ my_hosts | d([]) }}" hosts: "{{ my_hosts | d([]) }}"
become: true become: true
tasks: tasks:
- name: install public keys - name: install public keys
ansible.posix.authorized_key: ansible.posix.authorized_key:
user: "{{ lookup('env','USER') }}" user: "{{ lookup('env','USER') }}"
state: present state: present
key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}" key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
- name: change sudoers file - name: change sudoers file
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path: /etc/sudoers path: /etc/sudoers

View File

@ -3,10 +3,12 @@
hosts: "{{ my_hosts | d([]) }}" hosts: "{{ my_hosts | d([]) }}"
become: true become: true
become_user: "{{ lookup('env','USER') }}" become_user: "{{ lookup('env','USER') }}"
tasks: tasks:
- name: create new volume - name: create new volume
community.docker.docker_volume: community.docker.docker_volume:
name: portainer-data name: portainer-data
- name: deploy portainer - name: deploy portainer
community.docker.docker_container: community.docker.docker_container:
name: portainer name: portainer

View File

@ -2,6 +2,7 @@
- name: deploy traefik v2.5 - name: deploy traefik v2.5
hosts: "{{ my_hosts | d([]) }}" hosts: "{{ my_hosts | d([]) }}"
become: true become: true
tasks: tasks:
- name: deploy traefik - name: deploy traefik
become_user: "{{ lookup('env','USER') }}" become_user: "{{ lookup('env','USER') }}"

View File

@ -2,6 +2,7 @@
- name: install core packages - name: install core packages
hosts: "{{ my_hosts | d([]) }}" hosts: "{{ my_hosts | d([]) }}"
become: true become: true
tasks: tasks:
- name: install core packages - name: install core packages
ansible.builtin.apt: ansible.builtin.apt:

View File

@ -2,6 +2,7 @@
- name: install docker - name: install docker
hosts: "{{ my_hosts | d([]) }}" hosts: "{{ my_hosts | d([]) }}"
become: true become: true
tasks: tasks:
- name: install docker dependencies - name: install docker dependencies
ansible.builtin.apt: ansible.builtin.apt:
@ -12,16 +13,19 @@
- gnupg-agent - gnupg-agent
- software-properties-common - software-properties-common
update_cache: true update_cache: true
- name: add docker gpg key - name: add docker gpg key
ansible.builtin.apt_key: ansible.builtin.apt_key:
url: https://download.docker.com/linux/ubuntu/gpg url: https://download.docker.com/linux/ubuntu/gpg
state: present state: present
keyring: /etc/apt/keyrings/docker.gpg keyring: /etc/apt/keyrings/docker.gpg
- name: add docker repository - name: add docker repository
ansible.builtin.apt_repository: ansible.builtin.apt_repository:
filename: docker filename: docker
repo: deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu {{ ansible_lsb.codename|lower }} stable repo: deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu {{ ansible_lsb.codename|lower }} stable
state: present state: present
- name: install docker engine - name: install docker engine
ansible.builtin.apt: ansible.builtin.apt:
name: name:

View File

@ -2,10 +2,12 @@
- name: install microk8s - name: install microk8s
hosts: "{{ my_hosts | d([]) }}" hosts: "{{ my_hosts | d([]) }}"
become: true become: true
tasks: tasks:
- name: install microk8s - name: install microk8s
community.general.snap: community.general.snap:
classic: true classic: true
name: microk8s name: microk8s
- name: add userpermissions - name: add userpermissions
ansible.builtin.shell: "usermod -aG microk8s {{ lookup('env','USER') }}" ansible.builtin.shell: "usermod -aG microk8s {{ lookup('env','USER') }}"

View File

@ -3,6 +3,7 @@
hosts: all hosts: all
become: true become: true
become_method: sudo become_method: sudo
tasks: tasks:
- name: Install qemu-guest-agent - name: Install qemu-guest-agent
ansible.builtin.apt: ansible.builtin.apt:

View File

@ -2,6 +2,7 @@
- name: install core packages for virtual machines - name: install core packages for virtual machines
hosts: "{{ my_hosts | d([]) }}" hosts: "{{ my_hosts | d([]) }}"
become: true become: true
tasks: tasks:
- name: install packages - name: install packages
ansible.builtin.apt: ansible.builtin.apt:
@ -10,6 +11,7 @@
- nfs-common - nfs-common
- qemu-guest-agent - qemu-guest-agent
update_cache: true update_cache: true
- name: start guest qemu-guest-agent - name: start guest qemu-guest-agent
ansible.builtin.service: ansible.builtin.service:
name: qemu-guest-agent name: qemu-guest-agent

View File

@ -2,11 +2,13 @@
- name: install wireguard - name: install wireguard
hosts: "{{ my_hosts | d([]) }}" hosts: "{{ my_hosts | d([]) }}"
become: true become: true
tasks: tasks:
- name: install wireguard - name: install wireguard
ansible.builtin.apt: ansible.builtin.apt:
name: wireguard name: wireguard
update_cache: true update_cache: true
- name: generate private and public keypair - name: generate private and public keypair
ansible.builtin.shell: | ansible.builtin.shell: |
wg genkey | tee privatekey | wg pubkey > publickey wg genkey | tee privatekey | wg pubkey > publickey

View File

@ -2,6 +2,7 @@
- name: install zsh - name: install zsh
hosts: "{{ my_hosts | d([]) }}" hosts: "{{ my_hosts | d([]) }}"
become: true become: true
tasks: tasks:
- name: install zsh - name: install zsh
ansible.builtin.apt: ansible.builtin.apt:

View File

@ -1,13 +1,16 @@
--- ---
- name: check disk space - name: check disk space
hosts: "{{ my_hosts | d([]) }}" hosts: "{{ my_hosts | d([]) }}"
tasks: tasks:
- name: get disk usage - name: get disk usage
ansible.builtin.command: df -h ansible.builtin.command: df -h
register: disk_usage register: disk_usage
- name: check disk space available - name: check disk space available
ansible.builtin.shell: df -Ph / | awk 'NR==2 {print $5}' ansible.builtin.shell: df -Ph / | awk 'NR==2 {print $5}'
register: disk_usage register: disk_usage
# - name: send discord message when disk space is over 80% # - name: send discord message when disk space is over 80%
# uri: # uri:
# url: "your-webhook" # url: "your-webhook"

View File

@ -1,6 +1,7 @@
--- ---
- name: clean docker - name: clean docker
hosts: "{{ my_hosts | d([]) }}" hosts: "{{ my_hosts | d([]) }}"
tasks: tasks:
- name: prune non-dangling images - name: prune non-dangling images
community.docker.docker_prune: community.docker.docker_prune:

View File

@ -2,12 +2,14 @@
- name: check if system reboot is required - name: check if system reboot is required
hosts: "{{ my_hosts | d([]) }}" hosts: "{{ my_hosts | d([]) }}"
become: true become: true
tasks: tasks:
- name: check if system reboot is required - name: check if system reboot is required
become: true become: true
ansible.builtin.stat: ansible.builtin.stat:
path: /var/run/reboot-required path: /var/run/reboot-required
register: reboot_required register: reboot_required
- ansible.builtin.debug: - ansible.builtin.debug:
msg: "Reboot is required" msg: "Reboot is required"
when: reboot_required.stat.exists when: reboot_required.stat.exists

View File

@ -2,6 +2,7 @@
- name: reboot machine - name: reboot machine
hosts: "{{ my_hosts | d([]) }}" hosts: "{{ my_hosts | d([]) }}"
become: true become: true
tasks: tasks:
- name: reboot machine - name: reboot machine
ansible.builtin.reboot: ansible.builtin.reboot:

View File

@ -1,6 +1,7 @@
--- ---
- name: Update and upgrade apt packages - name: Update and upgrade apt packages
hosts: all hosts: all
tasks: tasks:
- name: Update packages with apt - name: Update packages with apt
when: ansible_pkg_mgr == 'apt' when: ansible_pkg_mgr == 'apt'

View File

@ -1,6 +1,7 @@
--- ---
- hosts: all - hosts: all
become: true become: true
tasks: tasks:
- name: install prerequisites - name: install prerequisites
ansible.builtin.apt: ansible.builtin.apt:
@ -11,12 +12,15 @@
- gnupg-agent - gnupg-agent
- software-properties-common - software-properties-common
update_cache: true update_cache: true
- name: add apt-key - name: add apt-key
ansible.builtin.apt_key: ansible.builtin.apt_key:
url: https://download.docker.com/linux/ubuntu/gpg url: https://download.docker.com/linux/ubuntu/gpg
- name: add docker repo - name: add docker repo
ansible.builtin.apt_repository: ansible.builtin.apt_repository:
repo: deb https://download.docker.com/linux/ubuntu focal stable repo: deb https://download.docker.com/linux/ubuntu focal stable
- name: install docker - name: install docker
ansible.builtin.apt: ansible.builtin.apt:
name: name:
@ -25,5 +29,6 @@
- containerd.io - containerd.io
- docker-compose - docker-compose
update_cache: true update_cache: true
- name: add userpermissions - name: add userpermissions
ansible.builtin.shell: "usermod -aG docker vagrant" ansible.builtin.shell: "usermod -aG docker vagrant"

View File

@ -1,11 +1,12 @@
--- ---
- hosts: all - hosts: all
become: true become: true
tasks: tasks:
- name: install microk8s - name: install microk8s
community.general.snap: community.general.snap:
classic: true classic: true
name: microk8s name: microk8s
- name: add userpermissions - name: add userpermissions
ansible.builtin.shell: "usermod -aG microk8s vagrant" ansible.builtin.shell: "usermod -aG microk8s vagrant"

View File

@ -1,6 +1,7 @@
--- ---
- hosts: all - hosts: all
become: true become: true
tasks: tasks:
- name: install cockpit - name: install cockpit
ansible.builtin.apt: ansible.builtin.apt: