From 8692bc2704f2a38890c93577e8f6743e611d5308 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ga=C3=ABtan=20Duchaussois?= Date: Thu, 22 Feb 2018 14:01:02 +0100 Subject: [PATCH] add travis file --- .travis.yml | 29 +++++++++++++++++++++++++++++ README.md | 2 +- tasks/addon.yml | 4 ++-- tasks/environment.yml | 2 +- tasks/main.yml | 6 +++--- tasks/setup.yml | 5 ++++- 6 files changed, 40 insertions(+), 8 deletions(-) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..49e7e1c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,29 @@ +--- +language: python +python: "2.7" + +# Use the new container infrastructure +sudo: false + +# Install ansible +addons: + apt: + packages: + - python-pip + +install: + # Install ansible + - pip install ansible + + # Check ansible version + - ansible --version + + # Create ansible.cfg with correct roles_path + - printf '[defaults]\nroles_path=../' >ansible.cfg + +script: + # Basic role syntax check + - ansible-playbook tests/test.yml -i tests/inventory --syntax-check + +notifications: + webhooks: https://galaxy.ansible.com/api/v1/notifications/ diff --git a/README.md b/README.md index 2ab8663..b049e6e 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Variables for the application - `clever_env`: a dict of environment variables for the application (without add_ons one already available), optional. - `clever_addons`: a list of dict describing addons enabled for the application from which we would use information during deploy, optional.
Example: `{ name: pg, env_prefix: POSTGRESQL_ADDON }` -- `clever_app_role`: role to be executed after environment and addons variables where gathered. Specific to an app, should be use to run migrations. Optional. +- `clever_app_tasks`: tasks file to be executed after environment and addons variables where gathered. Specific to an app, should be use to run migrations. Optional. - `domain`: the domain from which the application should be reachable, optional - `syslog_server`: UDP Syslog server to be used as UDPSyslog drain for the application, optional. Example: `udp://198.51.100.51:12345`. diff --git a/tasks/addon.yml b/tasks/addon.yml index cde7a1a..f6a4d14 100644 --- a/tasks/addon.yml +++ b/tasks/addon.yml @@ -1,9 +1,9 @@ - name: Gather addon information for {{ addon.name }} - shell: "clever env | grep {{ addon.env_prefix }} | sed -e 's/{{ addon.env_prefix }}_//' -e 's/=/: \"/' -e 's/$/\"/' > .clever-cloud/{{ addon.name }}_env.yml" + shell: "clever env | grep {{ addon.env_prefix }} | sed -e 's/{{ addon.env_prefix }}_//' -e 's/=/: \"/' -e 's/$/\"/' > {{ clever_app_confdir }}/{{ addon.name }}_env.yml" environment: CONFIGURATION_FILE: "{{ clever_login_file }}" - name: Include addon var for {{ addon.name }} include_vars: - file: "{{ addon.name }}_env.yml" + file: "{{ clever_app_confdir }}/{{ addon.name }}_env.yml" name: "{{ addon.name }}" diff --git a/tasks/environment.yml b/tasks/environment.yml index 3d1ddbf..1508ad4 100644 --- a/tasks/environment.yml +++ b/tasks/environment.yml @@ -4,7 +4,7 @@ dest: "{{ clever_app_confdir }}/env" no_log: true -- name: Create add_ons variable file +- name: Create addons variable file include_tasks: addon.yml vars: addon: "{{ item }}" diff --git a/tasks/main.yml b/tasks/main.yml index 539e591..fa23f6c 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -18,9 +18,9 @@ - clever - clever-env -- name: Include specific role - include_role: "{{ clever_app_role }}" - when: clever_app_role +- name: Include specific tasks + include_tasks: "{{ clever_app_tasks }}" + when: clever_app_tasks is defined tags: - clever - clever-specific-role diff --git a/tasks/setup.yml b/tasks/setup.yml index 49e91ca..ac9fdcb 100644 --- a/tasks/setup.yml +++ b/tasks/setup.yml @@ -1,7 +1,7 @@ - name: Check if clever command is available in path and version command: clever --version register: clever_returned_version - ignore_error: true + ignore_errors: true - name: Ensure user path exists file: @@ -11,6 +11,8 @@ - name: Download and install clever cli tools if necessary unarchive: remote_src: yes + extra_opts: + - "--strip-components=1" src: https://clever-tools.cellar.services.clever-cloud.com/releases/{{ clever_cli_version }}/clever-tools-{{ clever_cli_version }}_linux.tar.gz dest: "{{ ansible_env.HOME }}/{{ clever_user_path }}" when: clever_returned_version|failed or clever_returned_version.stdout != clever_cli_version @@ -19,6 +21,7 @@ copy: src: "{{ item }}" dest: "{{ ansible_env.HOME }}/{{ clever_user_path }}/{{ item }}" + mode: 0755 with_items: - clever-set-domain.sh - clever-set-drain.sh -- 2.41.0