Add all files needed to bring up VM and run agaric.com locally

This commit is contained in:
benjamin melançon 2018-08-20 10:45:20 -04:00
parent 52c8b60bac
commit 4d2bc0ee24
742 changed files with 24037 additions and 0 deletions

View file

@ -0,0 +1 @@
.DS_Store

View file

@ -0,0 +1,46 @@
---
services: docker
env:
- distro: centos7
init: /usr/lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
- distro: ubuntu1604
init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
- distro: debian8
init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
before_install:
# Pull container.
- 'docker pull geerlingguy/docker-${distro}-ansible:latest'
script:
- container_id=$(mktemp)
# Run container in detached state.
- 'docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} geerlingguy/docker-${distro}-ansible:latest "${init}" > "${container_id}"'
# Install dependencies.
- 'docker exec "$(cat ${container_id})" ansible-galaxy install -r /etc/ansible/roles/role_under_test/tests/requirements.yml'
# Ansible syntax check.
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml --syntax-check'
# Test role.
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml'
# Test role idempotence.
- idempotence=$(mktemp)
- docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml | tee -a ${idempotence}
- >
tail ${idempotence}
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
# Run script to test if Tideways is available and working.
- 'docker exec "$(cat ${container_id})" env TERM=xterm php /etc/ansible/roles/role_under_test/tests/tideways-test.php'
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/

View file

