From 03b40cf4008d2ae529f7b1baa74ac03077955043 Mon Sep 17 00:00:00 2001 From: Thom Toogood Date: Sat, 10 Dec 2016 11:39:14 +1100 Subject: [PATCH] Added upload-progress role. --- default.config.yml | 1 + provisioning/playbook.yml | 1 + provisioning/requirements.yml | 2 + .../thom8.php-upload-progress/.travis.yml | 58 +++++++++++++++++++ .../roles/thom8.php-upload-progress/README.md | 39 +++++++++++++ .../defaults/main.yml | 2 + .../thom8.php-upload-progress/meta/main.yml | 43 ++++++++++++++ .../thom8.php-upload-progress/tasks/main.yml | 56 ++++++++++++++++++ .../templates/uploadprogress.ini.j2 | 2 + .../tests/Dockerfile.centos-7 | 30 ++++++++++ .../tests/Dockerfile.ubuntu-12.04 | 13 +++++ .../tests/Dockerfile.ubuntu-14.04 | 13 +++++ .../thom8.php-upload-progress/tests/inventory | 1 + .../tests/test-source.yml | 20 +++++++ .../tests/uploadprogress-test.php | 20 +++++++ .../thom8.php-upload-progress/vars/Debian.yml | 3 + .../thom8.php-upload-progress/vars/RedHat.yml | 3 + 17 files changed, 307 insertions(+) create mode 100644 provisioning/roles/thom8.php-upload-progress/.travis.yml create mode 100644 provisioning/roles/thom8.php-upload-progress/README.md create mode 100644 provisioning/roles/thom8.php-upload-progress/defaults/main.yml create mode 100644 provisioning/roles/thom8.php-upload-progress/meta/main.yml create mode 100644 provisioning/roles/thom8.php-upload-progress/tasks/main.yml create mode 100644 provisioning/roles/thom8.php-upload-progress/templates/uploadprogress.ini.j2 create mode 100644 provisioning/roles/thom8.php-upload-progress/tests/Dockerfile.centos-7 create mode 100644 provisioning/roles/thom8.php-upload-progress/tests/Dockerfile.ubuntu-12.04 create mode 100644 provisioning/roles/thom8.php-upload-progress/tests/Dockerfile.ubuntu-14.04 create mode 100644 provisioning/roles/thom8.php-upload-progress/tests/inventory create mode 100644 provisioning/roles/thom8.php-upload-progress/tests/test-source.yml create mode 100644 provisioning/roles/thom8.php-upload-progress/tests/uploadprogress-test.php create mode 100644 provisioning/roles/thom8.php-upload-progress/vars/Debian.yml create mode 100644 provisioning/roles/thom8.php-upload-progress/vars/RedHat.yml diff --git a/default.config.yml b/default.config.yml index c13d780eb..4aca5052b 100644 --- a/default.config.yml +++ b/default.config.yml @@ -204,6 +204,7 @@ installed_extras: # - ruby # - selenium # - solr + # - upload-progress - varnish # - xdebug # - xhprof diff --git a/provisioning/playbook.yml b/provisioning/playbook.yml index a2522d41c..cf3abedb4 100644 --- a/provisioning/playbook.yml +++ b/provisioning/playbook.yml @@ -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' } diff --git a/provisioning/requirements.yml b/provisioning/requirements.yml index ed35c7bfc..3882ca8d8 100644 --- a/provisioning/requirements.yml +++ b/provisioning/requirements.yml @@ -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 diff --git a/provisioning/roles/thom8.php-upload-progress/.travis.yml b/provisioning/roles/thom8.php-upload-progress/.travis.yml new file mode 100644 index 000000000..67d45cf08 --- /dev/null +++ b/provisioning/roles/thom8.php-upload-progress/.travis.yml @@ -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/ diff --git a/provisioning/roles/thom8.php-upload-progress/README.md b/provisioning/roles/thom8.php-upload-progress/README.md new file mode 100644 index 000000000..c369de5f5 --- /dev/null +++ b/provisioning/roles/thom8.php-upload-progress/README.md @@ -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 diff --git a/provisioning/roles/thom8.php-upload-progress/defaults/main.yml b/provisioning/roles/thom8.php-upload-progress/defaults/main.yml new file mode 100644 index 000000000..8279f6ad8 --- /dev/null +++ b/provisioning/roles/thom8.php-upload-progress/defaults/main.yml @@ -0,0 +1,2 @@ +--- +workspace: /root diff --git a/provisioning/roles/thom8.php-upload-progress/meta/main.yml b/provisioning/roles/thom8.php-upload-progress/meta/main.yml new file mode 100644 index 000000000..885eb036e --- /dev/null +++ b/provisioning/roles/thom8.php-upload-progress/meta/main.yml @@ -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 diff --git a/provisioning/roles/thom8.php-upload-progress/tasks/main.yml b/provisioning/roles/thom8.php-upload-progress/tasks/main.yml new file mode 100644 index 000000000..dc7c6698a --- /dev/null +++ b/provisioning/roles/thom8.php-upload-progress/tasks/main.yml @@ -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 diff --git a/provisioning/roles/thom8.php-upload-progress/templates/uploadprogress.ini.j2 b/provisioning/roles/thom8.php-upload-progress/templates/uploadprogress.ini.j2 new file mode 100644 index 000000000..6bcbad366 --- /dev/null +++ b/provisioning/roles/thom8.php-upload-progress/templates/uploadprogress.ini.j2 @@ -0,0 +1,2 @@ +; activate and configurate for php uploadprogress module +extension={{ php_uploadprogress_module_path }}/uploadprogress.so diff --git a/provisioning/roles/thom8.php-upload-progress/tests/Dockerfile.centos-7 b/provisioning/roles/thom8.php-upload-progress/tests/Dockerfile.centos-7 new file mode 100644 index 000000000..10c2684ce --- /dev/null +++ b/provisioning/roles/thom8.php-upload-progress/tests/Dockerfile.centos-7 @@ -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"] diff --git a/provisioning/roles/thom8.php-upload-progress/tests/Dockerfile.ubuntu-12.04 b/provisioning/roles/thom8.php-upload-progress/tests/Dockerfile.ubuntu-12.04 new file mode 100644 index 000000000..576e3bce8 --- /dev/null +++ b/provisioning/roles/thom8.php-upload-progress/tests/Dockerfile.ubuntu-12.04 @@ -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 diff --git a/provisioning/roles/thom8.php-upload-progress/tests/Dockerfile.ubuntu-14.04 b/provisioning/roles/thom8.php-upload-progress/tests/Dockerfile.ubuntu-14.04 new file mode 100644 index 000000000..cb7a7bda4 --- /dev/null +++ b/provisioning/roles/thom8.php-upload-progress/tests/Dockerfile.ubuntu-14.04 @@ -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 diff --git a/provisioning/roles/thom8.php-upload-progress/tests/inventory b/provisioning/roles/thom8.php-upload-progress/tests/inventory new file mode 100644 index 000000000..2fbb50c4a --- /dev/null +++ b/provisioning/roles/thom8.php-upload-progress/tests/inventory @@ -0,0 +1 @@ +localhost diff --git a/provisioning/roles/thom8.php-upload-progress/tests/test-source.yml b/provisioning/roles/thom8.php-upload-progress/tests/test-source.yml new file mode 100644 index 000000000..dee464c36 --- /dev/null +++ b/provisioning/roles/thom8.php-upload-progress/tests/test-source.yml @@ -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 diff --git a/provisioning/roles/thom8.php-upload-progress/tests/uploadprogress-test.php b/provisioning/roles/thom8.php-upload-progress/tests/uploadprogress-test.php new file mode 100644 index 000000000..a77ff8e5a --- /dev/null +++ b/provisioning/roles/thom8.php-upload-progress/tests/uploadprogress-test.php @@ -0,0 +1,20 @@ +