From 1a981762840072121c4c1b102e6ff242ce6cfede Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Mon, 13 Mar 2017 13:57:36 -0500 Subject: [PATCH] Fixes #1213: Add task-specific tags for supercharged reprovisioning. --- docs/extending/ansible-args.md | 15 ++++++++++- provisioning/playbook.yml | 48 +++++++++++++++++++++++----------- 2 files changed, 47 insertions(+), 16 deletions(-) diff --git a/docs/extending/ansible-args.md b/docs/extending/ansible-args.md index 051aa36ca..20f18f245 100644 --- a/docs/extending/ansible-args.md +++ b/docs/extending/ansible-args.md @@ -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: diff --git a/provisioning/playbook.yml b/provisioning/playbook.yml index 7d7f360c1..d1053106d 100644 --- a/provisioning/playbook.yml +++ b/provisioning/playbook.yml @@ -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: @@ -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' } @@ -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' } @@ -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 }}"