From 1ed033b2a86d6b4eded759d51385d296be1c0067 Mon Sep 17 00:00:00 2001 From: Ivan Grynenko Date: Sun, 12 Jun 2016 19:14:45 +1000 Subject: [PATCH] Squashed 'lemp-rhel7/roles/ansible-role-drush/' content from commit 6abbd27 git-subtree-dir: lemp-rhel7/roles/ansible-role-drush git-subtree-split: 6abbd27d51dfcd34b693a72f69af984ebc73bd49 --- .travis.yml | 42 +++++++++++++++++++++++++++++++++++ README.md | 56 +++++++++++++++++++++++++++++++++++++++++++++++ defaults/main.yml | 10 +++++++++ meta/main.yml | 46 ++++++++++++++++++++++++++++++++++++++ tasks/main.yml | 38 ++++++++++++++++++++++++++++++++ tests/inventory | 1 + tests/test.yml | 13 +++++++++++ 7 files changed, 206 insertions(+) create mode 100644 .travis.yml create mode 100644 README.md create mode 100644 defaults/main.yml create mode 100644 meta/main.yml create mode 100644 tasks/main.yml create mode 100644 tests/inventory create mode 100644 tests/test.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..7125a00 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,42 @@ +--- +language: python +python: "2.7" + +env: + - SITE=test.yml + +before_install: + - sudo add-apt-repository ppa:ondrej/php5 -y + - sudo apt-get update -q + - 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 geerlingguy.composer geerlingguy.git + +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 drush is installed and working. + - drush --version + +notifications: + webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..6e8dc88 --- /dev/null +++ b/README.md @@ -0,0 +1,56 @@ +# Ansible Role: Drush + +[![Build Status](https://travis-ci.org/geerlingguy/ansible-role-drush.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-drush) + +Installs Drush, a command line shell and scripting interface for Drupal, on any Linux or UNIX system. + +## Requirements + +None. + +## Role Variables + +Available variables are listed below, along with default values (see `defaults/main.yml`): + + drush_install_path: /usr/local/share/drush + +The location of the entire drush installation (includes all the supporting files, as well as the `drush` executable file. + + drush_path: /usr/local/bin/drush + +The path where drush will be installed and available to your system. Should be in your user's `$PATH` so you can run commands simply with `drush` instead of the full path. + + drush_version: "master" + +The version of Drush to install (examples: `"master"` for the bleeding edge, `"7.x"`, `"6.x"`, `"6.2.0"`). This should be a string as it refers to a git branch, tag, or commit hash. + + drush_keep_updated: no + drush_force_update: no + +Whether to keep Drush up-to-date with the latest revision of the branch specified by `drush_version`, and whether to force the update (e.g. overwrite local modifications to the drush repository). + + drush_composer_cli_options: "--prefer-source --no-interaction" + +These options are the safest for avoiding GitHub API rate limits when installing Drush, and can be very helpful when working on dependencies/installation, but builds can be sped up substantially by changing the first option to --prefer-dist. + +## Dependencies + + - geerlingguy.git (Installs Git). + - geerlingguy.php (Installs PHP). + - geerlingguy.composer (Installs Composer). + +## Example Playbook + + - hosts: servers + roles: + - { role: geerlingguy.drush } + +After the playbook runs, the `drush` command will be accessible from 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/). diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..eff2827 --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,10 @@ +--- +drush_install_path: /usr/local/share/drush +drush_path: /usr/local/bin/drush +drush_version: "master" +drush_keep_updated: no +drush_force_update: no + +# These options are the safest for avoiding GitHub API rate limits, but builds +# can be sped up substantially by changing to --prefer-dist. +drush_composer_cli_options: "--prefer-source --no-interaction" diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..0e0d581 --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,46 @@ +--- +dependencies: + - geerlingguy.git + - geerlingguy.php + - geerlingguy.composer + +galaxy_info: + author: geerlingguy + description: Drush - command line shell for Drupal + company: "Midwestern Mac, LLC" + license: "license (BSD, MIT)" + min_ansible_version: 1.4 + 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 diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..287fa65 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,38 @@ +--- +- name: Clone Drush from GitHub. + git: + repo: https://github.com/drush-ops/drush.git + dest: "{{ drush_install_path }}" + version: "{{ drush_version }}" + update: "{{ drush_keep_updated }}" + force: "{{ drush_force_update }}" + register: drush_clone + +- name: Check for composer.json + stat: path={{ drush_install_path }}/composer.json + register: drush_composer + +# See: https://github.com/geerlingguy/ansible-role-drush/issues/6 +- name: Ensure Drush can be installed on Debian Wheezy. + shell: > + {{ composer_path }} update {{ drush_composer_cli_options }} + chdir={{ drush_install_path }} + when: drush_clone.changed and ansible_distribution == "Debian" and ansible_distribution_release == "wheezy" and drush_composer.stat.exists + +- name: Install Drush dependencies with Composer. + shell: > + {{ composer_path }} install {{ drush_composer_cli_options }} + chdir={{ drush_install_path }} + when: drush_clone.changed and drush_composer.stat.exists + +- name: Create drush symlink. + file: + src: "{{ drush_install_path }}/drush" + dest: "{{ drush_path }}" + state: link + +- name: Run drush to finish setting it up. + command: "{{ drush_path }}" + register: drush_result + changed_when: "'Execute a drush command' not in drush_result.stdout" + become: no diff --git a/tests/inventory b/tests/inventory new file mode 100644 index 0000000..2fbb50c --- /dev/null +++ b/tests/inventory @@ -0,0 +1 @@ +localhost diff --git a/tests/test.yml b/tests/test.yml new file mode 100644 index 0000000..da27b63 --- /dev/null +++ b/tests/test.yml @@ -0,0 +1,13 @@ +--- +- hosts: localhost + remote_user: root + + vars: + php_enable_webserver: false + php_opcache_enable: "0" + + roles: + - geerlingguy.php + - geerlingguy.composer + - geerlingguy.git + - ansible-role-drush