Skip to content

Commit

Permalink
Merge pull request #12 from idealista/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
jmonterrubio authored Dec 18, 2018
2 parents 3fdb827 + 31dbce5 commit 770af53
Show file tree
Hide file tree
Showing 29 changed files with 294 additions and 224 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ tests/__pycache__
.cache
.vagrant
venv/
*.pyc
*.pyc
Pipfile
Pipfile.lock
19 changes: 11 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
---
language: python
python: "2.7.13"
sudo: required
group: deprecated-2017Q4

services:
- docker

install:
- pip install ansible==2.4.0.0
- pip install molecule==1.25.0
- pip install ansible-lint==3.4.20
- pip install docker
matrix:
include:
- python: 2.7
env: REQUIREMENTS=test-requirements-27.txt
- python: 3.6
env: REQUIREMENTS=test-requirements-36.txt
fast_finish: true

install:
- pip install pipenv
- pipenv install -r $REQUIREMENTS
script:
- molecule test --driver docker
- pipenv run molecule test

notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/
18 changes: 18 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

extends: default

rules:
braces:
max-spaces-inside: 1
level: error
brackets:
max-spaces-inside: 1
level: error
line-length: disable
# NOTE(retr0h): Templates no longer fail this lint rule.
# Uncomment if running old Molecule templates.
# truthy: disable

ignore: |
.molecule/
molecule/
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a ch

[Full Changelog](https://github.com/idealista/consul_keystore-role/compare/master...develop)

## [1.0.2] - 2018-12-18

### Fixed

- *[#10](https://github.com/idealista/consul-keystore_role/issues/10) Fix problem removing properties in python 3* @jmonterrubio

## [1.0.1] - 2018-11-13

### Fixed
Expand All @@ -21,6 +27,7 @@ This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a ch

*Initial version* @jmonterrubio

[1.0.2]: https://github.com/idealista/consul_keystore-role/tree/1.0.2
[1.0.1]: https://github.com/idealista/consul_keystore-role/tree/1.0.1
[1.0.0]: https://github.com/idealista/consul_keystore-role/tree/1.0.0
[Unreleased]: https://github.com/idealista/consul_keystore-role/tree/develop
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ These instructions will get you a copy of the role for your Ansible Playbook. On

### Prerequisities

Ansible 2.4.3.0 version installed.
Molecule 1.25 version installed.
Ansible-Lint 3.4.20 version installed.
python-consul 1.1.0 version installed
Ansible 2.5.5.0
Python 3.6 or Python 2.7
Other combinations may work but they're not tested.

Inventory destination should be a Debian environment.

For testing purposes, [Molecule](https://molecule.readthedocs.io/) with [Vagrant](https://www.vagrantup.com/) as driver (with [hostmanager](https://github.com/devopsgroup-io/vagrant-hostmanager) 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.
See [test-requirements-27](test-requirements-27.txt) and [test-requirements-36](test-requirements-36.txt).

### Installing

Expand Down Expand Up @@ -66,18 +66,20 @@ Look to the [defaults](defaults/main.yml) properties file to see the possible co
## Testing
```sh
molecule test
$ pipenv install -r test-requirements-27.txt --python 2.7
$ pipenv run molecule test
```

or
and

```sh
./tests/scripts/run-test.sh
$ pipenv install -r test-requirements-36.txt --python 3.6
$ pipenv run molecule test
```

## Built With

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

## Versioning

Expand Down
2 changes: 1 addition & 1 deletion filter_plugins/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ class FilterModule(object):

def filters(self):
return {
'flatten': flatten
'flatten_collection': flatten
}
2 changes: 1 addition & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
galaxy_info:
company: Idealista S.A.U.
description: Consul Keystore Manager
min_ansible_version: 2.4.3.0
min_ansible_version: 2.5.5.0
license: Apache 2.0
platforms:
- name: Debian
Expand Down
135 changes: 0 additions & 135 deletions molecule.yml

This file was deleted.

13 changes: 13 additions & 0 deletions molecule/default/Dockerfile.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# 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 && apt-get clean; \
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python2-dnf bash && dnf clean all; \
elif [ $(command -v yum) ]; then yum makecache fast && yum update -y && yum install -y python sudo yum-plugin-ovl bash && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
elif [ $(command -v zypper) ]; then zypper refresh && zypper update -y && zypper install -y python sudo bash python-xml && zypper clean -a; \
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates; fi
Empty file added molecule/default/INSTALL.rst
Empty file.
69 changes: 69 additions & 0 deletions molecule/default/create.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
- name: Create
hosts: localhost
connection: local
gather_facts: false
no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}"
vars:
molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}"
molecule_ephemeral_directory: "{{ lookup('env', 'MOLECULE_EPHEMERAL_DIRECTORY') }}"
molecule_scenario_directory: "{{ lookup('env', 'MOLECULE_SCENARIO_DIRECTORY') }}"
molecule_yml: "{{ lookup('file', molecule_file) | molecule_from_yaml }}"
tasks:
- name: Create Dockerfiles from image names
template:
src: "{{ molecule_scenario_directory }}/Dockerfile.j2"
dest: "{{ molecule_ephemeral_directory }}/Dockerfile_{{ item.image | regex_replace('[^a-zA-Z0-9_]', '_') }}"
with_items: "{{ molecule_yml.platforms }}"
register: platforms

- name: Discover local Docker images
docker_image_facts:
name: "molecule_local/{{ item.item.name }}"
with_items: "{{ platforms.results }}"
register: docker_images

- name: Build an Ansible compatible image
docker_image:
path: "{{ molecule_ephemeral_directory }}"
name: "molecule_local/{{ item.item.image }}"
dockerfile: "{{ item.item.dockerfile | default(item.invocation.module_args.dest) }}"
force: "{{ item.item.force | default(true) }}"
with_items: "{{ platforms.results }}"
when: platforms.changed or docker_images.results | map(attribute='images') | select('equalto', []) | list | count >= 0

- name: Create docker network(s)
docker_network:
name: "{{ item }}"
state: present
with_items: "{{ molecule_yml.platforms | molecule_get_docker_networks }}"

- name: Create molecule instance(s)
docker_container:
name: "{{ item.name }}"
hostname: "{{ item.name }}"
image: "molecule_local/{{ item.image }}"
state: started
recreate: false
log_driver: json-file
command: "{{ item.command | default('bash -c \"while true; do sleep 10000; done\"') }}"
privileged: "{{ item.privileged | default(omit) }}"
volumes: "{{ item.volumes | default(omit) }}"
capabilities: "{{ item.capabilities | default(omit) }}"
exposed_ports: "{{ item.exposed_ports | default(omit) }}"
published_ports: "{{ item.published_ports | default(omit) }}"
ulimits: "{{ item.ulimits | default(omit) }}"
networks: "{{ item.networks | default(omit) }}"
dns_servers: "{{ item.dns_servers | default(omit) }}"
register: server
with_items: "{{ molecule_yml.platforms }}"
async: 7200
poll: 0

- name: Wait for instance(s) creation to complete
async_status:
jid: "{{ item.ansible_job_id }}"
register: docker_jobs
until: docker_jobs.finished
retries: 300
with_items: "{{ server.results }}"
Loading

0 comments on commit 770af53

Please sign in to comment.