From 2db6b4beba4930d43d56e98c7267d61ca56e80e4 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Thu, 18 Aug 2022 18:12:59 +0200 Subject: [PATCH] Added swapfile and ssh configuration role --- README.md | 29 ++-------------------------- playbook.yml | 10 ++++++++++ roles/native-ssh/meta/main.yml | 2 ++ roles/native-ssh/tasks copy/main.yml | 5 +++++ roles/native-ssh/tasks/main.yml | 6 ++++++ roles/native-swapfile/meta/main.yml | 2 ++ roles/native-swapfile/tasks/main.yml | 10 ++++++++++ 7 files changed, 37 insertions(+), 27 deletions(-) create mode 100644 roles/native-ssh/meta/main.yml create mode 100644 roles/native-ssh/tasks copy/main.yml create mode 100644 roles/native-ssh/tasks/main.yml create mode 100644 roles/native-swapfile/meta/main.yml create mode 100644 roles/native-swapfile/tasks/main.yml diff --git a/README.md b/README.md index 6b73114..d102c4e 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/playbook.yml b/playbook.yml index 4fbde18..20a7d4d 100644 --- a/playbook.yml +++ b/playbook.yml @@ -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 diff --git a/roles/native-ssh/meta/main.yml b/roles/native-ssh/meta/main.yml new file mode 100644 index 0000000..3bce5ff --- /dev/null +++ b/roles/native-ssh/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: +- native-git \ No newline at end of file diff --git a/roles/native-ssh/tasks copy/main.yml b/roles/native-ssh/tasks copy/main.yml new file mode 100644 index 0000000..738d421 --- /dev/null +++ b/roles/native-ssh/tasks copy/main.yml @@ -0,0 +1,5 @@ +- name: Install caffeine + kewlfft.aur.aur: + use: yay + name: + - caffeine-ng \ No newline at end of file diff --git a/roles/native-ssh/tasks/main.yml b/roles/native-ssh/tasks/main.yml new file mode 100644 index 0000000..20c4eb4 --- /dev/null +++ b/roles/native-ssh/tasks/main.yml @@ -0,0 +1,6 @@ +- name: pull ssh repository from {{ssh_configuration_repository}} + git: + repo: "{{ssh_configuration_repository}}" + dest: "$HOME/.ssh" + update: yes + become: false \ No newline at end of file diff --git a/roles/native-swapfile/meta/main.yml b/roles/native-swapfile/meta/main.yml new file mode 100644 index 0000000..3bce5ff --- /dev/null +++ b/roles/native-swapfile/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: +- native-git \ No newline at end of file diff --git a/roles/native-swapfile/tasks/main.yml b/roles/native-swapfile/tasks/main.yml new file mode 100644 index 0000000..4bf046b --- /dev/null +++ b/roles/native-swapfile/tasks/main.yml @@ -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 \ No newline at end of file