diff --git a/tasks/configure-app.yml b/tasks/configure-app.yml new file mode 100644 index 0000000..b21b1e4 --- /dev/null +++ b/tasks/configure-app.yml @@ -0,0 +1,42 @@ +--- +- yum: + name="{{ item }}" + state=latest + update_cache=yes + with_items: + - git + - screen + - vim + - ntp + - php + +# Source: https://github.com/relrod/phabricator-ansible +- name: Set PHABRICATOR_ENV. Forever. + shell: creates=/etc/profile.d/phabricator.sh echo 'export PHABRICATOR_ENV=custom/myconfig' > /etc/profile.d/phabricator.sh + +- name: Source the new profile file. + shell: source /etc/profile.d/phabricator.sh + +- name: Clone facebook/libphutil + git: repo=https://github.com/facebook/libphutil.git dest=/srv/www/facebook/libphutil + +- name: Clone facebook/arcanist + git: repo=https://github.com/facebook/arcanist.git dest=/srv/www/facebook/arcanist + +- name: Clone facebook/phabricator to {{ phabricator_path }} + git: repo=https://github.com/facebook/phabricator.git dest=/srv/www/facebook/phabricator + +- name: Create a conf/custom directory. + file: state=directory path={{ phabricator_path }}/conf/custom + +- name: Place a starting-point custom config in {{ phabricator_path }}conf/custom/myconfig.conf.php + template: src=myconfig.conf.php dest={{ phabricator_path }}conf/custom/myconfig.conf.php + +- name: Migrate the database + command: chdir={{ phabricator_path }} ./bin/storage upgrade --force + +- name: Start PHD daemons + command: chdir={{ phabricator_path }} ./bin/phd start + +- name: Create the repository directory + command: mkdir -p {{ repositories_path }} diff --git a/templates/haproxy.cfg.j2 b/templates/haproxy.cfg.j2 new file mode 100644 index 0000000..2a81f12 --- /dev/null +++ b/templates/haproxy.cfg.j2 @@ -0,0 +1,38 @@ +global + log 127.0.0.1 local2 + + chroot /var/lib/haproxy + pidfile /var/run/haproxy.pid + maxconn 4000 + user root + group root + daemon + + # turn on stats unix socket + stats socket /var/lib/haproxy/stats level admin + +defaults + mode http + log global + option httplog + option dontlognull + option http-server-close + option forwardfor except 127.0.0.0/8 + option redispatch + retries 3 + timeout http-request 10s + timeout queue 1m + timeout connect 10s + timeout client 1m + timeout server 1m + timeout http-keep-alive 10s + timeout check 10s + maxconn 3000 + +backend app + listen myapplb {{ external_ip }}:80 + balance roundrobin + {% for host in groups['app'] %} + server {{ host }} {{ hostvars[host]['inventory_hostname'] }}:80 + {% endfor %} + diff --git a/templates/myconfig.conf.php b/templates/myconfig.conf.php new file mode 100644 index 0000000..4aeadab --- /dev/null +++ b/templates/myconfig.conf.php @@ -0,0 +1,12 @@ + 'http://{{domain}}/', + 'mysql.host' => 'localhost', + 'mysql.user' => 'root', + 'metamta.default-address' => 'phabricator@{{domain}}', + 'metamta.domain' => '{{domain}}', + 'phabricator.timezone' => 'Europe/London', + 'pygments.enabled' => true, + // NOTE: Check default.conf.php for detailed explanations of all the + // configuration options, including these. +) + phabricator_read_config_file('development'); diff --git a/templates/phabricator.conf b/templates/phabricator.conf new file mode 100644 index 0000000..433d3fe --- /dev/null +++ b/templates/phabricator.conf @@ -0,0 +1,38 @@ +server { + server_name {{ domain }}; + + root {{ phabricator_path}}webroot; + try_files $uri $uri/ /index.php; + + location / { + index index.php; + + if ( !-f $request_filename ) + { + rewrite ^/(.*)$ /index.php?__path__=/$1 last; + break; + } + } + + location /index.php { + fastcgi_pass localhost:9000; + fastcgi_index index.php; + + #required if PHP was built with --enable-force-cgi-redirect + fastcgi_param REDIRECT_STATUS 200; + + #variables to make the $_SERVER populate in PHP + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + fastcgi_param QUERY_STRING $query_string; + fastcgi_param REQUEST_METHOD $request_method; + fastcgi_param CONTENT_TYPE $content_type; + fastcgi_param CONTENT_LENGTH $content_length; + + fastcgi_param SCRIPT_NAME $fastcgi_script_name; + + fastcgi_param GATEWAY_INTERFACE CGI/1.1; + fastcgi_param SERVER_SOFTWARE nginx/$nginx_version; + + fastcgi_param REMOTE_ADDR $remote_addr; + } +}