Skip to content

Commit

Permalink
Merge pull request #58 from idealista/features/56
Browse files Browse the repository at this point in the history
Upgrade to Molecule 2.20.1 and Ansible 2.4.5.0
  • Loading branch information
José Noguera authored May 8, 2019
2 parents c334338 + 05458a9 commit d5f289f
Show file tree
Hide file tree
Showing 16 changed files with 124 additions and 157 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ tests/__pycache__
.molecule
.cache
.vagrant
tests/roles
tests/roles
Pipfile*
14 changes: 7 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
---
language: python
python: "2.7.13"
python: "2.7.15"
sudo: required
group: deprecated-2017Q4

env:
- PIPENV_IGNORE_VIRTUALENVS=1

services:
- docker

install:
- pip install ansible==2.4.2.0
- pip install molecule==1.25.0
- pip install ansible-lint==3.4.20
- pip install docker
- pip install pipenv==2018.11.26
- pipenv install -r test-requirements.txt
script:
- molecule test --driver docker
- pipenv run molecule test

notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ END OF TERMS AND CONDITIONS

APPENDIX: How to apply the Apache License to your work

Copyright 2018 Idealista S.A.U.
Copyright 2019 Idealista S.A.U.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
13 changes: 6 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ This ansible role installs a Apache Airflow server in a Debian/Ubuntu environmen

## Getting Started

These instructions will get you a copy of the role for your ansible playbook. Once launched, it will install a [Apache Airflow](https://airflow.incubator.apache.org/) server in a Debian or Ubuntu system.
These instructions will get you a copy of the role for your ansible playbook. Once launched, it will install a [Apache Airflow](https://airflow.apache.org/) server in a Debian or Ubuntu system.

### Prerequisities

Ansible 2.4.1.0 version installed.
Ansible 2.4.5.0 version installed.
Inventory destination should be a Debian or Ubuntu environment.

For testing purposes, [Molecule](https://molecule.readthedocs.io/) with [Vagrant](https://www.vagrantup.com/) as driver (with [landrush](https://github.com/vagrant-landrush/landrush) plugin) and [VirtualBox](https://www.virtualbox.org/) as provider.
For testing purposes, [Molecule](https://molecule.readthedocs.io/) with [Docker](https://www.docker.com/) as driver.

### Installing

Expand Down Expand Up @@ -75,14 +75,13 @@ airflow_required_python_packages:
## Testing
```
molecule test --platform=Debian9
pipenv install -r test-requirements.txt --python 2.7
pipenv run molecule test
```

See molecule.yml to check possible testing platforms.

## Built With

![Ansible](https://img.shields.io/badge/ansible-2.4.1.0-green.svg)
![Ansible](https://img.shields.io/badge/ansible-2.4.5.0-green.svg)

## Versioning

Expand Down
5 changes: 1 addition & 4 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
galaxy_info:
company: Idealista S.A.U.
description: Apache Airflow role
min_ansible_version: 2.4.1.0
min_ansible_version: 2.4.5.0
license: Apache 2.0
platforms:
- name: Debian
versions:
- stretch
- name: Ubuntu
versions:
- xenial
95 changes: 0 additions & 95 deletions molecule.yml

This file was deleted.

9 changes: 9 additions & 0 deletions molecule/default/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Molecule managed

{% if item.registry is defined %}
FROM {{ item.registry.url }}/{{ item.image }}
{% else %}
FROM {{ item.image }}
{% endif %}

RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get upgrade -y && apt-get install -y python sudo bash ca-certificates systemd systemd-sysv && apt-get clean; fi
File renamed without changes.
File renamed without changes.
33 changes: 33 additions & 0 deletions molecule/default/molecule.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
dependency:
name: galaxy
driver:
name: docker
lint:
name: yamllint
enabled: False

platforms:
- name: airflow-${MOLECULE_DISTRO:-stretch}
image: debian:${MOLECULE_DISTRO:-stretch}
privileged: true
capabilities:
- SYS_ADMIN
volumes:
- '/sys/fs/cgroup:/sys/fs/cgroup:ro'
groups:
- airflow
command: '/lib/systemd/systemd'

provisioner:
name: ansible
lint:
name: ansible-lint
enabled: False
scenario:
name: default
verifier:
name: goss
lint:
name: yamllint
enabled: False
6 changes: 6 additions & 0 deletions molecule/default/playbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---

- name: Converge
hosts: all
roles:
- role: airflow-role
File renamed without changes.
56 changes: 56 additions & 0 deletions molecule/default/verify.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
# This is an example playbook to execute goss tests.
# Tests need distributed to the appropriate ansible host/groups
# prior to execution by `goss validate`.

- name: Verify
hosts: all
become: true
vars:
goss_version: v0.3.6
goss_arch: amd64
goss_dst: /usr/local/bin/goss
goss_url: "https://github.com/aelsabbahy/goss/releases/download/{{ goss_version }}/goss-linux-{{ goss_arch }}"
goss_test_directory: /tmp
goss_format: documentation

vars_files:
- ../../defaults/main.yml
- ./group_vars/airflow/main.yml

tasks:
- name: Download and install Goss
get_url:
url: "{{ goss_url }}"
dest: "{{ goss_dst }}"
mode: 0755
register: download_goss
until: download_goss is succeeded
retries: 3

- name: Copy Goss tests to remote
template:
src: "{{ item }}"
dest: "{{ goss_test_directory }}/{{ item | basename }}"
with_fileglob:
- "{{ lookup('env', 'MOLECULE_VERIFIER_TEST_DIRECTORY') }}/test_*.yml"

- name: Register test files
shell: "ls {{ goss_test_directory }}/test_*.yml"
register: test_files

- name: Execute Goss tests
command: "{{ goss_dst }} -g {{ item }} validate --format {{ goss_format }} --retry-timeout 2"
register: test_results
with_items: "{{ test_files.stdout_lines }}"

- name: Display details about the Goss results
debug:
msg: "{{ item.stdout_lines }}"
with_items: "{{ test_results.results }}"

- name: Fail when tests fail
fail:
msg: "Goss failed to validate"
when: item.rc != 0
with_items: "{{ test_results.results }}"
3 changes: 3 additions & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ansible==2.4.5.0
molecule==2.20.1
docker==3.7.2
31 changes: 0 additions & 31 deletions tests/goss/verifier.yml

This file was deleted.

11 changes: 0 additions & 11 deletions tests/playbook.yml

This file was deleted.

0 comments on commit d5f289f

Please sign in to comment.