From 26b96ecd2988c0416f83fe9334e82ae44e2f486d Mon Sep 17 00:00:00 2001 From: Cian Hatton Date: Mon, 1 Aug 2022 13:19:55 +0100 Subject: [PATCH] added user variables --- ansible/homelab/playbooks/redeploy-dashy.yml | 2 ++ ansible/homelab/playbooks/restore-all.yml | 2 ++ ansible/homelab/playbooks/setup-home-lab.yml | 2 ++ ansible/homelab/playbooks/volume-restore.yml | 2 ++ .../homelab/tasks/checkout-git-repos-tasks.yml | 8 ++++---- ansible/homelab/tasks/install-sudo-tasks.yml | 16 ++++++++-------- ansible/homelab/variables.yml | 4 ++++ 7 files changed, 24 insertions(+), 12 deletions(-) create mode 100644 ansible/homelab/variables.yml diff --git a/ansible/homelab/playbooks/redeploy-dashy.yml b/ansible/homelab/playbooks/redeploy-dashy.yml index c51285e..f408c42 100644 --- a/ansible/homelab/playbooks/redeploy-dashy.yml +++ b/ansible/homelab/playbooks/redeploy-dashy.yml @@ -1,5 +1,7 @@ --- - hosts: servers + vars_files: + - ../variables.yml become: true tasks: - name: Checkout Git Repos diff --git a/ansible/homelab/playbooks/restore-all.yml b/ansible/homelab/playbooks/restore-all.yml index bf77335..37261a0 100644 --- a/ansible/homelab/playbooks/restore-all.yml +++ b/ansible/homelab/playbooks/restore-all.yml @@ -14,6 +14,8 @@ --- - name: Redeploy Portainer and All Volumes hosts: servers + vars_files: + - ../variables.yml tasks: - name: Restore Tautulli import_tasks: ../tasks/restore-volume-tasks.yml diff --git a/ansible/homelab/playbooks/setup-home-lab.yml b/ansible/homelab/playbooks/setup-home-lab.yml index d594715..5ae1340 100644 --- a/ansible/homelab/playbooks/setup-home-lab.yml +++ b/ansible/homelab/playbooks/setup-home-lab.yml @@ -1,6 +1,8 @@ --- - hosts: servers become: true + vars_files: + - ../variables.yml tasks: - name: Update and upgrade apt packages apt: diff --git a/ansible/homelab/playbooks/volume-restore.yml b/ansible/homelab/playbooks/volume-restore.yml index 3057fc3..6f6685a 100644 --- a/ansible/homelab/playbooks/volume-restore.yml +++ b/ansible/homelab/playbooks/volume-restore.yml @@ -2,6 +2,8 @@ # ansible-playbook -v ansible/playbooks/volume-restore.yml -e "container_name=mariadb" --- - hosts: servers + vars_files: + - ../variables.yml tasks: - name: Restore Volume import_tasks: ../tasks/restore-volume-tasks.yml diff --git a/ansible/homelab/tasks/checkout-git-repos-tasks.yml b/ansible/homelab/tasks/checkout-git-repos-tasks.yml index 0141cd6..a104329 100644 --- a/ansible/homelab/tasks/checkout-git-repos-tasks.yml +++ b/ansible/homelab/tasks/checkout-git-repos-tasks.yml @@ -2,12 +2,12 @@ - name: Git checkout HomeLab repository ansible.builtin.git: repo: 'https://github.com/chatton/HomeLab.git' - dest: /home/cianhatton/checkouts/HomeLab + dest: "/home/{{homelab_user}}/checkouts/HomeLab" force: true version: master - name: Change Ownership file: - path: /home/cianhatton/checkouts/HomeLab - owner: cianhatton - group: cianhatton \ No newline at end of file + path: "/home/{{homelab_user}}/checkouts/HomeLab" + owner: "{{homelab_user}}" + group: "{{homelab_group}}" \ No newline at end of file diff --git a/ansible/homelab/tasks/install-sudo-tasks.yml b/ansible/homelab/tasks/install-sudo-tasks.yml index dc88337..2dbcee8 100644 --- a/ansible/homelab/tasks/install-sudo-tasks.yml +++ b/ansible/homelab/tasks/install-sudo-tasks.yml @@ -7,21 +7,21 @@ state: latest update_cache: true -- name: Make sure we have a 'cianhatton' group +- name: Make sure we have a '{{homelab_group}}' group group: - name: cianhatton + name: "{{homelab_group}}" state: present -- name: Allow 'cianhatton' group to have passwordless sudo +- name: Allow '{{homelab_user}}' group to have passwordless sudo lineinfile: dest: /etc/sudoers state: present - regexp: '^%cianhatton' - line: '%cianhatton ALL=(ALL) NOPASSWD: ALL' + regexp: '^%{{homelab_user}}' + line: '%{{homelab_user}} ALL=(ALL) NOPASSWD: ALL' validate: 'visudo -cf %s' - name: Add User ansible.builtin.user: - name: cianhatton - comment: Cian Hatton + name: "{{homelab_user}}" + comment: "{{homelab_user}} user" uid: 1000 - group: cianhatton \ No newline at end of file + group: "{{homelab_group}}" \ No newline at end of file diff --git a/ansible/homelab/variables.yml b/ansible/homelab/variables.yml new file mode 100644 index 0000000..fcd149c --- /dev/null +++ b/ansible/homelab/variables.yml @@ -0,0 +1,4 @@ +--- +homelab_user: cianhatton +homelab_group: cianhatton +backup_dir: /mnt/hdds/backups/ \ No newline at end of file