Skip to content
This repository has been archived by the owner on Feb 13, 2023. It is now read-only.

Commit

Permalink
Added upload-progress role.
Browse files Browse the repository at this point in the history
  • Loading branch information
thom8 committed Dec 10, 2016
1 parent d7f4035 commit 2bcf3c2
Show file tree
Hide file tree
Showing 17 changed files with 307 additions and 0 deletions.
1 change: 1 addition & 0 deletions default.config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ installed_extras:
# - ruby
# - selenium
# - solr
# - upload-progress
- varnish
# - xdebug
# - xhprof
Expand Down
1 change: 1 addition & 0 deletions provisioning/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
- { role: geerlingguy.php-memcached, when: '"memcached" in installed_extras' }
- { role: geerlingguy.php-xdebug, when: '"xdebug" in installed_extras' }
- { role: geerlingguy.php-xhprof, when: '"xhprof" in installed_extras' }
- { role: thom8.php-upload-progress, when: '"upload-progress" in installed_extras' }
- { role: geerlingguy.blackfire, when: '"blackfire" in installed_extras' }
- { role: geerlingguy.adminer, when: '"adminer" in installed_extras' }
- { role: geerlingguy.pimpmylog, when: '"pimpmylog" in installed_extras' }
Expand Down
2 changes: 2 additions & 0 deletions provisioning/requirements.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
- src: arknoll.selenium
version: 2.0.0
- src: thom8.php-upload-progress
version: 1.0.1
- src: franklinkim.newrelic
version: 1.4.0
- src: geerlingguy.adminer
Expand Down
58 changes: 58 additions & 0 deletions provisioning/roles/thom8.upload-progress/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
sudo: required

env:
- distribution: centos
version: 7
init: /usr/lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
SITE: source
- distribution: ubuntu
version: 14.04
init: /sbin/init
run_opts: ""
SITE: source
- distribution: ubuntu
version: 12.04
init: /sbin/init
run_opts: ""
SITE: source

services:
- docker

before_install:
# Pull container
- 'sudo docker pull ${distribution}:${version}'
# Customize container
- 'sudo docker build --rm=true --file=tests/Dockerfile.${distribution}-${version} --tag=${distribution}-${version}:ansible tests'

script:
- container_id=$(mktemp)
# Run container in detached state
- 'sudo docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} ${distribution}-${version}:ansible "${init}" > "${container_id}"'

# Install dependencies.
- 'sudo docker exec "$(cat ${container_id})" ansible-galaxy install geerlingguy.php geerlingguy.repo-remi'

# Ansible syntax check.
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test-${SITE}.yml --syntax-check'

# Test role.
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test-${SITE}.yml'

# Test role idempotence.
- >
sudo docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test-${SITE}.yml
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
# Run script to test if Upload progress is available and working.
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm php /etc/ansible/roles/role_under_test/tests/uploadprogress-test.php'

# Clean up
- 'sudo docker stop "$(cat ${container_id})"'

notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
39 changes: 39 additions & 0 deletions provisioning/roles/thom8.upload-progress/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Ansible Role: Upload progress

