From 47cd582d3a90de07fe17a8bc4c0cb0f4ca91f090 Mon Sep 17 00:00:00 2001 From: Benjamyn Love Date: Thu, 25 May 2023 10:06:15 +1000 Subject: [PATCH] Initial --- .gitignore | 2 ++ README.md | 9 +++++++++ inventories/testing/hosts | 10 ++++++++++ roles/benssanity/tasks/main.yml | 31 +++++++++++++++++++++++++++++++ roles/sync/files/authorized_keys | 10 ++++++++++ roles/sync/tasks/main.yml | 15 +++++++++++++++ roles/update/tasks/main.yml | 22 ++++++++++++++++++++++ run.yml | 6 ++++++ 8 files changed, 105 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 inventories/testing/hosts create mode 100644 roles/benssanity/tasks/main.yml create mode 100644 roles/sync/files/authorized_keys create mode 100644 roles/sync/tasks/main.yml create mode 100644 roles/update/tasks/main.yml create mode 100644 run.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b308ccb --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*.id_rsa +*.id_rsa* diff --git a/README.md b/README.md new file mode 100644 index 0000000..67a154b --- /dev/null +++ b/README.md @@ -0,0 +1,9 @@ +Ansible playbooks for the home network + +Add hosts to inventory/production/hosts + +Add testing hosts to inventory/testing/hosts + + +run with `ansible-playbook -i INVENTORYFILE run.yml` + diff --git a/inventories/testing/hosts b/inventories/testing/hosts new file mode 100644 index 0000000..4c35917 --- /dev/null +++ b/inventories/testing/hosts @@ -0,0 +1,10 @@ +[servers] +proxmox ansible_host=10.6.9.46 +docker ansible_host=10.6.9.199 +gitea ansible_host=10.6.9.44 +ipa ansible_host=10.6.9.23 +seedy2 ansible_host=10.6.9.5 +tailscale ansible_host=10.6.9.109 +backups ansible_host=10.6.9.79 +build ansible_host=10.6.9.103 +ansible ansible_host=10.6.9.37 diff --git a/roles/benssanity/tasks/main.yml b/roles/benssanity/tasks/main.yml new file mode 100644 index 0000000..bdc0794 --- /dev/null +++ b/roles/benssanity/tasks/main.yml @@ -0,0 +1,31 @@ +--- +- name: Vim is installed and up to date (rhel) + yum: + name: "{{ item }}" + state: latest + loop: + - vim + - wget + - git + when: ansible_distribution == 'CentOS' or ansible_distribution == 'RedHat' or ansible_distribution == 'AlmaLinux' + +- name: Vim is installed and up to date (debian) + apt: + name: "{{ item }}" + state: present + update_cache: yes + loop: + - vim + - wget + - git + when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' + +- name: Vim is installed and up to date (arch) + community.general.pacman: + name: "{{ item }}" + state: present + loop: + - vim + - wget + - git + when: ansible_distribution == 'Archlinux' diff --git a/roles/sync/files/authorized_keys b/roles/sync/files/authorized_keys new file mode 100644 index 0000000..5b2ee41 --- /dev/null +++ b/roles/sync/files/authorized_keys @@ -0,0 +1,10 @@ +# Synced with ansible + +# Ansible +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCx0kTJhCe3MRBAM4BQoY/Hb7uoYJA0hwTkwJ0Nr80helmMKTT22h5bh5gFBmoq645e66J1vCsWN5vAwF3J0vHSxWkH3SxwIojolMviZwjOOF4+Ym7oMk7ejCoS58llGi9hcOEjXpvbYD4fxe2hO3uihfvRO3kBLfaVdJnhQRzXn/vfRoKxuITLRo3dI6aAqiv+piRnfcCG9ZgqKUchsA8Gp1ZB3n3YIDUhYDEqG6Wd/k5Xyv37bcfB/Xsl0+s5IY1pIMJAvX/dxJxH6sPjG06NOTwZWQSVlAJFBAzpQyFvtcOYVCKKXm7COMHqUHtjftzG//Dl8ZdRWlt6e9ZSn/Vc8t3VfunUCi7Fnk/mDDSXrHAohwfK/wmep7c//QP61DSecmLVB7CVQ5lC/3bcieYsSK8LO8nPkP+sFQ4QNEPoZBRD/tGJbM5p/9nv1WtP+u4haTivmXBPyKFQr4wDuFAxiEN63bHMejS27NEG4i2NzdQiAt0ZGCTtsiLJku4CJb8= ben@archibold.lovelynet.net + +# Benjamyn Love +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC7oqGBT6uwAUw5FsQKDd8hfZ340OY8w3iWZq7UAf/iiU4dZOy3azLxEAIQHZiRlV+T7OxzaRgceyJgDNBDmsgJTv8jTen2wFr0a/wnt6FcvfbZqojxkyuAtThStX+d65/T3ASmnZOlWbsBYnDQTRxrNRxXp850MK7C5mkre4gMxdG/FtEmCXJMIYACacAi5R+mP2gHmrmLgfN0saqprVz1A2/aYPmDQz/MGKuGkj8x0Qm/GcMkYwxNNCCdJq8EoqR+umIm6RYwCdvcWP2wj2ut4b5ZOVg1l4PWtvqNLs4whrtstau0SQalXwyCIfecy5wcArALKDFxpl220lwIhmBZBVWuS6uwSmmbFJyvYAy7279rjDUimM1Vj0c+tPYoIrM0kvn+0JApf1lNTO3qPPe0MuL1CjzaE64rZEChhh+sWQpBDCea9ouyXw+nB0JsF96wSd5u9dTfehLmIcjSoTnBeiRZO5HdWwrPeI5fMLjINhh42QsVK4d8Gys1cZbPSEE= ben@archibold.lovelynet.net + +# Jordan Martin-Hall +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDSSjBLx4imVMgxhAo2za10/8HRE9ngjYF4vseVm9mwGFCUVbP3bCEq1dSSzPEuml239pFnMUNQqY857L+lh1KGbFp3x0iEzZa/+cbKQX1k4gGujdMEYXvyzW9vBptf11JdKASNuS7XOwSwlkAJiG+gW9gN5hvVldkHc/4uCZILvwVojtsBDfVbaB4BcNP694iGmmLbUgCfoMOXvR5+stFtfOaPR9I1yBdnW6Wmx/sX5fuNouq22s+X60HGOYrwDMDmq0uZV5riXkyAIa2LBdtaAiAj4FeCyL1GxRAhftPDTROxL8uYk+EIfVkdj+fZqBUBDALpK/Q92Qohhi+0XqT6ENuIdHZDeJrH5ebasDyLtpr+zJlVcxBIxJW+a8ub2NeaLZvlj4xkp/vvEKre9zrmxVMaFHGSmoi6QtBHR8GpwkVzJCiYVrMpzk6i/LW91mMwHXgje/oCu8g3DCCUIzpaBkMYn3qFHN6OR1IcaVD8qS4gg73ohn2UXM183LiwNms= jorraan@archbox.JMH diff --git a/roles/sync/tasks/main.yml b/roles/sync/tasks/main.yml new file mode 100644 index 0000000..2c77870 --- /dev/null +++ b/roles/sync/tasks/main.yml @@ -0,0 +1,15 @@ +--- +- name: verify that .ssh exists + file: + path: /root/.ssh + state: directory + mode: "0600" + tags: + - sync + +- name: sync ssh authorized_keys + copy: + src: authorized_keys + dest: /root/.ssh/authorized_keys + tags: + - sync diff --git a/roles/update/tasks/main.yml b/roles/update/tasks/main.yml new file mode 100644 index 0000000..8a67490 --- /dev/null +++ b/roles/update/tasks/main.yml @@ -0,0 +1,22 @@ +--- +- name: run updates (debian) + apt: upgrade=dist force_apt_get=yes + tags: + - debian + - update + when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' + +- name: run updates (rhel) + yum: + name: '*' + state: latest + tags: + - rhel + - update + when: ansible_distribution == 'CentOS' or ansible_distribution == 'RedHat' or ansible_distribution == 'AlmaLinux' + +- name: run updates (arch) + community.general.pacman: + update_cache: true + upgrade: true + when: ansible_distribution == 'Archlinux' diff --git a/run.yml b/run.yml new file mode 100644 index 0000000..3bc669f --- /dev/null +++ b/run.yml @@ -0,0 +1,6 @@ +--- +- hosts: all + roles: + - update + - sync + - benssanity