Skip to content
This repository was archived by the owner on Oct 8, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
09a6e98
Adding syncing for feature branches.
gregharvey Aug 10, 2023
fee7ee1
Cannot loop over import_role, changing for include_role.
gregharvey Aug 10, 2023
68d08f3
Merge branch '1.x' into feature_branching-PR-1.x
gregharvey Aug 10, 2023
24fb0fb
Merge branch 'feature_branching' into feature_branching-PR-1.x
gregharvey Aug 10, 2023
4492396
Merge branch '1.x' into feature_branching
gregharvey Aug 11, 2023
4f0e5f5
Adding ability to specify an exact filename for a settings template f…
gregharvey Aug 11, 2023
88fdaf3
Merge branch '1.x' into feature_branching-PR-1.x
gregharvey Aug 11, 2023
0d880ee
Merge branch 'feature_branching' into feature_branching-PR-1.x
gregharvey Aug 11, 2023
ce534be
Merging 1.x
gregharvey Jul 19, 2024
42e8c1f
First pass at NGINX vhost handling in ce-deploy.
gregharvey Jul 19, 2024
c469f1a
Merging 1.x
gregharvey Jul 19, 2024
8eb264a
Merge branch 'feature_branching' into feature_branching-PR-1.x
gregharvey Jul 19, 2024
edb30c9
Adding in the SSL role from ce-provision.
gregharvey Jul 19, 2024
41f33d5
Merge branch 'feature_branching' into feature_branching-PR-1.x
gregharvey Jul 19, 2024
9ac0221
Fixing role paths and ensuring NGINX ssl.yml is available.
gregharvey Jul 19, 2024
30c8d47
Merge branch 'feature_branching' into feature_branching-PR-1.x
gregharvey Jul 19, 2024
ca9fc27
Fixing NGINX role location.
gregharvey Jul 19, 2024
71dc27d
Merge branch 'feature_branching' into feature_branching-PR-1.x
gregharvey Jul 19, 2024
0841be4
Tweaking location of domain.yml so it loads the templates correctly.
gregharvey Jul 19, 2024
13c6bde
Merge branch 'feature_branching' into feature_branching-PR-1.x
gregharvey Jul 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions roles/deploy_code/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
---
# Required for NGINX config in feature branching.
_ce_provision_data_dir: /home/deploy/ce-deploy/data

deploy_code:
# Feature branching config.
feature_branch:
enabled: false
# NGINX domains to build, see ce-provision for docs: https://github.com/codeenigma/ce-provision/blob/2.x/roles/debian/nginx/defaults/main.yml#L133
domains: []
# Specify any additional symlink to create, with src (target) and dest (link).
# src: can be either absolute or relative to the dest (eg. '/var/my_data', '/home/deploy/simplesaml', '../../../myconfig')
# dest: can only be relative to the root of your repository (eg. 'www/themes/myassets', 'var/cache')
Expand Down
107 changes: 107 additions & 0 deletions roles/deploy_code/tasks/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,110 @@
loop_var: link
when:
- deploy_code.symlinks | length

# 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/2.x/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/2.x/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/2.x/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/2.x/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/2.x/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/2.x/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/2.x/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