From b10adbafd4182c9efb8717e1637ba0d0789d2455 Mon Sep 17 00:00:00 2001 From: Dionisio Date: Wed, 9 Mar 2022 13:01:16 +0100 Subject: [PATCH] Added Drupal9 and Localgov templates --- src/commands/create.ts | 2 + templates/drupal9/.gitignore | 2 + templates/drupal9/ce-dev/.gitignore | 2 + .../drupal9/ce-dev/ansible/deploy.yml.j2 | 57 +++++++++++++++++ .../drupal9/ce-dev/ansible/provision.yml.j2 | 64 +++++++++++++++++++ .../web/sites/default/ce-dev.drush.yml.j2 | 4 ++ .../web/sites/default/ce-dev.settings.php.j2 | 29 +++++++++ .../ce-dev/ce-dev.compose.prebuilt.yml.j2 | 39 +++++++++++ .../drupal9/ce-dev/ce-dev.compose.yml.j2 | 39 +++++++++++ templates/localgov/.gitignore | 2 + templates/localgov/ce-dev/.gitignore | 2 + .../localgov/ce-dev/ansible/deploy.yml.j2 | 61 ++++++++++++++++++ .../localgov/ce-dev/ansible/provision.yml.j2 | 64 +++++++++++++++++++ .../web/sites/default/ce-dev.drush.yml.j2 | 4 ++ .../web/sites/default/ce-dev.settings.php.j2 | 29 +++++++++ .../ce-dev/ce-dev.compose.prebuilt.yml.j2 | 39 +++++++++++ .../localgov/ce-dev/ce-dev.compose.yml.j2 | 39 +++++++++++ 17 files changed, 478 insertions(+) create mode 100644 templates/drupal9/.gitignore create mode 100644 templates/drupal9/ce-dev/.gitignore create mode 100644 templates/drupal9/ce-dev/ansible/deploy.yml.j2 create mode 100644 templates/drupal9/ce-dev/ansible/provision.yml.j2 create mode 100644 templates/drupal9/ce-dev/ansible/web/sites/default/ce-dev.drush.yml.j2 create mode 100644 templates/drupal9/ce-dev/ansible/web/sites/default/ce-dev.settings.php.j2 create mode 100644 templates/drupal9/ce-dev/ce-dev.compose.prebuilt.yml.j2 create mode 100644 templates/drupal9/ce-dev/ce-dev.compose.yml.j2 create mode 100644 templates/localgov/.gitignore create mode 100644 templates/localgov/ce-dev/.gitignore create mode 100644 templates/localgov/ce-dev/ansible/deploy.yml.j2 create mode 100644 templates/localgov/ce-dev/ansible/provision.yml.j2 create mode 100644 templates/localgov/ce-dev/ansible/web/sites/default/ce-dev.drush.yml.j2 create mode 100644 templates/localgov/ce-dev/ansible/web/sites/default/ce-dev.settings.php.j2 create mode 100644 templates/localgov/ce-dev/ce-dev.compose.prebuilt.yml.j2 create mode 100644 templates/localgov/ce-dev/ce-dev.compose.yml.j2 diff --git a/src/commands/create.ts b/src/commands/create.ts index 450b207..ba09a04 100644 --- a/src/commands/create.ts +++ b/src/commands/create.ts @@ -79,6 +79,8 @@ export default class CreateCmd extends BaseCmd { type: 'list', choices: [ 'drupal8', + 'drupal9', + 'localgov', 'blank', ], }]) diff --git a/templates/drupal9/.gitignore b/templates/drupal9/.gitignore new file mode 100644 index 0000000..5ec454f --- /dev/null +++ b/templates/drupal9/.gitignore @@ -0,0 +1,2 @@ +vendor +node_modules \ No newline at end of file diff --git a/templates/drupal9/ce-dev/.gitignore b/templates/drupal9/ce-dev/.gitignore new file mode 100644 index 0000000..1c1a5e7 --- /dev/null +++ b/templates/drupal9/ce-dev/.gitignore @@ -0,0 +1,2 @@ +*.retry +docker-compose.yml \ No newline at end of file diff --git a/templates/drupal9/ce-dev/ansible/deploy.yml.j2 b/templates/drupal9/ce-dev/ansible/deploy.yml.j2 new file mode 100644 index 0000000..29aaef8 --- /dev/null +++ b/templates/drupal9/ce-dev/ansible/deploy.yml.j2 @@ -0,0 +1,57 @@ +--- +# Template playbook for a local Drupal9 codebase. +- hosts: {{ project_name }}-web + vars: + - project_name: {{ project_name }} + - project_type: drupal8 + - webroot: web + - build_type: local + - _env_type: dev +{% raw %} + - _domain_name: www.{{ project_name }}.local + # Path to your project root. This must match the "volume" set in the docker-compose template. + - deploy_path: /home/ce-dev/deploy/live.local + # This actually does not take any backup, but is needed to populate settings.php. + - mysql_backup: + handling: none + credentials_handling: static + # A list of Drupal sites (for multisites). + - drupal: + sites: + - folder: "default" + public_files: "sites/default/files" + install_command: "-y si" + # Toggle config import on/off. Disabled for initial passes. + config_import_command: "" + # config_import_command: "cim" + config_sync_directory: "config/sync" + sanitize_command: "sql-sanitize" + # Remove after initial pass, to avoid reinstalling Drupal. + force_install: true + base_url: "https://{{ _domain_name }}" + # Composer command to run. + - composer: + command: install + no_dev: false + working_dir: "{{ deploy_path }}" + apcu_autoloader: false + pre_tasks: + # You can safely remove these steps once you have a working composer.json. + - name: Download composer file. + get_url: + url: https://raw.githubusercontent.com/drupal/recommended-project/9.3.x/composer.json + dest: "{{ deploy_path }}/composer.json" + force: false + - name: Install drush. + command: + cmd: composer require drush/drush:11.* + chdir: "{{ deploy_path }}" + roles: + - _init # Sets some variables the deploy scripts rely on. + - composer # Composer install step. + - database_backup # This is still needed to generate credentials. + - config_generate # Generates settings.php +# - sync/database_sync # Grab database from a remote server. + - database_apply # Run drush updb and config import. + - _exit # Some common housekeeping. +{% endraw %} diff --git a/templates/drupal9/ce-dev/ansible/provision.yml.j2 b/templates/drupal9/ce-dev/ansible/provision.yml.j2 new file mode 100644 index 0000000..2f75b3f --- /dev/null +++ b/templates/drupal9/ce-dev/ansible/provision.yml.j2 @@ -0,0 +1,64 @@ +- hosts: {{ project_name }}-web + become: true + vars: + - _domain_name: www.{{ project_name }}.local + - _env_type: dev + - project_name: {{ project_name }} + - mysql_client: + host: {{ project_name }}-db + user: root + password: ce-dev + {% raw %} + - nginx: + domains: + - server_name: "{{ _domain_name }}" + access_log: "/var/log/nginx-access.log" + error_log: "/var/log/nginx-error.log" + error_log_level: "notice" + webroot: "/home/ce-dev/deploy/live.local/web" + project_type: "drupal8" + ssl: + domain: "{{ _domain_name }}" + cert: "{{ _ce_dev_mkcert_base}}/{{ _domain_name }}.pem" + key: "{{ _ce_dev_mkcert_base}}/{{ _domain_name }}-key.pem" + handling: "unmanaged" + ratelimitingcrawlers: false + is_default: true + servers: + - port: 80 + ssl: false + https_redirect: true + - port: 443 + ssl: true + https_redirect: false + upstreams: [] + - php: + version: + - 7.4 + cli: + memory_limit: -1 + _env_type: dev + fpm: + _env_type: dev + - xdebug: + cli: true + - lhci: + enable_vnc: true +{% endraw %} + tasks: + - apt: + update_cache: true + - import_role: + name: _meta/common_base + - import_role: + name: mysql_client + - import_role: + name: php-cli + - import_role: + name: php-fpm + - import_role: + name: nginx + - import_role: + name: lhci + - import_role: + name: frontail diff --git a/templates/drupal9/ce-dev/ansible/web/sites/default/ce-dev.drush.yml.j2 b/templates/drupal9/ce-dev/ansible/web/sites/default/ce-dev.drush.yml.j2 new file mode 100644 index 0000000..b88bf28 --- /dev/null +++ b/templates/drupal9/ce-dev/ansible/web/sites/default/ce-dev.drush.yml.j2 @@ -0,0 +1,4 @@ +# @see https://github.com/drush-ops/drush/blob/master/examples/example.drush.yml + +options: + uri: '{{ site.base_url }}' \ No newline at end of file diff --git a/templates/drupal9/ce-dev/ansible/web/sites/default/ce-dev.settings.php.j2 b/templates/drupal9/ce-dev/ansible/web/sites/default/ce-dev.settings.php.j2 new file mode 100644 index 0000000..d5eb492 --- /dev/null +++ b/templates/drupal9/ce-dev/ansible/web/sites/default/ce-dev.settings.php.j2 @@ -0,0 +1,29 @@ + '{{ build_databases[0].name }}', + 'username' => '{{ build_databases[0].user }}', + 'password' => '{{ build_databases[0].password }}', + 'prefix' => '', + 'host' => '{{ build_databases[0].host }}', + 'port' => '3306', + 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', + 'driver' => 'mysql', +); + +$settings['file_private_path'] = '{{ build_private_file_path }}'; +$settings['file_public_path'] = '{{ build_public_file_path }}'; + +// Drupal < 8.8 +$config_directories['sync'] = '{{ build_config_sync_directory }}'; +// Drupal 8.8 +$settings['config_sync_directory'] = '{{ build_config_sync_directory }}'; diff --git a/templates/drupal9/ce-dev/ce-dev.compose.prebuilt.yml.j2 b/templates/drupal9/ce-dev/ce-dev.compose.prebuilt.yml.j2 new file mode 100644 index 0000000..9902799 --- /dev/null +++ b/templates/drupal9/ce-dev/ce-dev.compose.prebuilt.yml.j2 @@ -0,0 +1,39 @@ +version: '3.7' +x-ce_dev: + version: 1.x + registry: 'localhost:5000' + project_name: {{ project_name }} + provision: + - ce-dev/ansible/provision.yml + deploy: + - ce-dev/ansible/deploy.yml + urls: + - 'https://www.{{ project_name }}.local' +services: + web: + image: 'codeenigma/drupal8-web:latest' + expose: + - 443 + - 80 + x-ce_dev: + host_aliases: + - www.{{ project_name }}.local + # Uncomment and comment the "volumes" below to use Unison file sync. + # unison: + # - src: ../ + # dest: /home/ce-dev/deploy/live.local + # target_platforms: + # - darwin + # - linux + # ignore: + # - Name vendor + # - Name node_modules + # - Path */sites/*/files + volumes: + - ../:/home/ce-dev/deploy/live.local:delegated + cap_add: + - NET_ADMIN + db: + image: 'codeenigma/drupal8-db:latest' + environment: + MYSQL_ROOT_PASSWORD: ce-dev diff --git a/templates/drupal9/ce-dev/ce-dev.compose.yml.j2 b/templates/drupal9/ce-dev/ce-dev.compose.yml.j2 new file mode 100644 index 0000000..61cd6f7 --- /dev/null +++ b/templates/drupal9/ce-dev/ce-dev.compose.yml.j2 @@ -0,0 +1,39 @@ +version: "3.7" +x-ce_dev: + version: 1.x + registry: localhost:5000 + project_name: {{ project_name }} + provision: + - ce-dev/ansible/provision.yml + deploy: + - ce-dev/ansible/deploy.yml + urls: + - https://www.{{ project_name }}.local +services: + web: + image: codeenigma/ce-dev-1.x:latest + expose: + - 443 + - 80 + x-ce_dev: + host_aliases: + - www.{{ project_name }}.local + # Uncomment and comment the "volumes" below to use Unison file sync. + # unison: + # - src: ../ + # dest: /home/ce-dev/deploy/live.local + # target_platforms: + # - darwin + # - linux + # ignore: + # - Name vendor + # - Name node_modules + # - Path */sites/*/files + volumes: + - ../:/home/ce-dev/deploy/live.local:delegated + cap_add: + - NET_ADMIN + db: + image: mariadb + environment: + MYSQL_ROOT_PASSWORD: ce-dev diff --git a/templates/localgov/.gitignore b/templates/localgov/.gitignore new file mode 100644 index 0000000..5ec454f --- /dev/null +++ b/templates/localgov/.gitignore @@ -0,0 +1,2 @@ +vendor +node_modules \ No newline at end of file diff --git a/templates/localgov/ce-dev/.gitignore b/templates/localgov/ce-dev/.gitignore new file mode 100644 index 0000000..1c1a5e7 --- /dev/null +++ b/templates/localgov/ce-dev/.gitignore @@ -0,0 +1,2 @@ +*.retry +docker-compose.yml \ No newline at end of file diff --git a/templates/localgov/ce-dev/ansible/deploy.yml.j2 b/templates/localgov/ce-dev/ansible/deploy.yml.j2 new file mode 100644 index 0000000..96dea95 --- /dev/null +++ b/templates/localgov/ce-dev/ansible/deploy.yml.j2 @@ -0,0 +1,61 @@ +--- +# Template playbook for a local Drupal9 codebase. +- hosts: {{ project_name }}-web + vars: + - project_name: {{ project_name }} + - project_type: drupal8 + - webroot: web + - build_type: local + - _env_type: dev +{% raw %} + - _domain_name: www.{{ project_name }}.local + # Path to your project root. This must match the "volume" set in the docker-compose template. + - deploy_path: /home/ce-dev/deploy/live.local + # This actually does not take any backup, but is needed to populate settings.php. + - mysql_backup: + handling: none + credentials_handling: static + # A list of Drupal sites (for multisites). + - drupal: + sites: + - folder: "default" + public_files: "sites/default/files" + install_command: "-y si localgov" + # Toggle config import on/off. Disabled for initial passes. + config_import_command: "" + # config_import_command: "cim" + config_sync_directory: "config/sync" + sanitize_command: "sql-sanitize" + # Remove after initial pass, to avoid reinstalling Drupal. + force_install: true + base_url: "https://{{ _domain_name }}" + # Composer command to run. + - composer: + command: install + no_dev: false + working_dir: "{{ deploy_path }}" + apcu_autoloader: false + pre_tasks: + # You can safely remove these steps once you have a working composer.json. + - name: Download composer file. + get_url: + url: https://raw.githubusercontent.com/drupal/recommended-project/9.3.x/composer.json + dest: "{{ deploy_path }}/composer.json" + force: false + - name: Install drush. + command: + cmd: composer require drush/drush:11.* + chdir: "{{ deploy_path }}" + - name: Install localgov. + command: + cmd: composer require localgovdrupal/localgov + chdir: "{{ deploy_path }}" + roles: + - _init # Sets some variables the deploy scripts rely on. + - composer # Composer install step. + - database_backup # This is still needed to generate credentials. + - config_generate # Generates settings.php +# - sync/database_sync # Grab database from a remote server. + - database_apply # Run drush updb and config import. + - _exit # Some common housekeeping. +{% endraw %} diff --git a/templates/localgov/ce-dev/ansible/provision.yml.j2 b/templates/localgov/ce-dev/ansible/provision.yml.j2 new file mode 100644 index 0000000..2f75b3f --- /dev/null +++ b/templates/localgov/ce-dev/ansible/provision.yml.j2 @@ -0,0 +1,64 @@ +- hosts: {{ project_name }}-web + become: true + vars: + - _domain_name: www.{{ project_name }}.local + - _env_type: dev + - project_name: {{ project_name }} + - mysql_client: + host: {{ project_name }}-db + user: root + password: ce-dev + {% raw %} + - nginx: + domains: + - server_name: "{{ _domain_name }}" + access_log: "/var/log/nginx-access.log" + error_log: "/var/log/nginx-error.log" + error_log_level: "notice" + webroot: "/home/ce-dev/deploy/live.local/web" + project_type: "drupal8" + ssl: + domain: "{{ _domain_name }}" + cert: "{{ _ce_dev_mkcert_base}}/{{ _domain_name }}.pem" + key: "{{ _ce_dev_mkcert_base}}/{{ _domain_name }}-key.pem" + handling: "unmanaged" + ratelimitingcrawlers: false + is_default: true + servers: + - port: 80 + ssl: false + https_redirect: true + - port: 443 + ssl: true + https_redirect: false + upstreams: [] + - php: + version: + - 7.4 + cli: + memory_limit: -1 + _env_type: dev + fpm: + _env_type: dev + - xdebug: + cli: true + - lhci: + enable_vnc: true +{% endraw %} + tasks: + - apt: + update_cache: true + - import_role: + name: _meta/common_base + - import_role: + name: mysql_client + - import_role: + name: php-cli + - import_role: + name: php-fpm + - import_role: + name: nginx + - import_role: + name: lhci + - import_role: + name: frontail diff --git a/templates/localgov/ce-dev/ansible/web/sites/default/ce-dev.drush.yml.j2 b/templates/localgov/ce-dev/ansible/web/sites/default/ce-dev.drush.yml.j2 new file mode 100644 index 0000000..b88bf28 --- /dev/null +++ b/templates/localgov/ce-dev/ansible/web/sites/default/ce-dev.drush.yml.j2 @@ -0,0 +1,4 @@ +# @see https://github.com/drush-ops/drush/blob/master/examples/example.drush.yml + +options: + uri: '{{ site.base_url }}' \ No newline at end of file diff --git a/templates/localgov/ce-dev/ansible/web/sites/default/ce-dev.settings.php.j2 b/templates/localgov/ce-dev/ansible/web/sites/default/ce-dev.settings.php.j2 new file mode 100644 index 0000000..d5eb492 --- /dev/null +++ b/templates/localgov/ce-dev/ansible/web/sites/default/ce-dev.settings.php.j2 @@ -0,0 +1,29 @@ + '{{ build_databases[0].name }}', + 'username' => '{{ build_databases[0].user }}', + 'password' => '{{ build_databases[0].password }}', + 'prefix' => '', + 'host' => '{{ build_databases[0].host }}', + 'port' => '3306', + 'namespace' => 'Drupal\\Core\\Database\\Driver\\mysql', + 'driver' => 'mysql', +); + +$settings['file_private_path'] = '{{ build_private_file_path }}'; +$settings['file_public_path'] = '{{ build_public_file_path }}'; + +// Drupal < 8.8 +$config_directories['sync'] = '{{ build_config_sync_directory }}'; +// Drupal 8.8 +$settings['config_sync_directory'] = '{{ build_config_sync_directory }}'; diff --git a/templates/localgov/ce-dev/ce-dev.compose.prebuilt.yml.j2 b/templates/localgov/ce-dev/ce-dev.compose.prebuilt.yml.j2 new file mode 100644 index 0000000..9902799 --- /dev/null +++ b/templates/localgov/ce-dev/ce-dev.compose.prebuilt.yml.j2 @@ -0,0 +1,39 @@ +version: '3.7' +x-ce_dev: + version: 1.x + registry: 'localhost:5000' + project_name: {{ project_name }} + provision: + - ce-dev/ansible/provision.yml + deploy: + - ce-dev/ansible/deploy.yml + urls: + - 'https://www.{{ project_name }}.local' +services: + web: + image: 'codeenigma/drupal8-web:latest' + expose: + - 443 + - 80 + x-ce_dev: + host_aliases: + - www.{{ project_name }}.local + # Uncomment and comment the "volumes" below to use Unison file sync. + # unison: + # - src: ../ + # dest: /home/ce-dev/deploy/live.local + # target_platforms: + # - darwin + # - linux + # ignore: + # - Name vendor + # - Name node_modules + # - Path */sites/*/files + volumes: + - ../:/home/ce-dev/deploy/live.local:delegated + cap_add: + - NET_ADMIN + db: + image: 'codeenigma/drupal8-db:latest' + environment: + MYSQL_ROOT_PASSWORD: ce-dev diff --git a/templates/localgov/ce-dev/ce-dev.compose.yml.j2 b/templates/localgov/ce-dev/ce-dev.compose.yml.j2 new file mode 100644 index 0000000..61cd6f7 --- /dev/null +++ b/templates/localgov/ce-dev/ce-dev.compose.yml.j2 @@ -0,0 +1,39 @@ +version: "3.7" +x-ce_dev: + version: 1.x + registry: localhost:5000 + project_name: {{ project_name }} + provision: + - ce-dev/ansible/provision.yml + deploy: + - ce-dev/ansible/deploy.yml + urls: + - https://www.{{ project_name }}.local +services: + web: + image: codeenigma/ce-dev-1.x:latest + expose: + - 443 + - 80 + x-ce_dev: + host_aliases: + - www.{{ project_name }}.local + # Uncomment and comment the "volumes" below to use Unison file sync. + # unison: + # - src: ../ + # dest: /home/ce-dev/deploy/live.local + # target_platforms: + # - darwin + # - linux + # ignore: + # - Name vendor + # - Name node_modules + # - Path */sites/*/files + volumes: + - ../:/home/ce-dev/deploy/live.local:delegated + cap_add: + - NET_ADMIN + db: + image: mariadb + environment: + MYSQL_ROOT_PASSWORD: ce-dev