Skip to content

Commit

Permalink
Fixes to RedHat ansible (now working.) Ubuntu still not working.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimchandler committed Jun 12, 2017
1 parent 293f212 commit d17440a
Showing 10 changed files with 146 additions and 134 deletions.
7 changes: 4 additions & 3 deletions deploy/redhat/tasks/api_install.yml
Original file line number Diff line number Diff line change
@@ -15,11 +15,12 @@
yum: name={{item}} state=present
with_items:
- nodejs
- npm
when: ALL_IN_ONE == False

- name: Install npm
shell: curl -L https://www.npmjs.org/install.sh | sh
when: ALL_IN_ONE == False
# - name: Install npm
# shell: curl -L https://www.npmjs.org/install.sh | sh
# when: ALL_IN_ONE == False

- name: Install node.js module forever as global
npm: name=forever global=yes
62 changes: 31 additions & 31 deletions deploy/redhat/tasks/postfix.yml
Original file line number Diff line number Diff line change
@@ -2,9 +2,9 @@
# Licensed under the Apache License, Version 2.0 the "License";
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,70 +16,70 @@
# yum: name={{item}} state=present
# with_items:
# - postfix



- name: Postfix | Download archive
get_url: url=ftp://ftp.porcupine.org/mirrors/postfix-release/official/postfix-2.11.1.tar.gz dest=/usr/local/src/ timeout=60

- name: Postfix | Unarchive download
command: chdir=/usr/local/src/ tar xzvf postfix-2.11.1.tar.gz

- name: Postfix | Install prereqs for compiling
yum: name={{item}} state=present
with_items:
- db4-devel
- cyrus-sasl
- cyrus-sasl
- cyrus-sasl-devel
- openssl
- openssl-devel
- pcre
- pcre-devel
- openldap
- openldap-devel

- name: Postfix | Copy header db.h
command: cp /usr/include/libdb4/db.h /usr/include
when: ansible_os_family == "RedHat" and {{ ansible_distribution_version | version_compare('7.0', '>=') }}

- name: Postfix | Execute make makefiles1
command: chdir=/usr/local/src/postfix-2.11.1 make makefiles CCARGS='-fPIC -DUSE_TLS -DUSE_SSL -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -DPREFIX=\\"/usr\\" -DHAS_PCRE -I/usr/include/openssl -DHAS_PGSQL -I/usr/pgsql-9.3/lib -I/usr/include/sasl -I/usr/pgsql-9.3/include -I/usr/include' AUXLIBS='-L/usr/lib64 -L/usr/lib64/libdb4 -L/usr/lib64/openssl -lssl -lcrypto -L/usr/pgsql-9.3/lib -lpq -L/usr/lib64/sasl2 -lsasl2 -lpcre -lz -lm -lldap -llber -Wl,-rpath,/usr/lib64/openssl -pie -Wl,-z,relro' OPT='-O' DEBUG='-g'
command: chdir=/usr/local/src/postfix-2.11.1 make makefiles CCARGS='-fPIC -DUSE_TLS -DUSE_SSL -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -DPREFIX=\\"/usr\\" -DHAS_PCRE -I/usr/include/openssl -DHAS_PGSQL -I/usr/pgsql-9.6/lib -I/usr/include/sasl -I/usr/pgsql-9.6/include -I/usr/include' AUXLIBS='-L/usr/lib64 -L/usr/lib64/libdb4 -L/usr/lib64/openssl -lssl -lcrypto -L/usr/pgsql-9.6/lib -lpq -L/usr/lib64/sasl2 -lsasl2 -lpcre -lz -lm -lldap -llber -Wl,-rpath,/usr/lib64/openssl -pie -Wl,-z,relro' OPT='-O' DEBUG='-g'
when: ansible_os_family == "RedHat" and {{ ansible_distribution_version | version_compare('7.0', '>=') }}

