Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Emilien Kenler committed Jun 11, 2015
0 parents commit 2d3b898
Show file tree
Hide file tree
Showing 12 changed files with 2,118 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2014 Wizcorp

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
PHP
===

This role takes care of installing php on a web server to be able to run php application.

Configuration
--------------

### Inventory

```ini
[web:children]
web-somedc-prod

[web-somedc-prod]
web1.somedc.prod ansible_ssh_host=10.0.1.111

[web-somedc-prod:vars]
# Unix user/group of php-fpm processes
php_fpm_user = apache
php_fpm_group = apache

# What PHP version to use. Available: 5.4, 5.5 and 5.6. Default: 5.4.
php_version = 5.4

# What folder to use to store sessions. Default: /tmp
php_sessions_dir = /tmp
```

*Note:* If you want to change the PHP version on an already provisioned server,
you must first uninstall manually the previous version.

See also
---------

* [PHP](http://php.net/)
5 changes: 5 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
php_version: 5.4

php_fpm_user: apache
php_fpm_group: apache
php_sessions_dir: "/tmp"
6 changes: 6 additions & 0 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
- name: "Restart php-fpm"
service: >
name={{ php_fpm_service }}
state=restarted
tags:
- php
24 changes: 24 additions & 0 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
galaxy_info:
author: Emilien Kenler <ekenler@wizcorp.jp>
description: Installs PHP on a server
company: Wizcorp K.K.
license: MIT
min_ansible_version: 1.8.1
platforms:
- name: EL
versions:
- 6
- 7
categories:
- development
- web
dependencies:
- role: aeriscloud.repos
repositories:
centos6:
- epel
- remi
centos7:
- epel
- remi
- role: aeriscloud.yum
39 changes: 39 additions & 0 deletions tasks/centos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
- name: "Install PHP with php-fpm"
yum: >
name={{ item }}
state=latest
enablerepo=epel,remi
with_items:
- php{{ php_version | replace('.','') }}-php-pecl-apcu
- php{{ php_version | replace('.','') }}-php-cli
- php{{ php_version | replace('.','') }}-php-fpm
- php{{ php_version | replace('.','') }}-php-mysqlnd
- php{{ php_version | replace('.','') }}-php-pgsql
- php{{ php_version | replace('.','') }}-php-pdo
- php{{ php_version | replace('.','') }}-php-mbstring
notify:
- Restart php-fpm
tags:
- php
- pkgs

- name: "Set php facts"
set_fact:
php_fpm_service: php{{ php_version | replace('.','') }}-php-fpm
php_config_dir: /opt/remi/php{{ php_version | replace('.','') }}/root/etc
tags:
- php

- name: "Create symlink into /usr/bin"
file: >
src=/opt/remi/php{{ php_version | replace('.','') }}/root/usr/bin/{{ item }}
dest=/usr/bin/{{ item }}
owner=root
group=root
state=link
with_items:
- php
- php-cgi
- phar
tags:
- php
48 changes: 48 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
- include: centos.yml
when: ansible_distribution == 'CentOS'

- name: "Ensure php-fpm is running, and starts on boot"
service: >
name={{ php_fpm_service }}
enabled=yes
state=running
tags:
- php

- name: "Ensure the 'php_fpm_user' exists"
user: >
name={{ php_fpm_user }}
state=present
tags:
- php
- user

- name: "Set the php-fpm configuration"
template: >
src=www.conf
dest={{ php_config_dir }}/php-fpm.d/www.conf
notify:
- Restart php-fpm
tags:
- php
- files

- name: "Disable cgi.fix_pathinfo"
template: >
src=php.ini
dest={{ php_config_dir }}/php.ini
notify:
- Restart php-fpm
tags:
- php
- files

- name: "Create the log directory"
file: >
path=/var/log/php-fpm
owner={{ php_fpm_user }}
group={{ php_fpm_group }}
state=directory
tags:
- php
- files
Loading

0 comments on commit 2d3b898

Please sign in to comment.