Skip to content
This repository has been archived by the owner on Feb 13, 2023. It is now read-only.

Commit

Permalink
Issue #2109: Update Drupal and Drush roles to fix idempotence.
Browse files Browse the repository at this point in the history
  • Loading branch information
geerlingguy committed Nov 24, 2020
1 parent 448da88 commit bcb2707
Show file tree
Hide file tree
Showing 20 changed files with 311 additions and 66 deletions.
4 changes: 2 additions & 2 deletions provisioning/requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ roles:
- name: geerlingguy.daemonize
version: 1.2.1
- name: geerlingguy.drupal
version: 4.1.0
version: 4.2.0
- name: geerlingguy.drupal-console
version: 1.1.1
- name: geerlingguy.drush
version: 3.2.0
version: 3.3.0
- name: geerlingguy.elasticsearch
version: 4.2.0
- name: geerlingguy.firewall
Expand Down
1 change: 1 addition & 0 deletions provisioning/roles/geerlingguy.drupal/.ansible-lint
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
skip_list:
- '204'
- '503'
- '106'
72 changes: 72 additions & 0 deletions provisioning/roles/geerlingguy.drupal/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
name: CI
'on':
pull_request:
push:
branches:
- master
schedule:
- cron: "30 5 * * 1"

defaults:
run:
working-directory: 'geerlingguy.drupal'

jobs:

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Check out the codebase.
uses: actions/checkout@v2
with:
path: 'geerlingguy.drupal'

- name: Set up Python 3.
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install test dependencies.
run: pip3 install yamllint ansible-lint

- name: Lint code.
run: |
yamllint .
ansible-lint
molecule:
name: Molecule
runs-on: ubuntu-latest
strategy:
matrix:
include:
- distro: centos8
playbook: converge.yml
- distro: ubuntu1804
playbook: converge.yml
- distro: centos8
playbook: deploy.yml

steps:
- name: Check out the codebase.
uses: actions/checkout@v2
with:
path: 'geerlingguy.drupal'

- name: Set up Python 3.
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install test dependencies.
run: pip3 install ansible molecule[docker] docker

- name: Run Molecule tests.
run: molecule test
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
MOLECULE_DISTRO: ${{ matrix.distro }}
MOLECULE_PLAYBOOK: ${{ matrix.playbook }}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
# This workflow requires a GALAXY_API_KEY secret present in the GitHub
# repository or organization.
#
# See: https://github.com/marketplace/actions/publish-ansible-role-to-galaxy
# See: https://github.com/ansible/galaxy/issues/46

name: Release
'on':
push:
tags:
- '*'

defaults:
run:
working-directory: 'geerlingguy.drupal'

jobs:

release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Check out the codebase.
uses: actions/checkout@v2
with:
path: 'geerlingguy.drupal'

- name: Set up Python 3.
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install Ansible.
run: pip3 install ansible-base

- name: Trigger a new import on Galaxy.
run: ansible-galaxy role import --api-key ${{ secrets.GALAXY_API_KEY }} $(echo ${{ github.repository }} | cut -d/ -f1) $(echo ${{ github.repository }} | cut -d/ -f2)
31 changes: 0 additions & 31 deletions provisioning/roles/geerlingguy.drupal/.travis.yml

This file was deleted.

5 changes: 5 additions & 0 deletions provisioning/roles/geerlingguy.drupal/.yamllint
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
---
extends: default

rules:
line-length:
max: 160
level: warning

ignore: |
.github/stale.yml
.travis.yml
2 changes: 1 addition & 1 deletion provisioning/roles/geerlingguy.drupal/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Ansible Role: Drupal

