From e71dc87368199549581bfece4491c808f0b6273c Mon Sep 17 00:00:00 2001 From: Olli Graf Date: Sun, 17 Mar 2024 13:37:54 +0100 Subject: [PATCH] subtasks. --- ansible.cfg | 2 ++ inventory.yml | 11 ++++++++++- log2ram-st.yml | 7 +++++++ roles/gather-facts/tasks/main.yml | 7 +++++++ roles/log2ram-st/tasks/add_repo_key.yml | 7 +++++++ roles/log2ram-st/tasks/add_repo_source.yml | 9 +++++++++ roles/log2ram-st/tasks/install_log2ram.yml | 8 ++++++++ roles/log2ram-st/tasks/main.yml | 5 +++++ roles/log2ram-st/tasks/main.yml.bak | 7 +++++++ roles/log2ram/tasks/main.yml | 10 +++++----- roles/subtasks/reboot.yml | 5 +++++ roles/subtasks/upgrade.yml | 7 +++++++ 12 files changed, 79 insertions(+), 6 deletions(-) create mode 100644 log2ram-st.yml create mode 100644 roles/log2ram-st/tasks/add_repo_key.yml create mode 100644 roles/log2ram-st/tasks/add_repo_source.yml create mode 100644 roles/log2ram-st/tasks/install_log2ram.yml create mode 100644 roles/log2ram-st/tasks/main.yml create mode 100644 roles/log2ram-st/tasks/main.yml.bak create mode 100644 roles/subtasks/reboot.yml create mode 100644 roles/subtasks/upgrade.yml diff --git a/ansible.cfg b/ansible.cfg index e5b4c07..cc122e1 100644 --- a/ansible.cfg +++ b/ansible.cfg @@ -1,11 +1,13 @@ [defaults] inventory = inventory.yml +library = ./library interpreter_python = auto_silent nocows = 1 timeout= 60 force_valid_group_names = ignore #private_key_file = ~/.ssh/id_ed25519 private_key_file = ~/.ssh/id_rsa +default_module_path = ./library [ssh_connection] ssh_args = -o StrictHostKeyChecking=no diff --git a/inventory.yml b/inventory.yml index 246c494..3b65657 100644 --- a/inventory.yml +++ b/inventory.yml @@ -4,11 +4,20 @@ stack4: willie: kirk: brandine: + +test: + hosts: + hans: + cleatus: terry: webs: hosts: web[00:09]: +frinks: + hosts: + frink[00:05] + vars: - ansible_python_interpreter: /usr/bin/python3 + ansible_python_interpreter: /usr/bin/python diff --git a/log2ram-st.yml b/log2ram-st.yml new file mode 100644 index 0000000..8f02fbd --- /dev/null +++ b/log2ram-st.yml @@ -0,0 +1,7 @@ +--- +- hosts: "{{ target }}" + gather_facts: false + remote_user: pi + roles: + - log2ram-st + diff --git a/roles/gather-facts/tasks/main.yml b/roles/gather-facts/tasks/main.yml index 29d550e..e4d90f2 100644 --- a/roles/gather-facts/tasks/main.yml +++ b/roles/gather-facts/tasks/main.yml @@ -1,3 +1,10 @@ - name: Informationen sammeln ansible.builtin.debug: var: ansible_facts + +- name: leeres File anlegen + file: + path: /home/pi/testwhen + state: touch + when: (ansible_facts['hostname'] == 'brandine' or ansible_facts['hostname'] == 'kirk') + diff --git a/roles/log2ram-st/tasks/add_repo_key.yml b/roles/log2ram-st/tasks/add_repo_key.yml new file mode 100644 index 0000000..2d192c8 --- /dev/null +++ b/roles/log2ram-st/tasks/add_repo_key.yml @@ -0,0 +1,7 @@ +--- +- name: Key + become: true + apt_key: + url: https://azlux.fr/repo.gpg.key + state: present + diff --git a/roles/log2ram-st/tasks/add_repo_source.yml b/roles/log2ram-st/tasks/add_repo_source.yml new file mode 100644 index 0000000..cb25efb --- /dev/null +++ b/roles/log2ram-st/tasks/add_repo_source.yml @@ -0,0 +1,9 @@ +--- +- name: Paketquelle + become: true + apt_repository: + repo: 'deb http://packages.azlux.fr/debian/ bookworm main' + state: present + filename: log2ram + update_cache: yes + diff --git a/roles/log2ram-st/tasks/install_log2ram.yml b/roles/log2ram-st/tasks/install_log2ram.yml new file mode 100644 index 0000000..6e57fbb --- /dev/null +++ b/roles/log2ram-st/tasks/install_log2ram.yml @@ -0,0 +1,8 @@ +--- +- name: log2ram installieren + become: true + apt: + update_cache: yes + name: + - log2ram + diff --git a/roles/log2ram-st/tasks/main.yml b/roles/log2ram-st/tasks/main.yml new file mode 100644 index 0000000..3df1360 --- /dev/null +++ b/roles/log2ram-st/tasks/main.yml @@ -0,0 +1,5 @@ + - include: ../subtasks/upgrade.yml + - include: add_repo_key.yml + - include: add_repo_source.yml + - include: install_log2ram.yml + - include: ../subtasks/reboot.yml diff --git a/roles/log2ram-st/tasks/main.yml.bak b/roles/log2ram-st/tasks/main.yml.bak new file mode 100644 index 0000000..68e7dd4 --- /dev/null +++ b/roles/log2ram-st/tasks/main.yml.bak @@ -0,0 +1,7 @@ + +- name: logram Haupttask + tasks: + - include: add_repo_key.yml + - include: add_repo_source.yml + - include: install_log2ram.yml + diff --git a/roles/log2ram/tasks/main.yml b/roles/log2ram/tasks/main.yml index a32528e..8f73c8e 100644 --- a/roles/log2ram/tasks/main.yml +++ b/roles/log2ram/tasks/main.yml @@ -1,8 +1,8 @@ -#- name: PI Update -# become: true -# apt: -# update_cache: yes -# upgrade: dist +- name: PI Update + become: true + apt: + update_cache: yes + upgrade: dist - name: Key become: true apt_key: diff --git a/roles/subtasks/reboot.yml b/roles/subtasks/reboot.yml new file mode 100644 index 0000000..be84221 --- /dev/null +++ b/roles/subtasks/reboot.yml @@ -0,0 +1,5 @@ +--- +- name: Neustart + become: true + reboot: + diff --git a/roles/subtasks/upgrade.yml b/roles/subtasks/upgrade.yml new file mode 100644 index 0000000..ce85e73 --- /dev/null +++ b/roles/subtasks/upgrade.yml @@ -0,0 +1,7 @@ +--- +- name: PI Update + become: true + apt: + update_cache: yes + upgrade: dist +