]> git.immae.eu Git - github/fretlink/ansible-clever.git/commitdiff
add travis file 1/head
authorGaëtan Duchaussois <gaetan.duchaussois@fretlink.com>
Thu, 22 Feb 2018 13:01:02 +0000 (14:01 +0100)
committerGaëtan Duchaussois <gaetan.duchaussois@fretlink.com>
Thu, 22 Feb 2018 21:56:32 +0000 (22:56 +0100)
.travis.yml [new file with mode: 0644]
README.md
tasks/addon.yml
tasks/environment.yml
tasks/main.yml
tasks/setup.yml

diff --git a/.travis.yml b/.travis.yml
new file mode 100644 (file)
index 0000000..49e7e1c
--- /dev/null
@@ -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/
index 2ab86638bebe7529a3f48eab2879f2e99bf9c199..b049e6e3470b1d4f02fa158e1b4849cb850de26f 100644 (file)
--- 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.<br/>
   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`.
 
index cde7a1a8f3f7428d0fff38addd996daf67052312..f6a4d14b5a36d44aa4c6bcdef9ca2d59e5253b80 100644 (file)
@@ -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 }}"
index 3d1ddbf94ad80acd1c9f84157bee869d2fcb8a57..1508ad44eca8171a9908747a2ef07a4e38363a46 100644 (file)
@@ -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 }}"
index 539e59119d02ba2fa859fea0c2e48e729227f335..fa23f6c79aa55da219413f9f316ca9d12bbfe8c9 100644 (file)
@@ -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
index 49e91ca7beb99ac30fe4448ed5737c099dfa18a7..ac9fdcbede233d5985847c6ef071a7f152491f13 100644 (file)
@@ -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