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

Commit

Permalink
Fixes #1213: Add task-specific tags for supercharged reprovisioning.
Browse files Browse the repository at this point in the history
  • Loading branch information
geerlingguy committed Mar 13, 2017
1 parent 5a86ff7 commit 1a98176
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 16 deletions.
15 changes: 14 additions & 1 deletion docs/extending/ansible-args.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,20 @@

You can specify an additional argument to the `ansible-playbook` command by using the `DRUPALVM_ANSIBLE_ARGS` environment variable. This can be useful when debugging a task failure.

_Currently this feature has two quirks. It's only possible to pass on a single argument. You should not quote a flag's value as you would normally do in the shell._
> Note the following caveats:
>
> - Passing more than one argument may require special formatting. Read the [Ansible provisioner's `raw_arguments` docs](https://www.vagrantup.com/docs/provisioning/ansible_common.html#raw_arguments) for more info.
> - You should not quote a flag's value as you would normally do in the shell.
Run a specific set of tagged tasks:

```sh
# E.g. xdebug, drupal, webserver, database, cron...
DRUPALVM_ANSIBLE_ARGS='--tags=xdebug' vagrant provision

# Or combine them (e.g. if adding new databases and virtualhosts).
DRUPALVM_ANSIBLE_ARGS='--tags=webserver,database' vagrant provision
```

Display verbose ansible output:

Expand Down
48 changes: 33 additions & 15 deletions provisioning/playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
set_fact:
php_webserver_daemon: nginx
when: drupalvm_webserver == 'nginx'
tags: ['webserver', 'database', 'php']

- name: Set the correct XHProf package when PHP 5.5 or 5.6 is used.
set_fact:
Expand All @@ -59,43 +60,50 @@
path: "/root/php{{ php_version }}"
state: directory
mode: 0775
tags: ['php']

roles:
# Essential roles.
- { role: geerlingguy.repo-remi, when: ansible_os_family == 'RedHat' }
- geerlingguy.firewall
- geerlingguy.git
- geerlingguy.postfix
- { role: geerlingguy.apache, when: drupalvm_webserver == 'apache' }
- { role: geerlingguy.apache-php-fpm, when: drupalvm_webserver == 'apache' }
- { role: geerlingguy.nginx, when: drupalvm_webserver == 'nginx' }
- geerlingguy.php
- geerlingguy.php-pecl
- geerlingguy.composer
- { role: geerlingguy.mysql, when: drupal_db_backend == 'mysql' }
- { role: geerlingguy.php-mysql, when: drupal_db_backend == 'mysql' }
- { role: geerlingguy.postgresql, when: drupal_db_backend == 'pgsql' }
- { role: geerlingguy.php-pgsql, when: drupal_db_backend == 'pgsql' }
- { role: geerlingguy.repo-remi, when: ansible_os_family == 'RedHat', tags: ['webserver, php'] }
- { role: geerlingguy.firewall }
- { role: geerlingguy.git }
- { role: geerlingguy.postfix }
- { role: geerlingguy.apache, when: drupalvm_webserver == 'apache', tags: ['webserver']}
- { role: geerlingguy.apache-php-fpm, when: drupalvm_webserver == 'apache', tags: ['webserver'] }
- { role: geerlingguy.nginx, when: drupalvm_webserver == 'nginx', tags: ['webserver'] }
- { role: geerlingguy.php, tags: ['php'] }
- { role: geerlingguy.php-pecl, tags: ['php'] }
- { role: geerlingguy.composer }
- { role: geerlingguy.mysql, when: drupal_db_backend == 'mysql', tags: ['database'] }
- { role: geerlingguy.php-mysql, when: drupal_db_backend == 'mysql', tags: ['php', 'database'] }
- { role: geerlingguy.postgresql, when: drupal_db_backend == 'pgsql', tags: ['database'] }
- { role: geerlingguy.php-pgsql, when: drupal_db_backend == 'pgsql', tags: ['php', 'database'] }

# Conditionally-installed roles.
- { role: geerlingguy.drupal-console, when: 'drupal_major_version > 7 and "drupalconsole" in installed_extras' }
- { role: geerlingguy.drush, when: '"drush" in installed_extras' }
- { role: geerlingguy.memcached, when: '"memcached" in installed_extras' }
- { role: geerlingguy.php-memcached, when: '"memcached" in installed_extras' }

- role: geerlingguy.php-tideways
workspace: "/root/php{{ php_version }}"
when: '"tideways" in installed_extras'

- role: geerlingguy.php-xdebug
workspace: "/root/php{{ php_version }}"
when: '"xdebug" in installed_extras'
tags: ['xdebug']

- role: geerlingguy.php-xhprof
workspace: "/root/php{{ php_version }}"
when: '"xhprof" in installed_extras'

- role: thom8.php-upload-progress
workspace: "/root/php{{ php_version }}"
when: '"upload-progress" in installed_extras'

- { role: geerlingguy.blackfire, when: '"blackfire" in installed_extras' }
- { role: geerlingguy.adminer, when: '"adminer" in installed_extras' }
- { role: geerlingguy.adminer, when: '"adminer" in installed_extras', tags: ['database'] }
- { role: geerlingguy.pimpmylog, when: '"pimpmylog" in installed_extras' }
- { role: geerlingguy.daemonize, when: '"mailhog" in installed_extras' }
- { role: geerlingguy.mailhog, when: '"mailhog" in installed_extras' }
Expand All @@ -104,12 +112,14 @@
- { role: geerlingguy.redis, when: '"redis" in installed_extras' }
- { role: geerlingguy.php-redis, when: '"redis" in installed_extras' }
- { role: geerlingguy.ruby, when: '"ruby" in installed_extras' }

- role: geerlingguy.java
when: >
"java" in installed_extras or
"solr" in installed_extras or
"selenium" in installed_extras or
"elasticsearch" in installed_extras
- { role: arknoll.selenium, when: '"selenium" in installed_extras' }
- { role: geerlingguy.solr, when: '"solr" in installed_extras' }
- { role: geerlingguy.elasticsearch, when: '"elasticsearch" in installed_extras' }
Expand All @@ -121,19 +131,27 @@
tasks:
- include: tasks/sshd.yml
- include: tasks/extras.yml

- include: tasks/www.yml
tags: ['webserver']

- include: tasks/apparmor.yml
when: ansible_os_family == 'Debian' and drupal_db_backend == 'mysql'
tags: ['database']

# Build and configure the Drupal site.
- include_role: name=geerlingguy.drupal
static: no
tags: ['drupal']

- include: tasks/drush-aliases.yml

- include: tasks/cron.yml
tags: ['cron']

- include: tasks/dashboard.yml
when: dashboard_install_dir is defined and dashboard_install_dir != ''
tags: ['webserver', 'database']

- name: Run configured post-provision shell scripts.
script: "{{ item }}"
Expand Down

0 comments on commit 1a98176

Please sign in to comment.