From 7ec58a2f89a62db93dfb336177dac2b5087b8e6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavi=20Lle=C3=B3=20Tom=C3=A1s?= Date: Mon, 7 Oct 2024 15:42:12 +0200 Subject: [PATCH] Refs #8025 debian base rol - approche install packages, triggers-notify in main --- inventories/group_vars/all.yml | 11 ++++++ roles/debian-base/handlers/main.yml | 10 ++--- roles/debian-base/tasks/install.yml | 13 +------ roles/debian-base/tasks/locale.yml | 2 +- roles/debian-base/tasks/relayhost.yml | 53 ++++++++------------------- roles/debian-base/tasks/tzdata.yml | 2 +- 6 files changed, 34 insertions(+), 57 deletions(-) diff --git a/inventories/group_vars/all.yml b/inventories/group_vars/all.yml index 4615399..6eaa81a 100644 --- a/inventories/group_vars/all.yml +++ b/inventories/group_vars/all.yml @@ -19,3 +19,14 @@ awx_pub_key: > ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKzAwWm+IsqZCgMzjdZ7Do3xWtVtoUCpWJpH7KSi2a/H awx@verdnatura.es +base_packages: + - htop + - psmisc + - bash-completion + - screen + - aptitude + - vim + - tree + - btop + - ncdu + - debconf-utils diff --git a/roles/debian-base/handlers/main.yml b/roles/debian-base/handlers/main.yml index 8071c56..169347f 100644 --- a/roles/debian-base/handlers/main.yml +++ b/roles/debian-base/handlers/main.yml @@ -2,10 +2,6 @@ service: name: systemd-timesyncd state: restarted -- name: restart-exim - service: - name: exim4 - state: restarted - name: restart-ssh service: name: ssh @@ -18,7 +14,9 @@ service: name: nagios-nrpe-server state: restarted -- name: Generate locales +- name: generate locales command: /usr/sbin/locale-gen -- name: Reconfigure tzdata +- name: reconfigure tzdata command: dpkg-reconfigure -f noninteractive tzdata +- name: update exim configuration + command: update-exim4.conf diff --git a/roles/debian-base/tasks/install.yml b/roles/debian-base/tasks/install.yml index 635d024..a43a71e 100644 --- a/roles/debian-base/tasks/install.yml +++ b/roles/debian-base/tasks/install.yml @@ -2,15 +2,4 @@ apt: name: "{{ item }}" state: present - with_items: - - htop - - psmisc - - bash-completion - - screen - - aptitude - - vim - - aptitude - - tree - - btop - - ncdu - - debconf-utils + loop: "{{ base_packages }}" diff --git a/roles/debian-base/tasks/locale.yml b/roles/debian-base/tasks/locale.yml index 3ee9e6d..788b79d 100644 --- a/roles/debian-base/tasks/locale.yml +++ b/roles/debian-base/tasks/locale.yml @@ -7,4 +7,4 @@ loop: - { question: "locales/locales_to_be_generated", value: "en_US.UTF-8 UTF-8, es_ES.UTF-8 UTF-8", vtype: "multiselect" } - { question: "locales/default_environment_locales", value: "en_US.UTF-8", vtype: "string" } - notify: Generate locales + notify: generate locales diff --git a/roles/debian-base/tasks/relayhost.yml b/roles/debian-base/tasks/relayhost.yml index 88ee3e2..c66b162 100644 --- a/roles/debian-base/tasks/relayhost.yml +++ b/roles/debian-base/tasks/relayhost.yml @@ -3,46 +3,25 @@ name: exim4 state: present - name: Prepare exim configuration - lineinfile: - dest: /etc/exim4/update-exim4.conf.conf - regexp: "{{ item.regexp }}" - line: "{{ item.line }}" + blockinfile: + path: /etc/exim4/update-exim4.conf.conf + marker_begin: '--- BEGIN VN ---' + marker_end: '--- END VN ---' + marker: "# {mark}" + block: | + dc_eximconfig_configtype='satellite' + dc_other_hostnames='{{ ansible_fqdn }}' + dc_local_interfaces='127.0.0.1' + dc_readhost='{{ ansible_fqdn }}' + dc_smarthost='{{ smtp_server }}' + dc_hide_mailname='true' state: present - mode: 0644 - with_items: - - regexp: '^dc_eximconfig_configtype' - line: "dc_eximconfig_configtype='satellite'" - - regexp: '^dc_other_hostnames' - line: "dc_other_hostnames='{{ ansible_fqdn }}'" - - regexp: '^dc_local_interfaces' - line: "dc_local_interfaces='127.0.0.1'" - - regexp: '^dc_readhost' - line: "dc_readhost='{{ ansible_fqdn }}'" - - regexp: '^dc_relay_domains' - line: "dc_relay_domains=''" - - regexp: '^dc_minimaldns' - line: "dc_minimaldns='false'" - - regexp: '^dc_relay_nets' - line: "dc_relay_nets=''" - - regexp: '^dc_smarthost' - line: "dc_smarthost='{{ smtp_server }}'" - - regexp: '^CFILEMODE' - line: "CFILEMODE='644'" - - regexp: '^dc_use_split_config' - line: "dc_use_split_config='false'" - - regexp: '^dc_hide_mailname' - line: "dc_hide_mailname='true'" - - regexp: '^dc_mailname_in_oh' - line: "dc_mailname_in_oh='true'" - - regexp: '^dc_localdelivery' - line: "dc_localdelivery='mail_spool'" - notify: restart-exim + create: yes + mode: '0644' + notify: update exim configuration register: exim_config -- name: Update exim configuration - command: update-exim4.conf - when: exim_config.changed - name: Sending mail to verify relay host configuration works shell: > echo "If you see this message, relayhost on {{ ansible_fqdn }} has been configured correctly." \ | mailx -s "Relayhost test for {{ ansible_fqdn }}" "{{ sysadmin_mail }}" - when: exim_config.changed + when: exim_config.changed diff --git a/roles/debian-base/tasks/tzdata.yml b/roles/debian-base/tasks/tzdata.yml index 8683519..3f9bf17 100644 --- a/roles/debian-base/tasks/tzdata.yml +++ b/roles/debian-base/tasks/tzdata.yml @@ -8,4 +8,4 @@ - { question: "tzdata/Areas", value: "Europe" } - { question: "tzdata/Zones/Europe", value: "Madrid" } - { question: "tzdata/Zones/Etc", value: "UTC" } - notify: Reconfigure tzdata + notify: reconfigure tzdata