- name: Postfix | Execute make makefiles2
command: chdir=/usr/local/src/postfix-2.11.1 make makefiles CCARGS='-fPIC -DUSE_TLS -DUSE_SSL -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -DPREFIX=\\"/usr\\" -DHAS_PCRE -I/usr/include/openssl -DHAS_PGSQL -I/usr/pgsql-9.3/lib -I/usr/include/sasl -I/usr/pgsql-9.3/include -I/usr/include' AUXLIBS='-L/usr/lib64 -L/usr/lib64/libdb4 -L/usr/lib64/openssl -lssl -lcrypto -L/usr/pgsql-9.3/lib -lpq -L/usr/lib64/sasl2 -lsasl2 -lpcre -lz -lm -lldap -llber -Wl,-rpath,/usr/lib64/openssl -pie -Wl,-z,relro' OPT='-O' DEBUG='-g'
command: chdir=/usr/local/src/postfix-2.11.1 make makefiles CCARGS='-fPIC -DUSE_TLS -DUSE_SSL -DUSE_SASL_AUTH -DUSE_CYRUS_SASL -DPREFIX=\\"/usr\\" -DHAS_PCRE -I/usr/include/openssl -DHAS_PGSQL -I/usr/pgsql-9.6/lib -I/usr/include/sasl -I/usr/pgsql-9.6/include -I/usr/include' AUXLIBS='-L/usr/lib64 -L/usr/lib64/libdb4 -L/usr/lib64/openssl -lssl -lcrypto -L/usr/pgsql-9.6/lib -lpq -L/usr/lib64/sasl2 -lsasl2 -lpcre -lz -lm -lldap -llber -Wl,-rpath,/usr/lib64/openssl -pie -Wl,-z,relro' OPT='-O' DEBUG='-g'
when: ansible_os_family == "RedHat" and {{ ansible_distribution_version | version_compare('7.0', '<') }}

- name: Postfix | Execute make
command: chdir=/usr/local/src/postfix-2.11.1 make

- name: Postfix | Execute make upgrade
command: chdir=/usr/local/src/postfix-2.11.1 make upgrade

- name: Postfix | Configure Postfix
lineinfile: dest=/etc/postfix/main.cf regexp='^\s*inet_interfaces\s*=.*' line="inet_interfaces=all"
notify: Restart postfix

- name: Create the postfix user 'direct'
postgresql_user: name=direct state=present encrypted=yes role_attr_flags=NOSUPERUSER,NOCREATEDB,NOCREATEROLE
sudo_user: "{{postgresql_admin_user}}"

- name: Create the postfix database 'maildb'
postgresql_db: name=maildb state=present owner=direct
sudo_user: "{{postgresql_admin_user}}"

- name: Create postfix database structure
command: psql -d maildb -c "{{lookup('file', '../files/postfix.sql')}}"
sudo_user: "{{postgresql_admin_user}}"


- name: Create pgsql directory
file: path=/etc/postfix/pgsql state=directory

- name: Add postfix user to maildb
postgresql_user: name=postfix state=present password={{POSTFIX_PASSWORD}} db=maildb role_attr_flags=LOGIN
sudo_user: "{{postgresql_admin_user}}"

- name: Grant privileges on tables to user
postgresql_privs: database=maildb roles=postfix schema=public type=table objs=ALL_IN_SCHEMA grant_option=yes state=present priv=ALL
sudo_user: "{{postgresql_admin_user}}"
@@ -89,18 +89,18 @@
sudo_user: "{{postgresql_admin_user}}"

- name: Set authentication method for postfix
lineinfile: dest=/var/lib/pgsql/9.3/data/pg_hba.conf
lineinfile: dest=/var/lib/pgsql/9.6/data/pg_hba.conf
regexp='(# Put your actual configuration here\n)(local maildb postfix password)?'
backrefs=yes
state=present
line='\1local maildb postfix password\nlocal maildb direct trust'
backrefs=yes
state=present
line='\1local maildb postfix password\nlocal maildb direct trust'
sudo_user: "{{postgresql_admin_user}}"
# notify:
# notify:
# - Reload postgres

- name: Postfix | Reload postgres after setting authentication method
service: name=postgresql-9.3 state=reloaded
service: name=postgresql-9.6 state=reloaded

- name: Postfix | Add local domain to domains database
command: "{{SPOOL}}/tools/direct_domain add -d {{MAIL_DOMAIN}} -t local"
sudo_user: direct
@@ -110,13 +110,13 @@
- add_domain
- add_root_and_domain


