From da391d2f1f30c6b589815df30117375e362ff8de Mon Sep 17 00:00:00 2001 From: Noah Knegt Date: Fri, 12 Apr 2024 17:38:09 +0200 Subject: [PATCH] Add dotfiles integration Signed-off-by: Noah Knegt --- .yamllint.yml | 4 +++- roles/setup/tasks/config/noahk.yml | 17 +++++++++++++++++ roles/setup/tasks/main.yml | 28 +++++++++++++++++++++------- roles/setup/tasks/software/stow.yml | 6 ++++++ 4 files changed, 47 insertions(+), 8 deletions(-) create mode 100644 roles/setup/tasks/config/noahk.yml create mode 100644 roles/setup/tasks/software/stow.yml diff --git a/.yamllint.yml b/.yamllint.yml index cf1c947..10d2a8b 100644 --- a/.yamllint.yml +++ b/.yamllint.yml @@ -7,7 +7,9 @@ ignore: | rules: truthy: - allowed-values: ['true', 'false'] + allowed-values: ["true", "false"] check-keys: false level: error line-length: disable + comments: + min-spaces-from-content: 1 diff --git a/roles/setup/tasks/config/noahk.yml b/roles/setup/tasks/config/noahk.yml new file mode 100644 index 0000000..c280aed --- /dev/null +++ b/roles/setup/tasks/config/noahk.yml @@ -0,0 +1,17 @@ +--- +- name: Setup dotfiles repo + when: inventory_hostname in groups['localhost'] + ansible.builtin.git: + repo: https://git.noahknegt.com/noah.knegt/dotfiles.git # noqa: latest + depth: 1 + dest: /home/noahk/dotfiles + accept_hostkey: true + +- name: Use stow to set up config data + when: inventory_hostname in groups['localhost'] + become: true + become_user: noahk + become_method: ansible.builtin.su + ansible.builtin.command: cd /home/noahk/dotfiles && stow -t ~ . + register: stow_output + changed_when: stow_output.rc != 0 diff --git a/roles/setup/tasks/main.yml b/roles/setup/tasks/main.yml index 4eeb246..11af54c 100644 --- a/roles/setup/tasks/main.yml +++ b/roles/setup/tasks/main.yml @@ -10,21 +10,35 @@ --- - name: Include distribution variables - ansible.builtin.include_vars: "{{ ansible_distribution }}.yml" + ansible.builtin.include_vars: + file: "{{ ansible_distribution }}.yml" # Setup the ansible user - name: Create ansible user - ansible.builtin.include_tasks: users/ansible.yml + ansible.builtin.include_tasks: + file: users/ansible.yml - name: Create usable user - ansible.builtin.include_tasks: users/noahk.yml + ansible.builtin.include_tasks: + file: users/noahk.yml - # Setup the sshd +# Setup the sshd - name: Setup openssh - ansible.builtin.include_tasks: system/openssh.yml + ansible.builtin.include_tasks: + file: system/openssh.yml # Setup the repositories for Debian based systems - name: Setup Debian based repositories - ansible.builtin.include_tasks: software/repositories.yml + ansible.builtin.include_tasks: + file: software/repositories.yml - name: Install and configure UFW - ansible.builtin.include_tasks: software/ufw.yml + ansible.builtin.include_tasks: + file: software/ufw.yml + +- name: Install stow + ansible.builtin.include_tasks: + file: software/stow.yml + +- name: Configure the usable user + ansible.builtin.include_tasks: + file: config/noahk.yml diff --git a/roles/setup/tasks/software/stow.yml b/roles/setup/tasks/software/stow.yml new file mode 100644 index 0000000..f29b3b5 --- /dev/null +++ b/roles/setup/tasks/software/stow.yml @@ -0,0 +1,6 @@ +--- +- name: Install stow + when: inventory_hostname in groups['localhost'] + ansible.builtin.package: + name: stow + state: present