diff --git a/tasks/configure-app.yml b/tasks/configure-app.yml index 17a8cd3..7c47d5c 100644 --- a/tasks/configure-app.yml +++ b/tasks/configure-app.yml @@ -1,160 +1,163 @@ --- #- name: Wait for SSH to be available for App servers # wait_for: port=22 host="{{ hostvars[item]['inventory_hostname'] }}" timeout=180 # with_items: "{{ groups['app'] }}" - yum: name="{{ item }}" state=present enablerepo=cr #FIXME: disable when libunwind is in Base again with_items: - nginx - php - php-fpm - php-mysql - php-gd - php-mbstring - php-posix - php-pear - php-devel - php-ldap - pcre-devel - yum: name="{{ item }}" state=absent with_items: - php-pecl-apcu ## Users - user: name="{{ phd_user }}" - user: name="{{ www_user }}" - user: name: "{{ vcs_user }}" password: "NP" shell: "/bin/sh" - name: Create sudoers template: src: sudoers dest: "/etc/sudoers.d/phabricator" mode: 0440 owner: root group: root validate: "/usr/sbin/visudo -cf %s" ## Nginx - name: Copy nginx config template: src=nginx-phabricator.conf dest=/etc/nginx/conf.d/phabricator.conf - name: Start nginx service: name=nginx state=restarted enabled=true # PHP CGI - name: Start PHP fastcgi service: name=php-fpm state=restarted enabled=true - name: Copy php.ini configuration template: src=php.ini dest=/etc/php.ini notify: restart php-fpm - name: Install APC shell: yes '' | pecl install apc; echo '' # SSH - name: SSH hook for phabricator template: src: phabricator_ssh_hook.sh dest: /usr/libexec/phabricator_ssh_hook.sh group: "{{ phd_user }}" mode: 0755 - name: SSHd config for phabricator template: src: phabricator_sshd_config dest: /etc/ssh/sshd_config.phabricator mode: 0640 - name: SSHd systemd service for phabricator template: src: phabricator_sshd_init dest: /usr/lib/systemd/system/sshd_phabricator.service mode: 0640 notify: restart sshd_phabricator - name: Start sshd for phabricator service: name=sshd_phabricator state=restarted enabled=true ## Phabricator # Source: https://github.com/relrod/phabricator-ansible - name: Create log directory file: state=directory path=/var/log/phabricator owner="{{ phd_user }}" group="{{ phd_user }}" - name: Create directory file: state=directory path=/srv/www owner="{{ phd_user }}" - name: Create tmp directory file: state=directory path=/var/tmp/phd/ owner="{{ phd_user }}" - name: Clone facebook/libphutil git: repo: https://github.com/facebook/libphutil.git dest: /srv/www/facebook/libphutil version: stable sudo_user: "{{ phd_user }}" - name: Clone facebook/arcanist git: repo: https://github.com/facebook/arcanist.git dest: /srv/www/facebook/arcanist version: stable sudo_user: "{{ phd_user }}" - name: Clone facebook/phabricator to {{ phabricator_path }} git: repo: https://github.com/facebook/phabricator.git dest: /srv/www/facebook/phabricator version: stable sudo_user: "{{ phd_user }}" - name: Create a conf/custom directory. file: state=directory path={{ phabricator_path }}/conf/custom sudo_user: "{{ phd_user }}" - name: Place a starting-point custom config in {{ phabricator_path }}conf/custom/myconfig.conf.php template: src=phabricator_myconfig.conf.php dest={{ phabricator_path }}conf/custom/myconfig.conf.php sudo_user: "{{ phd_user }}" - name: Include the config shell: echo 'custom/myconfig' > {{ phabricator_path }}conf/local/ENVIRONMENT - sudo_user: "{{ phd_user }}" - -- name: Stop PHD daemons - command: chdir={{ phabricator_path }} ./bin/phd stop + args: + creates: "{{ phabricator_path }}conf/local/ENVIRONMENT" sudo_user: "{{ phd_user }}" - name: Migrate the database command: chdir={{ phabricator_path }} ./bin/storage upgrade --force sudo_user: "{{ phd_user }}" when: "'{{ inventory_hostname }}' == '{{ groups.app[0] }}'" - name: Create the repository directory file: state=directory path="{{ repositories_path }}" owner="{{ phd_user }}" group="{{ phd_user }}" - name: Mount NFS share mount: name: "{{ repositories_path }}" src: "{{ hostvars['127.0.0.1']['openstackjump']['openstack']['private_v4'] }}:{{ repositories_path }}" fstype: 'nfs' opts: 'auto' state: 'mounted' ## Application -- name: Start PHD daemons - command: chdir={{ phabricator_path }} ./bin/phd restart - sudo_user: "{{ phd_user }}" +- name: PHD systemd service for phabricator + template: + src: phabricator_phd_init + dest: /usr/lib/systemd/system/phd_phabricator.service + mode: 0640 + +- name: Start PHD + service: name=phd_phabricator state=started enabled=true diff --git a/templates/phabricator_phd_init b/templates/phabricator_phd_init new file mode 100644 index 0000000..0169e6a --- /dev/null +++ b/templates/phabricator_phd_init @@ -0,0 +1,14 @@ +[Unit] +Description=PHD Phabricator +After=remote-fs.target + +[Service] +ExecStart={{ phabricator_path }}bin phd start +ExecReload={{ phabricator_path }}bin phd restart +KillMode=process +Restart=on-failure +RestartSec=42s +User={{ phd_user }} + +[Install] +WantedBy=multi-user.target