Added swapfile and ssh configuration role

This commit is contained in:
Kevin Veen-Birkenbach 2022-08-18 18:12:59 +02:00
parent 25946e6925
commit aeab52ddd8
7 changed files with 37 additions and 27 deletions

View File

@ -1,4 +1,6 @@
# Client Playbook
[![License: AGPL v3](https://img.shields.io/badge/License-AGPL%20v3-blue.svg)](https://www.gnu.org/licenses/agpl-3.0)
Playbook to setup Manjaro GNOME clients.
# Setup
@ -11,33 +13,6 @@ ansible-galaxy collection install -r requirements.yml
- add ssh
# Refactor
```bash
FSTAB_SWAP_ENTRY="/swapfile none swap defaults 0 0"
SWAP_FILE="/swapfile"
FSTAB_FILE="/etc/fstab"
if grep -q "$FSTAB_SWAP_ENTRY" "$FSTAB_FILE"; then
info "Skipping creation of swap partion because entry allready exists in \"$FSTAB_FILE\"!"
else
info "Creating swap partition..." &&
sudo fallocate -l 16G "$SWAP_FILE" &&
sudo chmod 600 "$SWAP_FILE" &&
sudo mkswap "$SWAP_FILE" &&
sudo swapon "$SWAP_FILE" &&
sudo sh -c "echo \"$FSTAB_SWAP_ENTRY\">>\"$FSTAB_FILE\"" || error "Creation of swap partition failed."
fi
info "Setup SSH key..."
ssh_key_path="$HOME/.ssh/id_rsa"
if [ ! -f "$ssh_key_path" ]; then
info "SSH key $ssh_key_path doesn't exists!"
if [ ! -f "./data$ssh_key_path" ]; then
info "Importing ssh key by copying data..." &&
bash "$SCRIPT_PATH""/data/export-to-system.sh" || error "Copying failed."
else
info "Generating ssh key..." &&
ssh-keygen -t rsa -b 4096 -C "$USER@$HOSTNAME" || error "Key generation failed."
fi
fi
info "Setup, configuration and installation of dependencies for installed software..."
if pacman -Qi "arduino" > /dev/null ; then

View File

@ -12,6 +12,16 @@
become: true
roles:
- native-gnome
- name: setup ssh hosts
hosts: ssh_hosts
become: false
roles:
- native-ssh
- name: setup swapfile hosts
hosts: swapfile_hosts
become: false
roles:
- role: native-swapfile
- name: setup gaming hosts
hosts: gaming_hosts
become: true

View File

@ -0,0 +1,2 @@
dependencies:
- native-git

View File

@ -0,0 +1,5 @@
- name: Install caffeine
kewlfft.aur.aur:
use: yay
name:
- caffeine-ng

View File

@ -0,0 +1,6 @@
- name: pull ssh repository from {{ssh_configuration_repository}}
git:
repo: "{{ssh_configuration_repository}}"
dest: "$HOME/.ssh"
update: yes
become: false

View File

@ -0,0 +1,2 @@
dependencies:
- native-git

View File

@ -0,0 +1,10 @@
- name: pull swapfile creating script
git:
repo: "git@github.com:kevinveenbirkenbach/create-linux-swapfile.git"
dest: "$HOME/Repositories/github.com/kevinveenbirkenbach/create-linux-swapfile"
update: yes
become: false
- name: Execute create swapfile script
ansible.builtin.shell: bash "/home/{{client_username}}/Repositories/github.com/kevinveenbirkenbach/create-linux-swapfile/create-linux-swapfile.sh" "{{swapfile_size}}"
become: true