If you are using GitLab outside of the ILL, then you will need to use HTTPS and not SSH for clone/push/pull operations. If you are using the VPN, then SSH will work normally.

...
 
version 0.5.0
-------------
* ADDED functionality for printing missing templates when rendering manifest.yml files
* CHANGED removed environment. prefix for all manifest templates
version 0.4.0
-------------
* CHANGED the vm_name is now part of the Jinja2 environment
......
import collections
import glob
import jinja2
import jinja2.meta
import json
import os
import pprint
import sys
import yaml
from typing import Dict, List
......@@ -270,12 +272,24 @@ class PackerTemplate:
node["provisioners"] = self._provisioners
node["post-processors"] = self._postprocessors
# Render the jinja2 templates with the parameters dictionary provided in the template file and the available environment variables
jinja_template = jinja2.Template(repr(node))
s = jinja_template.render(environment=self._environment)
env = jinja2.Environment(undefined=jinja2.DebugUndefined)
template = env.from_string(repr(node))
rendered = template.render(**self._environment)
# Check if rendering was done correctly
ast = env.parse(rendered)
undefined = jinja2.meta.find_undeclared_variables(ast)
if undefined:
print(f'The following variables are undefined: {undefined!r}')
sys.exit(1)
# Replace back %< .* %> to {{ .* }}
rendered = rendered.replace("%<","{{")
rendered = rendered.replace(">%","}}")
# Dump to the output file
with open(output_file, "w") as fout:
json.dump(yaml.safe_load(s), fout, **kwargs)
json.dump(yaml.safe_load(rendered), fout, **kwargs)
def __str__(self) -> str:
"""Returns the string representation for this :class:`PackerTemplate`.
......
......@@ -20,7 +20,7 @@ __status__ : str = "Prototype"
__url__ : str = "https://code.ill.fr/panosc/data-analysis-services/packme"
__version__ : str = "0.4.0"
__version__ : str = "0.5.0"
__long_description_content_type__ : str ="text/markdown"
......
......@@ -8,8 +8,8 @@ packer:
iso_checksum_type: none
iso_checksum_url: none
disk_image: True
ssh_username: "{{ environment.ssh_username }}"
ssh_password: "{{ environment.root_password }}"
ssh_username: "{{ ssh_username }}"
ssh_password: "{{ root_password }}"
shutdown_command: "shutdown -P now"
provisioners:
......
......@@ -8,44 +8,44 @@ packer:
type: qemu
format: qcow2
iso_checksum_type: sha256
iso_checksum_url: "{{ environment.ubuntu_mirror }}/{{ environment.ubuntu_codename }}-updates/main/installer-amd64/current/images/SHA256SUMS"
iso_url: "{{ environment.ubuntu_mirror }}/{{ environment.ubuntu_codename }}-updates/main/installer-amd64/current/images/netboot/mini.iso"
ssh_username: "{{ environment.ssh_username }}"
ssh_password: "{{ environment.root_password }}"
iso_checksum_url: "{{ ubuntu_mirror }}/{{ ubuntu_codename }}-updates/main/installer-amd64/current/images/SHA256SUMS"
iso_url: "{{ ubuntu_mirror }}/{{ ubuntu_codename }}-updates/main/installer-amd64/current/images/netboot/mini.iso"
ssh_username: "{{ ssh_username }}"
ssh_password: "{{ root_password }}"
ssh_timeout: 60m
accelerator: kvm
headless: "{{ environment.headless }}"
headless: "{{ headless }}"
shutdown_command: "shutdown -P now"
qemuargs:
- - "-m"
- "{{ environment.memory }}"
- "{{ memory }}"
- - "-smp"
- "{{ environment.cpus }}"
- "{{ cpus }}"
boot_wait: 5s
boot_command:
- "<tab> "
- "preseed/url=http://{% raw %}{{ .HTTPIP }}:{{ .HTTPPort }}{% endraw %}/{{ environment.preseed_file_name }} "
- "preseed/url=http://%< .HTTPIP >%:%< .HTTPPort >%/{{ preseed_file_name }} "
- "auto-install/enable=true "
- "net.ifnames=0 "
- "netcfg/get_hostname={{ environment.vm_name }} "
- "netcfg/get_gateway={{ environment.gateway}} "
- "netcfg/get_nameservers={{ environment.dns_servers }} "
- "netcfg/hostname={{ environment.vm_name }} "
- "mirror/http/proxy={{ environment.proxy}} "
- "passwd/user-fullname={{ environment.user }} "
- "passwd/username={{ environment.user_fullname }} "
- "passwd/user-password= {{ environment.user_password }} "
- "passwd/user-password-again= {{ environment.user_password }} "
- "passwd/root-password={{ environment.root_password }} "
- "passwd/root-password-again={{ environment.root_password }} "
- "no_proxy={% raw %}{{ .HTTPIP }}{% endraw %},{{ environment.no_proxy }} "
- "netcfg/get_hostname={{ vm_name }} "
- "netcfg/get_gateway={{ gateway}} "
- "netcfg/get_nameservers={{ dns_servers }} "
- "netcfg/hostname={{ vm_name }} "
- "mirror/http/proxy={{ proxy}} "
- "passwd/user-fullname={{ user }} "
- "passwd/username={{ user_fullname }} "
- "passwd/user-password= {{ user_password }} "
- "passwd/user-password-again= {{ user_password }} "
- "passwd/root-password={{ root_password }} "
- "passwd/root-password-again={{ root_password }} "
- "no_proxy=%< .HTTPIP >%,{{ no_proxy }} "
- "<enter>"
disk_size: "{{ environment.disk_size }}"
disk_size: "{{ disk_size }}"
http_directory: "http"
provisioners:
- type: file
source: "system/etc/apt/sources.list_{{ environment.ubuntu_codename }}"
source: "system/etc/apt/sources.list_{{ ubuntu_codename }}"
destination: "/etc/apt/sources.list"
- type: file
......
......@@ -11,8 +11,8 @@ packer:
iso_checksum_type: none
iso_checksum_url: none
disk_image: True
ssh_username: "{{ environment.ssh_username }}"
ssh_password: "{{ environment.root_password }}"
ssh_username: "{{ ssh_username }}"
ssh_password: "{{ root_password }}"
shutdown_command: "shutdown -P now"
provisioners:
......@@ -22,4 +22,3 @@ packer:
- type: file
source: system/etc/ntp.conf
destination: /etc/ntp.conf