From 70056d12d620233cb8317bfefd892bf974e6152d Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Fri, 25 Oct 2024 20:31:08 +0800 Subject: [PATCH 1/4] Add generic grouping --- inventory | 1 + 1 file changed, 1 insertion(+) diff --git a/inventory b/inventory index 2fb0614..a2ecb52 100644 --- a/inventory +++ b/inventory @@ -1,3 +1,4 @@ +[general] 10.0.10.4 10.0.10.64 10.0.10.141 \ No newline at end of file From ef8924df3107758d4d66dae27f55397986161f26 Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Fri, 25 Oct 2024 20:36:12 +0800 Subject: [PATCH 2/4] Update groupings in playbooks --- inventory | 9 +++++++-- setup.yml | 4 +++- update.yml | 4 +++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/inventory b/inventory index a2ecb52..f7e3d16 100644 --- a/inventory +++ b/inventory @@ -1,4 +1,9 @@ -[general] +[debian] 10.0.10.4 10.0.10.64 -10.0.10.141 \ No newline at end of file +10.0.10.141 + +[openwrt] +10.0.10.1 +10.0.10.2 +10.0.10.3 \ No newline at end of file diff --git a/setup.yml b/setup.yml index d8b3718..d7bef02 100644 --- a/setup.yml +++ b/setup.yml @@ -1,5 +1,7 @@ --- -- hosts: all +- hosts: + - debian + - ubuntu # Runs on root user already become: false tasks: diff --git a/update.yml b/update.yml index 707ed69..3001417 100644 --- a/update.yml +++ b/update.yml @@ -1,5 +1,7 @@ --- -- hosts: all +- hosts: + - debian + - ubuntu # Runs on root user already become: false tasks: From ddf67b68a7e78f38359d119b49e67d8a484f0343 Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Fri, 25 Oct 2024 21:48:54 +0800 Subject: [PATCH 3/4] Add Ansible OpenWRT role --- README.md | 2 ++ requirements.yml | 3 +++ setup.yml | 3 +++ 3 files changed, 8 insertions(+) create mode 100644 requirements.yml diff --git a/README.md b/README.md index 5d13213..a98504f 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,8 @@ To install the Ansible playbook, follow these steps: 1. Clone this repository 2. Install Ansible on your system if you haven't already: `sudo apt-get install ansible` 3. Move into the repository directory: `cd /path/to/ansible-playbooks` +4. Navigate to the repository directory: `cd /path/to/ansible-playbooks` +5. Install required Ansible Galaxy roles using Ansible Galaxy: `ansible-galaxy install -r requirements.yml` ## Usage diff --git a/requirements.yml b/requirements.yml new file mode 100644 index 0000000..bf317d8 --- /dev/null +++ b/requirements.yml @@ -0,0 +1,3 @@ +- src: https://github.com/gekmihesg/ansible-openwrt.git + scm: git + version: master diff --git a/setup.yml b/setup.yml index d7bef02..8cf8240 100644 --- a/setup.yml +++ b/setup.yml @@ -31,6 +31,9 @@ - cifs-utils - borgbackup - curl + - syncthing + - socat + - fish # Cache is already updated from previous step update_cache: false autoremove: true From 2250c1c093df0063375cddfa1b7d255d2bebf39d Mon Sep 17 00:00:00 2001 From: Keannu Bernasol Date: Fri, 25 Oct 2024 22:35:10 +0800 Subject: [PATCH 4/4] Update folder structure --- .vscode/settings.json | 7 +++++-- ansible.cfg | 2 +- inventory/group_vars/debian.yml | 1 + inventory/group_vars/openwrt.yml | 1 + inventory/host_vars/10.0.10.1.yml | 1 + inventory => inventory/hosts | 0 setup.yml => roles/tasks/debian/setup.yml | 7 ++----- update.yml => roles/tasks/debian/update.yml | 4 +--- 8 files changed, 12 insertions(+), 11 deletions(-) create mode 100644 inventory/group_vars/debian.yml create mode 100644 inventory/group_vars/openwrt.yml create mode 100644 inventory/host_vars/10.0.10.1.yml rename inventory => inventory/hosts (100%) rename setup.yml => roles/tasks/debian/setup.yml (79%) rename update.yml => roles/tasks/debian/update.yml (69%) diff --git a/.vscode/settings.json b/.vscode/settings.json index 9b2da51..11c64eb 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -3,7 +3,10 @@ "yaml.schemas": { "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/ansible.json#/$defs/playbook": [ "file:///e%3A/Projects/AnsibleTest/setup.yml", - "file:///e%3A/Projects/AnsibleTest/update.yml" - ] + "file:///e%3A/Projects/AnsibleTest/update.yml", + "file:///e%3A/Projects/ansible-playbooks/roles/tasks/update.yml", + "file:///e%3A/Projects/ansible-playbooks/roles/tasks/setup.yml" + ], + "https://raw.githubusercontent.com/ansible/ansible-lint/main/src/ansiblelint/schemas/requirements.json": "file:///e%3A/Projects/ansible-playbooks/requirements.yml" } } diff --git a/ansible.cfg b/ansible.cfg index 1f82b59..8495b92 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -1,3 +1,3 @@ [defaults] -inventory = inventory +inventory = inventory/hosts private_key_file = ~/.ssh/id_rsa \ No newline at end of file diff --git a/inventory/group_vars/debian.yml b/inventory/group_vars/debian.yml new file mode 100644 index 0000000..a7d4a89 --- /dev/null +++ b/inventory/group_vars/debian.yml @@ -0,0 +1 @@ +# Debian-specific variables go here diff --git a/inventory/group_vars/openwrt.yml b/inventory/group_vars/openwrt.yml new file mode 100644 index 0000000..3e28929 --- /dev/null +++ b/inventory/group_vars/openwrt.yml @@ -0,0 +1 @@ +# OpenWRT-specific variables go here diff --git a/inventory/host_vars/10.0.10.1.yml b/inventory/host_vars/10.0.10.1.yml new file mode 100644 index 0000000..b34f540 --- /dev/null +++ b/inventory/host_vars/10.0.10.1.yml @@ -0,0 +1 @@ +# ARMv7 OpenWRT-specific variables for LeRouter-1 go here diff --git a/inventory b/inventory/hosts similarity index 100% rename from inventory rename to inventory/hosts diff --git a/setup.yml b/roles/tasks/debian/setup.yml similarity index 79% rename from setup.yml rename to roles/tasks/debian/setup.yml index 8cf8240..0f29358 100644 --- a/setup.yml +++ b/roles/tasks/debian/setup.yml @@ -1,23 +1,21 @@ --- - hosts: - debian - - ubuntu # Runs on root user already become: false tasks: - - name: Add SSH key to authorized_hosts - Debian/Ubuntu + - name: Add SSH key to authorized_hosts - Debian authorized_key: user: root state: present key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}" path: /root/.ssh/authorized_keys - when: ansible_distribution in ["Debian", "Ubuntu"] - name: Update all packages apt: update_cache: true autoremove: true state: latest - - name: Install packages - Debian/Ubuntu + - name: Install packages - Debian apt: name: - vim @@ -38,6 +36,5 @@ update_cache: false autoremove: true state: latest - when: ansible_distribution in ["Debian", "Ubuntu"] - name: Install ACME command: curl https://get.acme.sh | sh -s email=noehbernasol0@gmail.com diff --git a/update.yml b/roles/tasks/debian/update.yml similarity index 69% rename from update.yml rename to roles/tasks/debian/update.yml index 3001417..4223aad 100644 --- a/update.yml +++ b/roles/tasks/debian/update.yml @@ -1,7 +1,6 @@ --- - hosts: - debian - - ubuntu # Runs on root user already become: false tasks: @@ -10,7 +9,6 @@ update_cache: true autoremove: true state: latest - when: ansible_distribution in ["Debian", "Ubuntu"] + when: ansible_distribution in ["Debian"] - name: Update ACME command: /root/.acme.sh/acme.sh --upgrade --auto-upgrade - when: ansible_distribution in ["Debian", "Ubuntu"]