mailpit as utility v1
This commit is contained in:
		
							parent
							
								
									633831d95f
								
							
						
					
					
						commit
						d28f793ad9
					
				@ -12,6 +12,8 @@
 | 
			
		||||
#     php_version: "8.3"         # Must match one of your project's PHP versions
 | 
			
		||||
#   redis:
 | 
			
		||||
#     enabled: false
 | 
			
		||||
#   mailpit:
 | 
			
		||||
#     enabled: false             # Fake SMTP server to catch and view emails sent during local dev
 | 
			
		||||
 | 
			
		||||
# db_engine:
 | 
			
		||||
#   Choose between mariadb, mysql, or postgresql. Lenvi will install and manage the correct service.
 | 
			
		||||
@ -38,6 +40,8 @@ utilities:
 | 
			
		||||
    php_version: "8.3"
 | 
			
		||||
  redis:
 | 
			
		||||
    enabled: false
 | 
			
		||||
  mailpit:
 | 
			
		||||
    enabled: false
 | 
			
		||||
 | 
			
		||||
# 🛢️ Database Engine
 | 
			
		||||
db_engine: "mariadb"
 | 
			
		||||
 | 
			
		||||
@ -21,4 +21,6 @@
 | 
			
		||||
      when: utilities.phpmyadmin.enabled is defined and utilities.phpmyadmin.enabled
 | 
			
		||||
    - role: redis
 | 
			
		||||
      when: utilities.redis.enabled is defined and utilities.redis.enabled
 | 
			
		||||
    - role: mailpit
 | 
			
		||||
      when: utilities.mailpit.enabled is defined and utilities.mailpit.enabled
 | 
			
		||||
    - role: projects
 | 
			
		||||
							
								
								
									
										6
									
								
								roles/mailpit/handlers/main.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								roles/mailpit/handlers/main.yml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,6 @@
 | 
			
		||||
---
 | 
			
		||||
- name: "Restart Mailpit service"
 | 
			
		||||
  ansible.builtin.systemd:
 | 
			
		||||
    name: mailpit
 | 
			
		||||
    daemon_reload: yes
 | 
			
		||||
    state: restarted
 | 
			
		||||
							
								
								
									
										24
									
								
								roles/mailpit/tasks/main.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										24
									
								
								roles/mailpit/tasks/main.yml
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,24 @@
 | 
			
		||||
---
 | 
			
		||||
- name: "Install Mailpit using the official installation script"
 | 
			
		||||
  ansible.builtin.shell: "bash <(curl -sL https://raw.githubusercontent.com/axllent/mailpit/develop/install.sh)"
 | 
			
		||||
  args:
 | 
			
		||||
    creates: /usr/local/bin/mailpit
 | 
			
		||||
  register: mailpit_install
 | 
			
		||||
  changed_when: "mailpit_install.rc == 0 and 'Installed Mailpit to' in mailpit_install.stdout"
 | 
			
		||||
  become: yes
 | 
			
		||||
 | 
			
		||||
- name: "Create Mailpit systemd service file"
 | 
			
		||||
  ansible.builtin.template:
 | 
			
		||||
    src: mailpit.service.j2
 | 
			
		||||
    dest: /etc/systemd/system/mailpit.service
 | 
			
		||||
    owner: root
 | 
			
		||||
    group: root
 | 
			
		||||
    mode: '0644'
 | 
			
		||||
  notify: Restart Mailpit service
 | 
			
		||||
 | 
			
		||||
- name: "Ensure Mailpit service is enabled and started"
 | 
			
		||||
  ansible.builtin.systemd:
 | 
			
		||||
    name: mailpit
 | 
			
		||||
    enabled: yes
 | 
			
		||||
    state: started
 | 
			
		||||
    daemon_reload: yes
 | 
			
		||||
							
								
								
									
										14
									
								
								roles/mailpit/templates/mailpit.service.j2
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								roles/mailpit/templates/mailpit.service.j2
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,14 @@
 | 
			
		||||
[Unit]
 | 
			
		||||
Description=Mailpit
 | 
			
		||||
After=network.target
 | 
			
		||||
 | 
			
		||||
[Service]
 | 
			
		||||
User={{ ansible_user_id }}
 | 
			
		||||
Group={{ ansible_user_gid }}
 | 
			
		||||
Type=simple
 | 
			
		||||
ExecStart=/usr/local/bin/mailpit
 | 
			
		||||
Restart=always
 | 
			
		||||
RestartSec=5
 | 
			
		||||
 | 
			
		||||
[Install]
 | 
			
		||||
WantedBy=multi-user.target
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user