- name: Postfix | Add virtual maps
template: src=templates/{{item}} dest=/etc/postfix/pgsql/{{item}}
with_items:
- virtual_mailbox_maps.cf
- virtual_mailbox_domains.cf


- name: Postfix | Edit postfix config file and service entries
command: postconf {{item}}
@@ -127,7 +127,7 @@
- "-e 'virtual_mailbox_domains =pgsql:/etc/postfix/pgsql/virtual_mailbox_domains.cf'"
- "-e 'virtual_mailbox_maps = pgsql:/etc/postfix/pgsql/virtual_mailbox_maps.cf'"
- "-M direct-rx/unix='direct-rx unix - n n - - pipe flags=RXq user=direct argv=/var/spool/direct/smimercv.py ${queue_id} ${recipient} ${sender}'"
notify:
notify:
- Restart postfix


27 changes: 14 additions & 13 deletions deploy/redhat/tasks/postgres.yml
Original file line number Diff line number Diff line change
@@ -12,54 +12,55 @@
# limitations under the License.

- name: Install PGDG CentOS 6
yum: name=http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-centos93-9.3-1.noarch.rpm
yum: name=http://yum.postgresql.org/9.6/redhat/rhel-6-x86_64/pgdg-centos93-9.6-1.noarch.rpm
when: ansible_distribution == "CentOS" and {{ ansible_distribution_version | version_compare('7.0', '<') }}
sudo: yes

- name: Install PGDG RedHat 6
yum: name=http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-redhat93-9.3-1.noarch.rpm
yum: name=http://yum.postgresql.org/9.6/redhat/rhel-6-x86_64/pgdg-redhat93-9.6-1.noarch.rpm
when: ansible_distribution == "RedHat" and {{ ansible_distribution_version | version_compare('7.0', '<') }}
sudo: yes

- name: Install PGDG CentOS 7
yum: name=http://yum.postgresql.org/9.3/redhat/rhel-7-x86_64/pgdg-centos93-9.3-1.noarch.rpm
yum: name=http://yum.postgresql.org/9.6/redhat/rhel-7-x86_64/pgdg-centos93-9.6-1.noarch.rpm
when: ansible_distribution == "CentOS" and {{ ansible_distribution_version | version_compare('7.0', '>=') }}
sudo: yes

- name: Install PGDG RedHat 7
yum: name=http://yum.postgresql.org/9.3/redhat/rhel-7-x86_64/pgdg-redhat93-9.3-1.noarch.rpm
yum: name=https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7-x86_64/pgdg-redhat96-9.6-3.noarch.rpm
#yum: name=http://yum.postgresql.org/9.3/redhat/rhel-7-x86_64/pgdg-redhat93-9.6-1.noarch.rpm
when: ansible_distribution == "RedHat" and {{ ansible_distribution_version | version_compare('7.0', '>=') }}
sudo: yes

- name: Install PostgreSql packages
yum: name={{ item }} state=present
with_items:
- postgresql93-server
- postgresql93-contrib
- postgresql96-server
- postgresql96-contrib
- python-psycopg2

- name: Initialize new PostgreSql cluster RedHat-CentOS 6
command: /etc/init.d/postgresql-9.3 initdb
command: /etc/init.d/postgresql-9.6 initdb
args:
creates: /var/lib/pgsql/9.3/data/postgresql.conf
creates: /var/lib/pgsql/9.6/data/postgresql.conf
when: "{{ ansible_distribution_version | version_compare('7.0', '<') }}"

- name: Initialize new PostgreSql cluster RedHat-CentOS 7
command: /usr/pgsql-9.3/bin/postgresql93-setup initdb
command: /usr/pgsql-9.6/bin/postgresql96-setup initdb
args:
creates: /var/lib/pgsql/9.3/data/postgresql.conf
creates: /var/lib/pgsql/9.6/data/postgresql.conf
when: "{{ ansible_distribution_version | version_compare('7.0', '>=') }}"

