Skip to content
This repository was archived by the owner on Aug 21, 2022. It is now read-only.

Commit 78da641

Browse files
committed
fix: set container resource name
1 parent 82a4600 commit 78da641

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

__tests__/test-tf-generation.yml

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
- include_vars: "{{ stackhead__roles }}/stackhead_module_api/testdata/variables.yml"
88
- set_fact:
99
containerapp__expose: "{{ containerapp__expose|default([]) + item.expose }}"
10+
module_vars_test:
11+
container:
12+
terraform:
13+
resource_name: test_resource
1014
when: item.expose is defined and item.expose not in containerapp__expose|default([])
1115
with_items: "{{ app_config.domains }}"
1216
- block:
@@ -21,3 +25,5 @@
2125
stackhead__acme_folder: ""
2226
nginx_htpasswd_path: /etc/nginx/passwd
2327
nginx_basicauth_title: "Restricted area"
28+
stackhead_config:
29+
container: test

tasks/nginx_steps/generate-serverblock-tf.yml

+2
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@
44
src: "{{ module_role_path | default(role_path) }}/templates/terraform/nginx_server_block_docker.tf.j2"
55
dest: "{{ stackhead__tf_project_folder }}/nginx_server_block.tf"
66
force: true
7+
vars:
8+
container_resource_name: "{{ lookup('vars', stackhead_config.container|getstackhead.stackhead.module_vars_name).container.terraform.resource_name }}"

templates/terraform/nginx_server_block_docker.tf.j2

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ resource "nginx_server_block" "nginx-{{ project_name }}" {
33
filename = "{{ project_name }}.conf"
44
enable = true
55

6-
{%- set all_ports = containerapp__expose|getstackhead.stackhead.containerPorts(project_name) %}
6+
{%- set all_ports = containerapp__expose|getstackhead.stackhead.containerPorts(project_name, container_resource_name) %}
77
markers = {
88
docker_ports = "{{ all_ports|map(attribute='tfstring')|join(',') }}"
99
}
@@ -30,7 +30,7 @@ EOF
3030
{%- if nginx_expose is defined and nginx_expose.service is defined %}
3131
depends_on = [
3232
{% for nginx_expose in containerapp__expose if nginx_expose.external_port != 443 %}
33-
{% if not loop.first %},{% endif %}docker_container.stackhead-{{ project_name }}-{{ nginx_expose.service }}
33+
{% if not loop.first %},{% endif %}{{ container_resource_name }}.stackhead-{{ project_name }}-{{ nginx_expose.service }}
3434
{% endfor %}
3535
]
3636
{%- endif %}

0 commit comments

Comments
 (0)