-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrhel.yml
176 lines (138 loc) · 4.53 KB
/
rhel.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
---
# tasks file for rhel
- name: RHEL
hosts: localhost
become: true
tasks:
- name: Download .rpm package
get_url:
dest: /tmp/epel-release-latest-7.noarch.rpm
url: https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
force: no
- name: Install Downloaded .rpm package
yum:
name: /tmp/epel-release-latest-7.noarch.rpm
state: present
- name: Update all
yum:
name: '*'
state: latest
- name: Install necessary packages
yum:
name: "{{ item }}"
state: latest
with_items:
- gcc
- python34-devel
- python34-pip
- git
- nginx
ignore_errors: yes
- name: Install pgdg package
yum:
name: http://yum.postgresql.org/9.5/redhat/rhel-7-x86_64/pgdg-redhat95-9.5-3.noarch.rpm
state: present
- name: Install postgresql package's
yum:
name: "{{item}}"
state: latest
with_items:
- postgresql95
- postgresql95-server
- postgresql95-libs
- postgresql95-contrib
- postgresql95-devel
- name: Creating soft link
file:
src: /usr/pgsql-9.5/bin/pg_config
dest: /usr/bin/pg_config
state: link
- name: Init db
command: '/usr/pgsql-9.5/bin/postgresql95-setup initdb'
ignore_errors: yes
- name: Coping content
copy:
content: "(ident -> md5; peer-> ident)"
dest: /var/lib/pgsql/9.5/data/pg_hba.conf
- name: Start postgresql-9.5
service:
name: postgresql-9.5
state: "{{item}}"
with_items:
- started
- enabled
- command: sudo -u postgres psql -c "ALTER USER postgres WITH PASSWORD 'postgres';"
- command: sudo -u postgres psql -c "CREATE DATABASE transtats"
- name: Install pip3
easy_install:
name: pip3
- name: Install virtualenv
command: 'pip3 install virtualenv'
- name: create user transtats
user:
name: transtats
- name: switch user to transtats
command: '/bin/su - transtats'
- name: clone a git repo
git:
repo: https://github.com/transtats/transtats.git
- name: Create virtual env
command: 'cd /home/transtats/transtats && mkvirtualenv --system-site-packages --python=python3 projectenv'
- name: activate virtual env
shell: source projectenv/bin/activate
- name: install requirements
pip:
requirements: requirements/base.txt
virtualenv: /home/transtats/transtats/projectenv
- copy:
src: transtats/settings/keys.json.example
dest: transtats/settings/keys.json
- command: 'make migrate'
- command: 'gunicorn --bind 0.0.0.0:8000 transtats.wsgi:application (test) && exit'
- copy:
content: |
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=transtats
Group=nginx
WorkingDirectory=/home/transtats/transtats
ExecStart=/home/transtats/transtats/projectenv/bin/gunicorn --workers 3 --bind unix:/home/transtats/transtats/transtats/transtats.sock transtats.wsgi:application
[Install]
WantedBy=multi-user.target
dest: /etc/systemd/system/gunicorn.service
- service:
name: gunicorn
state: enabled
- service:
name: gunicorn
state: started
- copy:
content: |
server {
listen 80;
server_name transtats.int.devlab.redhat.com;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/transtats/transtats/transtats;
}
location / {
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://unix:/home/transtats/transtats/transtats/transtats.sock;
proxy_connect_timeout 180s;
proxy_read_timeout 300s;
}
}
dest: /etc/nginx/nginx.conf
- command: 'usermod -a -G transtats nginx'
- command: 'chmod 710 /home/transtats'
- service:
name: nginx
state: enabled
- service:
name: nginx
state: started