From e1db9541320daa1c60d529aeb4f9023d653241b9 Mon Sep 17 00:00:00 2001 From: Javier Monterrubio Date: Mon, 17 Dec 2018 18:54:25 +0100 Subject: [PATCH 1/6] Fix problem removing properties in python 3 --- .gitignore | 4 +- .travis.yml | 18 ++- .yamllint | 18 +++ CHANGELOG.md | 7 + README.md | 17 +-- filter_plugins/collection.py | 2 +- molecule.yml | 135 ------------------ molecule/default/Dockerfile.j2 | 13 ++ molecule/default/INSTALL.rst | 0 molecule/default/create.yml | 69 +++++++++ molecule/default/destroy.yml | 33 +++++ .../files/consul/another_properties.yml | 0 .../default}/files/consul/more.properties | 0 .../default}/files/consul/some_properties.yml | 0 .../default}/group_vars/all.yml | 4 +- .../default/group_vars/consul.yml | 0 molecule/default/molecule.yml | 33 +++++ molecule/default/playbook.yml | 6 + molecule/default/prepare.yml | 17 +++ {tests => molecule/default}/requirements.yml | 0 .../default/tests/test_consul_keystore.yml | 0 molecule/default/verify.yml | 59 ++++++++ tasks/consul_keys_publication.yml | 10 +- test-requirements.txt | 3 + tests/goss/verifier.yml | 33 ----- tests/playbook.yml | 13 -- tests/scripts/run-test.sh | 15 -- 27 files changed, 284 insertions(+), 225 deletions(-) create mode 100644 .yamllint delete mode 100644 molecule.yml create mode 100644 molecule/default/Dockerfile.j2 create mode 100644 molecule/default/INSTALL.rst create mode 100644 molecule/default/create.yml create mode 100644 molecule/default/destroy.yml rename {tests => molecule/default}/files/consul/another_properties.yml (100%) rename {tests => molecule/default}/files/consul/more.properties (100%) rename {tests => molecule/default}/files/consul/some_properties.yml (100%) rename {tests => molecule/default}/group_vars/all.yml (96%) rename tests/group_vars/consul_server.yml => molecule/default/group_vars/consul.yml (100%) create mode 100644 molecule/default/molecule.yml create mode 100644 molecule/default/playbook.yml create mode 100644 molecule/default/prepare.yml rename {tests => molecule/default}/requirements.yml (100%) rename tests/goss/specs/consul_keystore.yml.j2 => molecule/default/tests/test_consul_keystore.yml (100%) create mode 100644 molecule/default/verify.yml create mode 100644 test-requirements.txt delete mode 100644 tests/goss/verifier.yml delete mode 100644 tests/playbook.yml delete mode 100755 tests/scripts/run-test.sh diff --git a/.gitignore b/.gitignore index 3023c47..da2fbb3 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,6 @@ tests/__pycache__ .cache .vagrant venv/ -*.pyc \ No newline at end of file +*.pyc +Pipfile +Pipfile.lock \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 3f3b39b..b612e40 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,19 +2,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: + - env: ENV_PYTHON=2.7 + - env: ENV_PYTHON=3.6 + fast_finish: true +install: + - pip install pipenv + - pipenv install -r test-requirements.txt --python $ENV_PYTHON script: - - molecule test --driver docker + - pipenv run molecule test + - pipenv --rm + - rm Pipfile* notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/.yamllint b/.yamllint new file mode 100644 index 0000000..a90f779 --- /dev/null +++ b/.yamllint @@ -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/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 6fa0da8..14a58e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -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 diff --git a/README.md b/README.md index e39e0cb..a01837c 100644 --- a/README.md +++ b/README.md @@ -23,14 +23,12 @@ 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.4.3.0 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](test-requirements.txt). ### Installing @@ -66,13 +64,8 @@ Look to the [defaults](defaults/main.yml) properties file to see the possible co ## Testing ```sh -molecule test -``` - -or - -```sh -./tests/scripts/run-test.sh +$ pipenv install -r test-requirements.txt --python 2.7 +$ pipenv run molecule test ``` ## Built With diff --git a/filter_plugins/collection.py b/filter_plugins/collection.py index a99687d..9a6ff98 100644 --- a/filter_plugins/collection.py +++ b/filter_plugins/collection.py @@ -25,5 +25,5 @@ class FilterModule(object): def filters(self): return { - 'flatten': flatten + 'flatten_collection': flatten } \ No newline at end of file diff --git a/molecule.yml b/molecule.yml deleted file mode 100644 index c7efa78..0000000 --- a/molecule.yml +++ /dev/null @@ -1,135 +0,0 @@ ---- -molecule: - # directory in CWD to place all temp files, etc. - molecule_dir: .molecule - - # where temporary state will be stored (lives under molecule_dir) - state_file: state - - # name of temporary vagrantfile created during runs (lives under molecule_dir) - vagrantfile_file: vagrantfile - - # directories to ignore when doing trailing whitespace checks on files during verify command - ignore_paths: - - .git - - .vagrant - - .molecule - - venv - - # directory to look for goss tests - goss_dir: tests/goss - goss_playbook: verifier.yml - - # directory containing group_vars to use with ansible - group_vars: ../tests/group_vars - -# ansible related config -ansible: - playbook: tests/playbook.yml - -dependency: - name: galaxy - requirements_file: tests/requirements.yml - -# configuration options for the internal call to vagrant -vagrant: - raw_config_args: - - "hostmanager.enabled = true" - # Enable for debug purpose - # - "hostmanager.manage_host = true" - - "hostmanager.manage_guest = true" - - "hostmanager.ignore_private_ip = false" - - "hostmanager.include_offline = true" - - "vbguest.auto_update = false" - # molecule's --platform option will look for these names - platforms: - - name: Debian9 - box: debian/stretch64 - - name: Debian8 - box: debian/jessie64 - - providers: - - name: virtualbox - type: virtualbox - options: - memory: 512 - cpus: 1 - - instances: - - name: consul01 - ansible_groups: - - consul_server - interfaces: - - network_name: private_network - type: static - ip: 172.28.128.75 - auto_config: true - - - name: consul02 - ansible_groups: - - consul_server - interfaces: - - network_name: private_network - type: static - ip: 172.28.128.76 - auto_config: true - - - name: consul03 - ansible_groups: - - consul_server - interfaces: - - network_name: private_network - ip: 172.28.128.77 - type: static - auto_config: true - -docker: - network: - - name: consul-network - driver: bridge - - containers: - - name: consul01 - hostname: consul01 - ansible_groups: - - consul_server - image: geerlingguy/docker-debian9-ansible - image_version: latest - privileged: True - cap_add: - - SYS_ADMIN - volume_mounts: - - '/sys/fs/cgroup:/sys/fs/cgroup:ro' - command: '/lib/systemd/systemd' - network_mode: consul-network - - - name: consul02 - hostname: consul02 - ansible_groups: - - consul_server - image: geerlingguy/docker-debian9-ansible - image_version: latest - privileged: True - cap_add: - - SYS_ADMIN - volume_mounts: - - '/sys/fs/cgroup:/sys/fs/cgroup:ro' - command: '/lib/systemd/systemd' - network_mode: consul-network - - - name: consul03 - hostname: consul03 - ansible_groups: - - consul_server - image: geerlingguy/docker-debian9-ansible - image_version: latest - privileged: True - cap_add: - - SYS_ADMIN - volume_mounts: - - '/sys/fs/cgroup:/sys/fs/cgroup:ro' - command: '/lib/systemd/systemd' - network_mode: consul-network - -verifier: - name: goss diff --git a/molecule/default/Dockerfile.j2 b/molecule/default/Dockerfile.j2 new file mode 100644 index 0000000..56b6155 --- /dev/null +++ b/molecule/default/Dockerfile.j2 @@ -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 \ No newline at end of file diff --git a/molecule/default/INSTALL.rst b/molecule/default/INSTALL.rst new file mode 100644 index 0000000..e69de29 diff --git a/molecule/default/create.yml b/molecule/default/create.yml new file mode 100644 index 0000000..d95d7f0 --- /dev/null +++ b/molecule/default/create.yml @@ -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 }}" \ No newline at end of file diff --git a/molecule/default/destroy.yml b/molecule/default/destroy.yml new file mode 100644 index 0000000..1197edf --- /dev/null +++ b/molecule/default/destroy.yml @@ -0,0 +1,33 @@ +--- +- name: Destroy + hosts: localhost + connection: local + gather_facts: false + no_log: "{{ not lookup('env', 'MOLECULE_DEBUG') | bool }}" + vars: + molecule_file: "{{ lookup('env', 'MOLECULE_FILE') }}" + molecule_yml: "{{ lookup('file', molecule_file) | molecule_from_yaml }}" + tasks: + - name: Destroy molecule instance(s) + docker_container: + name: "{{ item.name }}" + state: absent + force_kill: "{{ item.force_kill | default(true) }}" + register: server + with_items: "{{ molecule_yml.platforms }}" + async: 7200 + poll: 0 + + - name: Wait for instance(s) deletion to complete + async_status: + jid: "{{ item.ansible_job_id }}" + register: docker_jobs + until: docker_jobs.finished + retries: 300 + with_items: "{{ server.results }}" + + - name: Delete docker network(s) + docker_network: + name: "{{ item }}" + state: absent + with_items: "{{ molecule_yml.platforms | molecule_get_docker_networks }}" \ No newline at end of file diff --git a/tests/files/consul/another_properties.yml b/molecule/default/files/consul/another_properties.yml similarity index 100% rename from tests/files/consul/another_properties.yml rename to molecule/default/files/consul/another_properties.yml diff --git a/tests/files/consul/more.properties b/molecule/default/files/consul/more.properties similarity index 100% rename from tests/files/consul/more.properties rename to molecule/default/files/consul/more.properties diff --git a/tests/files/consul/some_properties.yml b/molecule/default/files/consul/some_properties.yml similarity index 100% rename from tests/files/consul/some_properties.yml rename to molecule/default/files/consul/some_properties.yml diff --git a/tests/group_vars/all.yml b/molecule/default/group_vars/all.yml similarity index 96% rename from tests/group_vars/all.yml rename to molecule/default/group_vars/all.yml index 91b2107..01b561d 100644 --- a/tests/group_vars/all.yml +++ b/molecule/default/group_vars/all.yml @@ -1,8 +1,6 @@ --- consul_server_nodes: - consul01 - - consul02 - - consul03 consul_domain: test consul_datacenter: test @@ -47,4 +45,4 @@ consul_keystore_expand_keys: true consul_keystore_properties_files: - some_properties - another_properties - - more \ No newline at end of file + - more diff --git a/tests/group_vars/consul_server.yml b/molecule/default/group_vars/consul.yml similarity index 100% rename from tests/group_vars/consul_server.yml rename to molecule/default/group_vars/consul.yml diff --git a/molecule/default/molecule.yml b/molecule/default/molecule.yml new file mode 100644 index 0000000..10a26d5 --- /dev/null +++ b/molecule/default/molecule.yml @@ -0,0 +1,33 @@ +--- +dependency: + name: galaxy +driver: + name: docker +lint: + name: yamllint + options: + config-file: .yamllint + +platforms: + - name: consul01 + groups: + - consul + image: geerlingguy/docker-debian9-ansible + image_version: latest + privileged: true + cap_add: + - SYS_ADMIN + volumes: + - '/sys/fs/cgroup:/sys/fs/cgroup:ro' + command: '/lib/systemd/systemd' + +provisioner: + name: ansible + lint: + name: ansible-lint +scenario: + name: default +verifier: + name: goss + lint: + name: yamllint diff --git a/molecule/default/playbook.yml b/molecule/default/playbook.yml new file mode 100644 index 0000000..91b1f1a --- /dev/null +++ b/molecule/default/playbook.yml @@ -0,0 +1,6 @@ +--- + +- name: Environment + hosts: consul + roles: + - consul_keystore-role \ No newline at end of file diff --git a/molecule/default/prepare.yml b/molecule/default/prepare.yml new file mode 100644 index 0000000..ed45990 --- /dev/null +++ b/molecule/default/prepare.yml @@ -0,0 +1,17 @@ +--- +- name: Prepare + hosts: all + gather_facts: false + tasks: + - name: installing required libs + apt: + pkg: "{{ item }}" + state: present + with_items: + - net-tools + - netcat + +- name: Environment + hosts: consul + roles: + - consul diff --git a/tests/requirements.yml b/molecule/default/requirements.yml similarity index 100% rename from tests/requirements.yml rename to molecule/default/requirements.yml diff --git a/tests/goss/specs/consul_keystore.yml.j2 b/molecule/default/tests/test_consul_keystore.yml similarity index 100% rename from tests/goss/specs/consul_keystore.yml.j2 rename to molecule/default/tests/test_consul_keystore.yml diff --git a/molecule/default/verify.yml b/molecule/default/verify.yml new file mode 100644 index 0000000..2bf65d6 --- /dev/null +++ b/molecule/default/verify.yml @@ -0,0 +1,59 @@ +--- +# This is an example playbook to execute goss tests. +# Tests need distributed to the appropriate ansible host/groups +# prior to execution by `goss validate`. +# +# The goss ansible module is installed with molecule. The ANSIBLE_LIBRARY +# path is updated appropriately on `molecule verify`. + +# Details about ansible module: +# - https://github.com/indusbox/goss-ansible + +- name: Verify + hosts: all + 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/consul.yml + + tasks: + - name: Download and install goss + get_url: + url: "{{ goss_url }}" + dest: "{{ goss_dst }}" + mode: 0755 + + - name: Copy tests to remote + template: + src: "{{ item }}" + dest: "{{ goss_test_directory }}/{{ item | basename }}" + with_fileglob: + - "{{ playbook_dir }}/tests/test_*.yml" + + - name: Register test files + shell: "ls {{ goss_test_directory }}/test_*.yml" + register: test_files + + - name: Execute Goss tests + command: "goss -g {{ item }} validate --format {{ goss_format }}" + register: test_results + with_items: "{{ test_files.stdout_lines }}" + ignore_errors: true + + - 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 }}" diff --git a/tasks/consul_keys_publication.yml b/tasks/consul_keys_publication.yml index 47fc312..8cc2f8e 100644 --- a/tasks/consul_keys_publication.yml +++ b/tasks/consul_keys_publication.yml @@ -22,7 +22,7 @@ - name: Set consul_to_upload_properties set_fact: - consul_to_upload_properties: "{{ consul_yaml_file | flatten(sep=consul_key_separator) }}" + consul_to_upload_properties: "{{ consul_yaml_file | flatten_collection(sep=consul_key_separator) }}" - name: Consul | Read {{ consul_key_parent }} properties consul_keystore: @@ -30,13 +30,13 @@ port: "{{ consul_keystore_http_port }}" token: "{{ consul_keystore_acl_token }}" key: "{{ consul_key_parent + '/' }}" - recurse: yes + recurse: true state: present register: consul_backup_properties - name: Set consul_backup_keys set_fact: - consul_backup_keys: "{{ consul_backup_properties.data | map(attribute='Key') | map('regex_replace', consul_key_parent + '/') | list | filter }}" + consul_backup_keys: "{{ consul_backup_properties.data | map(attribute='Key') | map('regex_replace', consul_key_parent + '/') | list | filter | list}}" - name: Update consul_backup_keys expanded set_fact: @@ -93,13 +93,13 @@ port: "{{ consul_keystore_http_port }}" token: "{{ consul_keystore_acl_token }}" key: "{{ consul_key_parent + '/' }}" - recurse: yes + recurse: true state: present register: consul_backup_properties - name: Set consul_backup_keys set_fact: - consul_backup_keys: "{{ consul_backup_properties.data | map(attribute='Key') | map('regex_replace', consul_key_parent + '/') | list | filter }}" + consul_backup_keys: "{{ consul_backup_properties.data | map(attribute='Key') | map('regex_replace', consul_key_parent + '/') | list | filter | list }}" - name: Update consul_backup_keys expanded set_fact: diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 0000000..69b795c --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,3 @@ +ansible==2.5.3.0 +molecule==2.19.0 +docker==3.3.0 \ No newline at end of file diff --git a/tests/goss/verifier.yml b/tests/goss/verifier.yml deleted file mode 100644 index dbf9a5f..0000000 --- a/tests/goss/verifier.yml +++ /dev/null @@ -1,33 +0,0 @@ -- name: Testing prerequisites - hosts: all - gather_facts: yes - - vars: - goss_version: "v0.3.6" - goss_url: "https://github.com/aelsabbahy/goss/releases/download/{{ goss_version }}/goss-linux-amd64" - goss_results: goss_results - - tasks: - - include_vars: "{{ item }}" - with_items: - - ../../defaults/main.yml - - ../group_vars/all.yml - - ../group_vars/{{ group_names[0] }}.yml - - - name: Download and install Goss - get_url: - url: "{{ goss_url }}" - dest: "/usr/local/bin/goss" - mode: 0755 - - - name: Copy tests to remote - template: - src: "{{ playbook_dir }}/specs/{{ item }}.j2" - dest: "/tmp/{{ item }}" - with_items: - - consul_keystore.yml - - - name: Goss tests - command: "goss -g /tmp/{{ item }} validate -format tap" - with_items: - - consul_keystore.yml diff --git a/tests/playbook.yml b/tests/playbook.yml deleted file mode 100644 index 8d86e97..0000000 --- a/tests/playbook.yml +++ /dev/null @@ -1,13 +0,0 @@ ---- -- hosts: all - pre_tasks: - - name: Set Vagrant Consul interface - set_fact: - consul_interface: "eth1" - when: ansible_user == "vagrant" - roles: - - consul - -- hosts: consul01 - roles: - - consul_keystore-role diff --git a/tests/scripts/run-test.sh b/tests/scripts/run-test.sh deleted file mode 100755 index 503ee2d..0000000 --- a/tests/scripts/run-test.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash -set -e - -cd `dirname "$0"`/../.. -rm -rf venv -virtualenv venv -source venv/bin/activate -pip install molecule==1.25.0 -pip install ansible==2.4.3.0 -pip install ansible-lint==3.4.20 -pip install python-vagrant -pip install python-consul -molecule test -deactivate -rm -rf venv From 009719e3424d1ffb0c06d4374568f5bf6aa00d8e Mon Sep 17 00:00:00 2001 From: Javier Monterrubio Date: Tue, 18 Dec 2018 10:08:13 +0100 Subject: [PATCH 2/6] #10 Split and commented the test requirements howto --- .travis.yml | 8 +++----- test-requirements.txt => test-requirements-27.txt | 2 +- test-requirements-36.txt | 3 +++ 3 files changed, 7 insertions(+), 6 deletions(-) rename test-requirements.txt => test-requirements-27.txt (63%) create mode 100644 test-requirements-36.txt diff --git a/.travis.yml b/.travis.yml index b612e40..ec8f002 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,17 +8,15 @@ services: matrix: include: - - env: ENV_PYTHON=2.7 - - env: ENV_PYTHON=3.6 + - env: ENV_PYTHON=2.7 REQUIREMENTS=test-requirements-27.txt + - env: ENV_PYTHON=3.6 REQUIREMENTS=test-requirements-36.txt fast_finish: true install: - pip install pipenv - - pipenv install -r test-requirements.txt --python $ENV_PYTHON + - pipenv install -r $REQUIREMENTS --python $ENV_PYTHON script: - pipenv run molecule test - - pipenv --rm - - rm Pipfile* notifications: webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/test-requirements.txt b/test-requirements-27.txt similarity index 63% rename from test-requirements.txt rename to test-requirements-27.txt index 69b795c..fd9ad71 100644 --- a/test-requirements.txt +++ b/test-requirements-27.txt @@ -1,3 +1,3 @@ -ansible==2.5.3.0 +ansible==2.4.3.0 molecule==2.19.0 docker==3.3.0 \ No newline at end of file diff --git a/test-requirements-36.txt b/test-requirements-36.txt new file mode 100644 index 0000000..2bb52ef --- /dev/null +++ b/test-requirements-36.txt @@ -0,0 +1,3 @@ +ansible==2.5.5.0 +molecule==2.19.0 +docker==3.3.0 \ No newline at end of file From ce9c5aa8e3d869910486b3d081b14bb26a8476ad Mon Sep 17 00:00:00 2001 From: Javier Monterrubio Date: Tue, 18 Dec 2018 10:22:55 +0100 Subject: [PATCH 3/6] #10 Update ansible version for python 2.7 --- README.md | 15 ++++++++++++--- meta/main.yml | 2 +- test-requirements-27.txt | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index a01837c..4735498 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,9 @@ These instructions will get you a copy of the role for your Ansible Playbook. On ### Prerequisities -Ansible >= 2.4.3.0 +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. @@ -64,13 +66,20 @@ Look to the [defaults](defaults/main.yml) properties file to see the possible co ## Testing ```sh -$ pipenv install -r test-requirements.txt --python 2.7 +$ pipenv install -r test-requirements-27.txt --python 2.7 +$ pipenv run molecule test +``` + +and + +```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 diff --git a/meta/main.yml b/meta/main.yml index 9a4ccd7..17faa29 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -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 diff --git a/test-requirements-27.txt b/test-requirements-27.txt index fd9ad71..2bb52ef 100644 --- a/test-requirements-27.txt +++ b/test-requirements-27.txt @@ -1,3 +1,3 @@ -ansible==2.4.3.0 +ansible==2.5.5.0 molecule==2.19.0 docker==3.3.0 \ No newline at end of file From ed1f9e1836a122d47b733a2e54ff7a1c78e06367 Mon Sep 17 00:00:00 2001 From: Javier Monterrubio Date: Tue, 18 Dec 2018 10:28:15 +0100 Subject: [PATCH 4/6] #10 Test travis python matrix --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index ec8f002..fd2a41f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ --- language: python -python: "2.7.13" sudo: required services: @@ -8,13 +7,14 @@ services: matrix: include: - - env: ENV_PYTHON=2.7 REQUIREMENTS=test-requirements-27.txt - - env: ENV_PYTHON=3.6 REQUIREMENTS=test-requirements-36.txt + - 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 --python $ENV_PYTHON + - pipenv install -r $REQUIREMENTS script: - pipenv run molecule test From 2443a1e07a09056b76e673f9ec9c999200da7e49 Mon Sep 17 00:00:00 2001 From: Javier Monterrubio Date: Tue, 18 Dec 2018 10:31:59 +0100 Subject: [PATCH 5/6] #10 Test travis python matrix --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index fd2a41f..8a06db5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,7 @@ matrix: fast_finish: true install: + - pip install pipenv - pipenv install -r $REQUIREMENTS script: - pipenv run molecule test From 80be3c326989a150ea095879aeaa19981c57fed5 Mon Sep 17 00:00:00 2001 From: Javier Monterrubio Date: Tue, 18 Dec 2018 12:07:42 +0100 Subject: [PATCH 6/6] #10 Update readme links --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4735498..ca9a31b 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,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 [Docker](https://www.docker.com/) as driver. -See [test-requirements](test-requirements.txt). +See [test-requirements-27](test-requirements-27.txt) and [test-requirements-36](test-requirements-36.txt). ### Installing