diff --git a/inventory.yml b/inventory.yml index 83fe4ec..8016d0c 100644 --- a/inventory.yml +++ b/inventory.yml @@ -1,19 +1,34 @@ +--- + all: + children: + single-hosts: + rpi: + +# Hosts without special groups +single-hosts: + hosts: + srv-print: + ansible_host: 192.168.2.95 + ansible_user: ansible + +# All RPI hosts +rpi: hosts: children: - rpi: - hosts: - children: - rpi_ubuntu: - rpi_rpios: - vars: - ansible_user: pi - hosts: - octopi: - ansible_host: 192.168.2.99 - pihole: - ansible_host: 192.168.2.20 - naspi: - ansible_host: 192.168.2.75 - piprint: - ansible_host: 192.168.2.95 + rpi_ubuntu: + rpi_rpios: + +# RPI hosts with RPIOS +rpi_rpios: + vars: + ansible_user: pi + hosts: + octopi: + ansible_host: 192.168.2.99 + pihole: + ansible_host: 192.168.2.20 + naspi: + ansible_host: 192.168.2.75 + # piprint: + # ansible_host: 192.168.2.95 diff --git a/playbooks/patches.yml b/playbooks/patches.yml new file mode 100755 index 0000000..91d901f --- /dev/null +++ b/playbooks/patches.yml @@ -0,0 +1,24 @@ +- hosts: all + tasks: + + - name: Update Debian-based systems + block: + - name: Apt Update + apt: + update_cache: yes + + - name: Apt Upgrade + apt: + upgrade: safe + + - name: Check if reboot required + stat: + path: /var/run/reboot-required + register: reboot_required_file + + - name: Reboot if required + reboot: + when: reboot_required_file.stat.exists == true + + become: yes + when: ansible_facts['ansible_os_family'] == 'Debian' \ No newline at end of file diff --git a/playbooks/rpi_patches.yml b/playbooks/rpi_patches.yml deleted file mode 100755 index 35b21ce..0000000 --- a/playbooks/rpi_patches.yml +++ /dev/null @@ -1,19 +0,0 @@ -- hosts: rpi - become: yes - tasks: - - name: Apt Update - apt: - update_cache: yes - - - name: Apt Upgrade - apt: - upgrade: safe - - - name: Check if reboot required - stat: - path: /var/run/reboot-required - register: reboot_required_file - - - name: Reboot if required - reboot: - when: reboot_required_file.stat.exists == true \ No newline at end of file diff --git a/playbooks/ssh_keys.yml b/playbooks/ssh_keys.yml index caeca43..ac3c66d 100644 --- a/playbooks/ssh_keys.yml +++ b/playbooks/ssh_keys.yml @@ -1,9 +1,16 @@ -- hosts: rpi - become: yes +- become: yes tasks: - - name: add ansible@septentrion to authorized keys + - name: add ansible@septentrion to authorized keys for RaspberryPis + hosts: rpi ansible.posix.authorized_key: user: pi state: present key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCcB6Y1KvYdK2T4Ewg5ATE7dp67O+0RtPLWvfaiHfJoSJlipcgPKWcbFhxyAlKwQXYqILF03cfoaHXjMtNjiZpCWtUqlZVklNlQNtqyjYghn45PX1m+nmU4bMuBQw+b+J4N8KM5XfL5BAWlpFBMsWjTFEherkKCZs5ABMx6r9MiHaIb9gwjzsQBF+oqkqXAOLXd4kaSSYPHJcxfcWtKCW2S083+lfj+iwc3zwzwNoLcMeiE9eKpTXvDldCXZ5pvd762llNn24Zsa/O1i+HOGm3EkeoeBSW08sj5nGSV8CmjzM1eQI8FZzcteaTkL916Ny+NwgsZ7NogDtpZCBwdwnNE+APG060Mq1ul1sX6KblCOAXUIDyhmJCV2XuJZNd74pzTs4jZKTXjwYmG4Tq0pATw6lKaHQSC2DlwWWkToaFd+ewQ2Mct43vfPFUIGWJHxciLEALb1ZTomOkmG5v2ZTfqp9cUtCkX90ZaYa3ADk5afjKf/2lKgr0ffL0BQjvnZ5M= ansible@Septentrion" + + - name: add ansible@septentrion to authorized keys for single hosts + hosts: single-hosts + ansible.posix.authorized_key: + user: ansible + state: present + key: "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCcB6Y1KvYdK2T4Ewg5ATE7dp67O+0RtPLWvfaiHfJoSJlipcgPKWcbFhxyAlKwQXYqILF03cfoaHXjMtNjiZpCWtUqlZVklNlQNtqyjYghn45PX1m+nmU4bMuBQw+b+J4N8KM5XfL5BAWlpFBMsWjTFEherkKCZs5ABMx6r9MiHaIb9gwjzsQBF+oqkqXAOLXd4kaSSYPHJcxfcWtKCW2S083+lfj+iwc3zwzwNoLcMeiE9eKpTXvDldCXZ5pvd762llNn24Zsa/O1i+HOGm3EkeoeBSW08sj5nGSV8CmjzM1eQI8FZzcteaTkL916Ny+NwgsZ7NogDtpZCBwdwnNE+APG060Mq1ul1sX6KblCOAXUIDyhmJCV2XuJZNd74pzTs4jZKTXjwYmG4Tq0pATw6lKaHQSC2DlwWWkToaFd+ewQ2Mct43vfPFUIGWJHxciLEALb1ZTomOkmG5v2ZTfqp9cUtCkX90ZaYa3ADk5afjKf/2lKgr0ffL0BQjvnZ5M= ansible@Septentrion"