summaryrefslogtreecommitdiffstats
path: root/vagrant_support/playbook.yml
blob: 0934441433cef3b8d28e5f2e9a2b12d13db2e1a8 (plain)
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
---
- hosts: all
  become: true
  tasks:
    - include: timezone.yml
    - name: install epel-release
      yum: name=epel-release state=present

    - name: install common packages
      yum: name={{item}} state=present
      with_items:
        - libselinux-python
        - policycoreutils-python
        - python-urllib3
        - python-pyasn1
        - python2-ndg_httpsclient
        - pyOpenSSL
        - htop

    - name: permissive selinux
      selinux: state=permissive policy=targeted

    - name: disable selinux on reboot
      selinux: state=disabled

    - name: 'add {{WEB_HOSTNAME}} to /etc/hosts'
      lineinfile:
        dest: /etc/hosts
        regexp: '{{WEB_HOSTNAME}}'
        line: '{{WEB_IP}} {{WEB_HOSTNAME}}'
        owner: root
        group: root
        mode: 0644

    - name: 'add {{DB_HOSTNAME}} to /etc/hosts'
      lineinfile:
        dest: /etc/hosts
        regexp: '{{DB_HOSTNAME}}'
        line: '{{DB_IP}} {{DB_HOSTNAME}}'
        owner: root
        group: root
        mode: 0644

    - name: copy ntp.conf
      copy:
        src: ntp.conf
        dest: /etc/ntp.conf

    - name: setup time server
      service: name=ntpd enabled=yes

    - name: stop time server to run ntpdate
      service: name=ntpd state=stopped

    - name: run ntpdate
      shell: ntpdate pool.ntp.org

    - name: start time server
      service: name=ntpd state=started

- hosts: db
  become: true
  tasks:
    - name: fetch ius-release.rpm
      get_url:
        url: https://moz-devservices-bmocartons.s3.amazonaws.com/third-party/ius-release.rpm
        dest: /tmp/ius-release.rpm
        mode: 0600

    - name: fetch mysql rpm
      get_url:
        url: https://moz-devservices-bmocartons.s3.amazonaws.com/third-party/mysql-community-release-el6-5.noarch.rpm
        dest: /tmp/mysql-community-release-el6-5.noarch.rpm
        mode: 0600

    - name: add some extra repos
      yum: name={{item}} state=present
      with_items:
        - /tmp/ius-release.rpm
        - /tmp/mysql-community-release-el6-5.noarch.rpm

    - name: install mysql-server
      yum: name=mysql-community-server state=present

    - name: copy my.cnf
      copy:
        src: my.cnf
        dest: /etc/my.cnf

    - name: enable mysqld
      service: name=mysqld enabled=yes

    - name: restart mysqld
      service: name=mysqld state=restarted

    - name: 'check for bugs_bmo (failure is ok)'
      shell: mysql -u root -e 'show databases' | grep bugs_bmo
      register: bugs_bmo
      ignore_errors: true

    - name: create bugs_bmo
      shell: |-
        mysqladmin -u root create bugs_bmo
        mysql -u root -e 'GRANT ALL ON bugs_bmo.* TO bugs@"{{WEB_IP}}" IDENTIFIED BY "bugs"'
      when: bugs_bmo|failed

- hosts: web
  become: true
  tasks:
    - name: install web-specific packages
      yum: name={{item}} state=present
      with_items:
        - autoconf
        - automake
        - binutils
        - bison
        - byacc
        - elfutils
        - flex
        - gcc
        - gcc-c++
        - gd
        - gd-devel
        - gettext
        - git
        - libtool
        - make
        - mod_perl
        - mod_perl-devel
        - openssl
        - openssl-devel
        - patch
        - patchutils
        - perl
        - perl-core
        - pkgconfig
        - rpm-build
        - graphviz

    - name: fetch cpanm
      get_url:
        url: http://cpanmin.us
        dest: /usr/local/bin/cpanm
        mode: '0755'
    - name: install more recent Apache2::SizeLimit
      cpanm: name=Apache2::SizeLimit executable=/usr/local/bin/cpanm

    - name: 'check /opt/bmo (failure is ok)'
      shell: test -d /opt/bmo && test -f /opt/bmo/local/lib/perl5/Plack.pm
      register: opt_bmo
      ignore_errors: true

    - name: install vendor tarball
      unarchive:
        src: '{{VENDOR_BUNDLE_URL}}'
        dest: /opt
        remote_src: true
      when: opt_bmo|failed

    - name: check /opt/bmo
      shell: test -d /opt/bmo && test -f /opt/bmo/local/lib/perl5/Plack.pm
      when: opt_bmo|failed

    - name: add local symlink
      file: path=/vagrant/local src=/opt/bmo/local state=link force=true

    - name: make bmo data dir
      file: path=/data state=directory owner=vagrant group=apache mode=0775

    - name: fix owner of /vagrant
      file: path=/vagrant state=directory owner=vagrant group=apache recurse=yes

    - name: add data symlink
      file: path=/vagrant/data src=/data state=link force=true

    - include: memcached.yml

    - name: add vagrant to apache group
      user: name=vagrant groups=apache append=yes

    - name: bmo bundle refresher script
      template:
        src: bmo-refresh-bundle.j2
        dest: /usr/local/bin/bmo-refresh-bundle
        mode: 0755

    - include: checksetup.yml
      vars:
        LAZY: 0
    - include: cron.yml
    - include: jobqueue.yml
    - include: push.yml
    - include: email.yml
    - include: apache.yml
      vars:
        LAZY: 0
    - include: devtools.yml

    - name: fix owner of /vagrant/template_cache
      file: path=/vagrant/template_cache state=directory owner=vagrant group=apache recurse=yes

    - name: fix owner of /data
      file: path=/data state=directory owner=vagrant group=apache recurse=yes