This commit is contained in:
parent
90513e6e98
commit
7d53dcdf5a
@ -13,7 +13,7 @@ TEMPLATES = {
|
|||||||
"distro_package_manager": "apk",
|
"distro_package_manager": "apk",
|
||||||
"distro_releases": ["edge"],
|
"distro_releases": ["edge"],
|
||||||
"image": "cr.smcm.xyz/coder-images/alpine",
|
"image": "cr.smcm.xyz/coder-images/alpine",
|
||||||
"startup_scripts": ["startup_scripts/alpine_aports.tf.jinja"],
|
"startup_scripts": ["alpine_aports"],
|
||||||
},
|
},
|
||||||
"gcloud-terraform": {
|
"gcloud-terraform": {
|
||||||
"distro_name": "Ubuntu Linux",
|
"distro_name": "Ubuntu Linux",
|
||||||
@ -21,7 +21,7 @@ TEMPLATES = {
|
|||||||
"distro_package_manager": "apk",
|
"distro_package_manager": "apk",
|
||||||
"distro_releases": ["20.04", "22.04", "23.04", "23.10"],
|
"distro_releases": ["20.04", "22.04", "23.04", "23.10"],
|
||||||
"image": "cr.smcm.xyz/coder-images/ubuntu",
|
"image": "cr.smcm.xyz/coder-images/ubuntu",
|
||||||
"startup_scripts": ["startup_scripts/gcloud.tf.jinja", "startup_scripts/terraform.tf.jinja"],
|
"startup_scripts": ["gcloud", "terraform"],
|
||||||
},
|
},
|
||||||
"ubuntu": {
|
"ubuntu": {
|
||||||
"distro_name": "Ubuntu Linux",
|
"distro_name": "Ubuntu Linux",
|
||||||
@ -115,7 +115,8 @@ TEMPLATES = {
|
|||||||
"coder_user_home": "/opt/splunk/etc",
|
"coder_user_home": "/opt/splunk/etc",
|
||||||
"coder_user_uid": "41812",
|
"coder_user_uid": "41812",
|
||||||
"coder_user_gid": "41812",
|
"coder_user_gid": "41812",
|
||||||
"vs_code_root": "/opt/splunk"
|
"vs_code_root": "/opt/splunk",
|
||||||
|
"startup_scripts": ["splunk_ansible"]
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"terraform": {
|
"terraform": {
|
||||||
@ -146,7 +147,7 @@ def main(ctx):
|
|||||||
"name": "generate {coder_template}".format(coder_template = coder_template),
|
"name": "generate {coder_template}".format(coder_template = coder_template),
|
||||||
"image": "cr.smcm.xyz/drone-plugins/jinja2",
|
"image": "cr.smcm.xyz/drone-plugins/jinja2",
|
||||||
"settings": {
|
"settings": {
|
||||||
"template": "{jinja_template}.tf.jinja".format(jinja_template = jinja_template),
|
"template": "{jinja_template}.tf.j2".format(jinja_template = jinja_template),
|
||||||
"context": context,
|
"context": context,
|
||||||
"output": "{coder_template}/main.tf".format(coder_template = coder_template),
|
"output": "{coder_template}/main.tf".format(coder_template = coder_template),
|
||||||
},
|
},
|
||||||
|
|||||||
28
_distro.tf.j2
Normal file
28
_distro.tf.j2
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{% extends "base.tf.jinja" %}
|
||||||
|
|
||||||
|
{% block parameters %}
|
||||||
|
{{ super() }}
|
||||||
|
|
||||||
|
data "coder_parameter" "distro_release" {
|
||||||
|
name = "{{ distro_name }} Release"
|
||||||
|
description = "{{ distro_name }} Release"
|
||||||
|
type = "string"
|
||||||
|
default = ""
|
||||||
|
|
||||||
|
mutable = true
|
||||||
|
option {
|
||||||
|
name = "Latest"
|
||||||
|
value = ""
|
||||||
|
}
|
||||||
|
{% for version in distro_releases %}
|
||||||
|
option {
|
||||||
|
name = "{{ version }}"
|
||||||
|
value = "-{{ version }}"
|
||||||
|
}
|
||||||
|
{% endfor %}
|
||||||
|
}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block kubernetes_pod_main_image %}
|
||||||
|
image = "{{image}}${data.coder_parameter.distro_release.value}:latest"
|
||||||
|
{% endblock %}
|
||||||
@ -1,60 +0,0 @@
|
|||||||
{% extends "base.tf.jinja" %}
|
|
||||||
|
|
||||||
{% block parameters %}
|
|
||||||
{{ super() }}
|
|
||||||
|
|
||||||
data "coder_parameter" "distro_release" {
|
|
||||||
name = "{{ distro_name }} Release"
|
|
||||||
description = "{{ distro_name }} Release"
|
|
||||||
type = "string"
|
|
||||||
default = ""
|
|
||||||
|
|
||||||
mutable = true
|
|
||||||
option {
|
|
||||||
name = "Latest"
|
|
||||||
value = ""
|
|
||||||
}
|
|
||||||
{% for version in distro_releases %}
|
|
||||||
option {
|
|
||||||
name = "{{ version }}"
|
|
||||||
value = "-{{ version }}"
|
|
||||||
}
|
|
||||||
{% endfor %}
|
|
||||||
}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block kubernetes_pod_main_image %}
|
|
||||||
image = "{{image}}${data.coder_parameter.distro_release.value}:latest"
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block post_startup_script_setup_home %}
|
|
||||||
{% if startup_scripts %}
|
|
||||||
{% for startup_script in startup_scripts %}
|
|
||||||
###
|
|
||||||
# Begin {startup_script}
|
|
||||||
###
|
|
||||||
|
|
||||||
{% include startup_script %}
|
|
||||||
|
|
||||||
###
|
|
||||||
# End {startup_script}
|
|
||||||
###
|
|
||||||
{% endfor %}
|
|
||||||
{% endif %}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block startup_script_install_packages %}
|
|
||||||
{% if distro_package_manager == "apt" %}
|
|
||||||
sudo apt update
|
|
||||||
|
|
||||||
{% if packages_to_install is defined %}
|
|
||||||
sudo apt install {{ packages_to_install | join(" ") }}
|
|
||||||
{% endif %}
|
|
||||||
{% elif distro_package_manager == "apk" %}
|
|
||||||
sudo apk update
|
|
||||||
|
|
||||||
{% if packages_to_install is defined %}
|
|
||||||
sudo apk add {{ packages_to_install | join(" ") }}
|
|
||||||
{% endif %}
|
|
||||||
{% endif %}
|
|
||||||
{% endblock %}
|
|
||||||
@ -171,7 +171,22 @@ resource "coder_agent" "main" {
|
|||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block startup_script_install_packages %}
|
{% block startup_script_install_packages %}
|
||||||
{% endblock %}
|
{% if packages_to_install %}
|
||||||
|
{% if distro_package_manager == "apt" %}
|
||||||
|
sudo apt update
|
||||||
|
sudo apt -y install \
|
||||||
|
{% for package in packages_to_install %}
|
||||||
|
{{package}}{{ " \\" if not loop.last else "" }}
|
||||||
|
{% endfor %}
|
||||||
|
{% elif distro_package_manager == "apk" %}
|
||||||
|
sudo apk update
|
||||||
|
sudo apk add \
|
||||||
|
{% for package in packages_to_install %}
|
||||||
|
{{package}}{{ " \\" if not loop.last else "" }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}+
|
||||||
|
|
||||||
{% block post_startup_script_install_packages %}
|
{% block post_startup_script_install_packages %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@ -243,6 +258,22 @@ resource "coder_app" "code-server" {
|
|||||||
{% block coder_apps %}
|
{% block coder_apps %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block coder_scripts %}
|
||||||
|
{% if startup_scripts %}
|
||||||
|
{% for startup_script in startup_scripts %}
|
||||||
|
resource "coder_script" "{{ startup_script }}" {
|
||||||
|
agent_id = coder_agent.main.id
|
||||||
|
display_name = "{{ startup_script }}"
|
||||||
|
script = <<EOT
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
{% include "startup_scripts/" + startup_script + ".sh.j2" %}
|
||||||
|
EOT
|
||||||
|
}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block home_volume %}
|
{% block home_volume %}
|
||||||
resource "kubernetes_persistent_volume_claim" "home" {
|
resource "kubernetes_persistent_volume_claim" "home" {
|
||||||
metadata {
|
metadata {
|
||||||
@ -18,11 +18,6 @@ resource "coder_app" "splunk" {
|
|||||||
}
|
}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block startup_script_cleanup %}
|
|
||||||
sudo ln -s python3 /usr/bin/python
|
|
||||||
sudo -E -u ansible /sbin/entrypoint.sh start | tee splunk-startup.log &
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block kubernetes_pod_main_env %}
|
{% block kubernetes_pod_main_env %}
|
||||||
env {
|
env {
|
||||||
name = "SPLUNK_PASSWORD"
|
name = "SPLUNK_PASSWORD"
|
||||||
2
startup_scripts/splunk_ansible.sh.j2
Normal file
2
startup_scripts/splunk_ansible.sh.j2
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[ -e /usr/bin/python ] || sudo ln -s python3 /usr/bin/python
|
||||||
|
sudo -E -u ansible /sbin/entrypoint.sh start | tee splunk-startup.log &
|
||||||
Reference in New Issue
Block a user