2023-10-13 11:24:56 +00:00
|
|
|
---
|
|
|
|
|
2023-10-17 08:04:48 +00:00
|
|
|
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
2023-10-13 11:24:56 +00:00
|
|
|
# Reconfigure locales - enable en_US-UTF8 and es_ES-UTF8
|
|
|
|
- name: reconfigure locales enable en_US-UTF8 and es_ES-UTF8
|
|
|
|
debconf:
|
|
|
|
name: locales
|
|
|
|
question: locales/default_environment_locale
|
|
|
|
value: en_US-UTF8, es_ES-UTF8
|
|
|
|
vtype: multiselect
|
2023-10-17 08:04:48 +00:00
|
|
|
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
2023-10-13 11:24:56 +00:00
|
|
|
|
2023-10-17 08:04:48 +00:00
|
|
|
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
2023-10-13 11:24:56 +00:00
|
|
|
# Reconfigure timezone - Europe/Madrid
|
|
|
|
- name: reconfigure timezone Europe/Madrid
|
2023-10-13 11:45:50 +00:00
|
|
|
debconf:
|
|
|
|
name: tzdata
|
|
|
|
question: tzdata/Zones/Europe
|
|
|
|
value: Madrid
|
|
|
|
vtype: select
|
2023-10-17 08:04:48 +00:00
|
|
|
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
2023-10-13 11:24:56 +00:00
|
|
|
|
2023-10-17 08:04:48 +00:00
|
|
|
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
2023-10-13 11:24:56 +00:00
|
|
|
# update packages
|
|
|
|
- name: update packages
|
|
|
|
apt:
|
|
|
|
name: "*"
|
|
|
|
state: latest
|
2023-10-16 05:40:25 +00:00
|
|
|
update_cache: true
|
|
|
|
force_apt_get: true
|
2023-10-17 08:04:48 +00:00
|
|
|
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
2023-10-13 11:24:56 +00:00
|
|
|
|
2023-10-17 08:04:48 +00:00
|
|
|
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
2023-10-13 11:24:56 +00:00
|
|
|
# upgrade packages
|
|
|
|
- name: upgrade packages
|
|
|
|
apt:
|
|
|
|
upgrade: dist
|
|
|
|
state: latest
|
2023-10-16 05:40:25 +00:00
|
|
|
force_apt_get: true
|
2023-10-17 08:04:48 +00:00
|
|
|
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
2023-10-13 11:24:56 +00:00
|
|
|
|
2023-10-17 08:04:48 +00:00
|
|
|
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
2023-10-13 12:49:11 +00:00
|
|
|
# install packages
|
|
|
|
- name: install some packages (vim htop psmisc aptitude)
|
2023-10-13 11:24:56 +00:00
|
|
|
apt:
|
2023-10-13 12:49:11 +00:00
|
|
|
name: "{{ item }}"
|
2023-10-13 11:24:56 +00:00
|
|
|
state: present
|
2023-10-13 12:49:11 +00:00
|
|
|
with_items:
|
|
|
|
- vim
|
|
|
|
- htop
|
|
|
|
- psmisc
|
|
|
|
- aptitude
|
|
|
|
- nslcd
|
|
|
|
- exim4
|
2023-10-17 08:04:48 +00:00
|
|
|
- fail2ban
|
|
|
|
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
2023-10-13 12:49:11 +00:00
|
|
|
|
2023-10-17 08:04:48 +00:00
|
|
|
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
2023-10-13 11:24:56 +00:00
|
|
|
# Reconfigure relayhost smtp to smtp.verdnatura.es
|
|
|
|
- name: reconfigure relayhost to smtp.verdnatura.es
|
2023-10-16 11:48:20 +00:00
|
|
|
lineinfile:
|
|
|
|
dest: "{{ exim_configuration_file }}"
|
|
|
|
regexp: "{{ item.regexp }}"
|
|
|
|
line: "{{ item.line }}"
|
|
|
|
state: present
|
|
|
|
mode: 0644
|
|
|
|
with_items:
|
|
|
|
- regexp: '^dc_eximconfig_configtype'
|
|
|
|
line: "dc_eximconfig_configtype='{{ exim_dc_eximconfig_configtype }}'"
|
|
|
|
- regexp: '^dc_other_hostnames'
|
2023-10-16 13:13:31 +00:00
|
|
|
line: "dc_other_hostnames='{{ dc_other_hostnames }}'.verdnatura.es"
|
2023-10-16 11:48:20 +00:00
|
|
|
- regexp: '^dc_local_interfaces'
|
|
|
|
line: "dc_local_interfaces='{{ dc_local_interfaces }}'"
|
|
|
|
- regexp: '^dc_readhost'
|
2023-10-16 13:13:31 +00:00
|
|
|
line: "dc_readhost='{{ dc_readhost }}'.verdnatura.es"
|
2023-10-16 11:48:20 +00:00
|
|
|
- regexp: '^dc_relay_domains'
|
|
|
|
line: "dc_relay_domains='{{ dc_relay_domains }}'"
|
|
|
|
- regexp: '^dc_minimaldns'
|
|
|
|
line: "dc_minimaldns='{{ dc_minimaldns }}'"
|
|
|
|
- regexp: '^dc_relay_nets'
|
|
|
|
line: "dc_relay_nets='{{ dc_relay_nets }}'"
|
|
|
|
- regexp: '^dc_smarthost'
|
|
|
|
line: "dc_smarthost='{{ dc_smarthost }}'"
|
|
|
|
- regexp: '^CFILEMODE'
|
|
|
|
line: "CFILEMODE='{{ CFILEMODE }}'"
|
|
|
|
- regexp: '^dc_use_split_config'
|
|
|
|
line: "dc_use_split_config='{{ dc_use_split_config }}'"
|
|
|
|
- regexp: '^dc_hide_mailname'
|
|
|
|
line: "dc_hide_mailname='{{ dc_hide_mailname }}'"
|
|
|
|
- regexp: '^dc_mailname_in_oh'
|
|
|
|
line: "dc_mailname_in_oh='{{ dc_mailname_in_oh }}'"
|
|
|
|
- regexp: '^dc_localdelivery'
|
|
|
|
line: "dc_localdelivery='{{ dc_localdelivery }}'"
|
|
|
|
notify: restart exim4
|
2023-10-17 09:23:27 +00:00
|
|
|
register: exim4_config
|
2023-10-17 08:04:48 +00:00
|
|
|
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
2023-10-16 07:51:12 +00:00
|
|
|
|
2023-10-16 11:48:20 +00:00
|
|
|
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
# DONT WORK :(
|
|
|
|
#- name: reconfigure relayhost to smtp.verdnatura.es
|
|
|
|
# debconf:
|
|
|
|
# name: exim4-config
|
|
|
|
# question: "{{ item.name }}"
|
|
|
|
# value: "{{ item.value }}"
|
|
|
|
# vtype: string
|
|
|
|
# loop:
|
|
|
|
# - name: exim4/dc_smarthost
|
|
|
|
# value: smtp.verdnatura.es
|
|
|
|
# - name: exim4/dc_local_interfaces
|
|
|
|
# value: ""
|
|
|
|
# - name: exim4/dc_minimaldns
|
|
|
|
# value: 'false'
|
|
|
|
# - name: exim4/dc_readhost
|
|
|
|
# value: "{{ ansible_nodename }}" # var to define survey(encuesta)
|
|
|
|
# - name: exim4/dc_other_hostnames
|
|
|
|
# value: ""
|
|
|
|
# - name: exim4/dc_eximconfig_configtype
|
|
|
|
# value: "mail sent by smarthost; no local mail"
|
|
|
|
# - name: exim4/mailname
|
|
|
|
# value: "{{ ansible_nodename }}" # var to define survey(encuesta)
|
|
|
|
# - name: exim4/use_split_config
|
|
|
|
# value: 'false'
|
|
|
|
#
|
2023-10-16 09:10:49 +00:00
|
|
|
# generate master config
|
2023-10-16 11:48:20 +00:00
|
|
|
#- name: generate master config
|
|
|
|
# command: update-exim4.conf
|
|
|
|
# notify: apply reconfig
|
|
|
|
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
2023-10-13 12:49:11 +00:00
|
|
|
|
2023-10-16 13:24:14 +00:00
|
|
|
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
2023-10-17 08:04:48 +00:00
|
|
|
# DONT WORK :(
|
2023-10-16 13:24:14 +00:00
|
|
|
# NEEDS to INSTALL more MODULES with -> ansible-galaxy collection install community.general
|
|
|
|
#
|
2023-10-16 06:08:52 +00:00
|
|
|
# Send mail to verify relay-host
|
2023-10-16 06:33:12 +00:00
|
|
|
#- name: sending mail to verify exim4 config works
|
|
|
|
# mail:
|
|
|
|
# host: smtp.verdnatura.es
|
|
|
|
# port: 465
|
|
|
|
# subject: Verify Ansible playbook deployment exim4
|
|
|
|
# body: Hello , this is an e-mail to verify exim4 config works on {{ ansible_facts['ansible_nodename'] }}
|
|
|
|
# to:
|
|
|
|
# - informatica@verdnatura.es
|
|
|
|
# - rubenb@verdnatura.es
|
|
|
|
# delegate_to: localhost
|
2023-10-16 13:24:14 +00:00
|
|
|
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
2023-10-17 08:04:48 +00:00
|
|
|
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
# Send mail to verify relay-host
|
2023-10-17 08:59:24 +00:00
|
|
|
# Create file with message
|
2023-10-17 09:08:29 +00:00
|
|
|
#- name: create file and add line
|
|
|
|
# lineinfile:
|
|
|
|
# path: /tmp/messagefileverify
|
|
|
|
# line: Verify send email from host {{ ansible_nodename }}'.verdnatura.es with mailx , bye.
|
|
|
|
# create: yes
|
2023-10-17 09:18:17 +00:00
|
|
|
# Send mail with module shell (shell module accepts pipes "|" , command module dont accept pipes)
|
2023-10-17 08:04:48 +00:00
|
|
|
- name: sending mail to verify exim4 config works
|
2023-10-17 09:18:17 +00:00
|
|
|
shell: echo "Verify send email from host {{ ansible_nodename }}.verdnatura.es with mailx , bye." | mailx -s "test mail verify exim4 for the host {{ ansible_nodename }}.verdnatura.es" -c rubenb@verdnatura.es,nada@verdnatura.es,juan@verdnatura.es,davidl@verdnatura.es informatica@verdnatura.es
|
2023-10-17 09:23:27 +00:00
|
|
|
when: exim4_config.changed
|
2023-10-17 08:59:24 +00:00
|
|
|
# Delete tmp file /tmp/messagefileverify
|
2023-10-17 09:08:29 +00:00
|
|
|
#- name: delete tmp file /tmp/messagefileverify
|
|
|
|
# file:
|
|
|
|
# path: /tmp/messagefileverify
|
|
|
|
# state: absent
|
2023-10-17 08:04:48 +00:00
|
|
|
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
2023-10-16 13:24:14 +00:00
|
|
|
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
# configure centralized authentication [nslcd]
|
|
|
|
# paso1 - Copy
|
|
|
|
|
|
|
|
# paso2 - lineinfile password with vault
|
2023-10-16 06:08:52 +00:00
|
|
|
|
2023-10-16 13:24:14 +00:00
|
|
|
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
2023-10-16 06:08:52 +00:00
|
|
|
|
2023-10-16 13:24:14 +00:00
|
|
|
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
# Proteger grub
|
2023-10-17 08:04:48 +00:00
|
|
|
- name: GRUB se password boot protection
|
|
|
|
blockinfile:
|
|
|
|
path: /etc/grub.d/40_custom
|
|
|
|
block: |
|
2023-10-17 08:19:35 +00:00
|
|
|
set superusers="{{ user_grub }}"
|
|
|
|
password_pbkdf2 {{ user_grub }} {{ code_grub }}
|
2023-10-17 08:48:34 +00:00
|
|
|
register: grub_register
|
2023-10-17 08:07:51 +00:00
|
|
|
|
|
|
|
# update grub
|
|
|
|
- name: update grub config
|
|
|
|
command: update-grub
|
2023-10-17 08:48:34 +00:00
|
|
|
when: grub_register.changed
|
2023-10-17 08:07:51 +00:00
|
|
|
|
2023-10-16 13:24:14 +00:00
|
|
|
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
|
|
|
|
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
|
|
|
# Install and configure FAIL2BAN
|
|
|
|
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|