diff --git a/roles/mgrote.r8152_kernel_module/defaults/main.yml b/roles/mgrote.r8152_kernel_module/defaults/main.yml index d4f0dee8..611fcbfd 100644 --- a/roles/mgrote.r8152_kernel_module/defaults/main.yml +++ b/roles/mgrote.r8152_kernel_module/defaults/main.yml @@ -1,11 +1,12 @@ --- - r8152_filename: r8152.53.56-2.15.0 + r8152_module_needed: false # standardmäßig falsch r8152_packages: - pve-headers - build-essential - make - r8152_reboot_timeout: 90 - r8152_pre_reboot_delay: 120 - r8152_post_reboot_delay: 60 - r8152_module_needed: false - r8152_safekeeping_reboot_delay: 12 + - dkms + r8152_safekeeping_reboot_delay: 12 # nach wieviel minuten wird der pc neugestartet, tasks wird am ende gelöscht wenn alles erfolgreich war + # damit ist sichergestellt das der pc wieder hochfährt falls etwas passiert + r8152_src_dir: /usr/src/r8125-9.004.01 # wo wird das entpackte archiv abgelegt + r8152_filename: r8125-dkms_9.004.01.tar.gz # wie ist der dateiname auf dem ansible controller + r8152_version: 9.004.01 # wie lautet die versuin diff --git a/roles/mgrote.r8152_kernel_module/files/r8125-dkms_9.004.01.tar.gz b/roles/mgrote.r8152_kernel_module/files/r8125-dkms_9.004.01.tar.gz new file mode 100644 index 00000000..f91b8cdb Binary files /dev/null and b/roles/mgrote.r8152_kernel_module/files/r8125-dkms_9.004.01.tar.gz differ diff --git a/roles/mgrote.r8152_kernel_module/files/r8152.53.56-2.15.0.tar.bz2 b/roles/mgrote.r8152_kernel_module/files/r8152.53.56-2.15.0.tar.bz2 deleted file mode 100644 index 6a85f32a..00000000 Binary files a/roles/mgrote.r8152_kernel_module/files/r8152.53.56-2.15.0.tar.bz2 and /dev/null differ diff --git a/roles/mgrote.r8152_kernel_module/tasks/dkms.yml b/roles/mgrote.r8152_kernel_module/tasks/dkms.yml new file mode 100644 index 00000000..3ccd9110 --- /dev/null +++ b/roles/mgrote.r8152_kernel_module/tasks/dkms.yml @@ -0,0 +1,34 @@ +--- + - name: dkms add + become: yes + ansible.builtin.shell: dkms add -m r8125 -v "{{ r8152_version }}" + args: + chdir: "{{ r8152_src_dir }}" + + - name: dkms build + become: yes + ansible.builtin.shell: dkms build -m r8125 -v "{{ r8152_version }}" + args: + chdir: "{{ r8152_src_dir }}" + + - name: dkms install + become: yes + ansible.builtin.shell: dkms install -m r8125 -v "{{ r8152_version }}" + args: + chdir: "{{ r8152_src_dir }}" + + - name: depmod -a + become: yes + ansible.builtin.shell: depmod -a + args: + chdir: "{{ r8152_src_dir }}" + + - name: update initramfs + become: yes + ansible.builtin.shell: update-initramfs -u + args: + chdir: "{{ r8152_src_dir }}" + + - name: reboot + ansible.builtin.reboot: + reboot_timeout: 120 diff --git a/roles/mgrote.r8152_kernel_module/tasks/doing.yml b/roles/mgrote.r8152_kernel_module/tasks/doing.yml index 640f7baf..6bc7d012 100644 --- a/roles/mgrote.r8152_kernel_module/tasks/doing.yml +++ b/roles/mgrote.r8152_kernel_module/tasks/doing.yml @@ -4,8 +4,6 @@ ansible.builtin.package: name: "{{ r8152_packages }}" state: present - register: aptp - - name: add reboot(for safekeeping) become: yes @@ -15,69 +13,24 @@ become: yes ansible.builtin.apt: update_cache: yes - register: aptc - name: updated installed packages become: yes ansible.builtin.package: upgrade: dist - register: apti - - - name: reboot - 1 - ansible.builtin.reboot: - reboot_timeout: "{{ r8152_reboot_timeout }}" - pre_reboot_delay: "{{ r8152_reboot_timeout }}" - post_reboot_delay: "{{ r8152_post_reboot_delay }}" - when: - - aptp.changed - - apti.changed - - aptc.changed - name: create dirs ansible.builtin.file: path: "{{ item }}" state: directory loop: - - "/tmp/r8152/" - - "/lib/modules/r8152/{{ r8152_filename }}" + - "{{ r8152_src_dir }}" - - name: copy archive - become: yes - ansible.builtin.copy: - src: "files/{{ r8152_filename }}.tar.bz2" - dest: "/tmp/r8152/{{ r8152_filename }}.tar.bz2" - mode: '0775' - - - name: extract archive + - name: copy and extract archive become: yes ansible.builtin.unarchive: - src: "/tmp/r8152/{{ r8152_filename }}.tar.bz2" - dest: "/lib/modules/r8152/{{ r8152_filename }}" + src: "{{ r8152_filename }}" + dest: "{{ r8152_src_dir }}" mode: a+x extra_opts: [--strip-components=1] # entfernt die erste Ebene des Archives - remote_src: yes #datei liegt also auf dem zielsystem - - - name: make - community.general.make: - chdir: "/lib/modules/r8152/{{ r8152_filename }}" - become: yes - - - name: make install - community.general.make: - chdir: "/lib/modules/r8152/{{ r8152_filename }}" - target: install - become: yes - - - name: depmod -a - become: yes - ansible.builtin.shell: depmod -a - - - name: reboot - 2 - ansible.builtin.reboot: - reboot_timeout: "{{ r8152_reboot_timeout }}" - pre_reboot_delay: "{{ r8152_reboot_timeout }}" - post_reboot_delay: "{{ r8152_post_reboot_delay }}" - - - name: cancel reboot(for safekeeping) - become: yes - ansible.builtin.shell: shutdown -c + remote_src: no #datei liegt also auf dem ansible-controller diff --git a/roles/mgrote.r8152_kernel_module/tasks/main.yml b/roles/mgrote.r8152_kernel_module/tasks/main.yml index b2a23c31..adf2d3a2 100644 --- a/roles/mgrote.r8152_kernel_module/tasks/main.yml +++ b/roles/mgrote.r8152_kernel_module/tasks/main.yml @@ -1,9 +1,9 @@ --- - - name: check if module is installed - folder - become: yes - stat: - path: "/lib/modules/r8152/{{ r8152_filename }}" - register: folder_exists +# - name: check if module is installed - folder +# become: yes +# stat: + # path: "/lib/modules/r8152/{{ r8152_filename }}" +# register: folder_exists - name: check if module is installed - lsmod become: yes @@ -11,6 +11,10 @@ register: module_in_lsmod changed_when: False # sorgt dafür das der Task nie als "changed" angezeigt wird - - name: include tasks (task get skipped if the folder or the module exists or r8152_module_needed == false) + - name: include install-tasks (task get skipped if the folder or the module exists or r8152_module_needed == false) include_tasks: doing.yml - when: ((folder_exists.stat.exists == False) or (module_in_lsmod.stdout.find('r8152') == -1)) and (r8152_module_needed == true) + when: (module_in_lsmod.stdout.find('r8152') == -1) and (r8152_module_needed == true) + + - name: include dkms-tasks (task get skipped if the folder or the module exists or r8152_module_needed == false) + include_tasks: dkms.yml + when: (module_in_lsmod.stdout.find('r8152') == -1) and (r8152_module_needed == true)