aboutsummaryrefslogtreecommitdiffhomepage
path: root/tasks
diff options
context:
space:
mode:
Diffstat (limited to 'tasks')
-rw-r--r--tasks/addon.yml9
-rw-r--r--tasks/deploy.yml30
-rw-r--r--tasks/environment.yml11
-rw-r--r--tasks/login.yml15
-rw-r--r--tasks/main.yml32
-rw-r--r--tasks/setup.yml25
6 files changed, 122 insertions, 0 deletions
diff --git a/tasks/addon.yml b/tasks/addon.yml
new file mode 100644
index 0000000..cde7a1a
--- /dev/null
+++ b/tasks/addon.yml
@@ -0,0 +1,9 @@
1- name: Gather addon information for {{ addon.name }}
2 shell: "clever env | grep {{ addon.env_prefix }} | sed -e 's/{{ addon.env_prefix }}_//' -e 's/=/: \"/' -e 's/$/\"/' > .clever-cloud/{{ addon.name }}_env.yml"
3 environment:
4 CONFIGURATION_FILE: "{{ clever_login_file }}"
5
6- name: Include addon var for {{ addon.name }}
7 include_vars:
8 file: "{{ addon.name }}_env.yml"
9 name: "{{ addon.name }}"
diff --git a/tasks/deploy.yml b/tasks/deploy.yml
new file mode 100644
index 0000000..8b98d8c
--- /dev/null
+++ b/tasks/deploy.yml
@@ -0,0 +1,30 @@
1- name: Configure Drain
2 when: syslog_server is defined
3 command: clever-set-drain.sh
4 environment:
5 SYSLOG_UDP_SERVER: "{{ syslog_server }}"
6 CONFIGURATION_FILE: "{{ clever_login_file }}"
7
8- name: Configure Domain
9 when: domain is defined
10 command: clever-set-domain.sh
11 environment:
12 DOMAIN: "{{ domain }}"
13 CONFIGURATION_FILE: "{{ clever_login_file }}"
14
15- name: Push Environment
16 shell: "clever env import < {{ clever_app_confdir }}/env"
17 environment:
18 CONFIGURATION_FILE: "{{ clever_login_file }}"
19
20#TODO: Improve ssh-key validation
21- name: Accept Clever-Cloud servers
22 shell: "ssh-keyscan -H push-par-clevercloud-customers.services.clever-cloud.com >> ~/.ssh/known_hosts"
23
24- name: Push to Clever-Cloud to trigger deployment
25 command: "git push --force git+ssh://git@push-par-clevercloud-customers.services.clever-cloud.com/{{ clever_app }}.git HEAD:refs/heads/master"
26
27- name: Wait until deployment completion
28 command: clever-wait-deploy.sh
29 environment:
30 CONFIGURATION_FILE: "{{ clever_login_file }}"
diff --git a/tasks/environment.yml b/tasks/environment.yml
new file mode 100644
index 0000000..3d1ddbf
--- /dev/null
+++ b/tasks/environment.yml
@@ -0,0 +1,11 @@
1- name: Create environment file
2 template:
3 src: env.j2
4 dest: "{{ clever_app_confdir }}/env"
5 no_log: true
6
7- name: Create add_ons variable file
8 include_tasks: addon.yml
9 vars:
10 addon: "{{ item }}"
11 with_items: "{{ clever_addons }}"
diff --git a/tasks/login.yml b/tasks/login.yml
new file mode 100644
index 0000000..0eb310f
--- /dev/null
+++ b/tasks/login.yml
@@ -0,0 +1,15 @@
1- name: Create .clever-cloud directory
2 file:
3 path: "{{ clever_app_confdir }}"
4 state: directory
5
6- name: Fill the login file
7 template:
8 src: cleverlogin.j2
9 dest: "{{ clever_login_file }}"
10 no_log: true
11
12- name: Link app
13 shell: clever link {{ clever_app }}
14 environment:
15 CONFIGURATION_FILE: "{{ clever_login_file }}"
diff --git a/tasks/main.yml b/tasks/main.yml
new file mode 100644
index 0000000..539e591
--- /dev/null
+++ b/tasks/main.yml
@@ -0,0 +1,32 @@
1---
2# tasks file for clever
3- name: Setup environment for clever
4 include_tasks: setup.yml
5 tags:
6 - clever
7 - clever-setup
8
9- name: Login to clever
10 include_tasks: login.yml
11 tags:
12 - clever
13 - clever-login
14
15- name: Manage environment
16 include_tasks: environment.yml
17 tags:
18 - clever
19 - clever-env
20
21- name: Include specific role
22 include_role: "{{ clever_app_role }}"
23 when: clever_app_role
24 tags:
25 - clever
26 - clever-specific-role
27
28- name: Deploy app
29 include_tasks: deploy.yml
30 tags:
31 - clever
32 - clever-deploy
diff --git a/tasks/setup.yml b/tasks/setup.yml
new file mode 100644
index 0000000..49e91ca
--- /dev/null
+++ b/tasks/setup.yml
@@ -0,0 +1,25 @@
1- name: Check if clever command is available in path and version
2 command: clever --version
3 register: clever_returned_version
4 ignore_error: true
5
6- name: Ensure user path exists
7 file:
8 path: "{{ ansible_env.HOME }}/{{ clever_user_path }}"
9 state: directory
10
11- name: Download and install clever cli tools if necessary
12 unarchive:
13 remote_src: yes
14 src: https://clever-tools.cellar.services.clever-cloud.com/releases/{{ clever_cli_version }}/clever-tools-{{ clever_cli_version }}_linux.tar.gz
15 dest: "{{ ansible_env.HOME }}/{{ clever_user_path }}"
16 when: clever_returned_version|failed or clever_returned_version.stdout != clever_cli_version
17
18- name: Install helper scripts
19 copy:
20 src: "{{ item }}"
21 dest: "{{ ansible_env.HOME }}/{{ clever_user_path }}/{{ item }}"
22 with_items:
23 - clever-set-domain.sh
24 - clever-set-drain.sh
25 - clever-wait-deploy.sh