-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.yml
68 lines (62 loc) · 2.36 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
###
# Clone and deploy a project repository
#
# This module clones and deploys a project repository to clone_root, which
# should be specified in the group_vars for a particular project.
# It provides repo_info and ver, which are both used to produce the folder
# directory.
#
###
- name: Clone and deploy a project repository
block:
- name: Debug environmental variables early in deploy cycle
debug:
msg: "PATH: {{ path }} / LD_LIBRARY_PATH: {{ ld_library_path }} / PYTHONPATH: {{ python_path }} / ansible ansible_distribution_release: {{ ansible_distribution_release }}"
verbosity: 2
when: ansible_distribution == 'Springdale'
- name: Ensure deploy user has access to install root
become: true
file:
dest: "{{ install_root }}"
owner: "{{ deploy_user }}"
group: "{{ deploy_user }}"
recurse: yes
# only set owner when deploy user is defined
# (i.e. on PUL vms, where deploy user is different than remote user)
when: deploy_user is defined and ansible_distribution != 'Springdale'
- name: Clone project repository and set to the correct version
become: true
become_user: "{{ deploy_user }}"
git:
repo: "{{ repo_url }}/"
dest: "{{ clone_root }}/{{ repo }}"
version: "{{ gitref }}"
# register repo_info for group_vars
register: repo_info
- name: Get python package version
become: true
become_user: "{{ deploy_user }}"
shell:
cmd: "python -c 'import {{ django_app }}; print({{ django_app }}.__version__)'"
chdir: "{{ clone_root}}/{{ repo }}"
register: python_app_version
tags:
- django
- name: Create the deploy directory (to recursively create parent dirs if necessary)
become: true
become_user: "{{ deploy_user }}"
file:
state: directory
dest: "{{ deploy }}"
- name: Sync checkout to deploy directory
become: true
become_user: "{{ deploy_user }}"
synchronize:
src: "{{ clone_root }}/{{ repo }}/"
# deploy constructed dynamicallly in group_vars
dest: "{{ deploy }}/"
# sync remotely -- inventory_hostname is a magic var that always points
# to host where the playbook is being run.
delegate_to: "{{ inventory_hostname }}"
rescue:
- include_tasks: roles/create_deployment/tasks/fail.yml