Skip to content

Commit

Permalink
Create postfix playbook
Browse files Browse the repository at this point in the history
- Install and configure postfix.
- Add empty line.
- Change restart to reload.
- Add postmap, addresses, aliases and create folders.
- Install and configure postfix.
- Add empty line.
- Rename postfix-service to postfix-handlers.
- Use postfix reload instead of service reload feature.
- Move postfix to webservers.
- Add virtual_alias_maps to postfix playbook.
- Move all from common to web folder.

Fixes #6
Closes #33
  • Loading branch information
dzydzany authored and rxaviers committed Dec 11, 2014
1 parent 070a02d commit 543f9fb
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 2 deletions.
6 changes: 4 additions & 2 deletions site.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,20 @@
tasks:
- include: common/bootstrap.yml


- name: configure and deploy the webservers and application code
hosts: webservers
remote_user: root

tasks:
- include: web/deploy.yml
- include: web/fastcgi.yml
- include: web/git.yml

- include: web/fastcgi.yml
- include: web/mysql.yml
- include: web/nginx-passenger.yml
- include: web/nodejs.yml
- include: web/php.yml
- include: web/postfix.yml
- include: web/postgresql.yml
- include: web/ruby.yml

Expand All @@ -32,4 +33,5 @@
- include: web/mysql-handlers.yml
- include: web/nginx-passenger-handlers.yml
- include: web/php-fastcgi-handlers.yml
- include: web/postfix-handlers.yml
- include: web/postgresql-handlers.yml
11 changes: 11 additions & 0 deletions web/postfix-handlers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---

- name: Reload postfix
command: /usr/sbin/postfix reload

- name: Postmap addresses
command: postmap /etc/postfix/virtual/addresses
notify: Reload postfix

- name: Restart postfix
action: service name=postfix state=restarted
43 changes: 43 additions & 0 deletions web/postfix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---

- name: Install postfix
apt: name=postfix state=installed

- name: Ensure that postfix is started and enabled on boot
service: name=postfix state=started enabled=yes

- name: Set mailname
copy: dest=/etc/mailname content={{ inventory_hostname }}

- name: Configure postfix
lineinfile:
regexp='{{ item.regexp }}' backrefs=yes line='{{ item.line }}' dest=/etc/postfix/main.cf
with_items:
- { regexp: '^#myorigin = /etc/mailname', line: 'myorigin = /etc/mailname' }
- { regexp: '^myhostname', line: 'myhostname = {{ inventory_hostname }}' }
- { regexp: '^mydestination', line: 'mydestination = $myhostname, /etc/postfix/virtual/domains, localhost, localhost.localdomain, localhost' }
notify: Restart postfix

- name: Remove lines from postfix
lineinfile:
regexp='{{ item.regexp }}' backrefs=yes dest=/etc/postfix/main.cf state=absent
with_items:
- { regexp: '^alias_maps' }
- { regexp: '^alias_database' }
notify: Reload postfix

- name: Add virtual_alias_maps line
lineinfile: line='virtual_alias_maps = hash:/etc/postfix/virtual/addresses'
dest=/etc/postfix/main.cf
notify: Reload postfix

- name: Ensure that Postfix virtual folder exsists
file: path=/etc/postfix/virtual state=directory

- name: Configure addresses for postfix
copy: src=web/postfix/addresses dest=/etc/postfix/virtual/addresses
notify: Postmap addresses

- name: Configure domains for postfix
copy: src=web/postfix/domains dest=/etc/postfix/virtual/domains
notify: Reload postfix
Empty file added web/postfix/addresses
Empty file.
Empty file added web/postfix/domains
Empty file.

0 comments on commit 543f9fb

Please sign in to comment.