From d6a9c3198f623f8cb76426862061859a27a28643 Mon Sep 17 00:00:00 2001 From: Alexander Dexl Date: Sat, 5 Jul 2025 09:35:22 +0000 Subject: [PATCH] added first playbooks --- apt_update_debian.yml | 17 +++++++++++++++++ apt_update_ubuntu.yml | 9 +++++++++ check_user_adexl_exists.yml | 13 +++++++++++++ deploy_ssh_key.yml | 10 ++++++++++ install_checkmk.yml | 12 ++++++++++++ 5 files changed, 61 insertions(+) create mode 100644 apt_update_debian.yml create mode 100644 apt_update_ubuntu.yml create mode 100644 check_user_adexl_exists.yml create mode 100644 deploy_ssh_key.yml create mode 100644 install_checkmk.yml diff --git a/apt_update_debian.yml b/apt_update_debian.yml new file mode 100644 index 0000000..8b329fc --- /dev/null +++ b/apt_update_debian.yml @@ -0,0 +1,17 @@ +--- +- hosts: debian + become: true + tasks: + - name: Update package cache + apt: + update_cache: yes + tags: update + + - name: Upgrade all packages + apt: + upgrade: dist # or "safe" for safe-upgrade, or "full" for full-upgrade + tags: update + + - name: Reboot the system if required + reboot: + when: ansible_reboot_pending diff --git a/apt_update_ubuntu.yml b/apt_update_ubuntu.yml new file mode 100644 index 0000000..5e9d797 --- /dev/null +++ b/apt_update_ubuntu.yml @@ -0,0 +1,9 @@ +--- + - hosts: ubuntu + + tasks: + - name: Update apt cache and repositories + apt: + update_cache: yes + upgrade: yes + autoremove: yes diff --git a/check_user_adexl_exists.yml b/check_user_adexl_exists.yml new file mode 100644 index 0000000..434043b --- /dev/null +++ b/check_user_adexl_exists.yml @@ -0,0 +1,13 @@ +--- +- hosts: ubuntu + become: true + tasks: + - name: Benutzer adexl prüfen und ggf. anlegen + user: + name: adexl + state: present + shell: /bin/bash + groups: users + append: yes + register: user_check + ignore_errors: true diff --git a/deploy_ssh_key.yml b/deploy_ssh_key.yml new file mode 100644 index 0000000..9e52c47 --- /dev/null +++ b/deploy_ssh_key.yml @@ -0,0 +1,10 @@ +--- + - hosts: ubuntu,debian,raspberry + tasks: + + - name: Deploy Ansible SSH-Key + authorized_key: + user: root + key: "{{ lookup('file', '/root/.ssh/id_rsa.pub') }}" + path: /root/.ssh/authorized_keys + state: present diff --git a/install_checkmk.yml b/install_checkmk.yml new file mode 100644 index 0000000..c250f41 --- /dev/null +++ b/install_checkmk.yml @@ -0,0 +1,12 @@ +--- +- hosts: all + become: true + roles: + - checkmk.general.agent + vars: + checkmk_agent_server: "192.168.1.11" + checkmk_agent_server_port: "8080" + checkmk_agent_version: "2.4.0p6" + checkmk_agent_site: "cmk" + checkmk_agent_auto_activation: true + checkmk_agent_server_protocol: http