From 2b963b55e82c75ffed62f07b03a99dc77455254a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rcio=20Fernandes?= Date: Wed, 19 Aug 2026 13:50:53 +0000 Subject: [PATCH] add ansible nodes management --- README.md | 2 +- ansible.cfg | 3 +++ {cluster => nodes}/README.md | 8 ------- nodes/ansible/group_vars/all/.gitignore | 1 + nodes/ansible/host_vars/.gitignore | 1 + nodes/ansible/hosts | 4 ++++ .../ansible/new-node-pre-setup.playbook.yaml | 23 +++++++++++++++++++ nodes/ansible/requirements.yml | 4 ++++ 8 files changed, 37 insertions(+), 9 deletions(-) create mode 100644 ansible.cfg rename {cluster => nodes}/README.md (97%) create mode 100644 nodes/ansible/group_vars/all/.gitignore create mode 100644 nodes/ansible/host_vars/.gitignore create mode 100644 nodes/ansible/hosts create mode 100644 nodes/ansible/new-node-pre-setup.playbook.yaml create mode 100644 nodes/ansible/requirements.yml diff --git a/README.md b/README.md index 9400c21..581f0dc 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ This repository is dedicated to documenting and maintaining the server configura The primary goal is to establish an k3s cluster capable of isolating services and communications related to home automation at the network level. The server operates within its own VLAN (`casa`) but requires controlled communication with other VLANs, such as `IOT Vlan` -For more information about k3s cluster/nodes setup check [readme](./cluster/README.md). +For more information about k3s cluster/nodes setup check [readme](./nodes/README.md). **Table of Contents:** diff --git a/ansible.cfg b/ansible.cfg new file mode 100644 index 0000000..f410b6a --- /dev/null +++ b/ansible.cfg @@ -0,0 +1,3 @@ +# Roles path +[defaults] +inventory = ./nodes/ansible diff --git a/cluster/README.md b/nodes/README.md similarity index 97% rename from cluster/README.md rename to nodes/README.md index 97ad681..6e16074 100644 --- a/cluster/README.md +++ b/nodes/README.md @@ -186,14 +186,6 @@ EOF ### casa - control Plane - k3s setup -``` bash -curl -sfL https://get.k3s.io | INSTALL_K3S_VERSION=v1.36.1+k3s1 \ -INSTALL_K3S_EXEC="\ ---flannel-backend=none \ ---disable-network-policy \ ---disable=servicelb" \ - sh - - ``` **Taint NoSchedule on master node:** diff --git a/nodes/ansible/group_vars/all/.gitignore b/nodes/ansible/group_vars/all/.gitignore new file mode 100644 index 0000000..1ab0aed --- /dev/null +++ b/nodes/ansible/group_vars/all/.gitignore @@ -0,0 +1 @@ +private.yaml \ No newline at end of file diff --git a/nodes/ansible/host_vars/.gitignore b/nodes/ansible/host_vars/.gitignore new file mode 100644 index 0000000..1ab0aed --- /dev/null +++ b/nodes/ansible/host_vars/.gitignore @@ -0,0 +1 @@ +private.yaml \ No newline at end of file diff --git a/nodes/ansible/hosts b/nodes/ansible/hosts new file mode 100644 index 0000000..8f25dcd --- /dev/null +++ b/nodes/ansible/hosts @@ -0,0 +1,4 @@ +[all] +casa +casa-mini-minion-01 +casa-minion-01 diff --git a/nodes/ansible/new-node-pre-setup.playbook.yaml b/nodes/ansible/new-node-pre-setup.playbook.yaml new file mode 100644 index 0000000..290f3ba --- /dev/null +++ b/nodes/ansible/new-node-pre-setup.playbook.yaml @@ -0,0 +1,23 @@ +# requirements, on device running ansible +# ansible-galaxy collection install ansible.posix +# python3 -m pip show passlib + +- name: Setup System + hosts: + - ??? + become: true + tasks: + - name: Add ansible user + ansible.builtin.user: + password: "{{ ansible_new_user_password | password_hash('sha512') }}" + name: "{{ ansible_new_user }}" + groups: sudo + shell: /bin/bash + create_home: yes + state: present + + - name: Add SSH authorized key + ansible.posix.authorized_key: + user: "{{ ansible_new_user }}" + key: "{{ lookup('file', '~/.ssh/id_ed25519.pub') }}" + state: present \ No newline at end of file diff --git a/nodes/ansible/requirements.yml b/nodes/ansible/requirements.yml new file mode 100644 index 0000000..c71e353 --- /dev/null +++ b/nodes/ansible/requirements.yml @@ -0,0 +1,4 @@ +collections: + - name: mylimbo.globals + source: ssh://git@git.limbosolutions.com:2222/myLimbo/ansible.collection.globals.git + type: git