From 99755b5231da7d40b51c9f94c1743682b4a02f33 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 15 May 2026 14:21:40 +0200 Subject: Add Raspbian cloud-init stuff --- personal_infra/.gitignore | 1 + personal_infra/playbooks/pis.yaml | 59 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 personal_infra/.gitignore create mode 100644 personal_infra/playbooks/pis.yaml diff --git a/personal_infra/.gitignore b/personal_infra/.gitignore new file mode 100644 index 00000000..e137d57f --- /dev/null +++ b/personal_infra/.gitignore @@ -0,0 +1 @@ +pi-data diff --git a/personal_infra/playbooks/pis.yaml b/personal_infra/playbooks/pis.yaml new file mode 100644 index 00000000..2c688772 --- /dev/null +++ b/personal_infra/playbooks/pis.yaml @@ -0,0 +1,59 @@ +--- +- hosts: pis + gather_facts: false + tasks: + - name: hash passwords + command: mkpasswd -s + register: hashed_password + delegate_to: 127.0.0.1 + args: + stdin: "{{ ansible_password }}" + - name: create pi-data + file: + path: "../pi-data/{{ inventory_hostname }}/" + state: directory + delegate_to: 127.0.0.1 + - name: create file + copy: + content: | + #cloud-config + + hostname: {{ inventory_hostname }} + manage_etc_hosts: true + + timezone: Europe/Madrid + + keyboard: + layout: es + + users: + - name: root + lock_passwd: false + hashed_passwd: {{ hashed_password.stdout }} + + enable_ssh: true + disable_root: false + ssh_pwauth: true + + write_files: + - content: | + PermitRootLogin yes + path: /etc/ssh/sshd_config.d/permit-root-login.conf + dest: "../pi-data/{{ inventory_hostname }}/user-data" + delegate_to: 127.0.0.1 + - name: create network-config + copy: + content: | + network: + version: 2 + ethernets: + eth0: + dhcp4: no + addresses: + - {{ network.self_internal_ip_with_prefixlen }} + gateway4: {{ network.router }} + nameservers: + # only for bootstrapping + addresses: [8.8.8.8] + dest: "../pi-data/{{ inventory_hostname }}/network-config" + delegate_to: 127.0.0.1 -- cgit v1.2.3