Skip to content
This repository was archived by the owner on Oct 8, 2025. It is now read-only.
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/_Sidebar.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
- [Database sync](/roles/sync/database_sync)
- [Database sync - MySQL](/roles/sync/database_sync/database_sync-mysql)
- [Tests](/roles/tests)
- [Behat tests](/roles/tests/tests_behat)
- [Diffy tests](/roles/tests/tests_diffy)
- [LHCI tests](/roles/tests/tests_lhci)
- [PHP CodeSniffer tests](/roles/tests/tests_phpcs)
Expand Down
2 changes: 2 additions & 0 deletions docs/roles/_init.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ bin_directory: "/home/{{ deploy_user }}/.bin"
cleanup_history_depth: 50
install_php_cachetool: true # set to false if you don't need cachetool, e.g. for a nodejs app
ce_deploy_version: 1.x
ce_provision_version: 2.x # the version of ce-provision to grab files from when roles are shared
lock_file: /tmp/ce-deploy-lock
provision_lock_file: /tmp/ce-provision-lock # must match _init.lock_file in ce-provision
skip_build_path_check: false # by default we're checking if track number matches
# Application specific variables.
drupal:
drush_verbose_output: false
Expand Down
1 change: 1 addition & 0 deletions docs/roles/deploy_code.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ Deploying code with autoscaling clusters relies on [cloud-init](https://cloudini
_ce_provision_data_dir: /home/deploy/ce-deploy/data

deploy_code:
ce_provision_version: "{{ ce_provision_version }}" # used to determine version of ce-provision to fetch roles from
# Feature branching config.
feature_branch:
enabled: false
Expand Down
23 changes: 13 additions & 10 deletions docs/roles/deploy_container.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ It is worth noting that even if you put your containers on private subnets and c
```yaml
---
deploy_container:
ce_provision_version: "{{ ce_provision_version }}" # used to determine version of ce-provision to fetch roles from
action: create # can also be destroy
container_name: example-container
container_tag: latest # tag will take format container_name:container_tag
container_force_build: true # force Docker to build and tag a new image
docker_registry_name: index.docker.io/example # combines with container_name to make the full registry name, docker_registry_name/container_name
# docker_registry_url: "https://index.docker.io/v1/"
docker_registry_user: example
docker_registry_pass: asdf1234
docker_base_command: "docker image build"
Expand All @@ -63,6 +65,7 @@ deploy_container:
# Note, you can if you wish make more restrictive roles and policies
aws_ecs:
enabled: false
service_type: web_app # other options: scheduled_task, e.g. a cron job
region: eu-west-1
aws_profile: example
tags: {}
Expand All @@ -71,14 +74,14 @@ deploy_container:
zone: example.com
aws_profile: example2 # might not be the same account
vpc_name: example
#vpc_id: vpc-XXXXXXX # optionally specify VPC ID to use
# vpc_id: vpc-XXXXXXX # optionally specify VPC ID to use
security_groups: [] # list of security groups, accepts names or IDs
cluster_name: example-cluster
family_name: example-task-definition
task_definition_revision: "" # integer, but must be presented as a string for Jinja2
task_definition_force_create: false # creates a task definition revision every time if set to true
task_execution_role_arn: "arn:aws:iam::000000000000:role/ecsTaskExecutionRole" # ARN of the IAM role to run the task as, must have access to the ECR repository if applicable
#task_role_arn: "" # required if you set service_enable_ssm to true
# task_role_arn: "" # required if you set service_enable_ssm to true
task_count: 1
task_minimum_count: 1
task_maximum_count: 4
Expand Down Expand Up @@ -111,23 +114,23 @@ deploy_container:
memory: 1024
launch_type: FARGATE
network_mode: awsvpc
#volumes: [] # list of additional volumes to attach
# volumes: [] # list of additional volumes to attach
target_group_name: example # can have a maximum of 32 characters, must contain only alphanumeric characters or hyphens, and must not begin or end with a hyphen
target_group_protocol: http
target_group_port: 8080 # ports lower than 1024 will require the app to be configured to run as a privileged user in the Dockerfile
target_group_wait_timeout: 200 # how long to wait for target group events to complete
targets: [] # typically we do not specify targets at this point, this will be handled automatically by the ECS service
#- Id: 10.0.0.2
# Port: 80
# AvailabilityZone: all
# - Id: 10.0.0.2
# Port: 80
# AvailabilityZone: all
health_check:
protocol: http
path: /
response_codes: "200"
# optional additional healthcheck settings
#interval: 60
#healthy_threshold_count: 3
#unhealthy_threshold_count: 5
## optional additional healthcheck settings
# interval: 60
# healthy_threshold_count: 3
# unhealthy_threshold_count: 5
# Requires the deploy IAM user to have the managed AWSCertificateManagerFullAccess and AmazonRoute53FullAccess policies attached
acm: # see https://github.com/codeenigma/ce-provision/tree/1.x/roles/aws/aws_acm
create_cert: false
Expand Down
25 changes: 25 additions & 0 deletions docs/roles/tests/tests_behat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Behat tests
[Behat](https://behat.org/) is an open source [Behaviour Driven Development](https://en.wikipedia.org/wiki/Behavior-driven_development) tool for building software that is often used for functional testing.

<!--TOC-->
<!--ENDTOC-->

<!--ROLEVARS-->
## Default variables
```yaml
---
behat:
install: false # set to true if you want ce-deploy to attempt to composer install Behat
tags: "~@javascript" # behat tags to run
verbose: false # set to true for verbose output
bin: "{{ deploy_path }}/vendor/bin/behat" # location of Behat
# List of outputs to create, defaults to 'pretty' to STDOUT
outputs:
- format: pretty # options are pretty, progress or junit
output: std # see docs for more information, supports output filepath or various formats
config_file: "{{ deploy_path }}/tests/behat/behat.yml" # path to config file
working_dir: "{{ deploy_path }}" # path to execute composer from

```

<!--ENDROLEVARS-->
2 changes: 2 additions & 0 deletions docs/roles/tests/tests_diffy.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ diffy:
main_env: dev # name of the 'good' environment to compare against (must be pre-configured in diffy)
test_env: custom # name of the environment to be compared (usually diffy's default 'custom' environment)
test_env_url: "" # set a base URL to use against the diffy 'custom' environment
bin: "{{ deploy_path }}/vendor/bin/diffy" # location of diffy
working_dir: "{{ deploy_path }}" # path to execute composer and related binaries from

```

Expand Down
3 changes: 2 additions & 1 deletion docs/roles/tests/tests_phpcs.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ See the installation documentation on packagist: https://packagist.org/packages/
```yaml
---
phpcs:
install: false # set to true if you want ce-deploy to attempt to composer install PHP CodeSniffer
install: false # set to true if you want ce-deploy to attempt to composer install PHP CodeSniffer
install_drupal_coder: false # set to true to install the Coder module for Drupal, which provides a Drupal standard for CodeSniffer
bin: "{{ deploy_path }}/vendor/bin/phpcs" # location of phpcs
standard: "" # optionally set the path to an installed standard, for example "vendor/drupal/coder/coder_sniffer/Drupal" for the Coder module for Drupal
extensions: "" # set optional extensions, for example for Drupal you could set "php,module,inc,theme,install" - defaults to "php,inc/php,js,css"
test_paths: [] # list of paths to test against
working_dir: "{{ deploy_path }}" # path to execute composer from

```

Expand Down
1 change: 1 addition & 0 deletions docs/roles/tests/tests_phpunit.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ phpunit:
target: ../modules # directory or file to test, defaults to Drupal's modules directory
bin: "{{ deploy_path }}/vendor/bin/phpunit" # location of phpunit
tests_path: "{{ deploy_path }}/{{ webroot }}/core" # directory containing the PHPUnit 'tests' directory, defaults to Drupal's core directory
working_dir: "{{ deploy_path }}" # path to execute composer from

```

Expand Down
2 changes: 2 additions & 0 deletions roles/_init/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ bin_directory: "/home/{{ deploy_user }}/.bin"
cleanup_history_depth: 50
install_php_cachetool: true # set to false if you don't need cachetool, e.g. for a nodejs app
ce_deploy_version: 1.x
ce_provision_version: 2.x # the version of ce-provision to grab files from when roles are shared
lock_file: /tmp/ce-deploy-lock
provision_lock_file: /tmp/ce-provision-lock # must match _init.lock_file in ce-provision
skip_build_path_check: false # by default we're checking if track number matches
# Application specific variables.
drupal:
drush_verbose_output: false
Expand Down
1 change: 1 addition & 0 deletions roles/deploy_code/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ Deploying code with autoscaling clusters relies on [cloud-init](https://cloudini
_ce_provision_data_dir: /home/deploy/ce-deploy/data

deploy_code:
ce_provision_version: "{{ ce_provision_version }}" # used to determine version of ce-provision to fetch roles from
# Feature branching config.
feature_branch:
enabled: false
Expand Down
23 changes: 13 additions & 10 deletions roles/deploy_container/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,13 @@ It is worth noting that even if you put your containers on private subnets and c
```yaml
---
deploy_container:
ce_provision_version: "{{ ce_provision_version }}" # used to determine version of ce-provision to fetch roles from
action: create # can also be destroy
container_name: example-container
container_tag: latest # tag will take format container_name:container_tag
container_force_build: true # force Docker to build and tag a new image
docker_registry_name: index.docker.io/example # combines with container_name to make the full registry name, docker_registry_name/container_name
# docker_registry_url: "https://index.docker.io/v1/"
docker_registry_user: example
docker_registry_pass: asdf1234
docker_base_command: "docker image build"
Expand All @@ -63,6 +65,7 @@ deploy_container:
# Note, you can if you wish make more restrictive roles and policies
aws_ecs:
enabled: false
service_type: web_app # other options: scheduled_task, e.g. a cron job
region: eu-west-1
aws_profile: example
tags: {}
Expand All @@ -71,14 +74,14 @@ deploy_container:
zone: example.com
aws_profile: example2 # might not be the same account
vpc_name: example
#vpc_id: vpc-XXXXXXX # optionally specify VPC ID to use
# vpc_id: vpc-XXXXXXX # optionally specify VPC ID to use
security_groups: [] # list of security groups, accepts names or IDs
cluster_name: example-cluster
family_name: example-task-definition
task_definition_revision: "" # integer, but must be presented as a string for Jinja2
task_definition_force_create: false # creates a task definition revision every time if set to true
task_execution_role_arn: "arn:aws:iam::000000000000:role/ecsTaskExecutionRole" # ARN of the IAM role to run the task as, must have access to the ECR repository if applicable
#task_role_arn: "" # required if you set service_enable_ssm to true
# task_role_arn: "" # required if you set service_enable_ssm to true
task_count: 1
task_minimum_count: 1
task_maximum_count: 4
Expand Down Expand Up @@ -111,23 +114,23 @@ deploy_container:
memory: 1024
launch_type: FARGATE
network_mode: awsvpc
#volumes: [] # list of additional volumes to attach
# volumes: [] # list of additional volumes to attach
target_group_name: example # can have a maximum of 32 characters, must contain only alphanumeric characters or hyphens, and must not begin or end with a hyphen
target_group_protocol: http
target_group_port: 8080 # ports lower than 1024 will require the app to be configured to run as a privileged user in the Dockerfile
target_group_wait_timeout: 200 # how long to wait for target group events to complete
targets: [] # typically we do not specify targets at this point, this will be handled automatically by the ECS service
#- Id: 10.0.0.2
# Port: 80
# AvailabilityZone: all
# - Id: 10.0.0.2
# Port: 80
# AvailabilityZone: all
health_check:
protocol: http
path: /
response_codes: "200"
# optional additional healthcheck settings
#interval: 60
#healthy_threshold_count: 3
#unhealthy_threshold_count: 5
## optional additional healthcheck settings
# interval: 60
# healthy_threshold_count: 3
# unhealthy_threshold_count: 5
# Requires the deploy IAM user to have the managed AWSCertificateManagerFullAccess and AmazonRoute53FullAccess policies attached
acm: # see https://github.com/codeenigma/ce-provision/tree/1.x/roles/aws/aws_acm
create_cert: false
Expand Down
3 changes: 1 addition & 2 deletions roles/live_symlink/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
---
deploy_user: 'deploy'
live_symlink:
# Either update (for successful builds) or revert.
operation: update
revert_on_fail: true
# Specify any additional directory symlink to create, with src (target) and dest (link).
# src: can be either absolute or relative to the dest (eg. '/var/my_data', '/home/deploy/simplesaml', '../../../myconfig')
# dest: can only be relative to the root of your repository (eg. 'www/themes/myassets', 'var/cache')
Expand Down
4 changes: 3 additions & 1 deletion roles/live_symlink/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

- ansible.builtin.set_fact:
_live_symlink_build_target: "{{ deploy_base_path }}/{{ project_name }}_{{ build_type }}_build_{{ previous_build_number }}"
when: deploy_operation == 'revert'
when:
- deploy_operation == 'revert'
- live_symlink.revert_on_fail

- ansible.builtin.set_fact:
_live_symlink_dest_target: "{{ live_symlink_dest }}"
Expand Down
25 changes: 25 additions & 0 deletions roles/tests/tests_behat/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Behat tests
[Behat](https://behat.org/) is an open source [Behaviour Driven Development](https://en.wikipedia.org/wiki/Behavior-driven_development) tool for building software that is often used for functional testing.

<!--TOC-->
<!--ENDTOC-->

<!--ROLEVARS-->
## Default variables
```yaml
---
behat:
install: false # set to true if you want ce-deploy to attempt to composer install Behat
tags: "~@javascript" # behat tags to run
verbose: false # set to true for verbose output
bin: "{{ deploy_path }}/vendor/bin/behat" # location of Behat
# List of outputs to create, defaults to 'pretty' to STDOUT
outputs:
- format: pretty # options are pretty, progress or junit
output: std # see docs for more information, supports output filepath or various formats
config_file: "{{ deploy_path }}/tests/behat/behat.yml" # path to config file
working_dir: "{{ deploy_path }}" # path to execute composer from

```

<!--ENDROLEVARS-->
12 changes: 12 additions & 0 deletions roles/tests/tests_behat/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
behat:
install: false # set to true if you want ce-deploy to attempt to composer install Behat
tags: "~@javascript" # behat tags to run
verbose: false # set to true for verbose output
bin: "{{ deploy_path }}/vendor/bin/behat" # location of Behat
# List of outputs to create, defaults to 'pretty' to STDOUT
outputs:
- format: pretty # options are pretty, progress or junit
output: std # see docs for more information, supports output filepath or various formats
config_file: "{{ deploy_path }}/tests/behat/behat.yml" # path to config file
working_dir: "{{ deploy_path }}" # path to execute composer from
29 changes: 29 additions & 0 deletions roles/tests/tests_behat/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
- name: Reset the _behat_outputs var.
ansible.builtin.set_fact:
_behat_outputs: ""

- name: Install Behat with composer.
ansible.builtin.import_role:
name: composer
when: behat.install
vars:
composer:
command: require
args: behat/behat
working_dir: "{{ behat.working_dir }}"

- name: Build Behat outputs string.
ansible.builtin.set_fact:
_behat_outputs: "{{ _behat_outputs }} -f {{ item.format }} -o {{ item.output }}"
with_items: "{{ behat.outputs }}"

- name: Add verbosity if requested.
ansible.builtin.set_fact:
_behat_outputs: "{{ _behat_outputs }} -v"
when: behat.verbose

- name: Run Behat command.
ansible.builtin.command:
cmd: "{{ behat.bin }} --config={{ behat.config_file }} --tags={{ behat.tags }} {{ _behat_outputs }}"
when: behat.outputs | length > 0
2 changes: 2 additions & 0 deletions roles/tests/tests_diffy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ diffy:
main_env: dev # name of the 'good' environment to compare against (must be pre-configured in diffy)
test_env: custom # name of the environment to be compared (usually diffy's default 'custom' environment)
test_env_url: "" # set a base URL to use against the diffy 'custom' environment
bin: "{{ deploy_path }}/vendor/bin/diffy" # location of diffy
working_dir: "{{ deploy_path }}" # path to execute composer and related binaries from

```

Expand Down
2 changes: 2 additions & 0 deletions roles/tests/tests_diffy/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ diffy:
main_env: dev # name of the 'good' environment to compare against (must be pre-configured in diffy)
test_env: custom # name of the environment to be compared (usually diffy's default 'custom' environment)
test_env_url: "" # set a base URL to use against the diffy 'custom' environment
bin: "{{ deploy_path }}/vendor/bin/diffy" # location of diffy
working_dir: "{{ deploy_path }}" # path to execute composer and related binaries from
7 changes: 4 additions & 3 deletions roles/tests/tests_diffy/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
composer:
command: require
args: diffywebsite/diffy-php
working_dir: "{{ diffy.working_dir }}"

- name: Login to diffy.
ansible.builtin.command:
cmd: "{{ deploy_path }}/vendor/bin/diffy auth:login {{ diffy.key }}"
cmd: "{{ diffy.bin }} auth:login {{ diffy.key }}"

- name: Run diffy with environment URL set.
ansible.builtin.command:
cmd: "{{ deploy_path }}/vendor/bin/diffy project:compare {{ diffy.project_id }} {{ diffy.main_env }} {{ diffy.test_env }} --env2Url={{ diffy.test_env_url }}"
cmd: "{{ diffy.bin }} project:compare {{ diffy.project_id }} {{ diffy.main_env }} {{ diffy.test_env }} --env2Url={{ diffy.test_env_url }}"
register: _diffy_report_id_with_env
when: diffy.test_env_url | length > 0

Expand All @@ -25,7 +26,7 @@

- name: Run diffy.
ansible.builtin.command:
cmd: "{{ deploy_path }}/vendor/bin/diffy project:compare {{ diffy.project_id }} {{ diffy.main_env }} {{ diffy.test_env }}"
cmd: "{{ diffy.bin }} project:compare {{ diffy.project_id }} {{ diffy.main_env }} {{ diffy.test_env }}"
register: _diffy_report_id_no_env
when: diffy.test_env_url | length == 0

Expand Down
3 changes: 2 additions & 1 deletion roles/tests/tests_phpcs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,13 @@ See the installation documentation on packagist: https://packagist.org/packages/
```yaml
---
phpcs:
install: false # set to true if you want ce-deploy to attempt to composer install PHP CodeSniffer
install: false # set to true if you want ce-deploy to attempt to composer install PHP CodeSniffer
install_drupal_coder: false # set to true to install the Coder module for Drupal, which provides a Drupal standard for CodeSniffer
bin: "{{ deploy_path }}/vendor/bin/phpcs" # location of phpcs
standard: "" # optionally set the path to an installed standard, for example "vendor/drupal/coder/coder_sniffer/Drupal" for the Coder module for Drupal
extensions: "" # set optional extensions, for example for Drupal you could set "php,module,inc,theme,install" - defaults to "php,inc/php,js,css"
test_paths: [] # list of paths to test against
working_dir: "{{ deploy_path }}" # path to execute composer from

```

Expand Down
Loading