- name: Configure pg_hba.conf
template:
src: templates/pg_hba.conf.j2
dest: "/var/lib/pgsql/9.3/data/pg_hba.conf"
dest: "/var/lib/pgsql/9.6/data/pg_hba.conf"
owner: "{{ postgresql_admin_user }}"
group: "{{ postgresql_admin_user }}"
mode: 0640

- name: Ensure PostgreSQL is listening on all addresses
lineinfile: dest=/var/lib/pgsql/9.3/data/postgresql.conf
lineinfile: dest=/var/lib/pgsql/9.6/data/postgresql.conf
regexp='^#?listen_addresses\s*='
line="listen_addresses = '*'"
state=present
@@ -68,4 +69,4 @@
# command: chkconfig postgresql on

- name: Check postgresql started and set it to be started at boot
service: name=postgresql-9.3 state=started enabled=yes
service: name=postgresql-9.6 state=started enabled=yes
22 changes: 11 additions & 11 deletions deploy/ubuntu/files/postfix.sql
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
-- Copyright 2014 MedicaSoft LLC USA and Info World SRL
-- Copyright 2014 MedicaSoft LLC USA and Info World SRL
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- distributed under the License is distributed on an AS-IS BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
@@ -34,21 +34,21 @@ ALTER INDEX address_lower_index
OWNER TO direct;

-- users trigger on address insert or update

CREATE OR REPLACE FUNCTION setUserDetails() RETURNS trigger LANGUAGE plpgsql AS $$
DECLARE
userNameP varchar(100);
domainP varchar(100);
address varchar(200);
i int;
BEGIN
address := NEW.address;
i := position('@' in address);
address := NEW.address;
i := position('@' in address);
userNameP := substring(address from 0 for i);
domainP := substring(address from i+1);

UPDATE users SET userName=userNameP, domain=domainP WHERE id=NEW.id;

RETURN NEW;
END
$$;
@@ -58,10 +58,10 @@ DROP TRIGGER IF EXISTS userAddressTrigger on users;

CREATE TRIGGER userAddressTrigger AFTER INSERT OR UPDATE OF address ON users
FOR EACH ROW EXECUTE PROCEDURE setUserDetails();






CREATE TABLE IF NOT EXISTS messages
(
id serial NOT NULL,
@@ -139,7 +139,7 @@ WITH (

ALTER TABLE domains
OWNER TO direct;

CREATE TABLE IF NOT EXISTS bundles
(
id serial NOT NULL,
20 changes: 11 additions & 9 deletions deploy/ubuntu/playbook.yml
Original file line number Diff line number Diff line change
@@ -2,9 +2,9 @@
# Licensed under the Apache License, Version 2.0 the "License";
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -13,14 +13,16 @@

---
- hosts: all
vars_files:
strategy: debug
vars_files:
- vars/vars.yml
sudo: yes
sudo: yes
gather_facts: False

tasks:
tasks:
- include: tasks/prereqs.yml
- include: tasks/postgres.yml
- include: tasks/certificates.yml
- include: tasks/postgres.yml
- include: tasks/certificates.yml
- include: tasks/pdns.yml user=postgres
- include: tasks/postfix.yml user=postgres
- include: tasks/api_install.yml
@@ -29,6 +31,6 @@
- include: tasks/logstash.yml
- include: tasks/kibana.yml
- include: tasks/nginx.yml
handlers:

handlers:
- include: handlers/handlers.yml
16 changes: 8 additions & 8 deletions deploy/ubuntu/tasks/api_deploy.yml
Original file line number Diff line number Diff line change
@@ -2,9 +2,9 @@
# Licensed under the Apache License, Version 2.0 the "License";
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -16,14 +16,14 @@

- name: Copy API config file
template: src=templates/config.js.j2 dest={{SPOOL}}/api/config.js

- name: Install the required Node.js packages
npm: path={{SPOOL}}/api
- name: Set Node.js app as Upstart service
template: src=templates/direct.conf.j2 dest=/etc/init/direct.conf

- name: Set Node.js app as systemd service
template: src=templates/direct.service.j2 dest=/etc/systemd/system/direct.service

- name: Start Node.js service
service: name=direct state=started
service: name=direct state=started


Loading

0 comments on commit d17440a

Please sign in to comment.