This repository was archived by the owner on Feb 26, 2024. It is now read-only.
File tree
Expand file treeCollapse file tree
Open diff view settings
project_containerapp/tasks
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: ansible/__tests__/test-tf-generation.yml +2Lines changed: 2 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
12 | 12 | stackhead__certificates_folder: "" |
13 | 13 | nginx_vhost_content: "{{ lookup('template', nginx_vhost_template) }}" |
14 | 14 | nginx_project_name: test |
| 15 | + containerapp__expose: |
| 16 | + service: test |
15 | 17 | resource_name: "{{ nginx_project_name }}" |
16 | 18 | app_config: |
17 | 19 | domain: example.com |
|
Collapse file
Copy file name to clipboard +1-2Lines changed: 1 addition & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | --- |
2 | 2 | nginx_vhost_template: "{{ playbook_dir }}/templates/nginx-vhost.j2" |
3 | | -nginx_basicauth_title: "Restricted area" |
4 | | -nginx_project_name: "_default" # should be set when using this role! |
| 3 | +nginx_basicauth_title: "Restricted area" |
Collapse file
Copy file name to clipboardExpand all lines: ansible/roles/config_nginx/tasks/main.yml +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
|
5 | 5 |
|
6 | 6 | - set_fact: |
7 | 7 | has_basic_auth: "{{ nginx_auth_basic is defined and nginx_auth_basic | length > 0 }}" |
8 | | - htpasswd_path: "{{ nginx_htpasswd_path }}/.{{ nginx_project_name }}" |
| 8 | + htpasswd_path: "{{ nginx_htpasswd_path }}/.{{ project_name }}" |
9 | 9 |
|
10 | 10 | - name: Generate htpasswd Terraform file |
11 | 11 | template: |
|
Collapse file
Copy file name to clipboardExpand all lines: ansible/roles/project_containerapp/tasks/main.yml -16Lines changed: 0 additions & 16 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
4 | 4 | src: "templates/terraform/docker.tf.j2" |
5 | 5 | dest: "{{ stackhead__tf_project_folder }}/docker.tf" |
6 | 6 | force: true |
7 | | - |
8 | | -- import_tasks: "roles/config_terraform/tasks/update-project-symlinks.yml" |
9 | | -- import_tasks: "roles/config_terraform/tasks/execute.yml" |
10 | | - |
11 | | -# Always fetch port - required for Nginx config update when domain changed |
12 | | -- block: |
13 | | - - name: "StackHead::Container || Get current Docker port" |
14 | | - shell: "docker port stackhead-{{ project_name }}-{{ item.name }} {{ containerapp__expose.port }}" |
15 | | - when: containerapp__expose is defined and item.name == containerapp__expose.service |
16 | | - with_items: "{{ containerapp__services }}" |
17 | | - register: used_port |
18 | | - |
19 | | - - set_fact: |
20 | | - container_port: "{{ item.stdout | replace('0.0.0.0:','') }}" |
21 | | - when: item.changed == true |
22 | | - with_items: "{{ used_port.results }}" |
Collapse file
Copy file name to clipboardExpand all lines: ansible/roles/stackhead_project/tasks/setup-containerapp.yml -5Lines changed: 0 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
12 | 12 | include_role: |
13 | 13 | name: config_nginx |
14 | 14 | vars: |
15 | | - nginx_project_name: "{{ project_name }}" |
16 | 15 | nginx_vhost_template: "{{ playbook_dir }}/templates/nginx-vhost.reverse-proxy.j2" |
17 | 16 | nginx_auth_basic: "{{ app_config.security.authentication|default([]) }}" |
18 | 17 | nginx_vhost: |
19 | 18 | server_name: "{{ app_config.domain }}" |
20 | 19 | use_https: 1 |
21 | | - proxy_pass_port: "{{ container_port }}" |
22 | 20 | state: present |
23 | 21 | filename: "{{ app_config.domain }}.conf" |
24 | | - when: container_port is defined |
25 | | - # currently not checking if Docker steps succeeded as we cant "register" the result due to import_role |
26 | | - # import_role is required because include_role does not pass the facts set in Docker role |
Collapse file
Copy file name to clipboardExpand all lines: ansible/roles/stackhead_project/tasks/setup-nativeapp.yml -1Lines changed: 0 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
|
10 | 10 | include_role: |
11 | 11 | name: config_nginx |
12 | 12 | vars: |
13 | | - nginx_project_name: "{{ project_name }}" |
14 | 13 | nginx_vhost_template: "{{ playbook_dir }}/templates/nginx-vhost.native.j2" |
15 | 14 | nginx_auth_basic: "{{ app_config.security.authentication|default([]) }}" |
16 | 15 | nginx_use_php: "{{ native_php_enabled }}" |
|
Collapse file
Copy file name to clipboardExpand all lines: ansible/roles/stackhead_setup/tasks/setup-terraform.yml +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
|
15 | 15 | name: andrewrothstein.terraform |
16 | 16 | - name: Download Nginx provider |
17 | 17 | get_url: |
18 | | - url: https://github.com/getstackhead/terraform-nginx/releases/download/v1.0.0/terraform-provider-nginx |
| 18 | + url: https://github.com/getstackhead/terraform-nginx/releases/download/v1.2.0/terraform-provider-nginx |
19 | 19 | dest: "{{ terraform_plugin_directory }}/terraform-provider-nginx" |
20 | 20 | mode: '0755' |
21 | 21 | owner: stackhead |
|
Collapse file
Copy file name to clipboardExpand all lines: ansible/templates/nginx-vhost.reverse-proxy.j2 +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
|
2 | 2 |
|
3 | 3 | {% block location %} |
4 | 4 | location / { |
5 | | - proxy_pass http://localhost:{{ nginx_vhost.proxy_pass_port }}; |
| 5 | + proxy_pass http://localhost:{~ docker_port ~}; |
6 | 6 | proxy_redirect off; |
7 | 7 | proxy_set_header X-Scheme $scheme; |
8 | 8 | proxy_set_header Host $host; |
|
Collapse file
Copy file name to clipboardExpand all lines: ansible/templates/terraform/nginx_server_block.tf.j2 +9Lines changed: 9 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
1 | 1 | resource "nginx_server_block" "{{ resource_name }}" { |
2 | 2 | filename = "{{ resource_name }}.conf" |
3 | 3 | enable = true |
| 4 | + markers = { |
| 5 | + docker_port = docker_container.stackhead-{{ project_name }}-{{ containerapp__expose.service }}.ports[0].external |
| 6 | + } |
4 | 7 | content = <<EOF |
5 | 8 | {{ nginx_vhost_content }} |
6 | 9 | EOF |
7 | 10 |
|
| 11 | +{% if containerapp__expose is defined and containerapp__expose.service is defined %} |
| 12 | + depends_on = [ |
| 13 | + docker_container.stackhead-{{ project_name }}-{{ containerapp__expose.service }} |
| 14 | + ] |
| 15 | +{% endif %} |
| 16 | + |
8 | 17 | provisioner "local-exec" { |
9 | 18 | command = "sudo systemctl reload nginx" |
10 | 19 | } |
|
Collapse file
Copy file name to clipboard +3Lines changed: 3 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
| 1 | +provider "nginx" { |
| 2 | +} |
| 3 | + |
1 | 4 | provider "acme" { |
2 | 5 | server_url = "{% if lookup('env','TEST') == '1' %}https://acme-staging-v02.api.letsencrypt.org/directory{% else %}https://acme-v02.api.letsencrypt.org/directory{% endif %}" |
3 | 6 | } |