[![Build Status](https://travis-ci.org/geerlingguy/ansible-role-drupal.svg?branch=master)](https://travis-ci.org/geerlingguy/ansible-role-drupal)
[![CI](https://github.com/geerlingguy/ansible-role-drupal/workflows/CI/badge.svg?event=push)](https://github.com/geerlingguy/ansible-role-drupal/actions?query=workflow%3ACI)

Builds and installs [Drupal](https://drupal.org/), an open source content management platform.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
- test-vars.yml

vars:
# Deploy from the Drupal VM Prod example project.
# Deploy from the Drupal for Kubernetes example project.
drupal_deploy: true
drupal_deploy_repo: "https://github.com/geerlingguy/drupalvm-live.git"
drupal_deploy_repo: "https://github.com/geerlingguy/drupal-for-kubernetes.git"
drupal_deploy_dir: /var/www/drupal
drupal_domain: "prod.drupalvm.com"
drupal_domain: "test.pidramble.com"

# Disable Composer-based codebase setup.
drupal_build_composer_project: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@ dependency:
name: galaxy
driver:
name: docker
lint: |
set -e
yamllint .
ansible-lint
platforms:
- name: instance
image: "geerlingguy/docker-${MOLECULE_DISTRO:-centos7}-ansible:latest"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,25 @@
become: false
when: not drupal_site_exists

# Use manual composer require tasks until Ansible 2.10.4 is released.
- name: Install dependencies with composer require (this may take a while).
composer:
command: require
arguments: "{{ item }}"
working_dir: "{{ drupal_composer_install_dir }}"
command: "{{ composer_path }} require {{ item }} -d {{ drupal_composer_install_dir }}"
register: composer_require_result
changed_when: "'Nothing to install' not in composer_require_result.stderr"
with_items: "{{ drupal_composer_dependencies|default([]) }}"
become: false
environment:
COMPOSER_PROCESS_TIMEOUT: 1200
COMPOSER_MEMORY_LIMIT: '-1'

# Switch back to this task after Ansible 2.10.4 is released.
# - name: Install dependencies with composer require (this may take a while).
# composer:
# command: require
# arguments: "{{ item }}"
# working_dir: "{{ drupal_composer_install_dir }}"
# with_items: "{{ drupal_composer_dependencies | default([]) }}"
# become: false
# environment:
# COMPOSER_PROCESS_TIMEOUT: 1200
# COMPOSER_MEMORY_LIMIT: '-1'
21 changes: 17 additions & 4 deletions provisioning/roles/geerlingguy.drupal/tasks/build-composer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
copy:
src: "{{ drupal_composer_path }}"
dest: "/tmp/drupalvm-composer.json"
mode: 0644
when: drupal_composer_path and not drupal_site_exists
become: false

Expand All @@ -28,13 +29,25 @@
when: not drupal_site_exists
become: false

# Use manual composer require tasks until Ansible 2.10.4 is released.
- name: Install dependencies with composer require (this may take a while).
composer:
command: require
arguments: "{{ item }}"
working_dir: "{{ drupal_composer_install_dir }}"
command: "{{ composer_path }} require {{ item }} -d {{ drupal_composer_install_dir }}"
register: composer_require_result
changed_when: "'Nothing to install' not in composer_require_result.stderr"
with_items: "{{ drupal_composer_dependencies|default([]) }}"
become: false
environment:
COMPOSER_PROCESS_TIMEOUT: 1200
COMPOSER_MEMORY_LIMIT: '-1'

# Switch back to this task after Ansible 2.10.4 is released.
# - name: Install dependencies with composer require (this may take a while).
# composer:
# command: require
# arguments: "{{ item }}"
# working_dir: "{{ drupal_composer_install_dir }}"
# with_items: "{{ drupal_composer_dependencies | default([]) }}"
# become: false
# environment:
# COMPOSER_PROCESS_TIMEOUT: 1200
# COMPOSER_MEMORY_LIMIT: '-1'
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
copy:
src: "{{ drush_makefile_path }}"
dest: /tmp/drupal.make.yml
mode: 0644
when: not drupal_site_exists

- name: Ensure drupal_core_path directory exists.
Expand Down
20 changes: 16 additions & 4 deletions provisioning/roles/geerlingguy.drupal/tasks/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,25 @@
stat: "path={{ drupal_deploy_dir }}/composer.json"
register: drupal_deploy_composer_file

# Use manual composer require tasks until Ansible 2.10.4 is released.
- name: Run composer install if composer.json is present.
composer:
command: install
working_dir: "{{ drupal_deploy_dir }}"
no_dev: "{{ drupal_composer_no_dev }}"
command: "composer install -d {{ drupal_deploy_dir }}{% if drupal_composer_no_dev %} --no-dev{% endif %}"
register: composer_install_result
changed_when: "'Nothing to install' not in composer_install_result.stderr"
when:
- drupal_deploy_composer_file.stat.exists
- drupal_deploy_composer_install
become: "{{ drupal_core_owner_become }}"
become_user: "{{ drupal_core_owner }}"

# Switch back to this task after Ansible 2.10.4 is released.
# - name: Run composer install if composer.json is present.
# composer:
# command: install
# working_dir: "{{ drupal_deploy_dir }}"
# no_dev: "{{ drupal_composer_no_dev }}"
# when:
# - drupal_deploy_composer_file.stat.exists
# - drupal_deploy_composer_install
# become: "{{ drupal_core_owner_become }}"
# become_user: "{{ drupal_core_owner }}"
76 changes: 76 additions & 0 deletions provisioning/roles/geerlingguy.drush/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
---
name: CI
'on':
pull_request:
push:
branches:
- master
schedule:
- cron: "0 4 * * 1"

defaults:
run:
working-directory: 'geerlingguy.drush'

jobs:

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Check out the codebase.
uses: actions/checkout@v2
with:
path: 'geerlingguy.drush'

- name: Set up Python 3.
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install test dependencies.
run: pip3 install yamllint ansible-lint

- name: Lint code.
run: |
yamllint .
ansible-lint
molecule:
name: Molecule
runs-on: ubuntu-latest
strategy:
matrix:
include:
- distro: centos7
playbook: converge.yml
- distro: ubuntu1804
playbook: converge.yml
- distro: debian9
playbook: converge.yml
- distro: centos7
playbook: composer.yml
- distro: centos7
playbook: source.yml

steps:
- name: Check out the codebase.
uses: actions/checkout@v2
with:
path: 'geerlingguy.drush'

- name: Set up Python 3.
uses: actions/setup-python@v2
with:
python-version: '3.x'

- name: Install test dependencies.
run: pip3 install ansible molecule[docker] docker

- name: Run Molecule tests.
run: molecule test
env:
PY_COLORS: '1'
ANSIBLE_FORCE_COLOR: '1'
MOLECULE_DISTRO: ${{ matrix.distro }}
MOLECULE_PLAYBOOK: ${{ matrix.playbook }}
Loading

0 comments on commit bcb2707

Please sign in to comment.