Skip to content
This repository has been archived by the owner on Feb 13, 2023. It is now read-only.

Include roles with Drupal VM codebase #815

Merged
merged 8 commits into from
Jul 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
.vagrant/
.bundle/
*.retry
.galaxy_install_info
vagrant_ansible_inventory_default
local.config.yml
config.yml
Expand All @@ -12,5 +13,4 @@ Vagrantfile.local
examples/prod/inventory
examples/prod/bootstrap/vars.yml
scripts/
roles/
drupal/
5 changes: 1 addition & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ script:
# Setup directories.
- 'sudo docker exec "$(cat ${container_id})" mkdir -p ${DRUPALVM_DIR}/drupal'

# Install dependencies.
- 'sudo docker exec "$(cat ${container_id})" ansible-galaxy install -r ${DRUPALVM_DIR}/provisioning/requirements.yml'

# Setup config directory.
- '[[ ! -z "${config_dir}" ]] && sudo docker exec "$(cat ${container_id})" mkdir -p ${config_dir} || true'

Expand All @@ -64,7 +61,7 @@ script:
- '[[ ! -z "${local_config}" ]] && sudo docker exec "$(cat ${container_id})" bash -c "cp ${DRUPALVM_DIR}/${local_config} ${config_dir:-$DRUPALVM_DIR}/local.config.yml" || true'

# Vagrantfile syntax check
- 'rubocop --except LineLength,Eval,MutableConstant'
- 'rubocop ./Vagrantfile --except LineLength,Eval,MutableConstant'

# Ansible syntax check.
- 'sudo docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook ${DRUPALVM_DIR}/provisioning/playbook.yml --syntax-check'
Expand Down
2 changes: 0 additions & 2 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
if which('ansible-playbook')
config.vm.provision 'ansible' do |ansible|
ansible.playbook = "#{host_drupalvm_dir}/provisioning/playbook.yml"
ansible.galaxy_role_file = "#{host_drupalvm_dir}/provisioning/requirements.yml"
ansible.extra_vars = {
config_dir: host_config_dir
}
Expand All @@ -137,7 +136,6 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# else
# config.vm.provision "ansible_local" do |ansible|
# ansible.playbook = "#{guest_drupalvm_dir}/provisioning/playbook.yml"
# ansible.galaxy_role_file = "#{guest_drupalvm_dir}/provisioning/requirements.yml"
# ansible.extra_vars = {
# config_dir: guest_config_dir
# }
Expand Down
3 changes: 0 additions & 3 deletions docs/other/overriding-configurations.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ config.vm.provider :virtualbox do |v|
# Cap the host CPU execution at 50% usage.
v.customize ["modifyvm", :id, "--cpuexecutioncap", "50"]
end

