From 6a684ac9d1537ae2380de32d28137177bb7dbc27 Mon Sep 17 00:00:00 2001 From: Ivan Grynenko Date: Mon, 13 Jun 2016 15:29:38 +1000 Subject: [PATCH] Squashed 'lemp-rhel7/roles/ansible-role-drupal-console/' content from commit 9622067 git-subtree-dir: lemp-rhel7/roles/ansible-role-drupal-console git-subtree-split: 9622067f57946a2bad71ddea37418f5b971a70b1 --- .travis.yml | 41 ++++++++++++++++++++++++++++++++++ README.md | 45 ++++++++++++++++++++++++++++++++++++++ defaults/main.yml | 4 ++++ meta/main.yml | 44 +++++++++++++++++++++++++++++++++++++ tasks/main.yml | 22 +++++++++++++++++++ tests/inventory | 1 + tests/test-self-update.yml | 15 +++++++++++++ tests/test.yml | 14 ++++++++++++ 8 files changed, 186 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-self-update.yml create mode 100644 tests/test.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..816fbdd --- /dev/null +++ b/.travis.yml @@ -0,0 +1,41 @@ +--- +sudo: required +language: python +python: "2.7" + +env: + - SITE=test.yml + - SITE=test-self-update.yml + +before_install: + - sudo apt-get update -qq + +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 Drupal Console is installed and working. + - drupal + +notifications: + webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..83aa15b --- /dev/null +++ b/README.md @@ -0,0 +1,45 @@ +# Ansible Role: Drupal Console + +[![Build Status](https://travis-ci.org/geerlingguy/ansible-role-drupal-console.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-drupal-console) + +Installs [Drupal Console](http://drupalconsole.com/) on any Linux or UNIX system. + +## Requirements + +`php` (version 5.4+) should be installed and working. + +## Role Variables + +Available variables are listed below, along with default values (see `defaults/main.yml`): + + drupal_console_path: /usr/local/bin/drupal + +The path where Drupal Console will be installed and available to your system. Should be in your user's `$PATH` so you can use Drupal Console by entering `drupal` instead of the full path. + + drupal_console_keep_updated: false + +By default, this role not update Drupal Console when it is run again. If you'd like always update Drupal Console to the latest version when this role is run, switch this variable to `true`. + + drupal_console_config: ~/.console + +The path to the Drupal Console configuration file. + +## Dependencies + + - geerlingguy.php (Installs PHP). + +## Example Playbook + + - hosts: servers + roles: + - { role: geerlingguy.drupal-console } + +After the playbook runs, `drupal` will be placed in `/usr/local/bin/drupal` (this location is configurable), and will be accessible via normal system accounts. + +## License + +MIT / BSD + +## Author Information + +This role was created in 2015 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..5885c7a --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,4 @@ +--- +drupal_console_path: /usr/local/bin/drupal +drupal_console_keep_updated: false +drupal_console_config: ~/.console diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..b08456f --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,44 @@ +--- +dependencies: + - geerlingguy.php + +galaxy_info: + author: geerlingguy + description: Drupal Console + 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: + - packaging + - web diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..5be2194 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,22 @@ +--- +- name: Install Drupal Console. + get_url: + url: https://drupalconsole.com/installer + dest: "{{ drupal_console_path }}" + +- name: Ensure Drupal Console is executable. + file: + path: "{{ drupal_console_path }}" + mode: 0755 + +- name: Run Drupal Console init. + shell: > + php {{ drupal_console_path }} init + creates={{ drupal_console_config }} + +- name: Update Drupal Console to latest version (if configured). + shell: > + php {{ drupal_console_path }} self-update + register: drupal_console_update + changed_when: "'console has been updated' in drupal_console_update.stdout" + when: drupal_console_keep_updated 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-self-update.yml b/tests/test-self-update.yml new file mode 100644 index 0000000..cb5934c --- /dev/null +++ b/tests/test-self-update.yml @@ -0,0 +1,15 @@ +--- +- hosts: localhost + remote_user: root + + vars: + php_enable_webserver: false + drupal_console_keep_updated: true + + pre_tasks: + - name: Add ondrej repository for PHP 5.6. + apt_repository: repo='ppa:ondrej/php5-5.6' + + roles: + - geerlingguy.php + - ansible-role-drupal-console diff --git a/tests/test.yml b/tests/test.yml new file mode 100644 index 0000000..cf4c49c --- /dev/null +++ b/tests/test.yml @@ -0,0 +1,14 @@ +--- +- hosts: localhost + remote_user: root + + vars: + php_enable_webserver: false + + pre_tasks: + - name: Add ondrej repository for PHP 5.6. + apt_repository: repo='ppa:ondrej/php5-5.6' + + roles: + - geerlingguy.php + - ansible-role-drupal-console