aboutsummaryrefslogtreecommitdiffhomepage
path: root/tasks
diff options
context:
space:
mode:
authorGaƫtan <36162164+gaetanfl@users.noreply.github.com>2018-02-23 18:10:48 +0100
committerGitHub <noreply@github.com>2018-02-23 18:10:48 +0100
commit4fdd3eb566b8b322789f74990181acc243ffb578 (patch)
tree4f0e9ffda46afe5e571d7071dd8e08c34a5b8928 /tasks
parent4882b0d33ce42a3b01ac9689d1809e362f314d3f (diff)
parent8692bc2704f2a38890c93577e8f6743e611d5308 (diff)
downloadansible-clever-4fdd3eb566b8b322789f74990181acc243ffb578.tar.gz
ansible-clever-4fdd3eb566b8b322789f74990181acc243ffb578.tar.zst
ansible-clever-4fdd3eb566b8b322789f74990181acc243ffb578.zip
Merge pull request #1 from gaetanfl/first_try
Migrating single tasks file to a galaxy role
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.yml28
6 files changed, 125 insertions, 0 deletions
diff --git a/tasks/addon.yml b/tasks/addon.yml
new file mode 100644
index 0000000..f6a4d14
--- /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_app_confdir }}/{{ 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: "{{ clever_app_confdir }}/{{ 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..1508ad4
--- /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 addons 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..fa23f6c
--- /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 tasks
22 include_tasks: "{{ clever_app_tasks }}"
23 when: clever_app_tasks is defined
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..ac9fdcb
--- /dev/null
+++ b/tasks/setup.yml
@@ -0,0 +1,28 @@
1- name: Check if clever command is available in path and version
2 command: clever --version
3 register: clever_returned_version
4 ignore_errors: 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 extra_opts:
15 - "--strip-components=1"
16 src: https://clever-tools.cellar.services.clever-cloud.com/releases/{{ clever_cli_version }}/clever-tools-{{ clever_cli_version }}_linux.tar.gz
17 dest: "{{ ansible_env.HOME }}/{{ clever_user_path }}"
18 when: clever_returned_version|failed or clever_returned_version.stdout != clever_cli_version
19
20- name: Install helper scripts
21 copy:
22 src: "{{ item }}"
23 dest: "{{ ansible_env.HOME }}/{{ clever_user_path }}/{{ item }}"
24 mode: 0755
25 with_items:
26 - clever-set-domain.sh
27 - clever-set-drain.sh
28 - clever-wait-deploy.sh