Skip to content
Snippets Groups Projects
Commit b0542398 authored by danielspeicher's avatar danielspeicher
Browse files

Merge branch 'develop' into 'main'

Develop

See merge request !21
parents eb13ab76 3f946124
No related branches found
No related tags found
1 merge request!21Develop
Pipeline #1256132 passed
......@@ -129,7 +129,7 @@ inventories at once.
### Running Ansible commands
To get a list of all prepard Ansible scripts, call
To get a list of all prepared Ansible scripts, call
```
dans INVENTORYNAME
......@@ -181,7 +181,7 @@ dans name1 direct setup "filter=ansible_*_mb"
### Other commands
For each inventory you downlaoded a separate Docker image, and a named Docker
For each inventory you downloaded a separate Docker image, and a named Docker
container for each of them is running in the background. There are a few extra
commands for those containers:
......
---
title: Ansible Docker Framework
repo: https://gitlab.lakedrops.com/gitlab/ansible
issues: https://gitlab.lakedrops.com/gitlab/ansible/-/issues
tags:
- ansible
- docker
- GitLab
---
# Using Ansible
If you also use an [Ansible inventory](/ansible) for your hosts, you can of
course integrate them into the GitLab pipelines too. To make this work, you
need a separate GitLab runner tagged with `ansible` and a configuration
like this:
```
[[runners]]
name = "Name of ansible runner"
url = "https://gitlab.lakedrops.com/"
token = "TOKEN"
executor = "docker"
environment = ["DOCKER_AUTH_CONFIG={\"auths\":{\"registry.lakedrops.com\":{\"auth\":\"YOURAUTHTOKEN\"}}}"]
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.docker]
tls_verify = false
hostname = "Ansible-INVENTORYNAME"
image = "registry.lakedrops.com/ansible-inventories/INVENTORYNAME:latest"
privileged = true
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["/home/gitlab-runner/.ssh/id_rsa:/root/.ssh/id_rsa", "/home/gitlab-runner/.a/variables.yml:/root/.ansible/secrets", "/home/gitlab-runner/.a/inventories/INVENTORYNAME:/root
/.ansible", "/etc/ansible.yml:/etc/ansible.yml", "/var/log/ansible:/var/log/ansible"]
pull_policy = "always"
shm_size = 0
```
The used placeholders in this example are:
- `TOKEN`: the token of the GitLab runner being generated during setup.
- `YOURAUTHTOKEN`: your auth token to the LakeDrops GitLab Docker registry.
- `INVENTORYNAME`: the name of the Ansible inventory to be used.
To learn more about the Ansible images for an inventory and how to set up some
configuration files, please have a look into
[Docker for Ansible](/docker/ansible).
Once you have the GitLab runner for Ansible setup for the Drupal project,
you can adjust your GitLab CI configuration:
## Using Ansible to Dump DB
You can replace the task above with this simple instruction:
```yaml
Download DB:
extends: '.dumpdb'
```
## Using Ansible for Deployment
You need a couple of additional variables and then you can replace the deploy
task above with this simple instruction:
```yaml
variables:
HOST_NAME: myhostname
SITE_NAME: mysiteid
Deploy:
extends: '.deploy'
```
The host name needs to be set to how the destination host is known in the
Ansible inventory, and the site name needs to be set to the ID of the Drupal
site in your inventory.
......@@ -207,6 +207,8 @@ you have to write the scripts for those two tasks yourselves.
tests will be skipped.
- `DISABLE_CI_TEST_CODESTYLE`: if this variable is set to any value, the
PHP CS tests will be skipped.
- `DISABLE_CI_TEST_CYPRESSE2E:`: if this variable is set to any value, the
Cypress tests will be skipped.
- `DISABLE_CI_TEST_PHPUNIT`: if this variable is set to any value, the
PHP unit tests will be skipped.
- `CAE`: This variable is being used by the Drupal module
......@@ -239,78 +241,6 @@ used to define dependencies:
- `deploy`
- `Deploy`
### Using Ansible
If you also use an [Ansible inventory](/ansible) for your hosts, you can of
course integrate them into the GitLab pipelines too. To make this work, you
need a separate GitLab runner tagged with `ansible` and a configuration
like this:
```
[[runners]]
name = "Name of ansible runner"
url = "https://gitlab.lakedrops.com/"
token = "TOKEN"
executor = "docker"
environment = ["DOCKER_AUTH_CONFIG={\"auths\":{\"registry.lakedrops.com\":{\"auth\":\"YOURAUTHTOKEN\"}}}"]
[runners.custom_build_dir]
[runners.cache]
[runners.cache.s3]
[runners.cache.gcs]
[runners.docker]
tls_verify = false
hostname = "Ansible-INVENTORYNAME"
image = "registry.lakedrops.com/ansible-inventories/INVENTORYNAME:latest"
privileged = true
disable_entrypoint_overwrite = false
oom_kill_disable = false
disable_cache = false
volumes = ["/home/gitlab-runner/.ssh/id_rsa:/root/.ssh/id_rsa", "/home/gitlab-runner/.a/variables.yml:/root/.ansible/secrets", "/home/gitlab-runner/.a/inventories/INVENTORYNAME:/root
/.ansible", "/etc/ansible.yml:/etc/ansible.yml", "/var/log/ansible:/var/log/ansible"]
pull_policy = "always"
shm_size = 0
```
The used placeholders in this example are:
- `TOKEN`: the token of the GitLab runner being generated during setup.
- `YOURAUTHTOKEN`: your auth token to the LakeDrops GitLab Docker registry.
- `INVENTORYNAME`: the name of the Ansible inventory to be used.
To learn more about the Ansible imeages for an inventory and how to set up some
configuration files, please have a look into
[Docker for Ansible](/docker/ansible).
Once you have the GitLab runner for Ansible setup for the Drupal project,
you can adjust your GitLab CI configuration:
#### Using Ansible to Dump DB
You can replace the task above with this simple instruction:
```yaml
Download DB:
extends: '.dumpdb'
```
#### Using Ansible for Deployment
You need a couple of additional variables and then you can replace the deploy
task above with this simple instruction:
```yaml
variables:
HOST_NAME: myhostname
SITE_NAME: mysiteid
Deploy:
extends: '.deploy'
```
The host name needs to be set to how the destination host is known in the
Ansible inventory, and the site name needs to be set to the ID of the Drupal
site in your inventory.
## Usage
This chapter is incomplete so far and needs more attention.
......@@ -356,7 +286,7 @@ executed in the `prepare` stage instead.
## Example
We provide a [Demo Drupal 9 project](https://gitlab.lakedrops.com/gitlab-ci-cd/demos/drupal-9)
We provide a [Demo Drupal 10 project](https://gitlab.lakedrops.com/gitlab-ci-cd/demos/drupal-10)
which uses this GitLab CI framework. If you want to give it a try, login to
our GitLab, go to the project and click on "Request access". Once we've
accepted your request, you can clone the project, make some changes and push
......@@ -376,3 +306,29 @@ Also, all the variables have been configured in the GitLab project settings,
because developers should not have access to them:
![Screenshot](/files/screenshots/Screenshot from 2021-01-23 17-20-07.png)
## GitLab CI for a single Drupal module
For building and testing a single `Drupal.org`, custom or contrib module, we make use of the official Drupal project
[GitLab Templates](https://www.drupal.org/project/gitlab_templates). To include the templates, we provide a
GitLab CI file [private-modules](https://gitlab.lakedrops.com/gitlab-ci-cd/drupal/-/blob/main/private-modules.yml?ref_type=heads),
which can be included in your own `gitlab-ci.yml` file.
This includes the following stages:
* build
* validate
* test
To get a complete documentation for this powerful project, see [here](https://project.pages.drupalcode.org/gitlab_templates/).
This file `private-modules.yml` includes another CI template called
[composer-packages.yml](https://gitlab.lakedrops.com/gitlab-ci-cd/composer-packages/-/blob/main/composer-packages.yml?ref_type=heads).
Here you can store your module as a composer package in your own GitLab installation. The versioning is also included.
Now you can use it in a `composer.json` file. You have to define the repository like this:
```yaml
"<your-name>": {
"type": "composer",
"url": "https://<your-domain>/api/v4/group/<your-group>/-/packages/composer/"
},
```
......@@ -266,6 +266,7 @@ nav:
- GitLab:
- gitlab/index.md
- Drupal: gitlab/drupal/index.md
- Ansible: gitlab/ansible/index.md
- DevOps:
- ALM:
- devops/alm/alm.md
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment