This repository was archived by the owner on Oct 8, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdeploy.yml
More file actions
148 lines (130 loc) · 5.08 KB
/
deploy.yml
File metadata and controls
148 lines (130 loc) · 5.08 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
---
- name: Copy project repository.
ansible.posix.synchronize:
src: "{{ _ce_deploy_build_dir }}/"
dest: "{{ deploy_path }}"
archive: true
rsync_opts:
- "--exclude=.git"
- name: Ensure project repository is readable.
ansible.builtin.file:
path: "{{ deploy_path }}"
state: directory
mode: 0755
- name: Project specific tasks.
ansible.builtin.include_role:
name: "deploy_code/deploy_code-{{ project_type }}"
- name: Generate additional templates.
ansible.builtin.template:
src: "{{ template.src }}"
dest: "{{ deploy_path }}/{{ template.dest }}"
with_items: "{{ deploy_code.templates }}"
loop_control:
loop_var: template
when:
- deploy_code.templates | length > 0
- deploy_operation == 'deploy'
- name: Create additional symlinks in build dir.
ansible.builtin.file:
src: "{{ link.src }}"
dest: "{{ deploy_path }}/{{ link.dest }}"
state: link
force: "{{ link.force | default(false) }}"
with_items: "{{ deploy_code.symlinks }}"
loop_control:
loop_var: link
when:
- deploy_code.symlinks | length > 0
# Additional vhost handling for feature branch builds.
# Fetch the NGINX domain handling tasks from ce-provision.
- name: Fetch the nginx role files from ce-provision.
when: deploy_code.feature_branch.enabled
delegate_to: localhost
block:
- name: Ensure the nginx directory exists.
ansible.builtin.file:
path: "{{ _ce_deploy_base_dir }}/roles/debian/nginx/{{ item }}"
state: directory
mode: '0755'
delegate_to: localhost
with_items:
- tasks
- defaults
- templates
- name: Ensure the ssl directory exists.
ansible.builtin.file:
path: "{{ _ce_deploy_base_dir }}/roles/debian/ssl/{{ item }}"
state: directory
mode: '0755'
delegate_to: localhost
with_items:
- tasks
- defaults
- templates
- name: Fetch nginx domain.yml.
ansible.builtin.get_url:
url: "https://raw.githubusercontent.com/codeenigma/ce-provision/{{ deploy_code.ce_provision_version }}/roles/debian/nginx/tasks/domain.yml"
dest: "{{ _ce_deploy_base_dir }}/roles/debian/nginx/domain.yml"
# Because of the way it is called, this needs putting into the playbook directory.
- name: Fetch nginx ssl.yml.
ansible.builtin.get_url:
url: "https://raw.githubusercontent.com/codeenigma/ce-provision/{{ deploy_code.ce_provision_version }}/roles/debian/nginx/tasks/ssl.yml"
dest: "{{ _ce_deploy_build_dir }}/deploy/ssl.yml"
- name: Fetch nginx defaults.
ansible.builtin.get_url:
url: "https://raw.githubusercontent.com/codeenigma/ce-provision/{{ deploy_code.ce_provision_version }}/roles/debian/nginx/defaults/main.yml"
dest: "{{ _ce_deploy_base_dir }}/roles/debian/nginx/defaults/main.yml"
- name: Fetch nginx templates.
ansible.builtin.get_url:
url: "https://raw.githubusercontent.com/codeenigma/ce-provision/{{ deploy_code.ce_provision_version }}/roles/debian/nginx/templates/{{ item }}"
dest: "{{ _ce_deploy_base_dir }}/roles/debian/nginx/templates/{{ item }}"
with_items:
- vhosts.j2
- cloudwatch-vhost.json.j2
- name: Fetch ssl tasks.
ansible.builtin.get_url:
url: "https://raw.githubusercontent.com/codeenigma/ce-provision/{{ deploy_code.ce_provision_version }}/roles/debian/ssl/tasks/{{ item }}.yml"
dest: "{{ _ce_deploy_base_dir }}/roles/debian/ssl/tasks/{{ item }}.yml"
with_items:
- copy
- generate
- letsencrypt
- main
- manual
- selfsigned
- unmanaged
- name: Fetch ssl defaults.
ansible.builtin.get_url:
url: "https://raw.githubusercontent.com/codeenigma/ce-provision/{{ deploy_code.ce_provision_version }}/roles/debian/ssl/defaults/main.yml"
dest: "{{ _ce_deploy_base_dir }}/roles/debian/ssl/defaults/main.yml"
- name: Fetch ssl templates.
ansible.builtin.get_url:
url: "https://raw.githubusercontent.com/codeenigma/ce-provision/{{ deploy_code.ce_provision_version }}/roles/debian/ssl/templates/{{ item }}"
dest: "{{ _ce_deploy_base_dir }}/roles/debian/ssl/templates/{{ item }}"
with_items:
- le_cron.sh.j2
# Generate the NGINX vhost.
- name: Create vhost.
when:
- deploy_code.feature_branch.domains is defined
- deploy_code.feature_branch.domains | length > 0
- deploy_code.feature_branch.enabled
become: true
block:
- name: Generate domain specific configuration.
ansible.builtin.include_tasks: "{{ _ce_deploy_base_dir }}/roles/debian/nginx/domain.yml"
with_items: "{{ deploy_code.feature_branch.domains }}"
loop_control:
loop_var: domain
- name: Test NGINX configuration.
ansible.builtin.command: nginx -t
register: _nginx_test_result
failed_when: false
- name: Display NGINX test result.
ansible.builtin.debug:
msg: "{{ _nginx_test_result.stderr }}"
- name: Ensure NGINX is reloaded.
ansible.builtin.service:
name: nginx
state: reloaded
when: _nginx_test_result.rc == 0