[![CircleCI](https://circleci.com/gh/beetboxvm/ansible-role-beetbox-upload-progress.svg?style=svg)](https://circleci.com/gh/beetboxvm/ansible-role-beetbox-upload-progress)

Installs Upload progress PHP extension on Linux servers.

## Requirements

Prior to running this role, make sure the `php-devel` and `@Development Tools` (for RHEL/CentOS) or `php5-dev` + `build-essential` packages (for Debian/Ubuntu) are present on the system, as they are required for the build of Upload progress.

## Role Variables

Available variables are listed below, along with default values (see `defaults/main.yml`):

workspace: /root

Where Xdebug setup files will be downloaded and built.

php_uploadprogress_module_path: /usr/lib/php5/modules

The path where `uploadprogress.so` will be installed.

php_uploadprogress_config_filename: 20-uploadprogress.ini

The file name for PHP config.

## Dependencies

- geerlingguy.php

## Example Playbook

- hosts: webservers
roles:
- { role: beetboxvm.upload-progress }

## License

MIT
2 changes: 2 additions & 0 deletions provisioning/roles/thom8.upload-progress/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
workspace: /root
43 changes: 43 additions & 0 deletions provisioning/roles/thom8.upload-progress/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
dependencies:
- geerlingguy.php

galaxy_info:
author: beetboxvm
description: PHP Upload progress for Linux.
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
categories:
- development
- web
56 changes: 56 additions & 0 deletions provisioning/roles/thom8.upload-progress/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
- name: Include OS-specific variables.
include_vars: "{{ ansible_os_family }}.yml"

- name: Define php_uploadprogress_module_path.
set_fact:
php_uploadprogress_module_path: "{{ __php_uploadprogress_module_path }}"
when: php_uploadprogress_module_path is not defined

- name: Define php_uploadprogress_config_filename.
set_fact:
php_uploadprogress_config_filename: "{{ __php_uploadprogress_config_filename }}"
when: php_uploadprogress_config_filename is not defined

- name: Download and untar uploadprogress.
unarchive:
src: "https://github.com/php/pecl-php-uploadprogress/archive/master.tar.gz"
dest: "{{ workspace }}"
copy: no
creates: "{{ workspace }}/pecl-php-uploadprogress-master"

- name: Build uploadprogress.
shell: >
{{ item }}
chdir={{ workspace }}/pecl-php-uploadprogress-master
creates={{ workspace }}/pecl-php-uploadprogress-master/modules/uploadprogress.so
with_items:
- phpize
- ./configure
- make
notify: restart webserver

- name: Ensure uploadprogress module path exists.
file:
path: "{{ php_uploadprogress_module_path }}"
state: directory
owner: root
group: root
mode: 0755

- name: Move uploadprogress module into place.
shell: >
cp {{ workspace }}/pecl-php-uploadprogress-master/modules/uploadprogress.so {{ php_uploadprogress_module_path }}/uploadprogress.so
creates={{ php_uploadprogress_module_path }}/uploadprogress.so
notify: restart webserver

- name: Add php extension config for uploadprogress.
template:
src: uploadprogress.ini.j2
dest: "{{ item }}/{{ php_uploadprogress_config_filename }}"
owner: root
group: root
force: yes
mode: 0644
with_items: "{{ php_extension_conf_paths }}"
notify: restart webserver
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
; activate and configurate for php uploadprogress module
extension={{ php_uploadprogress_module_path }}/uploadprogress.so
30 changes: 30 additions & 0 deletions provisioning/roles/thom8.upload-progress/tests/Dockerfile.centos-7
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
FROM centos:7

# Install systemd -- See https://hub.docker.com/_/centos/
RUN yum -y swap -- remove fakesystemd -- install systemd systemd-libs
RUN yum -y update; yum clean all; \
(cd /lib/systemd/system/sysinit.target.wants/; for i in *; do [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \
rm -f /lib/systemd/system/multi-user.target.wants/*; \
rm -f /etc/systemd/system/*.wants/*; \
rm -f /lib/systemd/system/local-fs.target.wants/*; \
rm -f /lib/systemd/system/sockets.target.wants/*udev*; \
rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \
rm -f /lib/systemd/system/basic.target.wants/*; \
rm -f /lib/systemd/system/anaconda.target.wants/*;

# Install Ansible
RUN yum -y install epel-release
RUN yum -y install git ansible sudo
RUN yum clean all

RUN yum install -y unzip
RUN yum groupinstall -y "Development Tools"

# Disable requiretty
RUN sed -i -e 's/^\(Defaults\s*requiretty\)/#--- \1/' /etc/sudoers

# Install Ansible inventory file
RUN echo -e '[local]\nlocalhost ansible_connection=local' > /etc/ansible/hosts

VOLUME ["/sys/fs/cgroup"]
CMD ["/usr/sbin/init"]
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM ubuntu:12.04
RUN apt-get update

# Install Ansible
RUN apt-get install -y software-properties-common python-software-properties git
RUN apt-add-repository -y ppa:ansible/ansible
RUN apt-get update
RUN apt-get install -y ansible

RUN apt-get install -y unzip

# Install Ansible inventory file
RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM ubuntu:14.04
RUN apt-get update

# Install Ansible
RUN apt-get install -y software-properties-common git
RUN apt-add-repository -y ppa:ansible/ansible
RUN apt-get update
RUN apt-get install -y ansible

RUN apt-get install -y unzip

# Install Ansible inventory file
RUN echo "[local]\nlocalhost ansible_connection=local" > /etc/ansible/hosts
1 change: 1 addition & 0 deletions provisioning/roles/thom8.upload-progress/tests/inventory
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
localhost
20 changes: 20 additions & 0 deletions provisioning/roles/thom8.upload-progress/tests/test-source.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
- hosts: all

vars:
php_enable_webserver: false
php_enablerepo: "remi,remi-php70"

pre_tasks:
- name: Ensure build dependencies are installed (RedHat).
yum: name=which state=present
when: ansible_os_family == 'RedHat'

- name: Add repository for PHP 7.0.
apt_repository: repo='ppa:ondrej/php'
when: ansible_os_family == 'Debian'

roles:
- { role: geerlingguy.repo-remi, when: ansible_os_family == 'RedHat' }
- geerlingguy.php
- role_under_test
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

/**
* @file
* Test if Upload progress is available and working.
*/

$success = FALSE;

// Check uploadprogress extension is loaded.
if (extension_loaded('uploadprogress')) {
$success = TRUE;
print "Upload progress working properly.\r\n";
exit(0);
}

if (!$success) {
print "Upload progress not working properly.\r\n";
exit(1);
}
3 changes: 3 additions & 0 deletions provisioning/roles/thom8.upload-progress/vars/Debian.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
__php_uploadprogress_module_path: /usr/lib/php5/modules
__php_uploadprogress_config_filename: 20-uploadprogress.ini
3 changes: 3 additions & 0 deletions provisioning/roles/thom8.upload-progress/vars/RedHat.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
__php_uploadprogress_module_path: /usr/lib64/php/modules
__php_uploadprogress_config_filename: uploadprogress.ini

0 comments on commit 2bcf3c2

Please sign in to comment.