diff --git a/defaults/main.yml b/defaults/main.yml index b3cb2399ad6d8e99f324354e4b3882eb9244d8ab..59e977cc0e025d389f4f139af186a8622c2af0e0 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,9 +1,11 @@ -drupal_install_drupal: true +--- + +drupal_install_drupal: yes drupal_contrib_subdir: drupal_links_relative_root: ../../.. drupal_config_directories: sync: sync -drupal_d6_create_symbolic_links: true +drupal_d6_create_symbolic_links: yes drupal_post_deploy_tasks: d6: - registry-rebuild diff --git a/tasks/apache.yml b/tasks/apache.yml index 849d6817e30c02430fbdcdbaa17c45cdc7dd781e..097d3f86102ed9c1184a7d64d5e2014dcd00a868 100644 --- a/tasks/apache.yml +++ b/tasks/apache.yml @@ -3,30 +3,31 @@ - block: - - name: Apache Configuration File - template: - src='vhost.conf' - dest='/etc/apache2/sites-available/{{ drupal.id }}-{{ drupal_domain.shortname|default("default") }}{{ apache_conf_ext }}' - owner='root' - group='root' - mode='664' - notify: - - "Apache | Restart Apache" + - name: Apache Configuration File + template: + src: vhost.conf + dest: /etc/apache2/sites-available/{{ drupal.id }}-{{ drupal_domain.shortname|default("default") }}{{ apache_conf_ext }} + owner: root + group: root + mode: 0664 + notify: + - Restart Apache - - name: Apache enable our new site(s) - command: a2ensite {{ drupal.id }}-{{ drupal_domain.shortname|default("default") }} creates=/etc/apache2/sites-enabled/{{ drupal.id }}-{{ drupal_domain.shortname|default("default") }}{{ apache_conf_ext }} - notify: - - "Apache | Restart Apache" + - name: Apache enable our new site(s) + command: a2ensite {{ drupal.id }}-{{ drupal_domain.shortname|default("default") }} creates=/etc/apache2/sites-enabled/{{ drupal.id }}-{{ drupal_domain.shortname|default("default") }}{{ apache_conf_ext }} + notify: + - Restart Apache - - name: Apache install SSL certificates - copy: - src='{{inventory_dir}}/files/ssl/{{ item.file }}' - dest='/etc/ssl/private' - with_items: '{{ drupal_domain.certs|default([]) }}' - notify: "Apache | Restart Apache" + - name: Apache install SSL certificates + copy: + src: '{{inventory_dir}}/files/ssl/{{ item.file }}' + dest: /etc/ssl/private + with_items: '{{ drupal_domain.certs|default([]) }}' + notify: + - Restart Apache - - include_tasks: apache_auth.yml - when: drupal_domain.apache_auth is defined and drupal_domain.apache_auth.active|default('true') == 'true' + - include_tasks: apache_auth.yml + when: drupal_domain.apache_auth is defined and drupal_domain.apache_auth.active|default('true') == 'true' tags: - ApacheConfig diff --git a/tasks/apache_auth.yml b/tasks/apache_auth.yml index 4457948f11cc88689a7e0d9cb47e792fcae0b153..fc1d590f268ad9c7589c13635dcaac84095f9348 100644 --- a/tasks/apache_auth.yml +++ b/tasks/apache_auth.yml @@ -3,37 +3,37 @@ - block: - - name: Ensure Password Directory - file: - path='{{ webRoot }}/passwords' - state='directory' - owner='{{ apacheUser }}' - group='{{ apacheUser }}' - mode='755' + - name: Ensure Password Directory + file: + path: '{{ webRoot }}/passwords' + state: directory + owner: '{{ apacheUser }}' + group: '{{ apacheUser }}' + mode: 0755 - - name: Setup AuthType Basic Credentials - htpasswd: - path='{{ webRoot }}/passwords/{{ drupal_domain.apache_auth.user }}' - name='{{ drupal_domain.apache_auth.user }}' - password='{{ drupal_domain.apache_auth.password|default("") }}' - owner='{{ apacheUser }}' - group='{{ apacheUser }}' - mode='640' - state='{{ drupal_domain.apache_auth.password is defined|ternary("present","absent") }}' - notify: - - "Apache | Restart Apache" + - name: Setup AuthType Basic Credentials + htpasswd: + path: '{{ webRoot }}/passwords/{{ drupal_domain.apache_auth.user }}' + name: '{{ drupal_domain.apache_auth.user }}' + password: '{{ drupal_domain.apache_auth.password|default("") }}' + owner: '{{ apacheUser }}' + group: '{{ apacheUser }}' + mode: 0640 + state: '{{ drupal_domain.apache_auth.password is defined|ternary("present","absent") }}' + notify: + - "Restart Apache" - - name: Setup AuthType Basic Credentials for extra users - htpasswd: - path='{{ webRoot }}/passwords/{{ drupal_domain.apache_auth.user }}' - name='{{ item.user }}' - password='{{ item.password }}' - owner='{{ apacheUser }}' - group='{{ apacheUser }}' - mode='640' - with_items: '{{ drupal_domain.apache_auth.extra_users|default([]) }}' - notify: - - "Apache | Restart Apache" + - name: Setup AuthType Basic Credentials for extra users + htpasswd: + path: '{{ webRoot }}/passwords/{{ drupal_domain.apache_auth.user }}' + name: '{{ item.user }}' + password: '{{ item.password }}' + owner: '{{ apacheUser }}' + group: '{{ apacheUser }}' + mode: 0640 + with_items: '{{ drupal_domain.apache_auth.extra_users|default([]) }}' + notify: + - "Restart Apache" tags: - ApacheConfig diff --git a/tasks/collect_config/collect.yml b/tasks/collect_config/collect.yml index 0f8ef9cc4d33e59715e549512c95a8ad6ddea370..d7d40efd512f46fc7e1595c84b967186cbdb3ed4 100644 --- a/tasks/collect_config/collect.yml +++ b/tasks/collect_config/collect.yml @@ -8,8 +8,8 @@ - name: Move exported config to working copy command: mv {{ pathExport }} {{ pathWorking }} # Note: If parallel processes are running the pathExport could be gone by now. - failed_when: false - ignore_errors: true + failed_when: no + ignore_errors: yes - name: Ensure working directory file: diff --git a/tasks/collect_config/commit/git.yml b/tasks/collect_config/commit/git.yml index 1dd465eee0ca1d488d4a5d36e87294340cd35c85..3ddc6ee47ecd09851743d9a7f53748b7662a2299 100644 --- a/tasks/collect_config/commit/git.yml +++ b/tasks/collect_config/commit/git.yml @@ -3,27 +3,27 @@ - block: - - name: Check Git Status - shell: git status -s - args: - chdir: '{{ webRoot }}' - become: false - register: git_status - - - block: - - - name: Add and commit files - shell: git {{ item }} + - name: Check Git Status + shell: git status -s args: chdir: '{{ webRoot }}' - become: false - with_items: - - add config/* - - config user.email "deployment@lakedrops.com" - - config user.name "Auto Config Export" - - commit -am "[ci skip] Config change on server" + become: no + register: git_status + + - block: + + - name: Add and commit files + shell: git {{ item }} + args: + chdir: '{{ webRoot }}' + become: no + with_items: + - add config/* + - config user.email "deployment@lakedrops.com" + - config user.name "Auto Config Export" + - commit -am "[ci skip] Config change on server" - when: git_status.stdout != '' + when: git_status.stdout != '' tags: - deploy diff --git a/tasks/collect_config/commit/gitextra.yml b/tasks/collect_config/commit/gitextra.yml index 86cf1019ef46c8dcbae9e4b4b847ab8f523e94fb..08ea74758aa612890ba7db51099d0b4be14f4773 100644 --- a/tasks/collect_config/commit/gitextra.yml +++ b/tasks/collect_config/commit/gitextra.yml @@ -3,27 +3,27 @@ - block: - - name: Check Git Status - shell: git status -s - args: - chdir: '{{ webRoot }}/{{ collect_config_key }}' - become: false - register: git_status - - - block: - - - name: Add and commit files - shell: git {{ item }} + - name: Check Git Status + shell: git status -s args: chdir: '{{ webRoot }}/{{ collect_config_key }}' - become: false - with_items: - - add * - - config user.email "deployment@lakedrops.com" - - config user.name "Auto Config Export" - - commit -am "[ci skip] Config change on server" + become: no + register: git_status + + - block: + + - name: Add and commit files + shell: git {{ item }} + args: + chdir: '{{ webRoot }}/{{ collect_config_key }}' + become: no + with_items: + - add * + - config user.email "deployment@lakedrops.com" + - config user.name "Auto Config Export" + - commit -am "[ci skip] Config change on server" - when: git_status.stdout != '' + when: git_status.stdout != '' tags: - deploy diff --git a/tasks/collect_config/finish/gitextra.yml b/tasks/collect_config/finish/gitextra.yml index 3f86c41f7b25fae34c128cb8c15ee5433e32fc48..f7bb3168bd0dc0abad46c8314bbe62289b205553 100644 --- a/tasks/collect_config/finish/gitextra.yml +++ b/tasks/collect_config/finish/gitextra.yml @@ -3,17 +3,17 @@ - block: - - name: Push - shell: git push - args: - chdir: '{{ webRoot }}/{{ collect_config_key }}' - become: false - when: git_status.stdout != '' + - name: Push + shell: git push + args: + chdir: '{{ webRoot }}/{{ collect_config_key }}' + become: no + when: git_status.stdout != '' - - name: Delete webroot working copy - file: - path: '{{ webRoot }}' - state: absent + - name: Delete webroot working copy + file: + path: '{{ webRoot }}' + state: absent tags: - deploy diff --git a/tasks/collect_config/finish/gitflow.yml b/tasks/collect_config/finish/gitflow.yml index e527160361c53a86383522f2de38f58c9201cad6..8a844602cee3894e7c031f0c00f7c982aa6805d7 100644 --- a/tasks/collect_config/finish/gitflow.yml +++ b/tasks/collect_config/finish/gitflow.yml @@ -3,19 +3,19 @@ - block: - - name: Finish Hotfix - shell: git {{ item }} - args: - chdir: '{{ webRoot }}' - become: false - with_items: - - flow hotfix finish -F -p -m "Config export {{ version }}" {{ version }} - when: git_status.stdout != '' + - name: Finish Hotfix + shell: git {{ item }} + args: + chdir: '{{ webRoot }}' + become: no + with_items: + - flow hotfix finish -F -p -m "Config export {{ version }}" {{ version }} + when: git_status.stdout != '' - - name: Delete webroot working copy - file: - path: '{{ webRoot }}' - state: absent + - name: Delete webroot working copy + file: + path: '{{ webRoot }}' + state: absent tags: - deploy diff --git a/tasks/collect_config/main.yml b/tasks/collect_config/main.yml index 95fa86a7393eb2beed46e17e0a434e9856171a8b..9975591986eeb65c3f5c9ab51100a812f2f3622a 100644 --- a/tasks/collect_config/main.yml +++ b/tasks/collect_config/main.yml @@ -3,23 +3,23 @@ - block: - - set_fact: - version='{{ lookup('pipe','date +%Y-%m-%d-%H-%M-%S') }}' - - set_fact: - webRoot='/tmp/ansible-cae-{{ drupal.id }}-{{ version }}-gitflow' - - set_fact: - pathConfig='{{ webRoot }}/{{ collect_config_key|default("config") }}/default/sync' - pathExport='{{ export_path }}' - pathWorking='/tmp/ansible-cae-{{ drupal.id }}-{{ version }}' - collectConfig={{ drupal.src.collectConfig|default([]) }} + - set_fact: + version: '{{ lookup('pipe','date +%Y-%m-%d-%H-%M-%S') }}' + - set_fact: + webRoot: '/tmp/ansible-cae-{{ drupal.id }}-{{ version }}-gitflow' + - set_fact: + pathConfig: '{{ webRoot }}/{{ collect_config_key|default("config") }}/default/sync' + pathExport: '{{ export_path }}' + pathWorking: /tmp/ansible-cae-{{ drupal.id }}-{{ version }} + collectConfig: '{{ drupal.src.collectConfig|default([]) }}' - - name: Check if export path exists - stat: - path: "{{ pathExport }}" - register: path_export_stat + - name: Check if export path exists + stat: + path: "{{ pathExport }}" + register: path_export_stat - - include_tasks: collect.yml - when: path_export_stat.stat.exists + - include_tasks: collect.yml + when: path_export_stat.stat.exists tags: - deploy diff --git a/tasks/collect_config/prepare/gitextra.yml b/tasks/collect_config/prepare/gitextra.yml index 53fd964563161156e9a09f71210172a15a5859c2..9c4c70957fb038dd8c22c67480f128551bcf1d9a 100644 --- a/tasks/collect_config/prepare/gitextra.yml +++ b/tasks/collect_config/prepare/gitextra.yml @@ -3,24 +3,24 @@ - block: - - name: Clone Git Repository - git: - accept_hostkey: yes - repo: '{{ drupal.src.git.extrarepos[item]["repository"] }}' - dest: '{{ webRoot }}/{{ item }}' - force: yes - version: '{{ drupal.src.git.extrarepos[item]["branch"]|default(omit) }}' - become: false - with_items: '{{ drupal.src.git.extrarepos|default([]) }}' - when: collect_config_key == item + - name: Clone Git Repository + git: + accept_hostkey: yes + repo: '{{ drupal.src.git.extrarepos[item]["repository"] }}' + dest: '{{ webRoot }}/{{ item }}' + force: yes + version: '{{ drupal.src.git.extrarepos[item]["branch"]|default(omit) }}' + become: no + with_items: '{{ drupal.src.git.extrarepos|default([]) }}' + when: collect_config_key == item - - name: Create Git Hook for commit message - copy: - content: | - #!/bin/sh - echo "[ci skip]" >>$1 - dest: '{{ webRoot }}/{{ collect_config_key }}/.git/hooks/prepare-commit-msg' - mode: 0777 + - name: Create Git Hook for commit message + copy: + content: | + #!/bin/sh + echo "[ci skip]" >>$1 + dest: '{{ webRoot }}/{{ collect_config_key }}/.git/hooks/prepare-commit-msg' + mode: 0777 tags: - deploy diff --git a/tasks/collect_config/prepare/gitflow.yml b/tasks/collect_config/prepare/gitflow.yml index c96e369bbd8a4c57e3f9cb619f7a869f1c827429..ec331972447b45dfd4d3459067d2bfc86e81d676 100644 --- a/tasks/collect_config/prepare/gitflow.yml +++ b/tasks/collect_config/prepare/gitflow.yml @@ -3,31 +3,31 @@ - block: - - name: Clone Git Repository - git: - accept_hostkey: yes - repo: '{{ drupal.src.git.repository }}' - dest: '{{ webRoot }}' - force: yes - version: '{{ drupal.src.git.branch|default(omit) }}' - become: false + - name: Clone Git Repository + git: + accept_hostkey: yes + repo: '{{ drupal.src.git.repository }}' + dest: '{{ webRoot }}' + force: yes + version: '{{ drupal.src.git.branch|default(omit) }}' + become: no - - name: Create Git Hook for commit message - copy: - content: | - #!/bin/sh - echo "[ci skip]" >>$1 - dest: '{{ webRoot }}/.git/hooks/prepare-commit-msg' - mode: 0777 + - name: Create Git Hook for commit message + copy: + content: | + #!/bin/sh + echo "[ci skip]" >>$1 + dest: '{{ webRoot }}/.git/hooks/prepare-commit-msg' + mode: 0777 - - name: Start Hotfix - shell: git {{ item }} - args: - chdir: '{{ webRoot }}' - become: false - with_items: - - flow init -d - - flow hotfix start -F {{ version }} + - name: Start Hotfix + shell: git {{ item }} + args: + chdir: '{{ webRoot }}' + become: no + with_items: + - flow init -d + - flow hotfix start -F {{ version }} tags: - deploy diff --git a/tasks/collect_db_dump/dump.yml b/tasks/collect_db_dump/dump.yml index fadba268f53ea52205bbb4a65354e213b9111fed..4d4a0882190097e6dc7588a60b4f3fd857dfad0e 100644 --- a/tasks/collect_db_dump/dump.yml +++ b/tasks/collect_db_dump/dump.yml @@ -3,34 +3,34 @@ - block: - - set_fact: - drushAlias='@{{ drupal.id }}.{{ drupal_domain.shortname|default("default") }}' - drushAliasValidate="'@{{ drupal.id }}.{{ drupal_domain.shortname|default('default') }}':" - - set_fact: - drushAlias='@{{ inventory_hostname }}{{ drushSubkey }}.{{ drupal_domain.shortname|default("default") }}' - drushAliasValidate='@{{ inventory_hostname }}{{ drushSubkey }}.{{ drupal_domain.shortname|default("default") }}' - when: drush_version_main|default('8') == '8' + - set_fact: + drushAlias: '@{{ drupal.id }}.{{ drupal_domain.shortname|default("default") }}' + drushAliasValidate: "'@{{ drupal.id }}.{{ drupal_domain.shortname|default('default') }}':" + - set_fact: + drushAlias: '@{{ inventory_hostname }}{{ drushSubkey }}.{{ drupal_domain.shortname|default("default") }}' + drushAliasValidate: '@{{ inventory_hostname }}{{ drushSubkey }}.{{ drupal_domain.shortname|default("default") }}' + when: drush_version_main|default('8') == '8' - - name: Check Drush Status - shell: drush -y {{ drushAlias }} status - args: - chdir: '{{ webRoot }}' - register: drush_status - changed_when: false - when: drushAliasValidate in drush_aliases.stdout_lines + - name: Check Drush Status + shell: drush -y {{ drushAlias }} status + args: + chdir: '{{ webRoot }}' + register: drush_status + changed_when: no + when: drushAliasValidate in drush_aliases.stdout_lines - - name: Dump DB - shell: drush -y {{ drushAlias }} sql-dump --result-file=/tmp/drupal-db-dump/{{ drushAlias }}.sql - args: - chdir: '{{ webRoot }}' - when: "drush_status is defined and ('Successful' in drush_status.stdout|default('') or 'Erfolgreich' in drush_status.stdout|default(''))" + - name: Dump DB + shell: drush -y {{ drushAlias }} sql-dump --result-file=/tmp/drupal-db-dump/{{ drushAlias }}.sql + args: + chdir: '{{ webRoot }}' + when: "drush_status is defined and ('Successful' in drush_status.stdout|default('') or 'Erfolgreich' in drush_status.stdout|default(''))" - - name: Fetch Dump File - fetch: - src: /tmp/drupal-db-dump/{{ drushAlias }}.sql - dest: '{{ dump_file }}' - flat: yes - when: "drush_status is defined and ('Successful' in drush_status.stdout|default('') or 'Erfolgreich' in drush_status.stdout|default(''))" + - name: Fetch Dump File + fetch: + src: /tmp/drupal-db-dump/{{ drushAlias }}.sql + dest: '{{ dump_file }}' + flat: yes + when: "drush_status is defined and ('Successful' in drush_status.stdout|default('') or 'Erfolgreich' in drush_status.stdout|default(''))" tags: - collect_db_dump diff --git a/tasks/collect_db_dump/main.yml b/tasks/collect_db_dump/main.yml index 1fefb44ab513b9db7664ef1b13a6597781bb867b..68a1ca6aed1d8d0d21fab382280a182124f26979 100644 --- a/tasks/collect_db_dump/main.yml +++ b/tasks/collect_db_dump/main.yml @@ -4,31 +4,31 @@ - block: - set_fact: - webRoot='/var/www{{ drupal.webRoot|default("") }}' - cronUser='root' - apacheUser='www-data' - apacheLogDir='/var/log/apache2' - drushSubkey='{{ drupal.drush_subkey|default("") }}' + webRoot: /var/www{{ drupal.webRoot|default("") }} + cronUser: root + apacheUser: www-data + apacheLogDir: /var/log/apache2 + drushSubkey: '{{ drupal.drush_subkey|default("") }}' when: drupal.jail is not defined - set_fact: - webRoot='{{ jailroot }}/{{ drupal.jail.name }}/var/www{{ drupal.webRoot|default("") }}' - cronUser='{{ drupal.jail.name }}' - apacheUser='{{ drupal.jail.name }}' - apacheLogDir='{{ jailroot }}/{{ drupal.jail.name }}/var/log/apache2' - drushSubkey='.{{ drupal.jail.name }}' + webRoot: '{{ jailroot }}/{{ drupal.jail.name }}/var/www{{ drupal.webRoot|default("") }}' + cronUser: '{{ drupal.jail.name }}' + apacheUser: '{{ drupal.jail.name }}' + apacheLogDir: '{{ jailroot }}/{{ drupal.jail.name }}/var/log/apache2' + drushSubkey: .{{ drupal.jail.name }} when: drupal.jail is defined - set_fact: - installSource={{ drupal.src|default([]) }} - relativeRoot='{{ drupal.relativeRoot|default(drupal_links_relative_root) }}' - drupalRoot='{{ webRoot }}{{ drupal.root|default("") }}' - docRoot='{{ webRoot }}{{ drupal.docroot|default(drupal.root|default("")) }}' + installSource: '{{ drupal.src|default([]) }}' + relativeRoot: '{{ drupal.relativeRoot|default(drupal_links_relative_root) }}' + drupalRoot: '{{ webRoot }}{{ drupal.root|default("") }}' + docRoot: '{{ webRoot }}{{ drupal.docroot|default(drupal.root|default("")) }}' - name: Check available Drush Aliases shell: drush sa args: chdir: '{{ webRoot }}' register: drush_aliases - changed_when: false + changed_when: no - name: Post Deploy Tasks include_tasks: dump.yml diff --git a/tasks/deploy/d7.yml b/tasks/deploy/d7.yml index 54c8e9aa147eff89cfb491fe791ae31d0183e85f..5a046af74b6ebca55fb19bc0bc8131142c08e7ce 100644 --- a/tasks/deploy/d7.yml +++ b/tasks/deploy/d7.yml @@ -5,9 +5,9 @@ dummy: yes # TODO: Let's see how we can generalize this and whether we need that for D6 as well. -#- name: Deploy | Drush -# shell: "drush -y @{{ deploy.drush.alias }} {{ item }}" -# with_items: -# - "fra" -# - "cc all" -# when: deploy.drush is defined +# - name: Deploy | Drush +# shell: "drush -y @{{ deploy.drush.alias }} {{ item }}" +# with_items: +# - "fra" +# - "cc all" +# when: deploy.drush is defined diff --git a/tasks/deploy/d8.yml b/tasks/deploy/d8.yml index 0228bac879db683f88ce7c5a0e80889eb098a9ee..2c04ea2b4b5d56455839a47aaf1341b8b937e32b 100644 --- a/tasks/deploy/d8.yml +++ b/tasks/deploy/d8.yml @@ -3,15 +3,15 @@ - block: - - name: Ensure extra directories - file: - path: '{{ drupalRoot }}{{ item }}' - state: directory - with_items: - - /modules/custom - - /modules/contrib - - /themes/custom - - /themes/contrib + - name: Ensure extra directories + file: + path: '{{ drupalRoot }}{{ item }}' + state: directory + with_items: + - /modules/custom + - /modules/contrib + - /themes/custom + - /themes/contrib tags: - deploy diff --git a/tasks/deploy/finalize_d8.yml b/tasks/deploy/finalize_d8.yml index 0bfeb24e24692e0a4d18051bba220d8995c453af..7d570ae697260a66e465d8ed7facef836052a5dd 100644 --- a/tasks/deploy/finalize_d8.yml +++ b/tasks/deploy/finalize_d8.yml @@ -3,50 +3,51 @@ - block: - - name: Check for config directory - stat: path='{{ webRoot }}{{ drupal.configRoot|default("/config") }}' - register: directory - - - block: - - - name: Ensure site specific config directory - file: - path: '{{ webRoot }}{{ drupal.configRoot|default("/config") }}/{{ item.shortname|default("default") }}' - state: directory - owner: '{{ apacheUser }}' - group: '{{ apacheUser }}' - mode: 0775 - with_items: '{{ drupal.domains }}' - when: item.install|default(true) - - - name: Link to site specific config directory - file: - src: ../../..{{ drupal.configRoot|default("/config") }}/{{ item.shortname|default("default") }} - path: '{{ drupalRoot }}/sites/{{ item.shortname|default("default") }}/files/{{ item.config|default("config") }}' - state: link - force: yes - owner: '{{ apacheUser }}' - group: '{{ apacheUser }}' - with_items: '{{ drupal.domains }}' - when: item.install|default(true) - - when: directory.stat.exists - - - block: - - - name: Ensure config directories - file: - path: '{{ drupalRoot }}/sites/{{ item.0.shortname|default("default") }}/files/{{ item.0.config|default("config") }}/{{ drupal_config_directories[item.1] }}' - state: directory - owner: '{{ apacheUser }}' - group: '{{ apacheUser }}' - mode: 0775 - with_nested: - - {{ drupal.domains }} - - {{ drupal_config_directories }} - when: item.0.install|default(true) - - when: not directory.stat.exists + - name: Check for config directory + stat: + path: '{{ webRoot }}{{ drupal.configRoot|default("/config") }}' + register: directory + + - block: + + - name: Ensure site specific config directory + file: + path: '{{ webRoot }}{{ drupal.configRoot|default("/config") }}/{{ item.shortname|default("default") }}' + state: directory + owner: '{{ apacheUser }}' + group: '{{ apacheUser }}' + mode: 0775 + with_items: '{{ drupal.domains }}' + when: item.install|default(true) + + - name: Link to site specific config directory + file: + src: ../../..{{ drupal.configRoot|default("/config") }}/{{ item.shortname|default("default") }} + path: '{{ drupalRoot }}/sites/{{ item.shortname|default("default") }}/files/{{ item.config|default("config") }}' + state: link + force: yes + owner: '{{ apacheUser }}' + group: '{{ apacheUser }}' + with_items: '{{ drupal.domains }}' + when: item.install|default(true) + + when: directory.stat.exists + + - block: + + - name: Ensure config directories + file: + path: '{{ drupalRoot }}/sites/{{ item.0.shortname|default("default") }}/files/{{ item.0.config|default("config") }}/{{ drupal_config_directories[item.1] }}' + state: directory + owner: '{{ apacheUser }}' + group: '{{ apacheUser }}' + mode: 0775 + with_nested: + - {{ drupal.domains }} + - {{ drupal_config_directories }} + when: item.0.install|default(true) + + when: not directory.stat.exists tags: - deploy diff --git a/tasks/deploy/gitcomposer.yml b/tasks/deploy/gitcomposer.yml index 7d6ed732075a9da118e71ba12e87611a3752ca8a..3f00e288022b2ec47c76cbbef0f51ef467bf2e93 100644 --- a/tasks/deploy/gitcomposer.yml +++ b/tasks/deploy/gitcomposer.yml @@ -20,7 +20,7 @@ dest: '{{ webRoot }}' force: yes version: '{{ drupal.src.git.branch|default(omit) }}' - become: false + become: no - name: Clone Git Extra Repositories git: @@ -29,7 +29,7 @@ dest: '{{ webRoot }}/{{ item }}' force: yes version: '{{ drupal.src.git.extrarepos[item]["branch"]|default(omit) }}' - become: false + become: no with_items: '{{ drupal.src.git.extrarepos|default([]) }}' - name: Create .env file @@ -42,11 +42,11 @@ - name: Run Composer composer: - command='install' - working_dir='{{ webRoot }}' - no_dev=yes - optimize_autoloader=yes - prefer_dist=yes + command: install + working_dir: '{{ webRoot }}' + no_dev: yes + optimize_autoloader: yes + prefer_dist: yes - name: Get Git Tag shell: git tag --points-at HEAD --sort -version:refname | head -1 @@ -55,8 +55,8 @@ register: git_tag_info - set_fact: - drupalDeployInfoBranch='{{ drupal.src.git.branch|default(omit) }}' - drupalDeployInfoTag='{{ git_tag_info.stdout }}' + drupalDeployInfoBranch: '{{ drupal.src.git.branch|default(omit) }}' + drupalDeployInfoTag: '{{ git_tag_info.stdout }}' tags: - deploy diff --git a/tasks/deploy/gitscript.yml b/tasks/deploy/gitscript.yml index bbf0e3fa2babde8ef5ce496d11637d88f4984351..d98112cfc7b39651e4866b5641c910bd725e3dc7 100644 --- a/tasks/deploy/gitscript.yml +++ b/tasks/deploy/gitscript.yml @@ -19,7 +19,7 @@ dest: '{{ webRoot }}{{ drupal.src.git.target }}' force: yes version: '{{ drupal.src.git.branch|default(omit) }}' - become: false + become: no when: drupal_first_installation or not drupal.src.git.bare|default(false) - name: Second Clone Git Repository diff --git a/tasks/deploy/post-tasks.yml b/tasks/deploy/post-tasks.yml index a0c87565c79e84e2c15753927160e190e786aad4..932e8ec1ff151c58d0ca8cea60cac2b770fcac0c 100644 --- a/tasks/deploy/post-tasks.yml +++ b/tasks/deploy/post-tasks.yml @@ -3,28 +3,28 @@ - block: - - set_fact: - drushAlias='@{{ drupal.id }}.{{ drupal_domain.shortname|default("default") }}' - drushAliasValidate="'@{{ drupal.id }}.{{ drupal_domain.shortname|default('default') }}':" - - set_fact: - drushAlias='@{{ inventory_hostname }}{{ drushSubkey }}.{{ drupal_domain.shortname|default("default") }}' - drushAliasValidate='@{{ inventory_hostname }}{{ drushSubkey }}.{{ drupal_domain.shortname|default("default") }}' - when: drush_version_main|default('8') == '8' + - set_fact: + drushAlias: '@{{ drupal.id }}.{{ drupal_domain.shortname|default("default") }}' + drushAliasValidate: "'@{{ drupal.id }}.{{ drupal_domain.shortname|default('default') }}':" + - set_fact: + drushAlias: '@{{ inventory_hostname }}{{ drushSubkey }}.{{ drupal_domain.shortname|default("default") }}' + drushAliasValidate: '@{{ inventory_hostname }}{{ drushSubkey }}.{{ drupal_domain.shortname|default("default") }}' + when: drush_version_main|default('8') == '8' - - name: Check Drush Status - shell: drush -y {{ drushAlias }} status - args: - chdir: '{{ webRoot }}' - register: drush_status - changed_when: false - when: drushAliasValidate in drush_aliases.stdout_lines + - name: Check Drush Status + shell: drush -y {{ drushAlias }} status + args: + chdir: '{{ webRoot }}' + register: drush_status + changed_when: no + when: drushAliasValidate in drush_aliases.stdout_lines - - name: Run Post Deploy Tasks - shell: drush -y {{ drushAlias }} {{ item }} - args: - chdir: '{{ webRoot }}' - with_items: '{{ drupal_post_deploy_tasks[drupal.version|default("d7")] }}' - when: "drush_status is defined and ('Successful' in drush_status.stdout|default('') or 'Erfolgreich' in drush_status.stdout|default(''))" + - name: Run Post Deploy Tasks + shell: drush -y {{ drushAlias }} {{ item }} + args: + chdir: '{{ webRoot }}' + with_items: '{{ drupal_post_deploy_tasks[drupal.version|default("d7")] }}' + when: "drush_status is defined and ('Successful' in drush_status.stdout|default('') or 'Erfolgreich' in drush_status.stdout|default(''))" tags: - deploy diff --git a/tasks/files.yml b/tasks/files.yml index b9c2dfb5d77b8aaa64f1f896520a2dce5686016d..9e600bbf09f749bde312dee7773dd59668332162 100644 --- a/tasks/files.yml +++ b/tasks/files.yml @@ -3,61 +3,62 @@ - block: - - set_fact: - dir='{{ webRoot }}/files/{{ drupal_domain.0.shortname|default("default") }}/{{ drupal_domain.1 }}' - src='{{ relativeRoot }}/files/{{ drupal_domain.0.shortname|default("default") }}/{{ drupal_domain.1 }}' - dest='{{ drupalRoot }}/sites/{{ drupal_domain.0.shortname|default("default") }}/{{ drupal_domain.1 }}' - - - include_tasks: files_mount.yml - when: drupal_domain.0.mountpoint is defined - - - name: Ensure File Directories - file: - dest='{{ dir }}' - state='directory' - owner='{{ apacheUser }}' - group='{{ apacheUser }}' - mode='755' - ignore_errors: yes - - - name: Check the status of the File Directory - stat: path='{{ dest }}' - register: directory - - - name: Move existing File Directory - shell: rm -rf {{ dir }} && mv {{ dest }} {{ dir }} - when: directory.stat.exists and directory.stat.isdir - - - name: Link Site Directory to File Directory - file: - src='{{ src }}' - dest='{{ dest }}' - state='link' - owner='{{ apacheUser }}' - group='{{ apacheUser }}' - mode='755' - - - name: Ensure .htaccess - template: - src='.htaccess' - dest='{{ dir }}/.htaccess' - owner='{{ apacheUser }}' - group='{{ apacheUser }}' - mode='444' - - - name: Ensure some files subdirectories - file: - dest='{{ dir }}/{{ item }}' - state='directory' - owner='{{ apacheUser }}' - group='{{ apacheUser }}' - mode='755' - with_items: - - css - - js - - languages - - translations - when: drupal_domain.1 == 'files' + - set_fact: + dir: '{{ webRoot }}/files/{{ drupal_domain.0.shortname|default("default") }}/{{ drupal_domain.1 }}' + src: '{{ relativeRoot }}/files/{{ drupal_domain.0.shortname|default("default") }}/{{ drupal_domain.1 }}' + dest: '{{ drupalRoot }}/sites/{{ drupal_domain.0.shortname|default("default") }}/{{ drupal_domain.1 }}' + + - include_tasks: files_mount.yml + when: drupal_domain.0.mountpoint is defined + + - name: Ensure File Directories + file: + dest: '{{ dir }}' + state: directory + owner: '{{ apacheUser }}' + group: '{{ apacheUser }}' + mode: 0755 + ignore_errors: yes + + - name: Check the status of the File Directory + stat: + path: '{{ dest }}' + register: directory + + - name: Move existing File Directory + shell: rm -rf {{ dir }} && mv {{ dest }} {{ dir }} + when: directory.stat.exists and directory.stat.isdir + + - name: Link Site Directory to File Directory + file: + src: '{{ src }}' + dest: '{{ dest }}' + state: link + owner: '{{ apacheUser }}' + group: '{{ apacheUser }}' + mode: 0755 + + - name: Ensure .htaccess + template: + src: .htaccess + dest: '{{ dir }}/.htaccess' + owner: '{{ apacheUser }}' + group: '{{ apacheUser }}' + mode: 0444 + + - name: Ensure some files subdirectories + file: + dest: '{{ dir }}/{{ item }}' + state: directory + owner: '{{ apacheUser }}' + group: '{{ apacheUser }}' + mode: 0755 + with_items: + - css + - js + - languages + - translations + when: drupal_domain.1 == 'files' tags: - SetPermissions diff --git a/tasks/files_mount.yml b/tasks/files_mount.yml index 73472ae20c43de7522a7e31f120875da8c1a1ae7..aefaed23a667f896236b85e54f077ea592d3022c 100644 --- a/tasks/files_mount.yml +++ b/tasks/files_mount.yml @@ -3,23 +3,23 @@ - block: - - name: Ensure mounted directory - file: - path='{{ drupal_domain.0.mountpoint }}/{{ drupal.id }}/{{ drupal_domain.0.shortname|default("default") }}' - state='directory' - owner='{{ apacheUser }}' - group='{{ apacheUser }}' - mode='755' + - name: Ensure mounted directory + file: + path: '{{ drupal_domain.0.mountpoint }}/{{ drupal.id }}/{{ drupal_domain.0.shortname|default("default") }}' + state: directory + owner: '{{ apacheUser }}' + group: '{{ apacheUser }}' + mode: 0755 - - name: Link webroot to mounted directory - file: - src='{{ drupal_domain.0.mountpoint }}/{{ drupal.id }}/{{ drupal_domain.0.shortname|default("default") }}' - dest='{{ webRoot }}/files/{{ drupal_domain.0.shortname|default("default") }}' - state='link' - owner='{{ apacheUser }}' - group='{{ apacheUser }}' - mode='755' - force='yes' + - name: Link webroot to mounted directory + file: + src: '{{ drupal_domain.0.mountpoint }}/{{ drupal.id }}/{{ drupal_domain.0.shortname|default("default") }}' + dest: '{{ webRoot }}/files/{{ drupal_domain.0.shortname|default("default") }}' + state: link + owner: '{{ apacheUser }}' + group: '{{ apacheUser }}' + mode: 0755 + force: yes tags: - SetPermissions diff --git a/tasks/install.yml b/tasks/install.yml index 78cf012c1f4ed4e027024faaed236da1b8550b3a..9f618aeee1d53763a6ee94feae3ed1368cf801eb 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -2,60 +2,60 @@ # file: roles/drupal/tasks/install.yml - block: - - set_fact: - webRoot='/var/www{{ drupal.webRoot|default("") }}' - cronUser='root' - apacheUser='www-data' - apacheLogDir='/var/log/apache2' - drushSubkey='{{ drupal.drush_subkey|default("") }}' - when: drupal.jail is not defined - - set_fact: - webRoot='{{ jailroot }}/{{ drupal.jail.name }}/var/www{{ drupal.webRoot|default("") }}' - cronUser='{{ drupal.jail.name }}' - apacheUser='{{ drupal.jail.name }}' - apacheLogDir='{{ jailroot }}/{{ drupal.jail.name }}/var/log/apache2' - drushSubkey='.{{ drupal.jail.name }}' - when: drupal.jail is defined - - set_fact: - drupalDeployInfoBranch='unknown' - drupalDeployInfoTag='unknown' - installSource={{ drupal.src|default([]) }} - relativeRoot='{{ drupal.relativeRoot|default(drupal_links_relative_root) }}' - drupalRoot='{{ webRoot }}{{ drupal.root|default("") }}' - docRoot='{{ webRoot }}{{ drupal.docroot|default(drupal.root|default("")) }}' + - set_fact: + webRoot: /var/www{{ drupal.webRoot|default("") }} + cronUser: root + apacheUser: www-data + apacheLogDir: /var/log/apache2 + drushSubkey: '{{ drupal.drush_subkey|default("") }}' + when: drupal.jail is not defined + - set_fact: + webRoot: '{{ jailroot }}/{{ drupal.jail.name }}/var/www{{ drupal.webRoot|default("") }}' + cronUser: '{{ drupal.jail.name }}' + apacheUser: '{{ drupal.jail.name }}' + apacheLogDir: '{{ jailroot }}/{{ drupal.jail.name }}/var/log/apache2' + drushSubkey: .{{ drupal.jail.name }} + when: drupal.jail is defined + - set_fact: + drupalDeployInfoBranch: unknown + drupalDeployInfoTag: unknown + installSource: '{{ drupal.src|default([]) }}' + relativeRoot: '{{ drupal.relativeRoot|default(drupal_links_relative_root) }}' + drupalRoot: '{{ webRoot }}{{ drupal.root|default("") }}' + docRoot: '{{ webRoot }}{{ drupal.docroot|default(drupal.root|default("")) }}' tags: - always - name: Ensure Drupal Root Directory file: - path='{{ docRoot }}' - state='directory' - owner='{{ apacheUser }}' - group='{{ apacheUser }}' - mode='775' + path: '{{ docRoot }}' + state: directory + owner: '{{ apacheUser }}' + group: '{{ apacheUser }}' + mode: 0775 - name: File Modes and Ownership file: - path='{{ docRoot }}' - owner='{{ apacheUser }}' - group='{{ apacheUser }}' - mode='g+w' - recurse=yes - follow=no + path: '{{ docRoot }}' + owner: '{{ apacheUser }}' + group: '{{ apacheUser }}' + mode: g+w + recurse: yes + follow: no tags: - deploy - name: Check Installation Requirement shell: ls {{ drupalRoot }}/index.php register: drupal_available - failed_when: false + failed_when: no - block: - - set_fact: - drupal_first_installation: no - - set_fact: - drupal_first_installation: yes - when: drupal_install_drupal and drupal_available is defined and drupal_available.stdout != [drupalRoot, '/index.php']|join('') + - set_fact: + drupal_first_installation: no + - set_fact: + drupal_first_installation: yes + when: drupal_install_drupal and drupal_available is defined and drupal_available.stdout != [drupalRoot, '/index.php']|join('') tags: - always @@ -107,17 +107,17 @@ - name: Configuration file template: - src='{{ item.src }}' - dest='{{ drupalRoot }}{{ item.dest }}' - owner='{{ apacheUser }}' - group='{{ apacheUser }}' - mode='664' + src: '{{ item.src }}' + dest: '{{ drupalRoot }}{{ item.dest }}' + owner: '{{ apacheUser }}' + group: '{{ apacheUser }}' + mode: 0664 with_items: '{{ drupal.templates|default([]) }}' - name: Ensure Settings Directory file: - dest='{{ webRoot }}/{{ item.1 }}/{{ item.0.shortname|default("default") }}' - state='directory' + dest: '{{ webRoot }}/{{ item.1 }}/{{ item.0.shortname|default("default") }}' + state: directory with_nested: - {{ drupal.domains }} - ['settings', 'config'] @@ -125,18 +125,18 @@ - name: Ensure Site Directories file: - dest='{{ drupalRoot }}/sites/{{ item.shortname|default("default") }}' - state='directory' + dest: '{{ drupalRoot }}/sites/{{ item.shortname|default("default") }}' + state: directory with_items: '{{ drupal.domains }}' when: item.install|default(true) - name: Ensure Files Directory file: - path='{{ webRoot }}/files' - state='directory' - owner='{{ apacheUser }}' - group='{{ apacheUser }}' - mode='775' + path: '{{ webRoot }}/files' + state: directory + owner: '{{ apacheUser }}' + group: '{{ apacheUser }}' + mode: 0775 when: drupal.install_extra_dirs|default(true) - include_tasks: mountpoints.yml @@ -155,10 +155,10 @@ - name: Create symbolic links file: - src='{{ item.shortname|default("default") }}' - path='{{ drupalRoot }}/sites/{{ item.1 }}' - state='link' - force=yes + src: '{{ item.shortname|default("default") }}' + path: '{{ drupalRoot }}/sites/{{ item.1 }}' + state: link + force: yes with_subelements: - {{ drupal.domains }} - aliases @@ -166,9 +166,9 @@ - name: Create the settings.php files template: - src='{{ drupal.template_dir|default('') }}{{ drupal.version|default("d7") }}_settings.php.jinja2' - dest='{{ webRoot }}/settings/{{ item.shortname|default("default") }}/settings.php' - backup=yes + src: '{{ drupal.template_dir|default('') }}{{ drupal.version|default("d7") }}_settings.php.jinja2' + dest: '{{ webRoot }}/settings/{{ item.shortname|default("default") }}/settings.php' + backup: yes with_items: '{{ drupal.domains }}' tags: - deploy @@ -177,30 +177,30 @@ - name: Create symbolic links file: - src='{{ relativeRoot }}/settings/{{ item.shortname|default("default") }}/settings.php' - path='{{ drupalRoot }}/sites/{{ item.shortname|default("default") }}/settings.php' - state='link' - force=yes + src: '{{ relativeRoot }}/settings/{{ item.shortname|default("default") }}/settings.php' + path: '{{ drupalRoot }}/sites/{{ item.shortname|default("default") }}/settings.php' + state: link + force: yes with_items: '{{ drupal.domains }}' when: item.install|default(true) - block: - - name: Create the drush.yml files - template: - src='drush-9.yml.jinja2' - dest='{{ webRoot }}/settings/{{ item.shortname|default("default") }}/drush.yml' - with_items: '{{ drupal.domains }}' - when: item.install|default(true) - - - name: Create symbolic links for drush.yml - file: - src='{{ relativeRoot }}/settings/{{ item.shortname|default("default") }}/drush.yml' - path='{{ drupalRoot }}/sites/{{ item.shortname|default("default") }}/drush.yml' - state='link' - force=yes - with_items: '{{ drupal.domains }}' - when: item.install|default(true) + - name: Create the drush.yml files + template: + src: drush-9.yml.jinja2 + dest: '{{ webRoot }}/settings/{{ item.shortname|default("default") }}/drush.yml' + with_items: '{{ drupal.domains }}' + when: item.install|default(true) + + - name: Create symbolic links for drush.yml + file: + src: '{{ relativeRoot }}/settings/{{ item.shortname|default("default") }}/drush.yml' + path: '{{ drupalRoot }}/sites/{{ item.shortname|default("default") }}/drush.yml' + state: link + force: yes + with_items: '{{ drupal.domains }}' + when: item.install|default(true) tags: - deploy @@ -213,17 +213,17 @@ - name: File Modes and Ownership file: - path='{{ item }}' - owner='{{ apacheUser }}' - group='{{ apacheUser }}' - mode='a-w' - recurse=yes - follow=no + path: '{{ item }}' + owner: '{{ apacheUser }}' + group: '{{ apacheUser }}' + mode: a-w + recurse: yes + follow: no with_items: - - {{ docRoot }} - - {{ webRoot }}/config - - {{ webRoot }}/files - - {{ webRoot }}/settings + - '{{ docRoot }}' + - '{{ webRoot }}/config' + - '{{ webRoot }}/files' + - '{{ webRoot }}/settings' tags: - deploy - SetPermissions @@ -232,13 +232,13 @@ - name: Make site directories writeable file: - path='{{ item }}' - mode='ug+w' - recurse=yes - follow=no + path: '{{ item }}' + mode: ug+w + recurse: yes + follow: no with_items: - - {{ webRoot }}/config - - {{ webRoot }}/files + - '{{ webRoot }}/config' + - '{{ webRoot }}/files' tags: - deploy - SetPermissions @@ -247,15 +247,15 @@ - name: Setup Crontabs for each domain cron: - name='Drupal {{ item.1.name }}' - month='{{ item.1.month|default(omit) }}' - day='{{ item.1.day|default(omit) }}' - weekday='{{ item.1.weekday|default(omit) }}' - hour='{{ item.1.hour|default(omit) }}' - minute='{{ item.1.minute|default(omit) }}' - job='{{ item.1.job }} >{{ item.1.redirect|default("/dev/null 2>&1") }}' - user='{{ item.1.user|default(cronUser) }}' - disabled='{{ item.1.disabled|default(false) }}' + name: Drupal {{ item.1.name }} + month: '{{ item.1.month|default(omit) }}' + day: '{{ item.1.day|default(omit) }}' + weekday: '{{ item.1.weekday|default(omit) }}' + hour: '{{ item.1.hour|default(omit) }}' + minute: '{{ item.1.minute|default(omit) }}' + job: '{{ item.1.job }} >{{ item.1.redirect|default("/dev/null 2>&1") }}' + user: '{{ item.1.user|default(cronUser) }}' + disabled: '{{ item.1.disabled|default(false) }}' with_subelements: - {{ drupal.domains }} - crontabs @@ -279,8 +279,8 @@ - name: Make htaccess read-only file: - path='{{ webRoot }}/files/{{ drupal_domain.0.shortname|default("default") }}/{{ drupal_domain.1 }}/.htaccess' - mode='444' + path: '{{ webRoot }}/files/{{ drupal_domain.0.shortname|default("default") }}/{{ drupal_domain.1 }}/.htaccess' + mode: 0444 with_nested: - {{ drupal.domains }} - ['files', 'private'] @@ -306,7 +306,7 @@ args: chdir: '{{ webRoot }}' register: drush_aliases - changed_when: false + changed_when: no tags: - deploy diff --git a/tasks/install/d8.yml b/tasks/install/d8.yml index bb8057f1ef745d924d24f46dbd95fc7702593360..1504e7258c866f52190bdc41ec409cd93193e214 100644 --- a/tasks/install/d8.yml +++ b/tasks/install/d8.yml @@ -2,12 +2,15 @@ # file: roles/drupal/tasks/install/d8.yml - block: - #- name: Drupalconsole run chain - # shell: drupal chain --file={{ webRoot }}{{ drupal.chain }} --no-interaction - # args: - # chdir: '{{ webRoot }}' - - name: Drupalconsole: Install Drupal - shell: drupal site:new {{ drupalRoot }} 8.1.1 --no-interaction chdir={{ webRoot }} + # - name: Drupalconsole run chain + # shell: drupal chain --file={{ webRoot }}{{ drupal.chain }} --no-interaction + # args: + # chdir: '{{ webRoot }}' + + - name: Drupalconsole Install Drupal + shell: drupal site:new {{ drupalRoot }} 8.1.1 --no-interaction + args: + chdir: '{{ webRoot }}' when: drupal.chain is defined diff --git a/tasks/install/drush.yml b/tasks/install/drush.yml index 7f6dbc342830b74ef54c343e9bf8d2c89edbc4f4..30499539ca99b925777d266320a84c4943605208 100644 --- a/tasks/install/drush.yml +++ b/tasks/install/drush.yml @@ -3,12 +3,14 @@ - name: Copy Drush Make Files copy: - src='{{ inventory_dir }}/files/drush/{{ item.src.makefile }}.make' - dest='{{ webRoot }}/drush/{{ item.src.makefile }}.make' - owner='{{ apacheUser }}' - group='{{ apacheUser }}' - mode='664' + src: '{{ inventory_dir }}/files/drush/{{ item.src.makefile }}.make' + dest: '{{ webRoot }}/drush/{{ item.src.makefile }}.make' + owner: '{{ apacheUser }}' + group: '{{ apacheUser }}' + mode: 0664 - name: Drush Make - shell: drush make --force-complete '{{ webRoot }}/drush/{{ item.src.makefile }}.make' . chdir='{{ docRoot }}' + shell: drush make --force-complete '{{ webRoot }}/drush/{{ item.src.makefile }}.make' . + args: + chdir: '{{ docRoot }}' become: no diff --git a/tasks/install/svn.yml b/tasks/install/svn.yml index ee9788a65925e9dc1c016860444c1e7f4a2f7d08..87645670e4e6ce5ca6833f11d079051d11a2c2af 100644 --- a/tasks/install/svn.yml +++ b/tasks/install/svn.yml @@ -3,12 +3,12 @@ - name: Remove Drupal Root Directory file: - path='{{ docRoot }}' - state='absent' + path: '{{ docRoot }}' + state: absent - name: Install and update Drupal trees from SVN subversion: - repo='{{ drupal.src.url }}' - dest='{{ webRoot }}{{ drupal.src.target }}' - force=yes + repo: '{{ drupal.src.url }}' + dest: '{{ webRoot }}{{ drupal.src.target }}' + force: yes become: no diff --git a/tasks/main.yml b/tasks/main.yml index 4eec1efc60ca5ade78cbb1c7e3332d4fbfe8ea7f..eae97a9cd71c48376462c4ba5a48bdd1ac9e630e 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -9,65 +9,65 @@ - block: - - name: Install Certs - include_tasks: ../../letsencrypt/tasks/cert.yml - with_subelements: - - {{ drupal_settings|default([]) }} - - domains - loop_control: - loop_var: domain - when: domain.1.protocol|default("https") == "https" and domain.1.letsencrypt|default(true) and (limit_site is not defined or limit_site == 'False' or domain.0.id is not defined or limit_site == domain.0.id) - tags: - - ApacheConfig + - name: Install Certs + include_tasks: ../../letsencrypt/tasks/cert.yml + with_subelements: + - '{{ drupal_settings|default([]) }}' + - domains + loop_control: + loop_var: domain + when: domain.1.protocol|default("https") == "https" and domain.1.letsencrypt|default(true) and (limit_site is not defined or limit_site == 'False' or domain.0.id is not defined or limit_site == domain.0.id) + tags: + - ApacheConfig when: not excluded_roles or "letsencrypt" not in excluded_roles and groups.proxyserver is not defined - block: - - name: Install Drupal - include_tasks: install.yml - with_items: '{{ drupal_settings|default([]) }}' - loop_control: - loop_var: drupal - when: limit_site is not defined or limit_site == 'False' or drupal.id is not defined or limit_site == drupal.id - tags: - - ApacheConfig - - cron - - deploy - - SetPermissions - - mysql + - name: Install Drupal + include_tasks: install.yml + with_items: '{{ drupal_settings|default([]) }}' + loop_control: + loop_var: drupal + when: limit_site is not defined or limit_site == 'False' or drupal.id is not defined or limit_site == drupal.id + tags: + - ApacheConfig + - cron + - deploy + - SetPermissions + - mysql when: not excluded_roles or "drupal" not in excluded_roles and drupal_install_drupal and (collect_config is not defined or not collect_config) - block: - - name: Collect Drupal Configuration - include_tasks: collect_config/main.yml - with_items: '{{ drupal_settings|default([]) }}' - loop_control: - loop_var: drupal - when: limit_site is not defined or limit_site == 'False' or drupal.id is not defined or limit_site == drupal.id - tags: - - deploy + - name: Collect Drupal Configuration + include_tasks: collect_config/main.yml + with_items: '{{ drupal_settings|default([]) }}' + loop_control: + loop_var: drupal + when: limit_site is not defined or limit_site == 'False' or drupal.id is not defined or limit_site == drupal.id + tags: + - deploy when: not excluded_roles or "drupal" not in excluded_roles and drupal_install_drupal and collect_config is defined and collect_config - block: - - name: Prepare dump directory - file: - path: /tmp/drupal-db-dump - state: '{{ item }}' - with_items: - - absent - - directory + - name: Prepare dump directory + file: + path: /tmp/drupal-db-dump + state: '{{ item }}' + with_items: + - absent + - directory - - name: Download DB Dump - include_tasks: collect_db_dump/main.yml - with_items: '{{ drupal_settings|default([]) }}' - loop_control: - loop_var: drupal - when: limit_site is not defined or limit_site == 'False' or drupal.id is not defined or limit_site == drupal.id + - name: Download DB Dump + include_tasks: collect_db_dump/main.yml + with_items: '{{ drupal_settings|default([]) }}' + loop_control: + loop_var: drupal + when: limit_site is not defined or limit_site == 'False' or drupal.id is not defined or limit_site == drupal.id when: not excluded_roles or "drupal" not in excluded_roles and drupal_install_drupal and collect_db_dump is defined and collect_db_dump tags: diff --git a/tasks/mountpoints.yml b/tasks/mountpoints.yml index 3c9cc6ac4888fed25d7686eb5e927df1d19c044a..47acef64b254d5a4bdd8966d38e7f39d5c476fc1 100644 --- a/tasks/mountpoints.yml +++ b/tasks/mountpoints.yml @@ -8,7 +8,7 @@ - name: Convert File System Type shell: '{{ fstype_convert[item.fstype] }}' when: item.fstype != fstype.stdout - ignore_errors: True + ignore_errors: yes - name: Ensure directory for mountpoint file: @@ -36,14 +36,14 @@ state: mounted # TODO: Be back out of double mount points but may bring back symbolic links here? -#- name: Mount the item in jail -# mount: -# path: '{{ jailroot }}/{{ drupal.jail.name }}{{ item.path }}' -# src: '{{ item.src }}' -# fstype: '{{ item.fstype }}' -# opts: '{{ item.opts|default(omit) }}' -# state: mounted -# when: drupal.jail is defined +# - name: Mount the item in jail +# mount: +# path: '{{ jailroot }}/{{ drupal.jail.name }}{{ item.path }}' +# src: '{{ item.src }}' +# fstype: '{{ item.fstype }}' +# opts: '{{ item.opts|default(omit) }}' +# state: mounted +# when: drupal.jail is defined - name: Ensure file directory in mountpoint file: @@ -55,30 +55,30 @@ - block: - - name: Create hidden file to be monitored - copy: - dest: '{{ item.path }}/.monitor' - mode: 0440 - content: "This file is here for monitoring purposes only." - tags: - - cron + - name: Create hidden file to be monitored + copy: + dest: '{{ item.path }}/.monitor' + mode: 0440 + content: "This file is here for monitoring purposes only." + tags: + - cron - - name: Create monitoring script - template: - src: mountpoint.monitor.jinja2 - dest: /usr/local/bin/monitor.{{ item.monitor.id }}.sh - owner: root - group: root - mode: 0775 - tags: - - cron + - name: Create monitoring script + template: + src: mountpoint.monitor.jinja2 + dest: /usr/local/bin/monitor.{{ item.monitor.id }}.sh + owner: root + group: root + mode: 0775 + tags: + - cron - - name: Install monitoring cron - cron: - name: Mountpoint monitoring {{ item.monitor.id }} - job: /usr/local/bin/monitor.{{ item.monitor.id }}.sh >>/var/log/monitor.{{ item.monitor.id }}.log 2>&1 - disabled: '{{ crons_disabled|default(false) }}' - tags: - - cron + - name: Install monitoring cron + cron: + name: Mountpoint monitoring {{ item.monitor.id }} + job: /usr/local/bin/monitor.{{ item.monitor.id }}.sh >>/var/log/monitor.{{ item.monitor.id }}.log 2>&1 + disabled: '{{ crons_disabled|default(false) }}' + tags: + - cron when: item.monitor is defined diff --git a/tasks/mysql.yml b/tasks/mysql.yml index 0faa83844617c62296154727347d3e5d7fc5fda8..daa93a353005c4b9c3328d35c7e0ebb451d54d96 100644 --- a/tasks/mysql.yml +++ b/tasks/mysql.yml @@ -3,85 +3,85 @@ - block: - - set_fact: - db='{{ drupal_domain.db }}' - extra={{ drupal_domain.db.extra|default([]) }} - external={{ drupal_domain.db.external|default([]) }} - external_hosts={{ drupal_domain.db.external_hosts|default([]) }} - tags: - - always + - set_fact: + db: '{{ drupal_domain.db }}' + extra: '{{ drupal_domain.db.extra|default([]) }}' + external: '{{ drupal_domain.db.external|default([]) }}' + external_hosts: '{{ drupal_domain.db.external_hosts|default([]) }}' + tags: + - always - - name: Ensure Database - mysql_db: - name='{{ db.name }}' - login_user='root' - login_password='{{ mysql_root_password|default("root") }}' - login_host='127.0.0.1' - login_port='{{ db.port|default('3306') }}' - state='present' + - name: Ensure Database + mysql_db: + name: '{{ db.name }}' + login_user: root + login_password: '{{ mysql_root_password|default("root") }}' + login_host: 127.0.0.1 + login_port: '{{ db.port|default("3306") }}' + state: present - - name: Ensure extra Databases - mysql_db: - name='{{ item.name }}' - login_user='root' - login_password='{{ mysql_root_password|default("root") }}' - login_host='127.0.0.1' - login_port='{{ item.port|default('3306') }}' - state='present' - with_items: '{{ extra }}' + - name: Ensure extra Databases + mysql_db: + name: '{{ item.name }}' + login_user: root + login_password: '{{ mysql_root_password|default("root") }}' + login_host: 127.0.0.1 + login_port: '{{ item.port|default("3306") }}' + state: present + with_items: '{{ extra }}' - - name: Create MySQL User - mysql_user: - user='{{ db.username|default("root") }}' - password='{{ db.password|default(mysql_root_password|default("root")) }}' - host='{{ item }}' - append_privs=yes - priv='{{ db.name }}.*:ALL' - login_user='root' - login_password='{{ mysql_root_password|default("root") }}' - login_host='127.0.0.1' - login_port='{{ db.port|default('3306') }}' - with_items: - - localhost - - 127.0.0.1 - - ::1 - - {{ inventory_hostname }} - when: db.username is defined and db.username != 'root' - ignore_errors: true + - name: Create MySQL User + mysql_user: + user: '{{ db.username|default("root") }}' + password: '{{ db.password|default(mysql_root_password|default("root")) }}' + host: '{{ item }}' + append_privs: yes + priv: '{{ db.name }}.*:ALL' + login_user: root + login_password: '{{ mysql_root_password|default("root") }}' + login_host: 127.0.0.1 + login_port: '{{ db.port|default("3306") }}' + with_items: + - localhost + - 127.0.0.1 + - ::1 + - {{ inventory_hostname }} + when: db.username is defined and db.username != 'root' + ignore_errors: yes - - name: Create MySQL User for extra Databases - mysql_user: - user='{{ item.0.username|default("root") }}' - password='{{ item.0.password|default(mysql_root_password|default("root")) }}' - host='{{ item.1 }}' - append_privs=yes - priv='{{ item.0.name }}.*:ALL' - login_user='root' - login_password='{{ mysql_root_password|default("root") }}' - login_host='127.0.0.1' - login_port='{{ item.0.port|default('3306') }}' - with_nested: - - {{ extra }} - - ['localhost', '127.0.0.1', '::1'] - when: item.0.username is defined and item.0.username != 'root' - ignore_errors: true + - name: Create MySQL User for extra Databases + mysql_user: + user: '{{ item.0.username|default("root") }}' + password: '{{ item.0.password|default(mysql_root_password|default("root")) }}' + host: '{{ item.1 }}' + append_privs: yes + priv: '{{ item.0.name }}.*:ALL' + login_user: root + login_password: '{{ mysql_root_password|default("root") }}' + login_host: 127.0.0.1 + login_port: '{{ item.0.port|default("3306") }}' + with_nested: + - {{ extra }} + - ['localhost', '127.0.0.1', '::1'] + when: item.0.username is defined and item.0.username != 'root' + ignore_errors: yes - - name: Create external MySQL Users - mysql_user: - user='{{ item.0.username|default("root") }}' - password='{{ item.0.password|default(mysql_root_password|default("root")) }}' - host='{{ item.1 }}' - append_privs=yes - priv='{{ item.0.priv }}' - login_user='root' - login_password='{{ mysql_root_password|default("root") }}' - login_host='127.0.0.1' - login_port='{{ item.0.port|default('3306') }}' - with_nested: - - {{ external }} - - {{ external_hosts }} - when: item.0.username is defined and item.0.username != 'root' - ignore_errors: true + - name: Create external MySQL Users + mysql_user: + user: '{{ item.0.username|default("root") }}' + password: '{{ item.0.password|default(mysql_root_password|default("root")) }}' + host: '{{ item.1 }}' + append_privs: yes + priv: '{{ item.0.priv }}' + login_user: root + login_password: '{{ mysql_root_password|default("root") }}' + login_host: 127.0.0.1 + login_port: '{{ item.0.port|default("3306") }}' + with_nested: + - {{ external }} + - {{ external_hosts }} + when: item.0.username is defined and item.0.username != 'root' + ignore_errors: yes tags: - mysql diff --git a/tasks/users/gitcomposer.yml b/tasks/users/gitcomposer.yml index 7df683f84f70c48559f878de9887ec6b788267a4..9dfca946e85d7ccd16c6608e67fc26bee9e0a876 100644 --- a/tasks/users/gitcomposer.yml +++ b/tasks/users/gitcomposer.yml @@ -3,30 +3,31 @@ - block: - - name: Make sure the git group exists - group: name='{{ drupal.src.name }}' + - name: Make sure the git group exists + group: + name: '{{ drupal.src.name }}' - - name: Add users to git group - user: - name='{{ item }}' - groups='{{ drupal.src.name }}' - append=yes - with_items: '{{ drupal.src.users|default([]) }}' + - name: Add users to git group + user: + name: '{{ item }}' + groups: '{{ drupal.src.name }}' + append: yes + with_items: '{{ drupal.src.users|default([]) }}' - - name: File Modes and Ownership for Repository - file: - path='{{ webRoot }}' - owner='root' - group='{{ drupal.src.name }}' - mode='ug+rw,o+r,o-w' - recurse=yes - follow=no + - name: File Modes and Ownership for Repository + file: + path: '{{ webRoot }}' + owner: root + group: '{{ drupal.src.name }}' + mode: ug+rw,o+r,o-w + recurse: yes + follow: no - - name: Extended Default File Modes and Ownership for Repository - command: setfacl -dRm u:root:rwX,g:{{ drupal.src.name }}:rwX,o::rX {{ webRoot }} + - name: Extended Default File Modes and Ownership for Repository + command: setfacl -dRm u:root:rwX,g:{{ drupal.src.name }}:rwX,o::rX {{ webRoot }} - - name: Extended File Modes and Ownership for Repository - command: setfacl -Rm u:root:rwX,g:{{ drupal.src.name }}:rwX,o::rX {{ webRoot }} + - name: Extended File Modes and Ownership for Repository + command: setfacl -Rm u:root:rwX,g:{{ drupal.src.name }}:rwX,o::rX {{ webRoot }} tags: - SetPermissions diff --git a/tasks/users/gitscript.yml b/tasks/users/gitscript.yml index 08b5dab90dd8327a1774611f5249d7b1a5d5a94c..07ac19692e88e8f7a39ba99469243a1f49dfefda 100644 --- a/tasks/users/gitscript.yml +++ b/tasks/users/gitscript.yml @@ -3,30 +3,31 @@ - block: - - name: Make sure the git group exists - group: name='{{ drupal.src.name }}' - - - name: Add users to git group - user: - name='{{ item }}' - groups='{{ drupal.src.name }}' - append=yes - with_items: '{{ drupal.src.users|default([]) }}' - - - name: File Modes and Ownership for Repository - file: - path='{{ webRoot }}{{ drupal.src.git.target }}' - owner='root' - group='{{ drupal.src.name }}' - mode='ug+rw,o+r,o-w' - recurse=yes - follow=no - - - name: Extended Default File Modes and Ownership for Repository - command: setfacl -dRm u:root:rwX,g:{{ drupal.src.name }}:rwX,o::rX {{ webRoot }}{{ drupal.src.git.target }} - - - name: Extended File Modes and Ownership for Repository - command: setfacl -Rm u:root:rwX,g:{{ drupal.src.name }}:rwX,o::rX {{ webRoot }}{{ drupal.src.git.target }} + - name: Make sure the git group exists + group: + name: '{{ drupal.src.name }}' + + - name: Add users to git group + user: + name: '{{ item }}' + groups: '{{ drupal.src.name }}' + append: yes + with_items: '{{ drupal.src.users|default([]) }}' + + - name: File Modes and Ownership for Repository + file: + path: '{{ webRoot }}{{ drupal.src.git.target }}' + owner: root + group: '{{ drupal.src.name }}' + mode: ug+rw,o+r,o-w + recurse: yes + follow: no + + - name: Extended Default File Modes and Ownership for Repository + command: setfacl -dRm u:root:rwX,g:{{ drupal.src.name }}:rwX,o::rX {{ webRoot }}{{ drupal.src.git.target }} + + - name: Extended File Modes and Ownership for Repository + command: setfacl -Rm u:root:rwX,g:{{ drupal.src.name }}:rwX,o::rX {{ webRoot }}{{ drupal.src.git.target }} tags: - SetPermissions @@ -35,4 +36,3 @@ when: drupal.src.cron is defined tags: - cron - diff --git a/tasks/users/gitscript_cron.yml b/tasks/users/gitscript_cron.yml index c992983f647de68c5fdaa941ca7f07ef9ca161c0..9483ade4fea38f8a27758139d719e9da7976fa78 100644 --- a/tasks/users/gitscript_cron.yml +++ b/tasks/users/gitscript_cron.yml @@ -5,26 +5,26 @@ - name: Create Update Scripts template: - src='scripts/update/{{ item }}.jinja2' - dest='{{ webRoot }}/.{{ item }}' - owner='root' - group='root' - mode='755' + src: scripts/update/{{ item }}.jinja2 + dest: '{{ webRoot }}/.{{ item }}' + owner: root + group: root + mode: 0755 with_items: - update - update-loop - name: Crontab for Update Script cron: - name='Drupal Update {{ drupal.src.name }}' - month='{{ drupal.src.cron.month|default(omit) }}' - day='{{ drupal.src.cron.day|default(omit) }}' - weekday='{{ drupal.src.cron.weekday|default(omit) }}' - hour='{{ drupal.src.cron.hour|default(omit) }}' - minute='{{ drupal.src.cron.minute|default(omit) }}' - job='{{ webRoot }}/.update-loop >>{{ webRoot }}/../log/git-update.log 2>&1' - user='root' - disabled='{{ crons_disabled|default(false) }}' + name: Drupal Update {{ drupal.src.name }} + month: '{{ drupal.src.cron.month|default(omit) }}' + day: '{{ drupal.src.cron.day|default(omit) }}' + weekday: '{{ drupal.src.cron.weekday|default(omit) }}' + hour: '{{ drupal.src.cron.hour|default(omit) }}' + minute: '{{ drupal.src.cron.minute|default(omit) }}' + job: '{{ webRoot }}/.update-loop >>{{ webRoot }}/../log/git-update.log 2>&1' + user: root + disabled: '{{ crons_disabled|default(false) }}' tags: - SetPermissions