add Final Infrastructure Setup
This commit is contained in:
commit
7733dde658
174 changed files with 204949 additions and 0 deletions
13
infrastructure/ansible/roles/smtplog/handlers/main.yml
Normal file
13
infrastructure/ansible/roles/smtplog/handlers/main.yml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
---
|
||||
|
||||
- name: Restart smtplog
|
||||
service:
|
||||
name: smtplog
|
||||
state: restarted
|
||||
|
||||
- name: Restart smtpweb
|
||||
service:
|
||||
name: smtpweb
|
||||
state: restarted
|
||||
|
||||
# vim:ft=ansible
|
||||
175
infrastructure/ansible/roles/smtplog/tasks/main.yml
Normal file
175
infrastructure/ansible/roles/smtplog/tasks/main.yml
Normal file
|
|
@ -0,0 +1,175 @@
|
|||
---
|
||||
|
||||
- name: Set current_host_config variable to access parameters referencing this host
|
||||
set_fact:
|
||||
current_host_config: "{{ item.value }}"
|
||||
when: item.value.hostname == ansible_fqdn
|
||||
with_dict: "{{ configs.host_config }}"
|
||||
|
||||
- name: install python-setuptools for Python interpreter
|
||||
package:
|
||||
name: python-setuptools
|
||||
state: present
|
||||
become: true
|
||||
when: ansible_distribution_major_version == "7"
|
||||
|
||||
- name: Deinstall postfix
|
||||
package:
|
||||
name: postfix
|
||||
state: absent
|
||||
become: true
|
||||
ignore_errors: true
|
||||
|
||||
- name: Install python 3.6
|
||||
package:
|
||||
name: python36
|
||||
state: present
|
||||
become: true
|
||||
when: ansible_distribution == "CentOS"
|
||||
|
||||
#Pip module has a parameter for system packages but it was added in 2.17 which might
|
||||
# be to new for some developer work stations
|
||||
#
|
||||
- name: Install aiosmtpd for pip3
|
||||
command: pip3 install --break-system-packages aiosmtpd
|
||||
become: true
|
||||
when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version == "24"
|
||||
|
||||
- name: Install aiosmtpd for pip3
|
||||
command: pip3 install aiosmtpd
|
||||
become: true
|
||||
when: (ansible_distribution == "Ubuntu" and (ansible_distribution_major_version == "20" or ansible_distribution_major_version == "22"))
|
||||
|
||||
- name: Install aiosmtpd for pip3
|
||||
command: pip3 install aiosmtpd
|
||||
become: true
|
||||
when: ((ansible_os_family == "RedHat" and (ansible_distribution_major_version == "7" or ansible_distribution_major_version == "8")) or ansible_distribution == "Rocky" )
|
||||
|
||||
- name: Create smtplog directory
|
||||
file:
|
||||
path: "{{ remote_deployment_dir }}/smtplog"
|
||||
state: directory
|
||||
|
||||
- name: Find smtpservices package
|
||||
local_action:
|
||||
module: find
|
||||
paths: "{{ configs.deployment_dir }}"
|
||||
patterns: "smtplog*.zip"
|
||||
file_type: file
|
||||
register: found_packages
|
||||
become: false
|
||||
|
||||
- name: Order packages to install
|
||||
set_fact:
|
||||
latest_package: "{{ found_packages.files | sort(attribute='mtime',reverse=true) | first }}"
|
||||
|
||||
- name: Unpack smtpservice
|
||||
unarchive:
|
||||
src: "{{ latest_package.path }}"
|
||||
dest: "{{ remote_deployment_dir }}/smtplog"
|
||||
|
||||
- name: Set the smtplog/smtpweb script location
|
||||
find:
|
||||
path: "{{ remote_deployment_dir }}/smtplog"
|
||||
pattern: "smtplog*"
|
||||
file_type: directory
|
||||
register: smtplog_deploy_dir
|
||||
|
||||
- name: Set smtplog/smtpweb path
|
||||
set_fact:
|
||||
smtplog_path: "{{ smtplog_deploy_dir.files | map(attribute='path') | join('') }}"
|
||||
|
||||
- name: Install smtplog script
|
||||
copy:
|
||||
src: "{{ smtplog_path }}/smtplog.py"
|
||||
dest: /usr/local/bin/smtplog.py
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
remote_src: true
|
||||
become: true
|
||||
|
||||
- name: Install smtplog systemd unit
|
||||
copy:
|
||||
src: "{{ smtplog_path }}/smtplog.service"
|
||||
dest: "{{ smtplog_service_file }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
remote_src: true
|
||||
become: true
|
||||
|
||||
- name: Set smtplog log directory
|
||||
lineinfile:
|
||||
dest: "{{ smtplog_service_file }}"
|
||||
regexp: '^WorkingDirectory.*$'
|
||||
line: "WorkingDirectory={{ smtplog_logdir }}"
|
||||
state: present
|
||||
become: true
|
||||
|
||||
- name: Set smtplog service start command line
|
||||
lineinfile:
|
||||
dest: "{{ smtplog_service_file }}"
|
||||
regexp: '^ExecStart.*$'
|
||||
line: "ExecStart={{ smtplog_dir }}/smtplog.py -a {{ current_host_config.smtplog_server_ip | default(current_host_config.ip) }} -d {{smtplog_maildir}} -p {{ smtplog_port }}"
|
||||
state: present
|
||||
become: true
|
||||
|
||||
- name: Create log directory
|
||||
file:
|
||||
path: "{{ smtplog_logdir }}"
|
||||
state: directory
|
||||
mode: 0755
|
||||
become: true
|
||||
|
||||
- name: Install smtpweb script
|
||||
copy:
|
||||
src: "{{ smtplog_path }}/smtpweb.py"
|
||||
dest: /usr/local/bin/smtpweb.py
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
remote_src: true
|
||||
become: true
|
||||
|
||||
- name: Install smtpweb systemd unit
|
||||
copy:
|
||||
src: "{{ smtplog_path }}/smtpweb.service"
|
||||
dest: "{{ smtpweb_service_file }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
remote_src: true
|
||||
become: true
|
||||
|
||||
- name: Set smtpweb log directory
|
||||
lineinfile:
|
||||
dest: "{{ smtpweb_service_file }}"
|
||||
regexp: '^WorkingDirectory.*$'
|
||||
line: "WorkingDirectory={{ smtpweb_logdir }}"
|
||||
state: present
|
||||
become: true
|
||||
|
||||
- name: Set smtpweb service start command line
|
||||
lineinfile:
|
||||
dest: "{{ smtpweb_service_file }}"
|
||||
regexp: '^ExecStart.*$'
|
||||
line: "ExecStart={{ smtplog_dir }}/smtpweb.py -a 127.0.0.1 -d {{smtplog_maildir}} -p {{ smtpweb_port }}"
|
||||
state: present
|
||||
become: true
|
||||
|
||||
- name: Create smptweb log directory
|
||||
file:
|
||||
path: "{{ smtpweb_logdir }}"
|
||||
state: directory
|
||||
mode: 0755
|
||||
become: true
|
||||
|
||||
- name: Start and enable smtplog
|
||||
service: name={{ item }} state=started enabled=True
|
||||
with_items:
|
||||
- smtplog
|
||||
- smtpweb
|
||||
become: true
|
||||
|
||||
# vim:ft=ansible
|
||||
Loading…
Add table
Add a link
Reference in a new issue