# Disable the galaxy role re-installation during provisions.
config.vm.provisioners[0].config.galaxy_role_file = nil
```

### Example: Using the `vagrant-aws` provider
Expand Down
2 changes: 0 additions & 2 deletions docs/other/php-56.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
Drupal VM defaults to PHP 7, but you can install and use 5.6 if you need to maximize compatibility with older Drupal 6 and 7 sites.

_Note: If you have Ansible installed on your host machine, make sure you're running the latest version of all Ansible role dependencies by running `ansible-galaxy install -r provisioning/requirements.yml --force` inside the root Drupal VM project folder._

## Ubuntu 16.04

Ubuntu 16.04 Xenial defaults to PHP 7.0 in it's system packages. No older versions of PHP will be supported if using this base box.
Expand Down
4 changes: 2 additions & 2 deletions provisioning/JJG-Ansible-Windows/windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ if ! command -v ansible >/dev/null; then
fi

# Install requirements.
echo "Installing Ansible roles from requirements file, if available."
find "$PLAYBOOK_DIR" \( -name "requirements.yml" -o -name "requirements.txt" \) -exec sudo ansible-galaxy install --force --ignore-errors -r {} \;
#echo "Installing Ansible roles from requirements file, if available."
#find "$PLAYBOOK_DIR" \( -name "requirements.yml" -o -name "requirements.txt" \) -exec sudo ansible-galaxy install --force --ignore-errors -r {} \;

# Run the playbook.
echo "Running Ansible provisioner defined in Vagrantfile."
Expand Down
15 changes: 15 additions & 0 deletions provisioning/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Drupal VM - Ansible Provisioning

Drupal VM uses the Ansible provisioner to build all the software that runs and supplements Drupal sites.

The Ansible configuration uses a variety of open source community-maintained Ansible Roles that are hosted on Ansible Galaxy, but Drupal VM includes the roles in the codebase for efficiency's sake.

**You should NOT make any manual changes to the roles in the `roles` directory**, but rather, contribute to the upstream roles corresponding to the role's folder name (e.g. for issues with the `geerlingguy.apache` role, see the [`geerlingguy.apache`](https://galaxy.ansible.com/geerlingguy/apache/) role page on Ansible Galaxy, and the role's [issue tracker on GitHub](https://github.com/geerlingguy/ansible-role-apache/issues)).

## Adding and Updating Galaxy roles

From time to time, third party roles need to be added or updated to enable new Drupal VM functionality or fix bugs. To update a role (e.g. `geerlingguy.apache`), find the role's `version` setting inside `requirements.yml`, bump the version to the required or latest version of the role, then run the following command _in the same directory as this README file_:

$ ansible-galaxy install -r requirements.yml --force

Then commit the updated `requirements.yml` file and the new and updated files within the `roles` directory in a new PR to the Drupal VM project.
2 changes: 2 additions & 0 deletions provisioning/ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[defaults]
roles_path = ./roles
24 changes: 24 additions & 0 deletions provisioning/roles/arknoll.selenium/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# OS generated files #
######################
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db

# IDE files #
#################
/.settings
/.buildpath
/.project
/nbproject
*.komodoproject
*.kpf
/.idea

# Other files #
###############
!empty
35 changes: 35 additions & 0 deletions provisioning/roles/arknoll.selenium/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
language: python
python: "2.7"

env:
- ANSIBLE_VERSION=1.6
- ANSIBLE_VERSION=1.7
- ANSIBLE_VERSION=1.8

before_install:
- sudo apt-get update -qq

install:
# Install Ansible.
- pip install ansible==$ANSIBLE_VERSION

# Add ansible.cfg to pick up roles path.
- "printf '[defaults]\\nroles_path = ../' > ansible.cfg"

script:
# Check the role/playbook's syntax.
- "ansible-playbook -i tests/inventory tests/test.yml --syntax-check"

# Run the role/playbook with ansible-playbook.
- "ansible-playbook -i tests/inventory tests/test.yml --connection=local --sudo -vvvv"

# Run the role/playbook again, checking to make sure it's idempotent.
- >
ansible-playbook -i tests/inventory tests/test.yml --connection=local --sudo
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)

notifications:
email: false
13 changes: 13 additions & 0 deletions provisioning/roles/arknoll.selenium/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright (c) Alex Knoll

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
61 changes: 61 additions & 0 deletions provisioning/roles/arknoll.selenium/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
## selenium [![Build Status](https://travis-ci.org/arknoll/ansible-role-selenium.svg?branch=master)](https://travis-ci.org/arknoll/ansible-role-selenium)

Set up selenium and Firefox for running selenium tests.

#### Requirements

* `java`

#### Variables

* `selenium_install_dir`: [default: `/opt`] Install directory
* `selenium_version`: [default: `2.44.0`] Install version

## Dependencies

None

#### Example

```yaml
---
- hosts: all
roles:
- selenium
```

#### Start/Stop/Restart Selenium

```
$ service selenium start
$ service selenium stop
$ service selenium restart
```

#### License and Author

Author:: Alex Knoll (arknoll@gmail.com)

Copyright:: 2015, Alex Knoll

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

#### Contributing

We welcome contributed improvements and bug fixes via the usual workflow:

1. Fork this repository
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new pull request
5 changes: 5 additions & 0 deletions provisioning/roles/arknoll.selenium/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
# defaults file for selenium
selenium_install_dir: /opt
selenium_version: 2.53.0
selenium_install_firefox: yes
4 changes: 4 additions & 0 deletions provisioning/roles/arknoll.selenium/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
# handlers file for selenium
- name: restart selenium
service: name=selenium state=restarted
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{install_date: 'Sat Jul 23 03:17:21 2016', version: 1.3.0}
21 changes: 21 additions & 0 deletions provisioning/roles/arknoll.selenium/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
# meta file for selenium
galaxy_info:
author: Alex Knoll
description: Set up selenium and Firefox for running selenium tests.
license: Apache V2
min_ansible_version: 1.3
platforms:
- name: EL
versions:
- 6
- 7
- name: Ubuntu
versions:
- all
- name: Debian
versions:
- all
categories:
- web
dependencies: []
42 changes: 42 additions & 0 deletions provisioning/roles/arknoll.selenium/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
# Tasks file for selenium
- name: create directory
file: "path={{ selenium_install_dir }}/selenium state=directory recurse=yes"
tags: [configuration, selenium, selenium-create-directory]

- name: download
get_url: "url=http://selenium-release.storage.googleapis.com/{{ selenium_version | regex_replace('\\.[0-9]+$', '') }}/selenium-server-standalone-{{ selenium_version }}.jar dest=/opt/selenium/selenium-server-standalone-{{ selenium_version }}.jar"
tags: [configuration, selenium, selenium-download]

- name: Install xvfb
apt: name={{item}}
with_items:
- xvfb
when: ansible_os_family == 'Debian'

- name: Install browser
apt: name={{item}}
with_items:
- firefox
when: ansible_os_family == 'Debian' and selenium_install_firefox

- name: Install browser Xvfb
yum: name={{item}}
with_items:
- xorg-x11-server-Xvfb
when: ansible_os_family == 'RedHat'

- name: Install browser
yum: name={{item}}
with_items:
- firefox
when: ansible_os_family == 'RedHat' and selenium_install_firefox


- name: install
template: src=selenium-init-{{ ansible_os_family }}.j2 dest=/etc/init.d/selenium owner=root group=root mode=0755
tags: [configuration, selenium, selenium-install]

- name: run
service: name=selenium state=started enabled=yes
tags: [configuration, selenium, selenium-run]
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

DISPLAY_ID=":1"
RUN_AS=root

JAVA_BIN=/usr/bin/java

XVFB_BIN=/usr/bin/xvfb-run

SELENIUM_DIR={{ selenium_install_dir }}/selenium
SELENIUM_PID_FILE="$SELENIUM_DIR/selenium.pid"
SELENIUM_JAR_FILE="$SELENIUM_DIR/selenium-server-standalone-{{ selenium_version }}.jar"
SELENIUM_LOG_FILE="$SELENIUM_DIR/selenium.log"
SELENIUM_DAEMON_OPTS=" -client -jar $SELENIUM_JAR_FILE -log $SELENIUM_LOG_FILE"

export DISPLAY="$DISPLAY_ID"

set -e

. /lib/lsb/init-functions

case "$1" in
start)
if status_of_proc -p $SELENIUM_PID_FILE "$SELENIUM_JAR_FILE" $SELENIUM_JAR_FILE > /dev/null; then
log_progress_msg "Service already running"
else
log_daemon_msg "Starting Selenium server"
log_progress_msg "selenium"
start-stop-daemon -c $RUN_AS --start --quiet --background --pidfile $SELENIUM_PID_FILE --make-pidfile --exec $XVFB_BIN $JAVA_BIN -- $SELENIUM_DAEMON_OPTS
fi
;;

stop)
if status_of_proc -p $SELENIUM_PID_FILE "$SELENIUM_JAR_FILE" $SELENIUM_JAR_FILE > /dev/null; then
log_daemon_msg "Stopping Selenium server"
log_progress_msg "selenium"
start-stop-daemon --stop --pidfile $SELENIUM_PID_FILE
else
log_progress_msg "Service not running"
fi
;;

restart|force-reload)
$0 stop
sleep 1
$0 start
;;

status)
status_of_proc -p $SELENIUM_PID_FILE "$SELENIUM_JAR_FILE" $SELENIUM_JAR_FILE && exit 0 || exit $?
;;

*)
N=/etc/init.d/selenium
echo "Usage: $N {start|stop|restart|force-reload|status}" >&2
exit 1
;;
esac
Loading