This commit is contained in:
parent
90513e6e98
commit
212b0ce9f5
@ -13,7 +13,7 @@ TEMPLATES = {
|
||||
"distro_package_manager": "apk",
|
||||
"distro_releases": ["edge"],
|
||||
"image": "cr.smcm.xyz/coder-images/alpine",
|
||||
"startup_scripts": ["startup_scripts/alpine_aports.tf.jinja"],
|
||||
"startup_scripts": ["alpine_aports"],
|
||||
},
|
||||
"gcloud-terraform": {
|
||||
"distro_name": "Ubuntu Linux",
|
||||
@ -21,7 +21,7 @@ TEMPLATES = {
|
||||
"distro_package_manager": "apk",
|
||||
"distro_releases": ["20.04", "22.04", "23.04", "23.10"],
|
||||
"image": "cr.smcm.xyz/coder-images/ubuntu",
|
||||
"startup_scripts": ["startup_scripts/gcloud.tf.jinja", "startup_scripts/terraform.tf.jinja"],
|
||||
"startup_scripts": ["gcloud", "terraform"],
|
||||
},
|
||||
"ubuntu": {
|
||||
"distro_name": "Ubuntu Linux",
|
||||
@ -115,7 +115,8 @@ TEMPLATES = {
|
||||
"coder_user_home": "/opt/splunk/etc",
|
||||
"coder_user_uid": "41812",
|
||||
"coder_user_gid": "41812",
|
||||
"vs_code_root": "/opt/splunk"
|
||||
"vs_code_root": "/opt/splunk",
|
||||
"startup_scripts": ["splunk_ansible"]
|
||||
},
|
||||
},
|
||||
"terraform": {
|
||||
@ -146,7 +147,7 @@ def main(ctx):
|
||||
"name": "generate {coder_template}".format(coder_template = coder_template),
|
||||
"image": "cr.smcm.xyz/drone-plugins/jinja2",
|
||||
"settings": {
|
||||
"template": "{jinja_template}.tf.jinja".format(jinja_template = jinja_template),
|
||||
"template": "{jinja_template}.tf.j2".format(jinja_template = jinja_template),
|
||||
"context": context,
|
||||
"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.j2" %}
|
||||
|
||||
{% 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 %}
|
||||
@ -1,4 +1,4 @@
|
||||
{% extends "base.tf.jinja" %}
|
||||
{% extends "base.tf.j2" %}
|
||||
|
||||
{% block parameters %}
|
||||
{{ super() }}
|
||||
@ -1,4 +1,4 @@
|
||||
{% extends "base.tf.jinja" %}
|
||||
{% extends "base.tf.j2" %}
|
||||
|
||||
{% if feature_flags is not defined %}
|
||||
{% set feature_flags = {} %}
|
||||
@ -1,4 +1,4 @@
|
||||
{% extends "base.tf.jinja" %}
|
||||
{% extends "base.tf.j2" %}
|
||||
|
||||
{% set vs_code_root = "/home/circleci/project" %}
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
{% extends "base.tf.jinja" %}
|
||||
{% extends "base.tf.j2" %}
|
||||
|
||||
{% block post_startup_script_setup_home %}
|
||||
[ -d "argocd" ] || mkdir argocd
|
||||
@ -171,7 +171,22 @@ resource "coder_agent" "main" {
|
||||
{% endblock %}
|
||||
|
||||
{% 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 %}
|
||||
{% endblock %}
|
||||
@ -243,6 +258,26 @@ resource "coder_app" "code-server" {
|
||||
{% block coder_apps %}
|
||||
{% 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
|
||||
|
||||
###--- begin {{ startup_script }} ---###
|
||||
|
||||
{% include "startup_scripts/" + startup_script + ".sh.j2" %}
|
||||
|
||||
###--- end {{ startup_script }} ---###
|
||||
EOT
|
||||
}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block home_volume %}
|
||||
resource "kubernetes_persistent_volume_claim" "home" {
|
||||
metadata {
|
||||
@ -1,4 +1,4 @@
|
||||
{% extends "base.tf.jinja" %}
|
||||
{% extends "base.tf.j2" %}
|
||||
|
||||
{% block coder_apps %}
|
||||
resource "coder_app" "jupyter" {
|
||||
@ -1,4 +1,4 @@
|
||||
{% extends "base.tf.jinja" %}
|
||||
{% extends "base.tf.j2" %}
|
||||
|
||||
{% block post_startup_script_setup_home %}
|
||||
sudo apt update && sudo apt install -y proxychains4
|
||||
@ -1,4 +1,4 @@
|
||||
{% extends "base.tf.jinja" %}
|
||||
{% extends "base.tf.j2" %}
|
||||
|
||||
{% block coder_apps %}
|
||||
resource "coder_app" "splunk" {
|
||||
@ -18,11 +18,6 @@ resource "coder_app" "splunk" {
|
||||
}
|
||||
{% 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 %}
|
||||
env {
|
||||
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 &
|
||||
@ -1,4 +1,4 @@
|
||||
{% extends "base.tf.jinja" %}
|
||||
{% extends "base.tf.j2" %}
|
||||
|
||||
{% block parameters %}
|
||||
{{ super() }}
|
||||
@ -1,4 +1,4 @@
|
||||
{% extends "base.tf.jinja" %}
|
||||
{% extends "base.tf.j2" %}
|
||||
|
||||
{% block parameters %}
|
||||
{{ super() }}
|
||||
Reference in New Issue
Block a user