mirror of
https://github.com/geerlingguy/ansible-role-apache
synced 2025-01-09 03:10:19 +01:00
Merge commit '5f3cedf30edd2149f0ef0c1c267d9c0250bb7393' as 'lemp-rhel7/roles/ansible-role-composer'
This commit is contained in:
commit
8ead96b1e1
11 changed files with 272 additions and 0 deletions
42
lemp-rhel7/roles/ansible-role-composer/.travis.yml
Normal file
42
lemp-rhel7/roles/ansible-role-composer/.travis.yml
Normal file
|
@ -0,0 +1,42 @@
|
|||
---
|
||||
sudo: required
|
||||
language: python
|
||||
python: "2.7"
|
||||
|
||||
env:
|
||||
- SITE=test.yml
|
||||
- SITE=test-global-require.yml
|
||||
|
||||
before_install:
|
||||
- sudo apt-get update -qq
|
||||
- sudo apt-get install curl
|
||||
|
||||
install:
|
||||
# Install Ansible.
|
||||
- pip install ansible
|
||||
|
||||
# Add ansible.cfg to pick up roles path.
|
||||
- "{ echo '[defaults]'; echo 'roles_path = ../'; } >> ansible.cfg"
|
||||
|
||||
# Install required dependencies.
|
||||
- ansible-galaxy install geerlingguy.php
|
||||
|
||||
script:
|
||||
# Check the role/playbook's syntax.
|
||||
- "ansible-playbook -i tests/inventory tests/$SITE --syntax-check"
|
||||
|
||||
# Run the role/playbook with ansible-playbook.
|
||||
- "ansible-playbook -i tests/inventory tests/$SITE --connection=local --sudo"
|
||||
|
||||
# Run the role/playbook again, checking to make sure it's idempotent.
|
||||
- >
|
||||
ansible-playbook -i tests/inventory tests/$SITE --connection=local --sudo
|
||||
| grep -q 'changed=0.*failed=0'
|
||||
&& (echo 'Idempotence test: pass' && exit 0)
|
||||
|| (echo 'Idempotence test: fail' && exit 1)
|
||||
|
||||
# Check if composer is installed and working.
|
||||
- composer
|
||||
|
||||
notifications:
|
||||
webhooks: https://galaxy.ansible.com/api/v1/notifications/
|
68
lemp-rhel7/roles/ansible-role-composer/README.md
Normal file
68
lemp-rhel7/roles/ansible-role-composer/README.md
Normal file
|
@ -0,0 +1,68 @@
|
|||
# Ansible Role: Composer
|
||||
|
||||
[![Build Status](https://travis-ci.org/geerlingguy/ansible-role-composer.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-composer)
|
||||
|
||||
Installs Composer, the PHP Dependency Manager, on any Linux or UNIX system.
|
||||
|
||||
## Requirements
|
||||
|
||||
- `php` (version 5.4+) should be installed and working (you can use the `geerlingguy.php` role to install).
|
||||
- `git` should be installed and working (you can use the `geerlingguy.git` role to install).
|
||||
|
||||
## Role Variables
|
||||
|
||||
Available variables are listed below, along with default values (see `defaults/main.yml`):
|
||||
|
||||
composer_path: /usr/local/bin/composer
|
||||
|
||||
The path where composer will be installed and available to your system. Should be in your user's `$PATH` so you can run commands simply with `composer` instead of the full path.
|
||||
|
||||
composer_keep_updated: false
|
||||
|
||||
Set this to `true` to update Composer to the latest release every time the playbook is run.
|
||||
|
||||
composer_home_path: '~/.composer'
|
||||
composer_home_owner: root
|
||||
composer_home_group: root
|
||||
|
||||
The `COMPOSER_HOME` path and directory ownership; this is the directory where global packages will be installed.
|
||||
|
||||
composer_version: ''
|
||||
|
||||
You can install a specific release of Composer, e.g. `composer_version: '1.0.0-alpha11'`. If left empty the latest development version will be installed. Note that `composer_keep_updated` will override this variable, as it will always install the latest development version.
|
||||
|
||||
composer_global_packages: {}
|
||||
|
||||
A list of packages to install globally (using `composer global require`). If you want to install any packages globally, add a list item with a dictionary with the `name` of the package and a `release`, e.g. `- { name: phpunit/phpunit, release: "4.7.*" }`. The 'release' is optional, and defaults to `@stable`.
|
||||
|
||||
composer_add_to_path: true
|
||||
|
||||
If `true`, and if there are any configured `composer_global_packages`, the `vendor/bin` directory inside `composer_home_path` will be added to the system's default `$PATH` (for all users).
|
||||
|
||||
composer_github_oauth_token: ''
|
||||
|
||||
GitHub OAuth token, used to avoid GitHub API rate limiting errors when building and rebuilding applications using Composer. Follow GitHub's directions to [Create a personal access token](https://help.github.com/articles/creating-an-access-token-for-command-line-use/) if you run into these rate limit errors.
|
||||
|
||||
php_executable: php
|
||||
|
||||
The executable name or full path to the PHP executable. This is defaulted to `php` if you don't override the variable.
|
||||
|
||||
## Dependencies
|
||||
|
||||
None (but make sure you've installed PHP; the `geerlingguy.php` role is recommended).
|
||||
|
||||
## Example Playbook
|
||||
|
||||
- hosts: servers
|
||||
roles:
|
||||
- geerlingguy.composer
|
||||
|
||||
After the playbook runs, `composer` will be placed in `/usr/local/bin/composer` (this location is configurable), and will be accessible via normal system accounts.
|
||||
|
||||
## License
|
||||
|
||||
MIT / BSD
|
||||
|
||||
## Author Information
|
||||
|
||||
This role was created in 2014 by [Jeff Geerling](http://jeffgeerling.com/), author of [Ansible for DevOps](http://ansiblefordevops.com/).
|
20
lemp-rhel7/roles/ansible-role-composer/defaults/main.yml
Normal file
20
lemp-rhel7/roles/ansible-role-composer/defaults/main.yml
Normal file
|
@ -0,0 +1,20 @@
|
|||
---
|
||||
composer_path: /usr/local/bin/composer
|
||||
composer_keep_updated: false
|
||||
composer_version: ''
|
||||
|
||||
# The directory where global packages will be installed.
|
||||
composer_home_path: '~/.composer'
|
||||
composer_home_owner: root
|
||||
composer_home_group: root
|
||||
|
||||
# A list of packages to install globally. See commented examples below for
|
||||
# usage; the 'release' is optional, and defaults to '@stable'.
|
||||
composer_global_packages: []
|
||||
# - { name: phpunit/phpunit, release: "4.7.x" }
|
||||
# - { name: phpunit/phpunit, release: "@stable" }
|
||||
|
||||
composer_add_to_path: true
|
||||
|
||||
# GitHub OAuth token (used to help overcome API rate limits).
|
||||
composer_github_oauth_token: ''
|
43
lemp-rhel7/roles/ansible-role-composer/meta/main.yml
Normal file
43
lemp-rhel7/roles/ansible-role-composer/meta/main.yml
Normal file
|
@ -0,0 +1,43 @@
|
|||
---
|
||||
dependencies: []
|
||||
|
||||
galaxy_info:
|
||||
author: geerlingguy
|
||||
description: Composer PHP Dependency Manager
|
||||
company: "Midwestern Mac, LLC"
|
||||
license: "license (BSD, MIT)"
|
||||
min_ansible_version: 1.9
|
||||
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:
|
||||
- packaging
|
||||
- web
|
|
@ -0,0 +1,17 @@
|
|||
---
|
||||
- name: Install configured globally-required packages.
|
||||
become: yes
|
||||
become_user: "{{ composer_home_owner }}"
|
||||
shell: >
|
||||
COMPOSER_HOME={{ composer_home_path }}
|
||||
composer global require {{ item.name }}:{{ item.release | default('@stable') }} --no-progress
|
||||
creates={{ composer_home_path }}/vendor/{{ item.name }}
|
||||
register: composer_global_require_result
|
||||
with_items: "{{ composer_global_packages }}"
|
||||
|
||||
- name: Add composer_home_path bin directory to global $PATH.
|
||||
template:
|
||||
src: composer.sh.j2
|
||||
dest: /etc/profile.d/composer.sh
|
||||
mode: 0644
|
||||
when: composer_add_to_path
|
53
lemp-rhel7/roles/ansible-role-composer/tasks/main.yml
Normal file
53
lemp-rhel7/roles/ansible-role-composer/tasks/main.yml
Normal file
|
@ -0,0 +1,53 @@
|
|||
---
|
||||
- name: Set php_executable variable to a default if not defined.
|
||||
set_fact:
|
||||
php_executable: php
|
||||
when: php_executable is not defined
|
||||
|
||||
- name: Check if Composer is installed.
|
||||
stat: "path={{ composer_path }}"
|
||||
register: composer_bin
|
||||
|
||||
- name: Download Composer installer.
|
||||
get_url:
|
||||
url: https://getcomposer.org/installer
|
||||
dest: /tmp/composer-installer.php
|
||||
mode: 0755
|
||||
when: not composer_bin.stat.exists
|
||||
|
||||
- name: Run Composer installer.
|
||||
command: >
|
||||
{{ php_executable }} composer-installer.php {% if composer_version != '' %} --version={{ composer_version }}{% endif %}
|
||||
chdir=/tmp
|
||||
when: not composer_bin.stat.exists
|
||||
|
||||
- name: Move Composer into globally-accessible location.
|
||||
shell: >
|
||||
mv /tmp/composer.phar {{ composer_path }}
|
||||
creates={{ composer_path }}
|
||||
when: not composer_bin.stat.exists
|
||||
|
||||
- name: Update Composer to latest version (if configured).
|
||||
shell: >
|
||||
{{ php_executable }} {{ composer_path }} self-update
|
||||
register: composer_update
|
||||
changed_when: "'Updating to version' in composer_update.stdout"
|
||||
when: composer_keep_updated
|
||||
|
||||
- name: Ensure composer directory exists.
|
||||
file:
|
||||
path: "{{ composer_home_path }}"
|
||||
owner: "{{ composer_home_owner }}"
|
||||
group: "{{ composer_home_group }}"
|
||||
state: directory
|
||||
|
||||
- name: Add GitHub OAuth token for Composer (if configured).
|
||||
template:
|
||||
src: "auth.json.j2"
|
||||
dest: "{{ composer_home_path }}/auth.json"
|
||||
owner: "{{ composer_home_owner }}"
|
||||
group: "{{ composer_home_group }}"
|
||||
when: composer_github_oauth_token != ''
|
||||
|
||||
- include: global-require.yml
|
||||
when: composer_global_packages|length > 0
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"github-oauth": {
|
||||
"github.com": "{{ composer_github_oauth_token }}"
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
export PATH=$PATH:{{ composer_home_path }}/vendor/bin
|
1
lemp-rhel7/roles/ansible-role-composer/tests/inventory
Normal file
1
lemp-rhel7/roles/ansible-role-composer/tests/inventory
Normal file
|
@ -0,0 +1 @@
|
|||
localhost
|
|
@ -0,0 +1,12 @@
|
|||
---
|
||||
- hosts: localhost
|
||||
remote_user: root
|
||||
|
||||
vars:
|
||||
php_enable_webserver: false
|
||||
composer_global_packages:
|
||||
- { name: phpunit/phpunit, release: "@stable" }
|
||||
|
||||
roles:
|
||||
- geerlingguy.php
|
||||
- ansible-role-composer
|
10
lemp-rhel7/roles/ansible-role-composer/tests/test.yml
Normal file
10
lemp-rhel7/roles/ansible-role-composer/tests/test.yml
Normal file
|
@ -0,0 +1,10 @@
|
|||
---
|
||||
- hosts: localhost
|
||||
remote_user: root
|
||||
|
||||
vars:
|
||||
php_enable_webserver: false
|
||||
|
||||
roles:
|
||||
- geerlingguy.php
|
||||
- ansible-role-composer
|
Loading…
Reference in a new issue