Compare commits

..

3 Commits

Author SHA1 Message Date
441a7b8e24 fix: simplifie code 2025-08-07 14:37:34 -04:00
40a500a3eb fix: default vars in tweaks 2025-08-07 14:37:17 -04:00
4e9fea5bc3 add: more default pacakges for debian 2025-08-07 04:18:29 -04:00
9 changed files with 70 additions and 26 deletions

View File

@ -2,3 +2,9 @@
nsf_mount__default: []
nfs_mounts: "{{ vars | dict2items | selectattr('key', 'match', '^nfs_mounts__.*') | map(attribute='value') | list | flatten | unique }}"
nfs_mounts_install_pkg: >-
{{
((nfs_mounts|d(false, true)) != false)
| ternary(true, false)
}}

View File

@ -8,7 +8,7 @@
role_config:
nfs_mounts: "{{ nfs_mounts }}"
tasks:
- Ensure nfs-client packages are installed
- "Ensure nfs-client packages are installed: {{ nfs_mounts_install_pkg }}"
- "Create {{ nfs_mounts | length }} mounts directories"
- "Ensure {{ nfs_mounts | length }} mounts are in fstab"
tags:
@ -19,6 +19,7 @@
package:
name: "{{ item }}"
state: present
when: nfs_mounts_install_pkg
with_items:
- nfs-common

View File

@ -13,4 +13,6 @@ system_packages: "{{ vars | dict2items | selectattr('key', 'match', '^system_pac
system_hostname: "{{ inventory_hostname | split('.') | first }}"
system_domain: "{{ (inventory_hostname | split('.'))[1:] | join('.') }}"
# system_domain: "lan.test"
system_fqdn: "{{ system_hostname }}.{{ system_domain }}"
system_fqdn: "{{ system_hostname }}.{{ system_domain }}"
system_real_fqdn:
system_real_address:

View File

@ -27,10 +27,21 @@
- name: Configure system hostname in /etc/hosts
ansible.builtin.lineinfile:
path: /etc/hosts
regexp: '^127\.0\.1\.1 '
line: '127.0.1.1 {{ system_fqdn }} {{ system_hostname }}'
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
state: present
register: machine_name_changed
loop:
- regexp: '^127\.0\.1\.1(\t\s)*'
line: '127.0.1.1 {{ system_fqdn }} {{ system_hostname }}'
state: present
- regexp: '^{{ system_real_address }}(\t\s)*'
line: "{{ system_real_address }} {{ system_real_fqdn }} {{ system_real_fqdn|split('.')|first }}"
state: >-
{{
( system_real_address|d('') != '' )
| ternary('present', 'absent')
}}
- name: "Apply system hostname (changed={{ machine_name_changed.changed }})"
ansible.builtin.shell:
@ -52,7 +63,7 @@
- wheel
- sudo
loop_control:
label: "Install package: {{ item }}"
label: "Ensure group: {{ item }}"
- name: Create users
user:
@ -93,19 +104,28 @@
# Configure package manager
# ==========================
- name: Configure APT preferences
#- name: Configure APT preferences
# copy:
# dest: "/etc/apt/apt.conf.d/{{ item.name }}"
# content: "{{ item.content }}"
# loop:
# - name: 01-norecommend
# content: |
# APT::Install-Recommends "{{ system_packages_norecommend | bool | ternary(0, 1) }}";
# - name: 02-suggest
# content: |
# APT::Install-Suggests "{{ system_packages_nosuggest | bool | ternary(0, 1) }}";
# loop_control:
# label: "Ensure APT preference: {{ item.content }}"
- name: Ensure apt only install minimal packages
copy:
dest: "/etc/apt/apt.conf.d/{{ item.name }}"
content: "{{ item.content }}"
loop:
- name: 01-norecommend
content: |
APT::Install-Recommends "{{ system_packages_norecommend | bool | ternary(0, 1) }}";
- name: 02-suggest
content: |
APT::Install-Suggests "{{ system_packages_nosuggest | bool | ternary(0, 1) }}";
loop_control:
label: "Ensure APT preference: {{ item.content }}"
dest: /etc/apt/apt.conf.d/90_install_mode
content: |
# Ansible managed
APT::Install-Recommends "{{ system_packages_norecommend | bool | ternary(1, 0) }}";
APT::Install-Suggests "{{ system_packages_nosuggest | bool | ternary(1, 0) }}";
- name: Install base tools
package:

View File

@ -6,3 +6,8 @@ disks_lv__default: []
disks_vg: "{{ vars | dict2items | selectattr('key', 'match', '^disks_vg__.*') | map(attribute='value') | list | flatten | unique }}"
disks_lv: "{{ vars | dict2items | selectattr('key', 'match', '^disks_lv__.*') | map(attribute='value') | list | flatten | unique }}"
disks_install_lvm_pkg: >-
{{
((pv|d(vg|d(lv|d(false, true)))) != false)
| ternary(true, false)
}}

View File

@ -9,7 +9,7 @@
disks_vg: "{{ disks_vg }}"
disks_lv: "{{ disks_lv }}"
tasks:
- Ensure lvm packages are installed
- "Ensure lvm packages are installed: {{ disks_install_lvm_pkg }}"
- Copy lvm detector script
- "Ensure all PVs and {{ disks_vg | length }} VGs are correctly setup"
- "Ensure all {{ disks_lv | length }} LVs are in correct state"
@ -24,6 +24,7 @@
- lvm2
- parted
state: present
when: disks_install_lvm_pkg
# This should be the way, as it is not possible with cloudinit ...
- name: Copy lvm volume detector script
@ -31,6 +32,7 @@
src: setup_lvm_devices.sh
dest: /usr/local/sbin/setup_lvm_devices.sh
mode: "755"
when: disks_install_lvm_pkg
- name: Ensure presence of all VG
community.general.lvg:

View File

@ -15,7 +15,7 @@ systemd_networkd_cleanup: false
systemd_networkd_cleanup_patterns: []
systemd_networkd_cleanup_patterns_use_regex: false
systemd_networkd_manage_nsswitch_config: true
systemd_networkd_manage_nsswitch_config: false
systemd_networkd_nsswitch_passwd: files systemd
systemd_networkd_nsswitch_group: files systemd
systemd_networkd_nsswitch_shadow: files systemd

View File

@ -0,0 +1,13 @@
tweaks_install_pkg:
- vim
- htop
- iftop
- iotop
- bash-completion
- lsof
- tree
- psmisc
- git

View File

@ -6,7 +6,7 @@
vars:
base_config:
tasks:
- install custom packages
- "install custom packages: {{ tweaks_install_pkg|join(' ') }}"
- configure bash
- configure git
- configure vim
@ -15,12 +15,7 @@
- name: Ensure base packages are installed
package:
name:
- vim
- htop
- iftop
- iotop
- bash-completion
name: "{{ tweaks_install_pkg }}"
state: present