@ -0,0 +1,61 @@
# Ansible Role: PHP-Tideways
[![Build Status](https://travis-ci.org/geerlingguy/ansible-role-php-tideways.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-php-tideways)
Installs the [Tideways PHP Profile Extension](https://github.com/tideways/php-profiler-extension) on Linux servers.
## Requirements
None.
## Role Variables
Available variables are listed below, along with default values (see `defaults/main.yml`):
workspace: /root
Where Tideways setup files will be downloaded and built.
tideways_download_url: https://github.com/tideways/php-profiler-extension/archive/master.zip
tideways_download_folder_name: php-profiler-extension-master
The URL from which Tideways will be downloaded.
tideways_api_key: ''
If you use the Tideways UI, set this variable to your API key. Otherwise the extension can be used along with the XHProf UI to view profiles.
tideways_install_xhprof_ui: yes
Tideways data-format is 100% compatible with XHProf so you can use the XHProf UI to browse profiles reports and the `XHProfRuns_Default` class to write the profile data to disk. If you use the Tideways UI, set this variable to `no`.
xhprof_download_url: https://github.com/phacility/xhprof/archive/master.tar.gz
xhprof_download_folder_name: xhprof-master
The URL from which XHProf will be downloaded.
php_xhprof_lib_dir: /usr/share/php/xhprof_lib
Directory where the XHProf PHP library is stored.
php_xhprof_html_dir: /usr/share/php/xhprof_html
Directory where the XHProf UI is stored.
## Dependencies
- geerlingguy.php
## Example Playbook
- hosts: webservers
roles:
- geerlingguy.php-tideways
## License
MIT / BSD
## Author Information
This role was created in 2017 by [Jeff Geerling](http://www.jeffgeerling.com/), author of [Ansible for DevOps](https://www.ansiblefordevops.com/).

View file

@ -0,0 +1,18 @@
---
workspace: /root
tideways_download_url: https://github.com/tideways/php-profiler-extension/archive/master.zip
tideways_download_folder_name: php-profiler-extension-master
# If you use the Tideways UI, set this variable to your API key. Otherwise the
# extension can be used along with the XHProf UI to view profiles.
tideways_api_key: ''
# XHProf UI
tideways_install_xhprof_ui: yes
__tideways_xhprof_download_url: https://github.com/phacility/xhprof/archive/master.tar.gz
__tideways_xhprof_download_folder_name: xhprof-master
__php_xhprof_lib_dir: /usr/share/php/xhprof_lib
__php_xhprof_html_dir: /usr/share/php/xhprof_html

View file

@ -0,0 +1,44 @@
---
dependencies:
- geerlingguy.php
galaxy_info:
author: geerlingguy
description: Tideways PHP Profiler Extension for Linux
company: "Midwestern Mac, LLC"
license: "license (BSD, MIT)"
min_ansible_version: 2.0
platforms:
- name: EL
versions:
- all
- name: GenericUNIX
versions:
- all
- name: Fedora
versions:
- all
- name: opensuse
versions:
- all
- name: GenericBSD
versions:
- all
- name: FreeBSD
versions:
- all
- name: Ubuntu
versions:
- all
- name: SLES
versions:
- all
- name: GenericLinux
versions:
- all
- name: Debian
versions:
- all
galaxy_tags:
- development
- web

View file

@ -0,0 +1,18 @@
---
- name: Ensure PHP configuration directories exist.
file:
path: "{{ item }}"
state: directory
mode: 0755
follow: true
with_items: "{{ php_extension_conf_paths }}"
- name: Copy Tideways INI into various other conf folders.
template:
src: tideways.ini.j2
dest: "{{ item }}/{{ php_tideways_config_filename }}"
owner: root
group: root
mode: 0644
with_items: "{{ php_extension_conf_paths }}"
notify: restart webserver

View file

@ -0,0 +1,62 @@
---
- name: Include OS-specific variables.
include_vars: "{{ ansible_os_family }}.yml"
- name: Define php_tideways_module_path.
set_fact:
php_tideways_module_path: "{{ __php_tideways_module_path }}"
when: php_tideways_module_path is not defined
- name: Define php_tideways_config_filename.
set_fact:
php_tideways_config_filename: "{{ __php_tideways_config_filename }}"
when: php_tideways_config_filename is not defined
# Setup/install tasks.
- name: Ensure dependencies for installing Tideways are present.
package: "name={{ item }} state=installed"
with_items:
- make
- gcc
- unzip
- name: Download and untar Tideways.
unarchive:
src: "{{ tideways_download_url }}"
dest: "{{ workspace }}"
copy: no
creates: "{{ workspace }}/{{ tideways_download_folder_name }}"
- name: Build Tideways.
shell: >
{{ item }}
chdir={{ workspace }}/{{ tideways_download_folder_name }}
creates={{ workspace }}/{{ tideways_download_folder_name }}/modules/tideways.so
with_items:
- phpize
- ./configure
- make
- make install
notify: restart webserver
- name: Ensure Tideways module path exists.
file:
path: "{{ php_tideways_module_path }}"
state: directory
owner: root
group: root
mode: 0755
- name: Move Tideways module into place.
shell: >
cp {{ workspace }}/{{ tideways_download_folder_name }}/modules/tideways.so {{ php_tideways_module_path }}/tideways.so
creates={{ php_tideways_module_path }}/tideways.so
notify: restart webserver
# TODO - Install the Tideways.php file for UI?
# $ php -r 'echo ini_get("extension_dir")."\n";'
# $ cp Tideways.php /path/to/php/lib
- include: configure.yml
- include: xhprof.yml
when: tideways_install_xhprof_ui

View file

@ -0,0 +1,42 @@
- name: Define xhprof_download_url.
set_fact:
xhprof_download_url: "{{ __tideways_xhprof_download_url }}"
when: xhprof_download_url is not defined
- name: Define xhprof_download_folder_name.
set_fact:
xhprof_download_folder_name: "{{ __tideways_xhprof_download_folder_name }}"
when: xhprof_download_folder_name is not defined
- name: Define php_xhprof_lib_dir.
set_fact:
php_xhprof_lib_dir: "{{ __php_xhprof_lib_dir }}"
when: php_xhprof_lib_dir is not defined
- name: Define php_xhprof_html_dir.
set_fact:
php_xhprof_html_dir: "{{ __php_xhprof_html_dir }}"
when: php_xhprof_html_dir is not defined
- name: Ensure dependencies for the XHProf UI are present.
package: "name={{ item }} state=installed"
with_items:
- graphviz
- name: Download and untar XHProf.
unarchive:
src: "{{ xhprof_download_url }}"
dest: "{{ workspace }}"
copy: no
creates: "{{ workspace }}/{{ xhprof_download_folder_name }}"
- name: Move XHProf PHP library into place.
shell: >
cp -r {{ workspace }}/{{ xhprof_download_folder_name }}/xhprof_lib {{ php_xhprof_lib_dir }}
creates={{ php_xhprof_lib_dir }}/utils/xhprof_lib.php
- name: Move XHProf UI into place.
shell: >
cp -r {{ workspace }}/{{ xhprof_download_folder_name }}/xhprof_html {{ php_xhprof_html_dir }}
creates={{ php_xhprof_html_dir }}/index.php
- include: configure.yml

View file

@ -0,0 +1,7 @@
[tideways]
extension="{{ php_tideways_module_path }}/tideways.so"
{% if tideways_api_key %}
tideways.api_key={{ tideways_api_key }}
{% else %}
tideways.auto_prepend_library=0
{% endif %}

View file

@ -0,0 +1,4 @@
---
- src: geerlingguy.repo-remi
- src: geerlingguy.repo-dotdeb
- src: geerlingguy.php

View file

@ -0,0 +1,31 @@
---
- hosts: all
vars:
php_enable_webserver: false
php_enablerepo: "remi,remi-php70"
pre_tasks:
- name: Update apt cache.
apt: update_cache=yes cache_valid_time=600
when: ansible_os_family == 'Debian'
- name: Set php_packages for PHP 7.0 Debian 8 install.
set_fact:
php_packages:
- php7.0-common
- php7.0-cli
- php7.0-dev
- php7.0-fpm
- libpcre3-dev
- php7.0-opcache
- php7.0-apcu
when: ansible_distribution == 'Debian'
roles:
- role: geerlingguy.repo-remi
when: ansible_os_family == 'RedHat'
- role: geerlingguy.repo-dotdeb
when: ansible_distribution == 'Debian'
- geerlingguy.php
- role_under_test

View file

@ -0,0 +1,50 @@
<?php
/**
* @file
* Test if Tideways is available and working.
*/
$tideways_root_dir = '/usr/share/php';
$xhprof_root_dir = '/usr/share/php';
$success = TRUE;
tideways_enable();
$data = tideways_disable();
if (isset($data['main()==>tideways_disable'])) {
print "Tideways profiling working.\r\n";
}
else {
print "Tideways profiling not working.\r\n";
$success = FALSE;
}
include $xhprof_root_dir . '/xhprof_lib/utils/xhprof_lib.php';
include $xhprof_root_dir . '/xhprof_lib/utils/xhprof_runs.php';
$output_dir = sys_get_temp_dir();
$xhprof_runs = new XHProfRuns_Default($output_dir);
$run_id = $xhprof_runs->save_run($data, 'xhprof_testing');
$filename = "$output_dir/$run_id.xhprof_testing.xhprof";
if (file_exists($filename)) {
print "XHProf PHP library writing to output directory.\r\n";
}
else {
print "XHProf PHP library not working.\r\n";
$success = FALSE;
}
ob_start();
include $xhprof_root_dir . '/xhprof_html/index.php';
$html = ob_get_clean();
if (strpos($html, "?run=$run_id") !== FALSE) {
print "XHProf UI working.\r\n";
}
else {
print "XHProf UI not working.\r\n";
$success = FALSE;
}
if (!$success) {
exit(1);
}

View file

@ -0,0 +1,3 @@
---
__php_tideways_module_path: /usr/lib/php7.0/modules
__php_tideways_config_filename: 20-tideways.ini

View file

@ -0,0 +1,3 @@
---
__php_tideways_module_path: /usr/lib64/php/modules
__php_tideways_config_filename: tideways.ini