From a6512fbd9652354cd85a1c47cdaa718803233093 Mon Sep 17 00:00:00 2001 From: Markus Katharina Brechtel Date: Tue, 18 Jan 2022 23:17:05 +0100 Subject: [PATCH 1/2] rename tasks and restructure packages --- tasks/debian_packages.yaml | 8 ++-- vars/main.yaml | 76 +++++++++++++++++++++++++++++++------- 2 files changed, 66 insertions(+), 18 deletions(-) diff --git a/tasks/debian_packages.yaml b/tasks/debian_packages.yaml index 11ccd5a..b326879 100644 --- a/tasks/debian_packages.yaml +++ b/tasks/debian_packages.yaml @@ -1,20 +1,20 @@ --- -- name: base packages +- name: debian base packages apt: pkg: "{{ debian_base_packages }}" when: debian_base_packages is defined -- name: boot packages +- name: debian boot packages apt: pkg: "{{ debian_boot_packages }}" when: debian_boot_packages is defined -- name: common packages +- name: debian common packages apt: pkg: "{{ debian_common_packages }}" -- name: custom packages +- name: debian custom packages apt: pkg: "{{ debian_custom_packages }}" when: debian_custom_packages is defined diff --git a/vars/main.yaml b/vars/main.yaml index 23a176a..7829bed 100644 --- a/vars/main.yaml +++ b/vars/main.yaml @@ -1,31 +1,62 @@ -debian_common_packages: - - # apt tools - - aptitude +debian_base_packages: # admin tools - lsof - less - psmisc - - lshw - ipcalc - ipv6calc # editors - nano - - vim # network tools - iputils-ping + + # network config + - resolvconf + + # compression + - unzip + - p7zip + - zip + - unzip + + # file sync tools + - rsync + - zsync + + # shells + - fish + + # ansible requirements + - python3 + - python3-apt + + # system + - console-setup + - dbus + +debian_common_packages: + + # apt tools + - aptitude + + # editors + - nano + - micro + - vim + - joe + + # network tools - whois - nmap - tcpdump - - dnsutils + - bind9-dnsutils - mtr - oping - - # network config - - resolvconf + - ipcalc + - ipv6calc # documentation - man-db @@ -62,13 +93,30 @@ debian_common_packages: - python3-setuptools - golang - # system - - console-setup - - dbus - # security tools - openssh-client - ssh-agent-filter - gnupg - gnupg-agent - agent-transfer + + # installation utils + - debootstrap + +debian_hardware_packages: + + # hardware utils + - pciutils + - usbutils + - acpi + - lshw + + # hard disk utils + - parted + - mdadm + - cryptsetup + - lvm2 + + # filesystem tools + - btrfs-progs + - dosfstools From 10cbe5436573e09f7506df773392530e78347bd5 Mon Sep 17 00:00:00 2001 From: Markus Katharina Brechtel Date: Fri, 21 Jan 2022 19:04:59 +0100 Subject: [PATCH 2/2] simplify common role --- defaults/main.yaml | 1 + tasks/debian_packages.yaml | 2 +- tasks/hostname.yaml | 15 ++------------- tasks/keyboard_configuration.yaml | 8 +------- tasks/root_user.yaml | 13 ++++++------- 5 files changed, 11 insertions(+), 28 deletions(-) diff --git a/defaults/main.yaml b/defaults/main.yaml index f9bce49..6da0bf4 100644 --- a/defaults/main.yaml +++ b/defaults/main.yaml @@ -29,4 +29,5 @@ debian_sources: true debian_backports_sources: "{{debian_sources}}" debian_security_sources: "{{debian_sources}}" +common_package_intallation: true microcode_update: false diff --git a/tasks/debian_packages.yaml b/tasks/debian_packages.yaml index b326879..3a327be 100644 --- a/tasks/debian_packages.yaml +++ b/tasks/debian_packages.yaml @@ -3,7 +3,6 @@ - name: debian base packages apt: pkg: "{{ debian_base_packages }}" - when: debian_base_packages is defined - name: debian boot packages apt: @@ -13,6 +12,7 @@ - name: debian common packages apt: pkg: "{{ debian_common_packages }}" + when: common_package_intallation - name: debian custom packages apt: diff --git a/tasks/hostname.yaml b/tasks/hostname.yaml index 56aa6e8..8bf0d14 100644 --- a/tasks/hostname.yaml +++ b/tasks/hostname.yaml @@ -5,26 +5,15 @@ name: "{{inventory_hostname}}" when: not root_target_directory is defined -- name: hostname file - copy: - content: "{{inventory_hostname}}" - dest: "{{ root_target_directory }}/etc/hostname" - when: root_target_directory is defined - -- name: hosts file - file: - path: "{{ root_target_directory }}/etc/hosts" - state: touch - when: root_target_directory is defined - name: localhost ipv4 entry lineinfile: dest: "{{ root_target_directory | default('') }}/etc/hosts" regexp: '^127\.0\.0\.1' - line: "127.0.0.1 localhost {{inventory_hostname}}" + line: "127.0.0.1 localhost {{inventory_hostname}} {{inventory_hostname_short}}" - name: localhost ipv6 entry lineinfile: dest: "{{ root_target_directory | default('') }}/etc/hosts" regexp: '^::1' - line: "::1 localhost ip6-localhost ip6-loopback {{inventory_hostname}}" + line: "::1 localhost ip6-localhost ip6-loopback {{inventory_hostname}} {{inventory_hostname_short}}" diff --git a/tasks/keyboard_configuration.yaml b/tasks/keyboard_configuration.yaml index f82f062..9dd3088 100644 --- a/tasks/keyboard_configuration.yaml +++ b/tasks/keyboard_configuration.yaml @@ -1,12 +1,6 @@ --- -- name: default directory - file: - path: "{{ root_target_directory | default('') }}/etc/default" - state: directory - when: root_target_directory is defined - - name: keyboard configuration template: src: default-keyboard.j2 - dest: "{{ root_target_directory | default('') }}/etc/default/keyboard" + dest: /etc/default/keyboard diff --git a/tasks/root_user.yaml b/tasks/root_user.yaml index 0196a8d..18ebf61 100644 --- a/tasks/root_user.yaml +++ b/tasks/root_user.yaml @@ -11,18 +11,17 @@ name: root generate_ssh_key: yes ssh_key_type: ed25519 - when: - - root_ssh_key - - not root_target_directory is defined + when: root_ssh_key - name: root user ssh directory file: - path: "{{ root_target_directory | default('') }}/root/.ssh" + path: /root/.ssh state: directory + mode: 0700 when: root_ssh_authorized_keys is defined - name: root user ssh authorized keys - template: - src: root_user_ssh_authorized_keys.j2 - dest: "{{ root_target_directory | default('') }}/root/.ssh/authorized_keys" + copy: + content: "{{ root_ssh_authorized_keys | join('\n') }}" + dest: /root/.ssh/authorized_keys when: root_ssh_authorized_keys is defined