Skip to content

Commit b115e5e

Browse files
committed
added cookiecutter posthooks for symlinks
1 parent 89833c9 commit b115e5e

File tree

6 files changed

+48
-13
lines changed

6 files changed

+48
-13
lines changed

cookiecutter/cookiecutter.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
{
22
"environment": "foo",
3-
"description" : "Describe the environment here"
3+
"description" : "Describe the environment here",
4+
"is_site_env": false,
5+
"parent_site_env": "None"
46
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import os
2+
import sys
3+
4+
{% if cookiecutter.is_site_env == False %}
5+
os.symlink("../../../tofu/layouts/main.tf", "tofu/main.tf")
6+
os.symlink("../../../tofu/variables.tf", "tofu/variables.tf")
7+
{% endif %}
8+
{% if cookiecutter.parent_site_env != 'None' %}
9+
if not os.path.isdir("../{{ cookiecutter.parent_site_env }}"):
10+
print("ERROR: Parent environment {{ cookiecutter.parent_site_env }} does not exist")
11+
sys.exit(1)
12+
os.symlink("../../{{ cookiecutter.parent_site_env }}/tofu/{{ cookiecutter.parent_site_env }}.auto.tfvars","tofu/{{ cookiecutter.parent_site_env }}.auto.tfvars")
13+
{% endif %}

cookiecutter/{{cookiecutter.environment}}/ansible.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ stderr_callback = debug
55
gathering = smart
66
forks = 30
77
host_key_checking = False
8-
inventory = ../common/inventory,inventory
8+
inventory = ../common/inventory,{{ '../'+cookiecutter.parent_site_env+'/inventory,' if cookiecutter.parent_site_env != 'None' }}inventory
99
collections_path = ../../ansible/collections
1010
roles_path = ../../ansible/roles
1111
filter_plugins = ../../ansible/filter_plugins

cookiecutter/{{cookiecutter.environment}}/tofu/main.tf

Lines changed: 0 additions & 11 deletions
This file was deleted.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Environment {{ 'independent' if cookiecutter.is_site_env else 'specific' }} variables are set here

tofu/layouts/main.tf

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
module "cluster" {
2+
source = "../../../tofu"
3+
environment_root = var.environment_root
4+
5+
cluster_name = var.cluster_name
6+
cluster_domain_suffix = var.cluster_domain_suffix
7+
cluster_networks = var.cluster_networks
8+
key_pair = var.key_pair
9+
control_ip_addresses = var.control_ip_addresses
10+
control_node_flavor = var.control_node_flavor
11+
login = var.login
12+
cluster_image_id = var.cluster_image_id
13+
compute = var.compute
14+
additional_nodegroups = var.additional_nodegroups
15+
state_dir = var.state_dir
16+
state_volume_size = var.state_volume_size
17+
state_volume_type = var.state_volume_type
18+
state_volume_provisioning = var.state_volume_provisioning
19+
home_volume_size = var.home_volume_size
20+
home_volume_type = var.home_volume_type
21+
home_volume_provisioning = var.home_volume_provisioning
22+
vnic_types = var.vnic_types
23+
login_security_groups = var.login_security_groups
24+
nonlogin_security_groups = var.nonlogin_security_groups
25+
volume_backed_instances = var.volume_backed_instances
26+
root_volume_size = var.root_volume_size
27+
root_volume_type = var.root_volume_type
28+
gateway_ip = var.gateway_ip
29+
cluster_nodename_template = var.cluster_nodename_template
30+
}

0 commit comments

Comments
 (0)